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

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

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

@ -142,8 +142,8 @@ class _AddEquipmentPageState extends State<AddEquipmentPage> {
physics: NeverScrollableScrollPhysics(),
children: [
GestureDetector(
onTap: () {
Get.to(() => SubmitEquipmentCodePage());
onTap: () async{
await Get.to(() => SubmitEquipmentCodePage());
},
child: Material(
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/widget/bee_divider.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:common_utils/common_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class OldAgeShowDataPage extends StatefulWidget {
final String imei;
const OldAgeShowDataPage({Key? key, required this.imei}) : super(key: key);
const OldAgeShowDataPage({Key? key,}) : super(key: key);
@override
_OldAgeShowDataPageState createState() => _OldAgeShowDataPageState();
@ -42,7 +41,7 @@ class _OldAgeShowDataPageState extends State<OldAgeShowDataPage> {
Future getData() async {
BaseModel base = await NetUtil().get(SAASAPI.bracelet.data, params: {
'imei': widget.imei,
'imei': UserTool.oldAgeProvider.bracelet?.imei,
});
if (base.data != null) {
_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_scaffold.dart';
class OldAgeSupportPageSimple extends StatefulWidget {
const OldAgeSupportPageSimple({Key? key}) : super(key: key);
class OldAgeSupportListPage extends StatefulWidget {
const OldAgeSupportListPage({Key? key}) : super(key: key);
@override
_OldAgeSupportPageSimpleState createState() =>
_OldAgeSupportPageSimpleState();
_OldAgeSupportListPageState createState() => _OldAgeSupportListPageState();
}
class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
BraceletListModel? _currentBracelet;
class _OldAgeSupportListPageState extends State<OldAgeSupportListPage> {
List<BraceletListModel> _bracelets = [];
EasyRefreshController _refreshController = EasyRefreshController();
@override
void initState() {
@ -37,6 +36,7 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
@override
void dispose() {
_refreshController.dispose();
super.dispose();
}
@ -74,10 +74,13 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
.bold
.make(),
24.w.heightBox,
if (_currentBracelet != null)
_braceletWidget(e: _currentBracelet!, bgColor: Color(0xFF6395D7),onTap: ()async{
Get.to(OldAgeShowDataPage(imei: _currentBracelet!.imei,));
})
if (UserTool.oldAgeProvider.bracelet != null)
_braceletWidget(
e: UserTool.oldAgeProvider.bracelet!,
select: true,
onTap: () async {
Get.to(OldAgeShowDataPage());
}),
],
),
);
@ -96,8 +99,9 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
..._bracelets
.map((e) => _braceletWidget(
e: e,
select: false,
onTap: () {
_currentBracelet = e;
UserTool.oldAgeProvider.changeImei(e);
setState(() {});
}))
.toList()
@ -108,24 +112,25 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
),
);
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(
title: '设备列表',
bodyColor: Colors.white,
body: SafeArea(
child: EasyRefresh(
controller: _refreshController,
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,
@ -137,35 +142,38 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
// 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(),
),
),
);
),
),
bottomNavi: Padding(
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w),
child: MaterialButton(
onPressed: () async {
await Get.to(() => AddEquipmentPage());
_refreshController.callRefresh();
},
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}) {
{required BraceletListModel e,
VoidCallback? onTap,
required bool select}) {
return GestureDetector(
onTap: onTap,
child: Container(
width: double.infinity,
padding: EdgeInsets.all(24.w),
decoration: BoxDecoration(
color: bgColor ?? Colors.black.withOpacity(0.06),
color: select ? Color(0xFF6395D7) : Colors.black.withOpacity(0.06),
borderRadius: BorderRadius.circular(16.w)),
child: Row(
children: [
@ -182,13 +190,15 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
'${e.deviceType} ${e.braceletBrand.name}'
.text
.size(24.sp)
.color(Colors.black.withOpacity(0.65))
.color(
select ? Colors.white : Colors.black.withOpacity(0.65))
.make(),
16.w.heightBox,
'设备码:${e.imei}'
.text
.size(24.sp)
.color(Colors.black.withOpacity(0.65))
.color(
select ? Colors.white : Colors.black.withOpacity(0.65))
.make(),
],
),
@ -197,15 +207,15 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
width: 15.w,
height: 16.w,
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.25),
color:select ? Colors.white : Colors.black.withOpacity(0.25),
borderRadius: BorderRadius.circular(16.w),
),
),
24.w.widthBox,
'${UserTool.oldAgeProvider.imei == e.imei ? '已连接' : '未开启'}'
'${select ? '已连接' : '未开启'}'
.text
.size(24.sp)
.color(Colors.black.withOpacity(0.65))
.color(select ? Colors.white : Colors.black.withOpacity(0.65))
.make(),
],
),

@ -84,9 +84,6 @@ class _SubmitEquipmentCodePageState extends State<SubmitEquipmentCodePage> {
if (base.success) {
Get.back();
Get.back();
if (UserTool.oldAgeProvider.imei.isEmpty) {
UserTool.oldAgeProvider.changeImei(_editingController.text);
}
} else {
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';
class OldAgeProvider extends ChangeNotifier {
String _imei='';
BraceletListModel? _bracelet;
String get imei => _imei;
BraceletListModel? get bracelet => _bracelet ;
void changeImei(String value) {
_imei = value;
void changeImei(BraceletListModel value) {
_bracelet = value;
notifyListeners();
}
}

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

Loading…
Cancel
Save