124 lines
3.7 KiB
Dart
124 lines
3.7 KiB
Dart
import 'dart:io';
|
||
|
||
import 'package:flutter/material.dart';
|
||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||
import 'package:get/get.dart';
|
||
import 'package:permission_handler/permission_handler.dart';
|
||
import 'package:star_lock/mine/addLock/addLock/addLock_logic.dart';
|
||
|
||
import '../../../appRouters.dart';
|
||
import '../../../app_settings/app_colors.dart';
|
||
import '../../../baseWidget.dart';
|
||
import '../../../tools/submitBtn.dart';
|
||
import '../../../tools/titleAppBar.dart';
|
||
import '../../../translations/trans_lib.dart';
|
||
|
||
class AddLockPage extends StatefulWidget {
|
||
const AddLockPage({Key? key}) : super(key: key);
|
||
|
||
@override
|
||
State<AddLockPage> createState() => _AddLockPageState();
|
||
}
|
||
|
||
class _AddLockPageState extends State<AddLockPage> with BaseWidget {
|
||
final logic = Get.put(AddLockLogic());
|
||
final state = Get.find<AddLockLogic>().state;
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Scaffold(
|
||
backgroundColor: Colors.white,
|
||
appBar: TitleAppBar(
|
||
barTitle: TranslationLoader.lanKeys!.addLock!.tr,
|
||
haveBack: true,
|
||
backgroundColor: AppColors.mainColor),
|
||
body: ListView(
|
||
// mainAxisAlignment: MainAxisAlignment.center,
|
||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||
children: [
|
||
SizedBox(
|
||
height: 100.h,
|
||
),
|
||
Row(
|
||
mainAxisAlignment: MainAxisAlignment.center,
|
||
children: [
|
||
Text(
|
||
TranslationLoader.lanKeys!.lightTouchScreen!.tr,
|
||
style: TextStyle(
|
||
fontSize: 24.sp,
|
||
),
|
||
),
|
||
],
|
||
),
|
||
SizedBox(
|
||
height: 120.h,
|
||
),
|
||
Obx(() => Image.asset(
|
||
state.lockTypeImg.value,
|
||
width: 278.w,
|
||
height: 278.w,
|
||
)),
|
||
SizedBox(
|
||
height: 120.h,
|
||
),
|
||
Row(
|
||
mainAxisAlignment: MainAxisAlignment.center,
|
||
children: [
|
||
Text(
|
||
TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
|
||
style: TextStyle(fontSize: 20.sp, fontWeight: FontWeight.w500),
|
||
),
|
||
],
|
||
),
|
||
SizedBox(
|
||
height: 120.h,
|
||
),
|
||
Container(
|
||
margin: EdgeInsets.only(left: 20.w, right: 20.w),
|
||
child: SubmitBtn(
|
||
btnName: TranslationLoader.lanKeys!.next!.tr,
|
||
borderRadius: 20.w,
|
||
onClick: () {
|
||
if (Platform.isIOS) {
|
||
Navigator.pushNamed(context, Routers.nearbyLockPage);
|
||
} else {
|
||
getMicrophonePermission().then((value) {
|
||
if (value) {
|
||
// 有权限
|
||
Navigator.pushNamed(context, Routers.nearbyLockPage);
|
||
} else {
|
||
//没有权限
|
||
openAppSettings(); //打开app系统设置
|
||
}
|
||
});
|
||
}
|
||
}),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
|
||
///请求权限
|
||
Future<bool> getMicrophonePermission() async {
|
||
// You can request multiple permissions at once.
|
||
Map<Permission, PermissionStatus> statuses = await [
|
||
Permission.bluetoothScan,
|
||
Permission.bluetoothConnect,
|
||
Permission.location,
|
||
].request();
|
||
|
||
//granted 通过,denied 被拒绝,permanentlyDenied 拒绝且不在提示
|
||
if (statuses[Permission.bluetoothScan]!.isGranted &&
|
||
statuses[Permission.bluetoothConnect]!.isGranted &&
|
||
statuses[Permission.location]!.isGranted) {
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
void onShow() {}
|
||
|
||
void onHide() {}
|
||
}
|