智慧养老列表修改 已选设备全局保存 自动刷新

pull/1/head
张萌 3 years ago
parent c7f6e77a8a
commit adc538516f

@ -113,7 +113,7 @@ List<AO> appObjects = [
AO('住房说明', Assets.newIcon.icRwsm.path, AO('住房说明', Assets.newIcon.icRwsm.path,
() => Get.to(() => HouseIntroducePage())), () => Get.to(() => HouseIntroducePage())),
AO('智慧养老', Assets.home.icZhyl.path, AO('智慧养老', Assets.home.icZhyl.path,
() => Get.to(() => OldAgeSupportPageSimple())), () => Get.to(() => OldAgeSupportListPage())),
AO('周边服务', Assets.home.icZbfw.path, null), AO('周边服务', Assets.home.icZbfw.path, null),
AO('任务发布', Assets.home.icRwfb.path, () => Get.to(() => TaskPage())), AO('任务发布', Assets.home.icRwfb.path, () => Get.to(() => TaskPage())),
AO('自营商城', Assets.icons.shoppingMall.path, null), AO('自营商城', Assets.icons.shoppingMall.path, null),

@ -142,8 +142,8 @@ class _AddEquipmentPageState extends State<AddEquipmentPage> {
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
children: [ children: [
GestureDetector( GestureDetector(
onTap: () { onTap: () async{
Get.to(() => SubmitEquipmentCodePage()); await Get.to(() => SubmitEquipmentCodePage());
}, },
child: Material( child: Material(
color: Colors.transparent, color: Colors.transparent,

@ -8,15 +8,14 @@ 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/utils/network/net_util.dart';
import 'package:aku_new_community/widget/bee_divider.dart'; import 'package:aku_new_community/widget/bee_divider.dart';
import 'package:aku_new_community/widget/bee_scaffold.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart';
import 'package:aku_new_community/widget/others/user_tool.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:common_utils/common_utils.dart'; import 'package:common_utils/common_utils.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class OldAgeShowDataPage extends StatefulWidget { class OldAgeShowDataPage extends StatefulWidget {
final String imei; const OldAgeShowDataPage({Key? key,}) : super(key: key);
const OldAgeShowDataPage({Key? key, required this.imei}) : super(key: key);
@override @override
_OldAgeShowDataPageState createState() => _OldAgeShowDataPageState(); _OldAgeShowDataPageState createState() => _OldAgeShowDataPageState();
@ -42,7 +41,7 @@ class _OldAgeShowDataPageState extends State<OldAgeShowDataPage> {
Future getData() async { Future getData() async {
BaseModel base = await NetUtil().get(SAASAPI.bracelet.data, params: { BaseModel base = await NetUtil().get(SAASAPI.bracelet.data, params: {
'imei': widget.imei, 'imei': UserTool.oldAgeProvider.bracelet?.imei,
}); });
if (base.data != null) { if (base.data != null) {
_model = BraceletModel.fromJson(base.data); _model = BraceletModel.fromJson(base.data);

@ -18,17 +18,16 @@ 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_divider.dart';
import 'package:aku_new_community/widget/bee_scaffold.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart';
class OldAgeSupportPageSimple extends StatefulWidget { class OldAgeSupportListPage extends StatefulWidget {
const OldAgeSupportPageSimple({Key? key}) : super(key: key); const OldAgeSupportListPage({Key? key}) : super(key: key);
@override @override
_OldAgeSupportPageSimpleState createState() => _OldAgeSupportListPageState createState() => _OldAgeSupportListPageState();
_OldAgeSupportPageSimpleState();
} }
class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> { class _OldAgeSupportListPageState extends State<OldAgeSupportListPage> {
BraceletListModel? _currentBracelet;
List<BraceletListModel> _bracelets = []; List<BraceletListModel> _bracelets = [];
EasyRefreshController _refreshController = EasyRefreshController();
@override @override
void initState() { void initState() {
@ -37,6 +36,7 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
@override @override
void dispose() { void dispose() {
_refreshController.dispose();
super.dispose(); super.dispose();
} }
@ -74,10 +74,13 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
.bold .bold
.make(), .make(),
24.w.heightBox, 24.w.heightBox,
if (_currentBracelet != null) if (UserTool.oldAgeProvider.bracelet != null)
_braceletWidget(e: _currentBracelet!, bgColor: Color(0xFF6395D7),onTap: ()async{ _braceletWidget(
Get.to(OldAgeShowDataPage(imei: _currentBracelet!.imei,)); e: UserTool.oldAgeProvider.bracelet!,
}) select: true,
onTap: () async {
Get.to(OldAgeShowDataPage());
}),
], ],
), ),
); );
@ -96,8 +99,9 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
..._bracelets ..._bracelets
.map((e) => _braceletWidget( .map((e) => _braceletWidget(
e: e, e: e,
select: false,
onTap: () { onTap: () {
_currentBracelet = e; UserTool.oldAgeProvider.changeImei(e);
setState(() {}); setState(() {});
})) }))
.toList() .toList()
@ -112,6 +116,7 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
bodyColor: Colors.white, bodyColor: Colors.white,
body: SafeArea( body: SafeArea(
child: EasyRefresh( child: EasyRefresh(
controller: _refreshController,
firstRefresh: true, firstRefresh: true,
header: MaterialHeader(), header: MaterialHeader(),
onRefresh: () async { onRefresh: () async {
@ -142,8 +147,9 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
bottomNavi: Padding( bottomNavi: Padding(
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w),
child: MaterialButton( child: MaterialButton(
onPressed: () { onPressed: () async {
Get.to(() => AddEquipmentPage()); await Get.to(() => AddEquipmentPage());
_refreshController.callRefresh();
}, },
color: Color(0xFF5096F1), color: Color(0xFF5096F1),
padding: EdgeInsets.symmetric(vertical: 24.w), padding: EdgeInsets.symmetric(vertical: 24.w),
@ -158,14 +164,16 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
} }
Widget _braceletWidget( Widget _braceletWidget(
{required BraceletListModel e, VoidCallback? onTap, Color? bgColor}) { {required BraceletListModel e,
VoidCallback? onTap,
required bool select}) {
return GestureDetector( return GestureDetector(
onTap: onTap, onTap: onTap,
child: Container( child: Container(
width: double.infinity, width: double.infinity,
padding: EdgeInsets.all(24.w), padding: EdgeInsets.all(24.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: bgColor ?? Colors.black.withOpacity(0.06), color: select ? Color(0xFF6395D7) : Colors.black.withOpacity(0.06),
borderRadius: BorderRadius.circular(16.w)), borderRadius: BorderRadius.circular(16.w)),
child: Row( child: Row(
children: [ children: [
@ -182,13 +190,15 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
'${e.deviceType} ${e.braceletBrand.name}' '${e.deviceType} ${e.braceletBrand.name}'
.text .text
.size(24.sp) .size(24.sp)
.color(Colors.black.withOpacity(0.65)) .color(
select ? Colors.white : Colors.black.withOpacity(0.65))
.make(), .make(),
16.w.heightBox, 16.w.heightBox,
'设备码:${e.imei}' '设备码:${e.imei}'
.text .text
.size(24.sp) .size(24.sp)
.color(Colors.black.withOpacity(0.65)) .color(
select ? Colors.white : Colors.black.withOpacity(0.65))
.make(), .make(),
], ],
), ),
@ -197,15 +207,15 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
width: 15.w, width: 15.w,
height: 16.w, height: 16.w,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.black.withOpacity(0.25), color:select ? Colors.white : Colors.black.withOpacity(0.25),
borderRadius: BorderRadius.circular(16.w), borderRadius: BorderRadius.circular(16.w),
), ),
), ),
24.w.widthBox, 24.w.widthBox,
'${UserTool.oldAgeProvider.imei == e.imei ? '已连接' : '未开启'}' '${select ? '已连接' : '未开启'}'
.text .text
.size(24.sp) .size(24.sp)
.color(Colors.black.withOpacity(0.65)) .color(select ? Colors.white : Colors.black.withOpacity(0.65))
.make(), .make(),
], ],
), ),

@ -84,9 +84,6 @@ class _SubmitEquipmentCodePageState extends State<SubmitEquipmentCodePage> {
if (base.success) { if (base.success) {
Get.back(); Get.back();
Get.back(); Get.back();
if (UserTool.oldAgeProvider.imei.isEmpty) {
UserTool.oldAgeProvider.changeImei(_editingController.text);
}
} else { } else {
BotToast.showText(text: base.msg); BotToast.showText(text: base.msg);
} }

@ -1,12 +1,13 @@
import 'package:aku_new_community/models/bracelet/bracelet_list_model.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class OldAgeProvider extends ChangeNotifier { class OldAgeProvider extends ChangeNotifier {
String _imei=''; BraceletListModel? _bracelet;
String get imei => _imei; BraceletListModel? get bracelet => _bracelet ;
void changeImei(String value) { void changeImei(BraceletListModel value) {
_imei = value; _bracelet = value;
notifyListeners(); notifyListeners();
} }
} }

@ -190,7 +190,7 @@ class ApplicationUtil {
title: '智慧养老', title: '智慧养老',
imgPath: Assets.home.icZhyl.path, imgPath: Assets.home.icZhyl.path,
onTap: () { onTap: () {
Get.to(() => OldAgeSupportPageSimple()); Get.to(() => OldAgeSupportListPage());
}), }),
AppElement( AppElement(
title: '周边服务', title: '周边服务',

Loading…
Cancel
Save