fmk
3 years ago
27 changed files with 752 additions and 383 deletions
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 990 B |
@ -0,0 +1,132 @@
|
||||
|
||||
|
||||
|
||||
import 'dart:io'; |
||||
|
||||
import 'package:android_intent_plus/android_intent.dart'; |
||||
import 'package:flutter/cupertino.dart'; |
||||
import 'package:flutter_bmflocation/bdmap_location_flutter_plugin.dart'; |
||||
import 'package:huixiang/generated/l10n.dart'; |
||||
import 'package:huixiang/view_widget/request_permission.dart'; |
||||
import 'package:permission_handler/permission_handler.dart'; |
||||
|
||||
class Location { |
||||
|
||||
static Location _instance; |
||||
|
||||
Location._internal() { |
||||
aMapFlutterLocation = LocationFlutterPlugin(); |
||||
} |
||||
|
||||
static Location getInstance() { |
||||
if (_instance == null) { |
||||
_instance = Location._internal(); |
||||
} |
||||
return _instance; |
||||
} |
||||
|
||||
LocationFlutterPlugin aMapFlutterLocation; |
||||
|
||||
prepareLoc() { |
||||
aMapFlutterLocation.prepareLoc({ |
||||
"coorType": "bd09ll", |
||||
"isNeedAddres": false, |
||||
"isNeedAltitude": false, |
||||
"isNeedLocationPoiList": false, |
||||
"isNeedLocationDescribe": false, |
||||
"isNeedNewVersionRgc": false, |
||||
"scanspan": 0, |
||||
"openGps": true, |
||||
"locationMode": 2, |
||||
}, { |
||||
"locationMode": "kCLLocationAccuracyBest", |
||||
"locationTimeout": 10, |
||||
"reGeocodeTimeout": 10, |
||||
"activityType": "CLActivityTypeAutomotiveNavigation", |
||||
"BMKLocationCoordinateType": "BMKLocationCoordinateTypeBMK09LL", |
||||
"isNeedNewVersionRgc": false, |
||||
}); |
||||
} |
||||
|
||||
Future<void> startLocation(context) async { |
||||
if (!(await Permission.locationWhenInUse.serviceStatus.isEnabled)) { |
||||
enableLocation(context); |
||||
print("object1111"); |
||||
return; |
||||
} |
||||
if (await Permission.location.isPermanentlyDenied) { |
||||
requestDialog(context); |
||||
print("object2222"); |
||||
} else if (await Permission.location.isGranted) { |
||||
aMapFlutterLocation.startLocation(); |
||||
print("object3333"); |
||||
} else if (await Permission.location.isUndetermined) { |
||||
await Permission.location.request(); |
||||
print("object44444"); |
||||
} else { |
||||
print("object5555"); |
||||
if (Platform.isIOS) { |
||||
//去设置中心 |
||||
requestDialog(context); |
||||
} else { |
||||
await Permission.location.request(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void sotpLocation() { |
||||
aMapFlutterLocation.stopLocation(); |
||||
} |
||||
|
||||
enableLocation(context) { |
||||
showCupertinoDialog( |
||||
context: context, |
||||
builder: (context) { |
||||
return RequestPermission( |
||||
"assets/image/icon_permission_location_bg.png", |
||||
S.of(context).nindingweigongnengweikaiqi, |
||||
S.of(context).weilexiangnintuijianfujindemendianxinxi, |
||||
S.of(context).dakaidingwei, |
||||
(result) async { |
||||
if (result) { |
||||
final AndroidIntent intent = AndroidIntent( |
||||
action: 'action_location_source_settings', |
||||
package: "com.zsw.huixiang"); |
||||
await intent.launch(); |
||||
// startLocation(); |
||||
} |
||||
}, |
||||
heightRatioWithWidth: 0.82, |
||||
); |
||||
}, |
||||
); |
||||
} |
||||
|
||||
requestDialog(context) { |
||||
showCupertinoDialog( |
||||
context: context, |
||||
builder: (context) { |
||||
return RequestPermission( |
||||
"assets/image/icon_permission_location_bg.png", |
||||
S.of(context).nindingweiquanxianweiyunxu, |
||||
S.of(context).weilexiangnintuijianfujindemendianxinxi, |
||||
S.of(context).kaiqiquanxian, |
||||
(result) async { |
||||
if (result) { |
||||
await openAppSettings(); |
||||
if (await Permission.location.isGranted) { |
||||
startLocation(context); |
||||
} |
||||
} |
||||
}, |
||||
heightRatioWithWidth: 0.82, |
||||
); |
||||
}); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,99 @@
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:huixiang/generated/l10n.dart'; |
||||
import 'package:huixiang/utils/font_weight.dart'; |
||||
import 'package:huixiang/view_widget/separator.dart'; |
||||
|
||||
class CommentMenu extends StatefulWidget { |
||||
final bool isSelf; |
||||
|
||||
final Function(String type) clickType; |
||||
|
||||
CommentMenu( |
||||
this.clickType, { |
||||
this.isSelf = false, |
||||
}); |
||||
|
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _CommentMenu(); |
||||
} |
||||
} |
||||
|
||||
class _CommentMenu extends State<CommentMenu> { |
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Container( |
||||
height: widget.isSelf ? 224.h : 164.h, |
||||
decoration: BoxDecoration( |
||||
color: Colors.white, |
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(8)), |
||||
), |
||||
child: Column( |
||||
mainAxisSize: MainAxisSize.max, |
||||
children: [ |
||||
InkWell( |
||||
onTap: () { |
||||
Navigator.of(context).pop(); |
||||
widget.clickType("huifu"); |
||||
}, |
||||
child: Container( |
||||
padding: EdgeInsets.all(20.h), |
||||
child: Text( |
||||
S.of(context).huifu, |
||||
style: TextStyle( |
||||
fontWeight: MyFontWeight.medium, |
||||
fontSize: 16.sp, |
||||
color: Color(0xFF353535), |
||||
), |
||||
), |
||||
), |
||||
), |
||||
Container( |
||||
height: 1.h, |
||||
color: Color(0xFFF7F7F7), |
||||
), |
||||
if (widget.isSelf) |
||||
InkWell( |
||||
onTap: () { |
||||
Navigator.of(context).pop(); |
||||
widget.clickType("shanchu"); |
||||
}, |
||||
child: Container( |
||||
padding: EdgeInsets.all(20.h), |
||||
child: Text( |
||||
S.of(context).shanchu, |
||||
style: TextStyle( |
||||
fontWeight: MyFontWeight.medium, |
||||
fontSize: 16.sp, |
||||
color: Color(0xFF353535), |
||||
), |
||||
), |
||||
), |
||||
), |
||||
if (widget.isSelf) |
||||
Container( |
||||
height: 1.h, |
||||
color: Color(0xFFF7F7F7), |
||||
), |
||||
InkWell( |
||||
onTap: () { |
||||
Navigator.of(context).pop(); |
||||
}, |
||||
child: Container( |
||||
padding: EdgeInsets.all(20.h), |
||||
child: Text( |
||||
S.of(context).quxiao, |
||||
style: TextStyle( |
||||
fontWeight: MyFontWeight.medium, |
||||
fontSize: 16.sp, |
||||
color: Color(0xFF727272), |
||||
), |
||||
), |
||||
), |
||||
), |
||||
], |
||||
), |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,105 @@
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:huixiang/generated/l10n.dart'; |
||||
import 'package:huixiang/utils/font_weight.dart'; |
||||
|
||||
class Tips extends StatefulWidget { |
||||
final Function tips; |
||||
|
||||
Tips(this.tips); |
||||
|
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _Tips(); |
||||
} |
||||
} |
||||
|
||||
class _Tips extends State<Tips> { |
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Material( |
||||
type: MaterialType.transparency, |
||||
child: Center( |
||||
child: Container( |
||||
width: MediaQuery.of(context).size.width - 80.w, |
||||
height: 146.h, |
||||
decoration: BoxDecoration( |
||||
color: Colors.white, |
||||
borderRadius: BorderRadius.circular(8), |
||||
), |
||||
child: Column( |
||||
children: [ |
||||
Container( |
||||
width: double.infinity, |
||||
height: 90.h, |
||||
alignment: Alignment.center, |
||||
child: Text( |
||||
S.of(context).querenyaoshanchudangqianpinglunma, |
||||
style: TextStyle( |
||||
fontSize: 17.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
color: Color(0xFF353535), |
||||
), |
||||
), |
||||
), |
||||
Container( |
||||
color: Color(0x1A000000), |
||||
height: 1.h, |
||||
), |
||||
Container( |
||||
height: 55.h, |
||||
child: Row( |
||||
mainAxisSize: MainAxisSize.max, |
||||
children: [ |
||||
Expanded( |
||||
child: InkWell( |
||||
onTap: widget.tips, |
||||
child: Container( |
||||
width: double.infinity, |
||||
height: 90.h, |
||||
alignment: Alignment.center, |
||||
child: Text( |
||||
S.of(context).quxiao, |
||||
style: TextStyle( |
||||
fontSize: 17.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
color: Color(0xFF353535), |
||||
), |
||||
), |
||||
), |
||||
), |
||||
flex: 1, |
||||
), |
||||
Container( |
||||
color: Color(0x1A000000), |
||||
width: 1.h, |
||||
), |
||||
Expanded( |
||||
child: InkWell( |
||||
onTap: widget.tips, |
||||
child: Container( |
||||
width: double.infinity, |
||||
height: 90.h, |
||||
alignment: Alignment.center, |
||||
child: Text( |
||||
S.of(context).queren, |
||||
style: TextStyle( |
||||
fontSize: 17.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
color: Color(0xFF32A060), |
||||
), |
||||
), |
||||
), |
||||
), |
||||
flex: 1, |
||||
), |
||||
], |
||||
), |
||||
), |
||||
], |
||||
), |
||||
), |
||||
), |
||||
); |
||||
} |
||||
} |
Loading…
Reference in new issue