diff --git a/lib/constants/application_objects.dart b/lib/constants/application_objects.dart index 59ba4bc0..23bab3ef 100644 --- a/lib/constants/application_objects.dart +++ b/lib/constants/application_objects.dart @@ -20,7 +20,7 @@ import 'package:aku_new_community/pages/life_pay/life_pay_page_new.dart'; import 'package:aku_new_community/pages/opening_code_page/opening_code_page.dart'; import 'package:aku_new_community/pages/renovation_manage/new_renovation/new_renovation_page.dart'; import 'package:aku_new_community/pages/service_browse/service_browse_page.dart'; -import 'package:aku_new_community/pages/services/old_age/old_age_support_page_simple.dart'; +import 'package:aku_new_community/pages/services/old_age/old_age_support_list_page.dart'; import 'package:aku_new_community/pages/setting_page/settings_page.dart'; import 'package:aku_new_community/pages/surrounding_enterprises/surrounding_enterprises_page.dart'; import 'package:aku_new_community/pages/visitor_access_page/visitor_access_page.dart'; diff --git a/lib/pages/services/old_age/equipment_list_page.dart b/lib/pages/services/old_age/equipment_list_page.dart index adaf39c4..391b7070 100644 --- a/lib/pages/services/old_age/equipment_list_page.dart +++ b/lib/pages/services/old_age/equipment_list_page.dart @@ -1,198 +1,34 @@ -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/widget/bee_divider.dart'; -import 'package:aku_new_community/widget/bee_scaffold.dart'; - -import 'add_equipment_page.dart'; - -class EquipmentListPage extends StatefulWidget { - const EquipmentListPage({Key? key}) : super(key: key); - - @override - _EquipmentListPageState createState() => _EquipmentListPageState(); -} - -class _EquipmentListPageState extends State { - BraceletListModel? _currentBracelet; - List _bracelets = []; - - @override - Widget build(BuildContext context) { - var user = Padding( - padding: EdgeInsets.only(left: 24.w, bottom: 24.w, right: 24.w), - child: Row( - children: [ - // CircleAvatar( - // child: Image.network( - // UserTool.userProvider.userInfoModel?.imgUrls.first.url ?? ''), - // ), - 24.w.widthBox, - '陈东强'.text.size(28.sp).color(Colors.black).make(), - Spacer(), - '切换用户'.text.size(24.sp).color(Colors.black.withOpacity(0.65)).make(), - 24.w.widthBox, - Icon( - CupertinoIcons.chevron_right, - size: 20.w, - ), - ], - ), - ); - var connected = Container( - padding: EdgeInsets.all(24.w), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - '当前连接' - .text - .size(24.sp) - .color(Colors.black.withOpacity(0.65)) - .bold - .make(), - 24.w.heightBox, - if (_currentBracelet != null) - _braceletWidget(e: _currentBracelet!, bgColor: Color(0xFF6395D7)) - ], - ), - ); - var bingding = Container( - padding: EdgeInsets.all(24.w), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - '已绑定设备' - .text - .size(24.sp) - .color(Colors.black.withOpacity(0.65)) - .bold - .make(), - 24.w.heightBox, - ..._bracelets - .map((e) => _braceletWidget( - e: e, - onTap: () { - _currentBracelet = e; - setState(() {}); - })) - .toList() - .sepWidget( - separate: 24.w.heightBox, - ), - ], - ), - ); - return BeeScaffold( - 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, - ], - ), - ), - ), - 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(), - ], - ), - ), - ); - } -} +// 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/widget/bee_divider.dart'; +// import 'package:aku_new_community/widget/bee_scaffold.dart'; +// +// import 'add_equipment_page.dart'; +// +// class EquipmentListPage extends StatefulWidget { +// const EquipmentListPage({Key? key}) : super(key: key); +// +// @override +// _EquipmentListPageState createState() => _EquipmentListPageState(); +// } +// +// class _EquipmentListPageState extends State { +// +// +// @override +// Widget build(BuildContext context) { +// +// } +// +// } diff --git a/lib/pages/services/old_age/old_age_support_page_simple.dart b/lib/pages/services/old_age/old_age_show_data_page.dart similarity index 75% rename from lib/pages/services/old_age/old_age_support_page_simple.dart rename to lib/pages/services/old_age/old_age_show_data_page.dart index 4762e714..0b08715e 100644 --- a/lib/pages/services/old_age/old_age_support_page_simple.dart +++ b/lib/pages/services/old_age/old_age_show_data_page.dart @@ -1,34 +1,28 @@ import 'dart:async'; import 'package:aku_new_community/constants/saas_api.dart'; -import 'package:aku_new_community/utils/network/base_model.dart'; -import 'package:aku_new_community/widget/others/user_tool.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -import 'package:bot_toast/bot_toast.dart'; -import 'package:common_utils/common_utils.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart' hide Response; -import 'package:velocity_x/velocity_x.dart'; - import 'package:aku_new_community/gen/assets.gen.dart'; import 'package:aku_new_community/models/bracelet/bracelet_model.dart'; -import 'package:aku_new_community/pages/services/old_age/add_equipment_page.dart'; -import 'package:aku_new_community/pages/services/old_age/equipment_list_page.dart'; +import 'package:aku_new_community/utils/headers.dart'; +import 'package:aku_new_community/utils/network/base_model.dart'; import 'package:aku_new_community/utils/network/net_util.dart'; import 'package:aku_new_community/widget/bee_divider.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; -class OldAgeSupportPageSimple extends StatefulWidget { - const OldAgeSupportPageSimple({Key? key}) : super(key: key); +class OldAgeShowDataPage extends StatefulWidget { + final String imei; + + const OldAgeShowDataPage({Key? key, required this.imei}) : super(key: key); @override - _OldAgeSupportPageSimpleState createState() => - _OldAgeSupportPageSimpleState(); + _OldAgeShowDataPageState createState() => _OldAgeShowDataPageState(); } -class _OldAgeSupportPageSimpleState extends State { +class _OldAgeShowDataPageState extends State { BraceletModel? _model; DateTime? _date; @@ -46,15 +40,26 @@ class _OldAgeSupportPageSimpleState extends State { _timer = null; } + Future getData() async { + BaseModel base = await NetUtil().get(SAASAPI.bracelet.data, params: { + 'imei': widget.imei, + }); + if (base.data != null) { + _model = BraceletModel.fromJson(base.data); + _date = DateTime.now(); + } + setState(() {}); + } + @override void initState() { + super.initState(); Future.delayed(Duration.zero, () async { var cancel = BotToast.showLoading(); await getData(); cancel(); _startTimer(); }); - super.initState(); } @override @@ -84,79 +89,63 @@ class _OldAgeSupportPageSimpleState extends State { .make(), ], ); - return _model == null - ? _emptyScaffold() - : BeeScaffold( - title: 'X5手环', - extendBody: true, - actions: [ - IconButton( - icon: Icon(CupertinoIcons.repeat), - iconSize: 30.w, - color: Colors.black, - onPressed: () { - Get.to(() => EquipmentListPage()); - }, - ) - ], - body: Container( - width: double.infinity, - height: double.infinity, - decoration: BoxDecoration( - image: DecorationImage( - alignment: Alignment.topCenter, - image: AssetImage(Assets.static.braceletHeader.path)), - gradient: LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - Colors.white, - Color(0xFFC0E5DC).withOpacity(0.355) - ]), - ), - child: _model == null - ? Container() - : SafeArea( - child: ListView( - padding: EdgeInsets.symmetric(horizontal: 32.w), - children: [ - 400.w.heightBox, - open, - 16.w.heightBox, - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - '数据更新自 ${DateUtil.formatDate(_date!, format: DateFormats.full)}' - .text - .size(22.sp) - .color(Colors.black.withOpacity(0.25)) - .make(), - 40.w.heightBox, - ], - ), - 40.w.heightBox, - overview(), - 24.w.heightBox, - statusCard(), - 40.w.heightBox, - bottomCard(), - 40.w.heightBox, - ], - ), + return BeeScaffold( + title: 'X5手环', + extendBody: true, + // actions: [ + // IconButton( + // icon: Icon(CupertinoIcons.repeat), + // iconSize: 30.w, + // color: Colors.black, + // onPressed: () { + // Get.to(() => EquipmentListPage()); + // }, + // ) + // ], + body: Container( + width: double.infinity, + height: double.infinity, + decoration: BoxDecoration( + image: DecorationImage( + alignment: Alignment.topCenter, + image: AssetImage(Assets.static.braceletHeader.path)), + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [Colors.white, Color(0xFFC0E5DC).withOpacity(0.355)]), + ), + child: _model == null + ? Container() + : SafeArea( + child: ListView( + padding: EdgeInsets.symmetric(horizontal: 32.w), + children: [ + 400.w.heightBox, + open, + 16.w.heightBox, + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + '数据更新自 ${DateUtil.formatDate(_date!, format: DateFormats.full)}' + .text + .size(22.sp) + .color(Colors.black.withOpacity(0.25)) + .make(), + 40.w.heightBox, + ], ), - ), - ); - } - - Future getData() async { - BaseModel base = await NetUtil().get(SAASAPI.bracelet.data, params: { - 'imei': UserTool.oldAgeProvider.imei, - }); - if (base.data != null) { - _model = BraceletModel.fromJson(base.data); - _date = DateTime.now(); - } - setState(() {}); + 40.w.heightBox, + overview(), + 24.w.heightBox, + statusCard(), + 40.w.heightBox, + bottomCard(), + 40.w.heightBox, + ], + ), + ), + ), + ); } Container bottomCard() { @@ -545,49 +534,4 @@ class _OldAgeSupportPageSimpleState extends State { ), ); } - - Widget _emptyScaffold() { - return BeeScaffold( - title: '智慧养老', - body: SafeArea( - child: Center( - child: Column( - children: [ - Assets.images.equipmentEmpty.image(width: 480.w, height: 480.w), - '当前没有绑定任何设备' - .text - .size(28.sp) - .color(Colors.black.withOpacity(0.25)) - .make(), - ], - ), - ), - ), - actions: [ - IconButton( - icon: Icon(CupertinoIcons.repeat), - iconSize: 30.w, - color: Colors.black, - onPressed: () { - Get.to(() => EquipmentListPage()); - }, - ) - ], - 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(), - ), - ), - ); - } } diff --git a/lib/pages/services/old_age/old_age_support_list_page.dart b/lib/pages/services/old_age/old_age_support_list_page.dart new file mode 100644 index 00000000..5b7251b3 --- /dev/null +++ b/lib/pages/services/old_age/old_age_support_list_page.dart @@ -0,0 +1,232 @@ +import 'dart:async'; + +import 'package:aku_new_community/constants/saas_api.dart'; +import 'package:aku_new_community/extensions/widget_list_ext.dart'; +import 'package:aku_new_community/models/bracelet/bracelet_list_model.dart'; +import 'package:aku_new_community/pages/services/old_age/old_age_show_data_page.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' hide Response; +import 'package:velocity_x/velocity_x.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/utils/network/net_util.dart'; +import 'package:aku_new_community/widget/bee_divider.dart'; +import 'package:aku_new_community/widget/bee_scaffold.dart'; + +class OldAgeSupportPageSimple extends StatefulWidget { + const OldAgeSupportPageSimple({Key? key}) : super(key: key); + + @override + _OldAgeSupportPageSimpleState createState() => + _OldAgeSupportPageSimpleState(); +} + +class _OldAgeSupportPageSimpleState extends State { + BraceletListModel? _currentBracelet; + List _bracelets = []; + + @override + void initState() { + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + + @override + Widget build(BuildContext context) { + var user = Padding( + padding: EdgeInsets.only(left: 24.w, bottom: 24.w, right: 24.w), + child: Row( + children: [ + // CircleAvatar( + // child: Image.network( + // UserTool.userProvider.userInfoModel?.imgUrls.first.url ?? ''), + // ), + 24.w.widthBox, + '陈东强'.text.size(28.sp).color(Colors.black).make(), + Spacer(), + '切换用户'.text.size(24.sp).color(Colors.black.withOpacity(0.65)).make(), + 24.w.widthBox, + Icon( + CupertinoIcons.chevron_right, + size: 20.w, + ), + ], + ), + ); + var connected = Container( + padding: EdgeInsets.all(24.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + '当前连接' + .text + .size(24.sp) + .color(Colors.black.withOpacity(0.65)) + .bold + .make(), + 24.w.heightBox, + if (_currentBracelet != null) + _braceletWidget(e: _currentBracelet!, bgColor: Color(0xFF6395D7),onTap: ()async{ + Get.to(OldAgeShowDataPage(imei: _currentBracelet!.imei,)); + }) + ], + ), + ); + var bingding = Container( + padding: EdgeInsets.all(24.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + '已绑定设备' + .text + .size(24.sp) + .color(Colors.black.withOpacity(0.65)) + .bold + .make(), + 24.w.heightBox, + ..._bracelets + .map((e) => _braceletWidget( + e: e, + onTap: () { + _currentBracelet = e; + setState(() {}); + })) + .toList() + .sepWidget( + separate: 24.w.heightBox, + ), + ], + ), + ); + return BeeScaffold( + 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: _bracelets.isEmpty + ? _emptyWidgt() + : ListView( + padding: EdgeInsets.all(24.w), + children: [ + // 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(), + ], + ), + ), + ); + } + + Widget _emptyWidgt() { + return SafeArea( + child: Center( + child: Column( + children: [ + Assets.images.equipmentEmpty.image(width: 480.w, height: 480.w), + '当前没有绑定任何设备' + .text + .size(28.sp) + .color(Colors.black.withOpacity(0.25)) + .make(), + ], + ), + ), + ); + } +} diff --git a/lib/utils/application_utils.dart b/lib/utils/application_utils.dart index 46e23b8f..34e90665 100644 --- a/lib/utils/application_utils.dart +++ b/lib/utils/application_utils.dart @@ -19,7 +19,7 @@ import 'package:aku_new_community/pages/life_pay/life_pay_page_new.dart'; import 'package:aku_new_community/pages/opening_code_page/opening_code_page.dart'; import 'package:aku_new_community/pages/renovation_manage/new_renovation/new_renovation_page.dart'; import 'package:aku_new_community/pages/service_browse/service_browse_page.dart'; -import 'package:aku_new_community/pages/services/old_age/old_age_support_page_simple.dart'; +import 'package:aku_new_community/pages/services/old_age/old_age_support_list_page.dart'; import 'package:aku_new_community/pages/surrounding_enterprises/surrounding_enterprises_page.dart'; import 'package:aku_new_community/ui/community/facility/facility_appointment_page.dart'; import 'package:aku_new_community/ui/function_and_service/task/task_page.dart';