|
|
|
@ -1,29 +1,20 @@
|
|
|
|
|
import 'package:aku_new_community/constants/saas_api.dart';
|
|
|
|
|
import 'package:aku_new_community/models/bracelet/bracelet_list_model.dart';
|
|
|
|
|
import 'package:aku_new_community/utils/network/net_util.dart';
|
|
|
|
|
import 'package:aku_new_community/widget/others/user_tool.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
import 'package:velocity_x/velocity_x.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:aku_new_community/extensions/widget_list_ext.dart';
|
|
|
|
|
import 'package:aku_new_community/gen/assets.gen.dart';
|
|
|
|
|
import 'package:aku_new_community/pages/services/old_age/add_equipment_page.dart';
|
|
|
|
|
import 'package:aku_new_community/widget/bee_divider.dart';
|
|
|
|
|
import 'package:aku_new_community/widget/bee_scaffold.dart';
|
|
|
|
|
|
|
|
|
|
class bracelet {
|
|
|
|
|
String title;
|
|
|
|
|
String describe;
|
|
|
|
|
bool open;
|
|
|
|
|
String path;
|
|
|
|
|
|
|
|
|
|
bracelet({
|
|
|
|
|
required this.title,
|
|
|
|
|
required this.describe,
|
|
|
|
|
required this.open,
|
|
|
|
|
required this.path,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
import 'add_equipment_page.dart';
|
|
|
|
|
|
|
|
|
|
class EquipmentListPage extends StatefulWidget {
|
|
|
|
|
const EquipmentListPage({Key? key}) : super(key: key);
|
|
|
|
@ -33,20 +24,8 @@ class EquipmentListPage extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _EquipmentListPageState extends State<EquipmentListPage> {
|
|
|
|
|
List<bracelet> _connects = [
|
|
|
|
|
bracelet(
|
|
|
|
|
title: 'x5手环',
|
|
|
|
|
describe: '爱牵挂',
|
|
|
|
|
open: true,
|
|
|
|
|
path: Assets.bracelet.x5.path),
|
|
|
|
|
];
|
|
|
|
|
List<bracelet> _bracelets = [
|
|
|
|
|
bracelet(
|
|
|
|
|
title: 'x8手环 旗舰型',
|
|
|
|
|
describe: '爱牵挂',
|
|
|
|
|
open: false,
|
|
|
|
|
path: Assets.bracelet.x8.path),
|
|
|
|
|
];
|
|
|
|
|
BraceletListModel? _currentBracelet;
|
|
|
|
|
List<BraceletListModel> _bracelets = [];
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
@ -82,49 +61,8 @@ class _EquipmentListPageState extends State<EquipmentListPage> {
|
|
|
|
|
.bold
|
|
|
|
|
.make(),
|
|
|
|
|
24.w.heightBox,
|
|
|
|
|
..._connects
|
|
|
|
|
.map((e) => Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
padding: EdgeInsets.all(24.w),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Color(0xFF6395D7),
|
|
|
|
|
borderRadius: BorderRadius.circular(16.w)),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Image.asset(
|
|
|
|
|
e.path,
|
|
|
|
|
width: 100.w,
|
|
|
|
|
height: 100.w,
|
|
|
|
|
),
|
|
|
|
|
12.w.widthBox,
|
|
|
|
|
Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
'${e.title}'.text.size(24.sp).white.make(),
|
|
|
|
|
16.w.heightBox,
|
|
|
|
|
'${e.describe}'.text.size(24.sp).white.make(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Spacer(),
|
|
|
|
|
Container(
|
|
|
|
|
width: 15.w,
|
|
|
|
|
height: 16.w,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(16.w),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
24.w.widthBox,
|
|
|
|
|
'${e.open ? '已连接' : '未开启'}'
|
|
|
|
|
.text
|
|
|
|
|
.size(24.sp)
|
|
|
|
|
.white
|
|
|
|
|
.make(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
))
|
|
|
|
|
.toList()
|
|
|
|
|
.sepWidget(separate: 24.w.heightBox),
|
|
|
|
|
if (_currentBracelet != null)
|
|
|
|
|
_braceletWidget(e: _currentBracelet!, bgColor: Color(0xFF6395D7))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
@ -141,55 +79,12 @@ class _EquipmentListPageState extends State<EquipmentListPage> {
|
|
|
|
|
.make(),
|
|
|
|
|
24.w.heightBox,
|
|
|
|
|
..._bracelets
|
|
|
|
|
.map((e) => Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
padding: EdgeInsets.all(24.w),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.black.withOpacity(0.06),
|
|
|
|
|
borderRadius: BorderRadius.circular(16.w)),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Image.asset(
|
|
|
|
|
e.path,
|
|
|
|
|
width: 100.w,
|
|
|
|
|
height: 100.w,
|
|
|
|
|
),
|
|
|
|
|
12.w.widthBox,
|
|
|
|
|
Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
'${e.title}'
|
|
|
|
|
.text
|
|
|
|
|
.size(24.sp)
|
|
|
|
|
.color(Colors.black.withOpacity(0.65))
|
|
|
|
|
.make(),
|
|
|
|
|
16.w.heightBox,
|
|
|
|
|
'${e.describe}'
|
|
|
|
|
.text
|
|
|
|
|
.size(24.sp)
|
|
|
|
|
.color(Colors.black.withOpacity(0.65))
|
|
|
|
|
.make(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Spacer(),
|
|
|
|
|
Container(
|
|
|
|
|
width: 15.w,
|
|
|
|
|
height: 16.w,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.black.withOpacity(0.25),
|
|
|
|
|
borderRadius: BorderRadius.circular(16.w),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
24.w.widthBox,
|
|
|
|
|
'${e.open ? '已连接' : '未开启'}'
|
|
|
|
|
.text
|
|
|
|
|
.size(24.sp)
|
|
|
|
|
.color(Colors.black.withOpacity(0.65))
|
|
|
|
|
.make(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
))
|
|
|
|
|
.map((e) => _braceletWidget(
|
|
|
|
|
e: e,
|
|
|
|
|
onTap: () {
|
|
|
|
|
_currentBracelet = e;
|
|
|
|
|
setState(() {});
|
|
|
|
|
}))
|
|
|
|
|
.toList()
|
|
|
|
|
.sepWidget(
|
|
|
|
|
separate: 24.w.heightBox,
|
|
|
|
@ -201,32 +96,103 @@ class _EquipmentListPageState extends State<EquipmentListPage> {
|
|
|
|
|
title: '设备列表',
|
|
|
|
|
bodyColor: Colors.white,
|
|
|
|
|
body: SafeArea(
|
|
|
|
|
child: EasyRefresh(
|
|
|
|
|
firstRefresh: true,
|
|
|
|
|
header: MaterialHeader(),
|
|
|
|
|
onRefresh: () async {
|
|
|
|
|
var base = await NetUtil().get(SAASAPI.bracelet.list);
|
|
|
|
|
if (base.success) {
|
|
|
|
|
_bracelets = (base.data as List)
|
|
|
|
|
.map((e) => BraceletListModel.fromJson(e))
|
|
|
|
|
.toList();
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
child: ListView(
|
|
|
|
|
padding: EdgeInsets.all(24.w),
|
|
|
|
|
children: [
|
|
|
|
|
// user,
|
|
|
|
|
// BeeDivider.horizontal(),
|
|
|
|
|
connected,
|
|
|
|
|
24.w.heightBox,
|
|
|
|
|
bingding,
|
|
|
|
|
BeeDivider.horizontal(),
|
|
|
|
|
// 24.w.heightBox,
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
padding: EdgeInsets.all(24.w),
|
|
|
|
|
children: [
|
|
|
|
|
TextButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Get.to(() => AddEquipmentPage());
|
|
|
|
|
},
|
|
|
|
|
child: '添加智能设备'
|
|
|
|
|
.text
|
|
|
|
|
.size(28.sp)
|
|
|
|
|
.color(Color(0xFF6395D7))
|
|
|
|
|
.make()),
|
|
|
|
|
// user,
|
|
|
|
|
// BeeDivider.horizontal(),
|
|
|
|
|
connected,
|
|
|
|
|
24.w.heightBox,
|
|
|
|
|
bingding,
|
|
|
|
|
BeeDivider.horizontal(),
|
|
|
|
|
// 24.w.heightBox,
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
bottomNavi: Padding(
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w),
|
|
|
|
|
child: MaterialButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Get.to(() => AddEquipmentPage());
|
|
|
|
|
},
|
|
|
|
|
color: Color(0xFF5096F1),
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 24.w),
|
|
|
|
|
minWidth: 686.w,
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(8.w),
|
|
|
|
|
),
|
|
|
|
|
child: '添加设备'.text.size(28.sp).white.make(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _braceletWidget(
|
|
|
|
|
{required BraceletListModel e, VoidCallback? onTap, Color? bgColor}) {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: onTap,
|
|
|
|
|
child: Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
padding: EdgeInsets.all(24.w),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: bgColor ?? Colors.black.withOpacity(0.06),
|
|
|
|
|
borderRadius: BorderRadius.circular(16.w)),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Image.asset(
|
|
|
|
|
e.braceletBrand.imgPath,
|
|
|
|
|
width: 100.w,
|
|
|
|
|
height: 100.w,
|
|
|
|
|
),
|
|
|
|
|
12.w.widthBox,
|
|
|
|
|
Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
'${e.deviceType} ${e.braceletBrand.name}'
|
|
|
|
|
.text
|
|
|
|
|
.size(24.sp)
|
|
|
|
|
.color(Colors.black.withOpacity(0.65))
|
|
|
|
|
.make(),
|
|
|
|
|
16.w.heightBox,
|
|
|
|
|
'设备码:${e.imei}'
|
|
|
|
|
.text
|
|
|
|
|
.size(24.sp)
|
|
|
|
|
.color(Colors.black.withOpacity(0.65))
|
|
|
|
|
.make(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Spacer(),
|
|
|
|
|
Container(
|
|
|
|
|
width: 15.w,
|
|
|
|
|
height: 16.w,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.black.withOpacity(0.25),
|
|
|
|
|
borderRadius: BorderRadius.circular(16.w),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
24.w.widthBox,
|
|
|
|
|
'${UserTool.oldAgeProvider.imei == e.imei ? '已连接' : '未开启'}'
|
|
|
|
|
.text
|
|
|
|
|
.size(24.sp)
|
|
|
|
|
.color(Colors.black.withOpacity(0.65))
|
|
|
|
|
.make(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|