Files
tuiche/lib/pages/mh_page/device_list.dart
2026-04-07 14:49:31 +08:00

146 lines
5.1 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutterflow_ui/flutterflow_ui.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/component/NullDataComponentWidget.dart';
import 'package:vbvs_app/pages/mh_page/device/device.dart';
import 'package:vbvs_app/pages/mh_page/searchWidget.dart';
import 'package:flutter/services.dart';
import '../../controller/mh_controller/device_list_controller.dart';
class DeviceListPage extends StatefulWidget {
const DeviceListPage({super.key});
@override
State<DeviceListPage> createState() => _DeviceListPageState();
}
class _DeviceListPageState extends State<DeviceListPage> {
final scaffoldKey = GlobalKey<ScaffoldState>();
DeviceListController controller = Get.find();
BoxConstraints? bodysize;
@override
void initState() {
super.initState();
controller.model.keyword = '';
controller.getDeviceList();
}
@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, cc) {
bodysize = cc;
return GestureDetector(
// onTap: () => FocusScope.of(context).unfocus(),,
child: Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/new_background.png'), // 本地图片
fit: BoxFit.fill, // 填满整个 Container
),
),
child: Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
systemOverlayStyle: SystemUiOverlayStyle(
statusBarColor: Colors.transparent, // 状态栏背景色
statusBarIconBrightness: Brightness.light, // 图标颜色Android
statusBarBrightness: Brightness.light, // 图标颜色iOS
),
backgroundColor: Colors.transparent,
automaticallyImplyLeading: false,
iconTheme: IconThemeData(color: Colors.white),
titleSpacing: 0,
// leading: returnIconButtomAddCallback(() {
// controller.saveDataApi();
// updateParm(isShowToast: false);
// }),
// leading: returnIconButtomNew,
title: Container(
width: double.infinity,
height: 180.rpx,
child: Stack(
alignment: Alignment.center,
children: [
// 中间居中的标题
Text(
'设备列表'.tr,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 30.rpx,
),
),
// 左侧图标
Positioned(
left: 0.rpx,
child: returnIconButtomNew(),
),
],
),
),
actions: [],
centerTitle: false,
),
backgroundColor: Colors.transparent,
body: Container(
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 10, 0, 23),
child: SearchWidget(
keyword: controller.model.keyword,
color: controller.model.color,
hint: "检索设备".tr,
onChange: (d) {
controller.model.keyword = d;
},
findCallback: () {
controller.getDeviceList();
},
),
),
Obx(() {
if (controller.model.deviceList == null ||
controller.model.deviceList.isEmpty) {
return Expanded(child: NullDataWidget());
}
// 如果 deviceList 不为空,渲染列表
return Expanded(
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.vertical,
children: controller.model.deviceList
.asMap()
.entries
.map((e) => DeviceInfoWidget(
index: e.key,
deviceListController: controller,
))
.toList()
.divide(const SizedBox(height: 10))
.addToEnd(const SizedBox(height: 100)),
),
);
}),
],
),
)
// Container(
// width: bodysize!.maxWidth,
// height: bodysize!.maxHeight,
// ),
),
));
});
}
}