更新绑定成功布局
This commit is contained in:
394
lib/pages/mh_page/device/mht_bind_device_success.dart
Normal file
394
lib/pages/mh_page/device/mht_bind_device_success.dart
Normal file
@@ -0,0 +1,394 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/color/app_uri_status.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/component/tool/CustomCard.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart';
|
||||
import 'package:vbvs_app/controller/device/body_device_controller.dart';
|
||||
import 'package:vbvs_app/controller/home/home_controller.dart';
|
||||
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
||||
import 'package:vbvs_app/controller/person/person_controller.dart';
|
||||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
|
||||
|
||||
class MHTBindDeviceSuccess extends StatefulWidget {
|
||||
const MHTBindDeviceSuccess({super.key});
|
||||
|
||||
@override
|
||||
State<MHTBindDeviceSuccess> createState() => _MHTBindDeviceSuccessState();
|
||||
}
|
||||
|
||||
class _MHTBindDeviceSuccessState extends State<MHTBindDeviceSuccess> {
|
||||
GlobalController globalController = Get.find();
|
||||
UserInfoController userInfoController = Get.find();
|
||||
BlueteethBindController blueteethBindController = Get.find();
|
||||
ThemeController themeController = Get.find();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, bodySize) => GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/images/new_background.png'), // 本地图片
|
||||
fit: BoxFit.fill, // 填满整个 Container
|
||||
),
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent, // 加上这一行
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
automaticallyImplyLeading: false,
|
||||
iconTheme: IconThemeData(
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
titleSpacing: 0,
|
||||
// leading: returnIconButtom,
|
||||
title: Container(
|
||||
width: double.infinity,
|
||||
height: 180.rpx,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
/// 居中标题
|
||||
Text(
|
||||
'绑定成功.标题'.tr,
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: 'Readex Pro',
|
||||
color: themeController.currentColor.sc3,
|
||||
letterSpacing: 0,
|
||||
fontSize: 30.rpx,
|
||||
),
|
||||
),
|
||||
|
||||
/// 左边返回按钮
|
||||
// Positioned(
|
||||
// left: 0,
|
||||
// child: returnIconButtom,
|
||||
// ),
|
||||
Positioned(
|
||||
left: 40.rpx,
|
||||
child: ClickableContainer(
|
||||
onTap: () {
|
||||
if (blueteethBindController.returnPage == 0) {
|
||||
MHTHomeController homeController = Get.find();
|
||||
// BodyDeviceController deviceController = Get.find();
|
||||
if (userInfoController.model.login == 1) {
|
||||
//查询人员信息列表
|
||||
homeController.getPersonList();
|
||||
//请求绑定设备列表
|
||||
// homeController.getSleepReport();
|
||||
homeController.getDeviceNum().then((apiResponse) {
|
||||
if (apiResponse.code != HttpStatusCodes.ok) {
|
||||
TopSlideNotification.show(
|
||||
Get.context!,
|
||||
text: apiResponse.msg!,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
}
|
||||
});
|
||||
homeController
|
||||
.getDeviceList(group: 'room')
|
||||
.then((apiResponse) {
|
||||
if (apiResponse.code != HttpStatusCodes.ok) {
|
||||
TopSlideNotification.show(
|
||||
Get.context!,
|
||||
text: apiResponse.msg!,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
} else {
|
||||
//请求睡眠报告
|
||||
// deviceController.getSleepReport();
|
||||
}
|
||||
});
|
||||
}
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (homeController.sleepDays.value.isNotEmpty) {
|
||||
homeController.selectedDayIndex.value =
|
||||
homeController.sleepDays.value.length - 1;
|
||||
}
|
||||
});
|
||||
Get.until((route) =>
|
||||
Get.currentRoute == "/mianPageBottomChange");
|
||||
} else {
|
||||
// Get.offNamed("/bodyDevice");
|
||||
// Get.offNamedUntil(page, predicate);
|
||||
Get.until(
|
||||
(route) => Get.currentRoute == "/bodyDevice");
|
||||
}
|
||||
},
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors
|
||||
.grey, // 可以设置为 themeController.currentColor.sc3 之类
|
||||
borderRadius: 8.rpx,
|
||||
padding: EdgeInsets.all(8.rpx), // 增加可点击区域
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/close.svg',
|
||||
width: 25.rpx,
|
||||
height: 25.rpx,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
actions: [],
|
||||
centerTitle: false,
|
||||
),
|
||||
body: SafeArea(
|
||||
top: true,
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(113.rpx, 0, 113.rpx, 0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
height: bodySize.maxHeight * 0.15,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 0.rpx, 0, 0),
|
||||
child: Container(
|
||||
width: 124.rpx,
|
||||
height: 124.rpx,
|
||||
// width: double.infinity,
|
||||
decoration: BoxDecoration(),
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/tick.svg',
|
||||
fit: BoxFit.cover,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 42.rpx, 0, 0),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional(0, 0),
|
||||
child: Text(
|
||||
'绑定成功.绑定成功'.tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 48.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 65.rpx, 0, 0),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional(0, 0),
|
||||
child: Text(
|
||||
'绑定成功.分享标题'.tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 30.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 48.rpx, 0, 0),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional(-1, 0),
|
||||
child: Text(
|
||||
'绑定成功.分享内容'.tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 110.rpx, 0, 0),
|
||||
child: CustomCard(
|
||||
borderRadius:
|
||||
AppConstants().button_container_radius, // 圆角半径
|
||||
onTap: () async {
|
||||
PersonController personController = Get.find();
|
||||
String deviceID =
|
||||
personController.currentPersonId.value;
|
||||
|
||||
BodyDeviceController bodyDeviceController =
|
||||
Get.find();
|
||||
await bodyDeviceController.getDeviceList();
|
||||
List deviceList =
|
||||
bodyDeviceController.deviceList.value;
|
||||
|
||||
if (deviceList != null && deviceList.isNotEmpty) {
|
||||
// 查找第一个 _id 匹配的设备
|
||||
final matchedDevice = deviceList.firstWhere(
|
||||
(element) => element['_id'] == deviceID,
|
||||
orElse: () => null,
|
||||
);
|
||||
|
||||
if (matchedDevice != null) {
|
||||
// 跳转并传入设备
|
||||
Get.toNamed("/deviceSharePage",
|
||||
arguments: matchedDevice);
|
||||
} else {
|
||||
print("未找到匹配的设备");
|
||||
}
|
||||
} else {
|
||||
print("设备列表为空");
|
||||
}
|
||||
},
|
||||
colors: [
|
||||
// 渐变色
|
||||
themeController.currentColor.sc1,
|
||||
themeController.currentColor.sc2,
|
||||
],
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width * 0.66,
|
||||
height: MediaQuery.sizeOf(context).height * 0.055,
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 500.rpx,
|
||||
minHeight: 90.rpx,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
'assets/img/icon/share.svg',
|
||||
width: 25.rpx,
|
||||
height: 25.rpx, // 如果 SVG 中没有固定颜色,可以这样设置
|
||||
color: Colors.white,
|
||||
),
|
||||
Text(
|
||||
'绑定成功.立即分享'.tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontFamily: 'Inter',
|
||||
fontSize: AppConstants()
|
||||
.normal_text_fontSize, // 自定义字体大小
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(width: 17.rpx)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 18.rpx, 0, 0),
|
||||
child: CustomCard(
|
||||
borderRadius:
|
||||
AppConstants().button_container_radius, // 圆角半径
|
||||
onTap: () {
|
||||
BlueteethBindController blueteethBindController =
|
||||
Get.find();
|
||||
if (blueteethBindController.returnPage == 0) {
|
||||
HomeController homeController = Get.find();
|
||||
BodyDeviceController deviceController = Get.find();
|
||||
if (userInfoController.model.login == 1) {
|
||||
homeController.getSleepReport();
|
||||
deviceController
|
||||
.getDeviceNum()
|
||||
.then((apiResponse) {
|
||||
if (apiResponse.code != HttpStatusCodes.ok) {}
|
||||
});
|
||||
deviceController
|
||||
.getDeviceList()
|
||||
.then((apiResponse) {
|
||||
if (apiResponse.code != HttpStatusCodes.ok) {
|
||||
} else {
|
||||
//请求睡眠报告
|
||||
deviceController.getSleepReport();
|
||||
}
|
||||
});
|
||||
}
|
||||
Get.until((route) =>
|
||||
Get.currentRoute == "/mianPageBottomChange");
|
||||
} else {
|
||||
// Get.offNamed("/bodyDevice");
|
||||
// Get.offNamedUntil(page, predicate);
|
||||
Get.until(
|
||||
(route) => Get.currentRoute == "/bodyDevice");
|
||||
}
|
||||
},
|
||||
colors: [
|
||||
// 渐变色
|
||||
themeController.currentColor.sc1,
|
||||
themeController.currentColor.sc2,
|
||||
],
|
||||
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width * 0.66,
|
||||
height: MediaQuery.sizeOf(context).height * 0.055,
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 500.rpx,
|
||||
minHeight: 90.rpx,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'绑定成功.返回'.tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontFamily: 'Inter',
|
||||
fontSize: AppConstants()
|
||||
.normal_text_fontSize, // 自定义字体大小
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(width: 17.rpx)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,8 @@ class MHTHomeController extends GetControllerEx<MHTHomeModel> {
|
||||
String wifiMac = "";
|
||||
var sleepDays = [].obs;
|
||||
|
||||
var selectedDayIndex = (6).obs;
|
||||
|
||||
Future<ApiResponse> getDeviceNum() async {
|
||||
try {
|
||||
ApiResponse apiResponse = ApiResponse(code: -1, msg: "设备.设备列表请求失败".tr);
|
||||
|
||||
@@ -32,7 +32,7 @@ class _NewHomePageState extends State<NewHomePage> {
|
||||
|
||||
GlobalController gloablController = Get.find();
|
||||
WeatherModelController weatherModelController = Get.find();
|
||||
var selectedDayIndex = (6).obs;
|
||||
// var selectedDayIndex = (6).obs;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -66,7 +66,7 @@ class _NewHomePageState extends State<NewHomePage> {
|
||||
}
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (homeController.sleepDays.value.isNotEmpty) {
|
||||
selectedDayIndex.value = homeController.sleepDays.value.length - 1;
|
||||
homeController.selectedDayIndex.value = homeController.sleepDays.value.length - 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -411,7 +411,7 @@ class _NewHomePageState extends State<NewHomePage> {
|
||||
personInfo.value =
|
||||
selectedPerson;
|
||||
|
||||
selectedDayIndex =
|
||||
homeController.selectedDayIndex =
|
||||
(6).obs;
|
||||
print("$val");
|
||||
if (val == null) {
|
||||
@@ -524,13 +524,13 @@ class _NewHomePageState extends State<NewHomePage> {
|
||||
var day = homeController
|
||||
.sleepDays[index];
|
||||
bool isSelected =
|
||||
selectedDayIndex
|
||||
homeController.selectedDayIndex
|
||||
.value ==
|
||||
index;
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
selectedDayIndex
|
||||
homeController.selectedDayIndex
|
||||
.value = index;
|
||||
int? timeMillis =
|
||||
parseToInt(day[
|
||||
|
||||
Reference in New Issue
Block a user