import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:ysairplane2/base/YSBase.dart'; import 'package:ysairplane2/tools/YSNetWorking.dart'; import 'package:ysairplane2/tools/YSTools.dart'; import 'YSMap.dart'; class YSLocationView extends StatelessWidget { final String locationStr; final String latitude; final String longitude; const YSLocationView({Key key, @required this.locationStr, @required this.latitude, @required this.longitude}) : super(key: key); @override Widget build(BuildContext context) { return GestureDetector( onTap: (){ Navigator.of(context).push( CupertinoPageRoute(builder: (context){ return YSLocation(locationStr: locationStr, latitude: latitude, longitude: longitude); }) ); }, child: Container( padding: EdgeInsets.only(bottom: hsp(20),top: hsp(20)), color: Colors.white, width: MediaQuery.of(context).size.width, child: Row( children: [ Icon(Icons.location_on,color: Color(0xFF5E5E5E),size: hsp(35),), Text(' $locationStr',style: TextStyle(fontSize: zsp(23),color: Color(0xFF5E5E5E)),), ], ), ), ); } } class YSLocation extends StatelessWidget { final String locationStr; final String latitude; final String longitude; const YSLocation({Key key, @required this.locationStr, @required this.latitude, @required this.longitude}) : super(key: key); @override Widget build(BuildContext context) { return YSBase( ystitle: locationStr, yschild: Container( height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44, width: MediaQuery.of(context).size.width, color: Colors.white, child: Stack( children: [ platformView( platforms: (value){ value.setMethodCallHandler((call) { Map item = {'lat':latitude,'lng':longitude ,'title':locationStr,'content':locationStr,'type':0}; value.invokeMethod('setLocation', item); return; }); } ), Positioned( bottom: hsp(100), left: hsp(50), right: hsp(50), height: hsp(200), child: GestureDetector( onTap: (){ showModalBottomSheet(context: context, builder: (context){ return YSChooseMapView(longitude: longitude,latitude: latitude,); },isScrollControlled: true); }, child: Container( padding: EdgeInsets.all(hsp(30)), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(10)) ), child: Row( children: [ Container( width: MediaQuery.of(context).size.width-hsp(220), child: Text(locationStr,maxLines: 3,), ), Icon(Icons.navigation,size: hsp(60),color: Colors.blueAccent,) ], ), ), ) ) ], ), ), ); } } class YSChooseMapView extends StatelessWidget { final String latitude; final String longitude; const YSChooseMapView({Key key, @required this.latitude, @required this.longitude}) : super(key: key); @override Widget build(BuildContext context) { return Container( height: hsp(420), width: MediaQuery.of(context).size.width, decoration: BoxDecoration( color: Color(0xFFF1F2F3), borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10)) ), child: ListView.separated( itemBuilder: (context,index){ return GestureDetector( onTap: (){ if(index==0){ XMapNavigatorUtil.gotoAMap(latitude: latitude,longitude: longitude,toInstallCallBack: (){ // ysFlutterToast(context, '高德地图未安装'); launch('https://wap.amap.com/?type=pcm&from=banner&src=pc'); }); }else if(index==1){ XMapNavigatorUtil.gotoTencentMap(latitude: latitude,longitude: longitude,toInstallCallBack: (){ // ysFlutterToast(context, '腾讯地图未安装'); launch('https://map.qq.com/mobile/'); }); }else if(index==2){ XMapNavigatorUtil.gotoBaiduMap(latitude: latitude,longitude: longitude,toInstallCallBack: (){ // ysFlutterToast(context, '百度地图未安装'); launch('https://map.baidu.com/mapclient-pages/download/?from=pcmap&source=index'); }); }else{ Navigator.pop(context); } }, behavior: HitTestBehavior.opaque, child: Container( height: hsp(99), color: Colors.white, alignment: Alignment.center, child: Text(index==0?'高德地图':index==1?'腾讯地图':index==2?'百度地图':'取消'), ), ); }, separatorBuilder: (context,index){ return Container(height: index==2?hsp(21):hsp(1),); }, itemCount: 4 ), ); } }