YSLocationView.dart 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:url_launcher/url_launcher.dart';
  4. import 'package:ysairplane2/base/YSBase.dart';
  5. import 'package:ysairplane2/tools/YSNetWorking.dart';
  6. import 'package:ysairplane2/tools/YSTools.dart';
  7. import 'YSMap.dart';
  8. class YSLocationView extends StatelessWidget {
  9. final String locationStr;
  10. final String latitude;
  11. final String longitude;
  12. const YSLocationView({Key key, @required this.locationStr, @required this.latitude, @required this.longitude}) : super(key: key);
  13. @override
  14. Widget build(BuildContext context) {
  15. return GestureDetector(
  16. onTap: (){
  17. Navigator.of(context).push(
  18. CupertinoPageRoute(builder: (context){
  19. return YSLocation(locationStr: locationStr, latitude: latitude, longitude: longitude);
  20. })
  21. );
  22. },
  23. child: Container(
  24. padding: EdgeInsets.only(bottom: hsp(20),top: hsp(20)),
  25. color: Colors.white,
  26. width: MediaQuery.of(context).size.width,
  27. child: Row(
  28. children: [
  29. Icon(Icons.location_on,color: Color(0xFF5E5E5E),size: hsp(35),),
  30. Text(' $locationStr',style: TextStyle(fontSize: zsp(23),color: Color(0xFF5E5E5E)),),
  31. ],
  32. ),
  33. ),
  34. );
  35. }
  36. }
  37. class YSLocation extends StatelessWidget {
  38. final String locationStr;
  39. final String latitude;
  40. final String longitude;
  41. const YSLocation({Key key, @required this.locationStr, @required this.latitude, @required this.longitude}) : super(key: key);
  42. @override
  43. Widget build(BuildContext context) {
  44. return YSBase(
  45. ystitle: locationStr,
  46. yschild: Container(
  47. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44,
  48. width: MediaQuery.of(context).size.width,
  49. color: Colors.white,
  50. child: Stack(
  51. children: [
  52. platformView(
  53. platforms: (value){
  54. value.setMethodCallHandler((call) {
  55. Map item = {'lat':latitude,'lng':longitude
  56. ,'title':locationStr,'content':locationStr,'type':0};
  57. value.invokeMethod('setLocation', item);
  58. return;
  59. });
  60. }
  61. ),
  62. Positioned(
  63. bottom: hsp(100),
  64. left: hsp(50),
  65. right: hsp(50),
  66. height: hsp(200),
  67. child: GestureDetector(
  68. onTap: (){
  69. showModalBottomSheet(context: context, builder: (context){
  70. return YSChooseMapView(longitude: longitude,latitude: latitude,);
  71. },isScrollControlled: true);
  72. },
  73. child: Container(
  74. padding: EdgeInsets.all(hsp(30)),
  75. decoration: BoxDecoration(
  76. color: Colors.white,
  77. borderRadius: BorderRadius.all(Radius.circular(10))
  78. ),
  79. child: Row(
  80. children: [
  81. Container(
  82. width: MediaQuery.of(context).size.width-hsp(220),
  83. child: Text(locationStr,maxLines: 3,),
  84. ),
  85. Icon(Icons.navigation,size: hsp(60),color: Colors.blueAccent,)
  86. ],
  87. ),
  88. ),
  89. )
  90. )
  91. ],
  92. ),
  93. ),
  94. );
  95. }
  96. }
  97. class YSChooseMapView extends StatelessWidget {
  98. final String latitude;
  99. final String longitude;
  100. const YSChooseMapView({Key key, @required this.latitude, @required this.longitude}) : super(key: key);
  101. @override
  102. Widget build(BuildContext context) {
  103. return Container(
  104. height: hsp(420),
  105. width: MediaQuery.of(context).size.width,
  106. decoration: BoxDecoration(
  107. color: Color(0xFFF1F2F3),
  108. borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10))
  109. ),
  110. child: ListView.separated(
  111. itemBuilder: (context,index){
  112. return GestureDetector(
  113. onTap: (){
  114. if(index==0){
  115. XMapNavigatorUtil.gotoAMap(latitude: latitude,longitude: longitude,toInstallCallBack: (){
  116. // ysFlutterToast(context, '高德地图未安装');
  117. launch('https://wap.amap.com/?type=pcm&from=banner&src=pc');
  118. });
  119. }else if(index==1){
  120. XMapNavigatorUtil.gotoTencentMap(latitude: latitude,longitude: longitude,toInstallCallBack: (){
  121. // ysFlutterToast(context, '腾讯地图未安装');
  122. launch('https://map.qq.com/mobile/');
  123. });
  124. }else if(index==2){
  125. XMapNavigatorUtil.gotoBaiduMap(latitude: latitude,longitude: longitude,toInstallCallBack: (){
  126. // ysFlutterToast(context, '百度地图未安装');
  127. launch('https://map.baidu.com/mapclient-pages/download/?from=pcmap&source=index');
  128. });
  129. }else{
  130. Navigator.pop(context);
  131. }
  132. },
  133. behavior: HitTestBehavior.opaque,
  134. child: Container(
  135. height: hsp(99),
  136. color: Colors.white,
  137. alignment: Alignment.center,
  138. child: Text(index==0?'高德地图':index==1?'腾讯地图':index==2?'百度地图':'取消'),
  139. ),
  140. );
  141. },
  142. separatorBuilder: (context,index){
  143. return Container(height: index==2?hsp(21):hsp(1),);
  144. },
  145. itemCount: 4
  146. ),
  147. );
  148. }
  149. }