app-starlock/star_lock/lib/main/lockMian/lockMain_page.dart
Daisy 3840f0c8c8 1,更新剩余部分UI
2,新增部分界面
3,新增公共组件底部白色添加按钮
2023-07-29 17:04:03 +08:00

207 lines
6.2 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
Widget build(BuildContext context) {
final logic = Get.put(GetxBle());
// Get.lazyPut(()=>GetxBle());
logic.scanner.startScan([]);
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: 44.w,
height: 44.w,
),
onPressed: () {
Scaffold.of(context).openDrawer();
},
)),
backgroundColor: AppColors.mainColor,
actionsList: [
TextButton(
child: const Text("", style: TextStyle(color: Colors.white)),
onPressed: () {
Navigator.pushNamed(context, Routers.starLockLoginPage);
},
),
],
),
drawer: Drawer(
width: 1.sw / 3 * 2,
child: StarLockMinePage(),
),
body: getLockList(),
// body: unHaveData(),
);
}
Widget getLockList() {
return ListView.builder(
itemCount: 5,
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: 122.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: 20.h,
),
Row(
children: [
SizedBox(width: 30.w),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
lockTypeTitle,
style: TextStyle(
fontSize: 24.sp, fontWeight: FontWeight.w500),
),
],
),
),
SizedBox(width: 20.w),
Text(
"100%",
style: TextStyle(
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
),
SizedBox(width: 2.w),
Image.asset(
'images/main/icon_main_cell.png',
width: 30.w,
height: 24.w,
),
SizedBox(width: 30.w),
],
),
SizedBox(
height: 20.h,
),
Row(
children: [
SizedBox(width: 30.w),
Text(
"永久/管理员",
style: TextStyle(
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
),
],
),
],
),
),
);
}
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() {}
}