176 lines
5.5 KiB
Dart
Executable File
176 lines
5.5 KiB
Dart
Executable File
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/tools/noData.dart';
|
|
|
|
import '../../../appRouters.dart';
|
|
import '../../../app_settings/app_colors.dart';
|
|
import '../../../tools/EasyRefreshTool.dart';
|
|
import '../../../tools/titleAppBar.dart';
|
|
import '../../mineSet/transferGateway/selectGetewayList_entity.dart';
|
|
import 'gatewayList_logic.dart';
|
|
import 'gatewayList_state.dart';
|
|
|
|
class GatewayListPage extends StatefulWidget {
|
|
const GatewayListPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<GatewayListPage> createState() => _GatewayListPageState();
|
|
}
|
|
|
|
class _GatewayListPageState extends State<GatewayListPage> {
|
|
final GatewayListLogic logic = Get.put(GatewayListLogic());
|
|
final GatewayListState state = Get.find<GatewayListLogic>().state;
|
|
|
|
Future<void> getHttpData({required bool isRefresh}) async {
|
|
logic.getGatewayListData(isRefresh: isRefresh).then((GetewayDataEntity value) {
|
|
if (mounted) {
|
|
setState(() {});
|
|
}
|
|
});
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
getHttpData(isRefresh: true);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: '网关'.tr,
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor,
|
|
actionsList: <Widget>[
|
|
GestureDetector(
|
|
onTap: () {
|
|
Get.toNamed(Routers.selectGatewayTypeNextTipPage)!.then((dynamic value) => getHttpData(isRefresh: true));
|
|
},
|
|
child: Image.asset(
|
|
'images/icon_add_white.png',
|
|
width: 36.w,
|
|
height: 36.w,
|
|
)),
|
|
SizedBox(
|
|
width: 30.w,
|
|
),
|
|
],
|
|
),
|
|
body: EasyRefreshTool(
|
|
onRefresh: () {
|
|
getHttpData(isRefresh: true);
|
|
},
|
|
onLoad: () {
|
|
getHttpData(isRefresh: false);
|
|
},
|
|
child: state.getewayListData.isNotEmpty ?ListView.separated(
|
|
itemCount: state.getewayListData.length,
|
|
itemBuilder: (BuildContext c, int index) {
|
|
final GetewayItemData item = state.getewayListData[index];
|
|
return _gatewatListItem(item, () {
|
|
Get.toNamed(Routers.gatewayDetailPage, arguments: {
|
|
'getewayItemData': item
|
|
})!.then((dynamic value) => getHttpData(isRefresh: true));
|
|
});
|
|
},
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
return Divider(
|
|
height: 1,
|
|
color: AppColors.greyLineColor,
|
|
indent: 20.w,
|
|
endIndent: 0,
|
|
);
|
|
},
|
|
):NoData()),
|
|
);
|
|
}
|
|
|
|
Widget _gatewatListItem(GetewayItemData getewayItemData, Function() action) {
|
|
return GestureDetector(
|
|
onTap: action,
|
|
child: Container(
|
|
// height: 100.h,
|
|
// margin: const EdgeInsets.only(bottom: 2),
|
|
padding:
|
|
EdgeInsets.only(left: 10.w, right: 20.w, top: 18.h, bottom: 18.h),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(10.w),
|
|
),
|
|
child: Row(
|
|
children: <Widget>[
|
|
SizedBox(
|
|
width: 10.w,
|
|
),
|
|
Image.asset(
|
|
'images/mine/icon_mine_gatewayListMainIcon.png',
|
|
width: 60.w,
|
|
height: 60.w,
|
|
),
|
|
SizedBox(
|
|
width: 20.w,
|
|
),
|
|
Expanded(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: <Widget>[
|
|
Text(
|
|
getewayItemData.gatewayName ?? '',
|
|
style: TextStyle(fontSize: 24.sp),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 5.h),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: <Widget>[
|
|
Image.asset(
|
|
'images/mine/icon_mine_gatewayListOnline.png',
|
|
width: 22.w,
|
|
height: 22.w,
|
|
),
|
|
SizedBox(
|
|
width: 10.w,
|
|
),
|
|
Text(
|
|
getewayItemData.isOnline == 1 ? '在线' : '离线',
|
|
style: TextStyle(fontSize: 18.sp),
|
|
),
|
|
SizedBox(
|
|
width: 80.w,
|
|
),
|
|
Image.asset(
|
|
'images/mine/icon_mine_gatewayListNumber.png',
|
|
width: 22.w,
|
|
height: 22.w,
|
|
),
|
|
SizedBox(
|
|
width: 10.w,
|
|
),
|
|
Text(
|
|
getewayItemData.lockNum.toString(),
|
|
style: TextStyle(
|
|
fontSize: 18.sp, fontWeight: FontWeight.w500),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(width: 20.h),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(width: 20.h),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|