172 lines
5.4 KiB
Dart
172 lines
5.4 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/app_settings/app_colors.dart';
|
|
import 'package:star_lock/mine/mineSet/mineSet_page.dart';
|
|
|
|
import '../../appRouters.dart';
|
|
import '../../baseWidget.dart';
|
|
import '../../mine/mine_page.dart';
|
|
import '../../tools/reactiveBlueTool/getx_ble.dart';
|
|
import '../../tools/titleAppBar.dart';
|
|
import '../../translations/trans_lib.dart';
|
|
|
|
class StarLockMain extends StatefulWidget {
|
|
const StarLockMain({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<StarLockMain> createState() => _StarLockMainState();
|
|
}
|
|
|
|
class _StarLockMainState extends State<StarLockMain> with BaseWidget{
|
|
// final logic = Get.put(GetxBle());
|
|
|
|
StreamSubscription<DiscoveredDevice>? _streamSubscription;
|
|
StreamSubscription<ConnectionStateUpdate>? _connectionStreamSubscription;
|
|
final flutterReactiveBle = FlutterReactiveBle();
|
|
List<DiscoveredDevice> deviceList = [];
|
|
|
|
@override
|
|
void setState(VoidCallback fn) {
|
|
// TODO: implement setState
|
|
super.setState(fn);
|
|
|
|
// BleScanner.to.startScan([
|
|
//
|
|
// ]);
|
|
|
|
GetxBle.call.scanner.startScan([]);
|
|
}
|
|
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: const Color(0xFFF5F5F5),
|
|
appBar: TitleAppBar(barTitle: TranslationLoader.lanKeys!.starLock!.tr, haveBack:false, haveOtherLeftWidget: true, leftWidget: Builder(
|
|
builder: (context) => IconButton(
|
|
icon: Image.asset("images/main/mainLeft_menu_icon.png",color:Colors.white, width: 60.w, height: 60.w,),
|
|
onPressed: () {
|
|
Scaffold.of(context).openDrawer();
|
|
},
|
|
)
|
|
),backgroundColor: AppColors.mainColor),
|
|
drawer: Drawer(
|
|
width:1.sw/3*2,
|
|
child: StarLockMinePage(),
|
|
),
|
|
body: getLockList(),
|
|
// body: unHaveData(),
|
|
);
|
|
}
|
|
|
|
Widget getLockList(){
|
|
return ListView.builder(
|
|
itemCount:10,
|
|
itemBuilder: (c, index){
|
|
return nearbyLockItem('images/icon_lock.png', "MCBN01-ea9240", (){
|
|
Navigator.pushNamed(context, Routers.lockDetailPage);
|
|
});
|
|
}
|
|
);
|
|
}
|
|
|
|
Widget nearbyLockItem(String lockTypeIcon, String lockTypeTitle, Function() action){
|
|
return GestureDetector(
|
|
onTap: action,
|
|
child: Container(
|
|
height: 150.h,
|
|
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(20.w),
|
|
),
|
|
child: Column(
|
|
// mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
SizedBox(height: 30.h,),
|
|
Row(
|
|
children: [
|
|
SizedBox(width:20.w),
|
|
Image.asset(lockTypeIcon, width: 50.w, height: 50.w,),
|
|
SizedBox(width:20.w),
|
|
Expanded(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(lockTypeTitle, style: TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w500), ),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(width:20.w),
|
|
Text("100%", style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w500), ),
|
|
SizedBox(width:5.w),
|
|
Image.asset('images/main/icon_main_cell.png', width: 50.w, height: 50.w,),
|
|
SizedBox(width:30.w),
|
|
],
|
|
),
|
|
SizedBox(height: 20.h,),
|
|
Row(
|
|
children: [
|
|
SizedBox(width:30.w),
|
|
Text("永久/管理员", style: TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w500), ),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget unHaveData(){
|
|
return Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
border: Border.all(width: 4, color: AppColors.mainColor),
|
|
borderRadius: BorderRadius.circular(75),
|
|
),
|
|
child:InkWell(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(30.0),
|
|
child: Image.asset('images/main/icon_main_addLock.png', width: 150.w, height: 150.w,),
|
|
),
|
|
onTap: () {
|
|
//实现回调函数
|
|
Navigator.pushNamed(context, Routers.seletLockTypePage,
|
|
// arguments: {
|
|
// "url": ConstConfig.privacAgreementUrl,
|
|
// "title": '隐私政策'
|
|
// }
|
|
);
|
|
},
|
|
)
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: h(50.h),),
|
|
Container(
|
|
padding: EdgeInsets.all(30.w),
|
|
child: Text(TranslationLoader.lanKeys!.whenAddingLockThePhoneMustBeNextToTheLock!.tr, style: TextStyle(fontSize: 30.sp, fontWeight: FontWeight.w800, color: AppColors.mainColor),)
|
|
)
|
|
],
|
|
);
|
|
}
|
|
|
|
void onShow(){
|
|
|
|
}
|
|
|
|
void onHide(){
|
|
|
|
}
|
|
}
|