Files
tuiche/lib/pages/device_control/smys.dart
2025-06-03 09:34:31 +08:00

381 lines
18 KiB
Dart

import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutter_switch/flutter_switch.dart';
import 'package:vbvs_app/common/color/appColors.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/pages/common/selectDialog.dart';
import '../../controller/mh/sleeping_habit_controller.dart';
//睡眠隐私
class Smys extends GetView<SleepingHabitController> {
Smys({super.key});
// get glController => Get.find<GlobalController>();
getLine() {
return Container(
height: 1,
color: stringToColor("#152676"),
);
}
// updateParm(
// {int time = 2, bool isShowToast = true, Function? errorccCallback = null}) {
// ApiService.request
// .post(
// "/api/device/info/time/privacy/info?mac=${glController.model.deviceMain["mac"]}&time=${controller.model.smysStartTimeToString}-${controller.model.smysEndTimeToString}&type=${controller.model.smysIsStart ? '1' : '0'}")
// .then((d) {
// if (isShowToast) {
// showToast("操作成功", color: color_success);
// }
// }).catchError((d) {
// if (time > 0) {
// updateParm(time: time - 1, isShowToast: isShowToast, errorccCallback: errorccCallback);
// } else {
// errorccCallback?.call();
// }
// });
// }
@override
Widget build(BuildContext context) {
SleepingHabitController controller = Get.find();
return LayoutBuilder(
builder: (context, boxConstraints) => 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(
backgroundColor: Colors.transparent,
appBar: AppBar(
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(
'睡眠隐私',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 30.rpx,
),
),
// 左侧图标
Positioned(
left: 20.rpx,
child: returnIconButtomNew,
),
],
),
),
actions: [],
centerTitle: false,
),
body: SafeArea(
top: true,
child: Obx(
() => Container(
padding: EdgeInsets.only(left: 30.rpx, right: 30.rpx),
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height * 1.123,
// decoration: BoxDecoration(
// color: Colors.transparent,
// image: DecorationImage(
// image: AssetImage("assets/images/background.png"),
// fit: BoxFit.cover,
// ),
// ),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Container(
width: double.infinity,
height: MediaQuery.sizeOf(context).height * 0.055,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: const Color(0xFF929699),
width: 0.rpx),
),
),
constraints: BoxConstraints(
minHeight: 90.rpx, // 设置最小高度
),
child: Padding(
padding: EdgeInsets.fromLTRB(
39.rpx, 0.rpx, 15.rpx, 0.rpx),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'睡眠隐私功能',
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Readex Pro',
color: Color(0xFF9EA4B7),
fontSize: 30.rpx,
letterSpacing: 0,
),
),
Container(
// height:
// MediaQuery.sizeOf(context).height *
// 0.04,
child: FlutterSwitch(
width: 70.rpx,
height: 36.rpx,
toggleSize: 30.rpx,
activeColor: Color(0XFF6BFDAC),
inactiveColor: Color(0XFF003058),
toggleColor: Color(0xFF011D33),
value: controller.model.smysIsStart,
onToggle: (val) {
controller.attr.update((getmodel) {
getmodel.model.smysIsStart = val;
});
},
)
// Switch.adaptive(
// value: controller.model.smysIsStart,
// onChanged: (newValue) async {
// controller.attr.update((getmodel) {
// getmodel.model.smysIsStart =
// newValue;
// });
// // updateParm(errorccCallback: () {
// // controller.attr.update((getmodel) {
// // getmodel.model.smysIsStart = !newValue;
// // });
// // });
// },
// activeTrackColor: Color(0xFF6BFDAC),
// inactiveTrackColor: Color(0xFF003058),
// inactiveThumbColor: Color(0xFF011D33),
// trackOutlineWidth: MaterialStateProperty
// .resolveWith<double?>(
// (Set<MaterialState> states) {
// if (states.contains(
// MaterialState.disabled)) {
// return null;
// }
// return null; // Use the default width.
// }),
// ),
),
],
),
)),
// getLine(),
Container(
width: double.infinity,
height: MediaQuery.sizeOf(context).height * 0.055,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: const Color(0xFF929699),
width: 0.rpx),
),
),
constraints: BoxConstraints(
minHeight: 90.rpx, // 设置最小高度
),
child: Padding(
padding: EdgeInsets.fromLTRB(
39.rpx, 0.rpx, 30.rpx, 0.rpx),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'开始时间',
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Readex Pro',
color: Color(0xFF9EA4B7),
fontSize: 30.rpx,
letterSpacing: 0,
),
),
InkWell(
onTap: () async {
showDayTimeSelectionDialog(context,
dayTimeArr:
controller.model.smysStartTime,
title: "开始时间", checkChange: (d) {
controller.attr.update((getmodel) {
getmodel.model.smysStartTime = [
int.parse("${d[0]}"),
int.parse("${d[1]}")
];
});
// updateParm();
});
},
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Text(
"${controller.model.smysStartTimeToString}",
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Readex Pro',
color: Colors.white,
fontSize: 36.rpx,
letterSpacing: 0,
),
),
SizedBox(
width: 16.rpx,
),
Icon(
Icons.expand_more,
color: Colors.white,
size: 40.rpx,
),
],
),
),
],
),
)),
// getLine(),
Container(
width: double.infinity,
height: MediaQuery.sizeOf(context).height * 0.055,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: const Color(0xFF929699),
width: 0.rpx),
),
),
constraints: BoxConstraints(
minHeight: 90.rpx, // 设置最小高度
),
child: Padding(
padding: EdgeInsets.fromLTRB(
39.rpx, 0.rpx, 30.rpx, 0.rpx),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'结束时间',
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Readex Pro',
color: Color(0xFF9EA4B7),
fontSize: 30.rpx,
letterSpacing: 0,
),
),
InkWell(
onTap: () async {
showDayTimeSelectionDialog(context,
dayTimeArr:
controller.model.smysEndTime,
title: "结束时间", checkChange: (d) {
controller.attr.update((getmodel) {
getmodel.model.smysEndTime = [
int.parse("${d[0]}"),
int.parse("${d[1]}")
];
});
// updateParm();
});
},
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Text(
"${controller.model.smysEndTimeToString}",
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Readex Pro',
color: Colors.white,
fontSize: 36.rpx,
letterSpacing: 0,
),
),
SizedBox(
width: 16.rpx,
),
Icon(
Icons.expand_more,
color: Colors.white,
size: 40.rpx,
),
],
),
),
],
),
),
),
// getLine(),
SizedBox(
height: 30.rpx,
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 25.rpx),
child: Container(
width: double.infinity,
decoration: BoxDecoration(),
child: Text(
'*注:开启睡眠隐私功能后,在设置的时间段内,将不会采集您的睡眠数据。',
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Readex Pro',
color: Color(0xFF9EA4B7),
fontSize: 20.rpx,
letterSpacing: 0,
),
),
),
)
],
),
),
),
),
),
),
)),
);
}
}