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

319 lines
14 KiB
Dart
Raw 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:flutter_svg/svg.dart';
import 'package:flutter_switch/flutter_switch.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 'package:flutter/services.dart';
import '../../controller/mh_controller/sleeping_habit_controller.dart';
//睡眠隐私
class Smys extends GetView<SleepingHabitController> {
Smys({super.key});
// get glController => Get.find<GlobalController>();
// 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(
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,
),
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(
'睡眠隐私功能'.tr,
style: TextStyle(
fontFamily: 'Readex Pro',
color: Color(0xFF9EA4B7),
fontSize: 26.rpx,
letterSpacing: 0,
),
),
],
),
)),
// getLine(),
InkWell(
onTap: () async {
showDayTimeSelectionDialog(context,
dayTimeArr: controller.model.smysStartTime,
title: "开始时间".tr, checkChange: (d) {
controller.attr.update((getmodel) {
getmodel.model.smysStartTime = [
int.parse("${d[0]}"),
int.parse("${d[1]}")
];
});
// updateParm();
});
},
child: Container(
width: double.infinity,
height: MediaQuery.sizeOf(context).height * 0.055,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Color(0xFF929699),
// color: Colors.red,
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(
'开始时间'.tr,
style: TextStyle(
fontFamily: 'Readex Pro',
color: Color(0xFF9EA4B7),
fontSize: 26.rpx,
letterSpacing: 0,
),
),
Row(
mainAxisSize: MainAxisSize.max,
children: [
Text(
"${controller.model.smysStartTimeToString}",
style: TextStyle(
fontFamily: 'Readex Pro',
color: Colors.white,
fontSize: 26.rpx,
letterSpacing: 0,
),
),
SizedBox(
width: 16.rpx,
),
Container(
height: 30.rpx,
width: 30.rpx,
child: SvgPicture.asset(
'assets/img/icon/expand_more.svg',
color: Colors.white,
))
],
),
],
),
)),
),
// getLine(),
InkWell(
onTap: () async {
showDayTimeSelectionDialog(context,
dayTimeArr: controller.model.smysEndTime,
title: "结束时间".tr, checkChange: (d) {
controller.attr.update((getmodel) {
getmodel.model.smysEndTime = [
int.parse("${d[0]}"),
int.parse("${d[1]}")
];
});
// updateParm();
});
},
child: 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(
'结束时间'.tr,
style: TextStyle(
fontFamily: 'Readex Pro',
color: Color(0xFF9EA4B7),
fontSize: 26.rpx,
letterSpacing: 0,
),
),
Row(
mainAxisSize: MainAxisSize.max,
children: [
Text(
"${controller.model.smysEndTimeToString}",
style: TextStyle(
fontFamily: 'Readex Pro',
color: Colors.white,
fontSize: 26.rpx,
letterSpacing: 0,
),
),
SizedBox(
width: 16.rpx,
),
Container(
height: 30.rpx,
width: 30.rpx,
child: SvgPicture.asset(
'assets/img/icon/expand_more.svg',
color: Colors.white,
))
],
),
],
),
),
),
), // getLine(),
SizedBox(
height: 30.rpx,
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 25.rpx),
child: Container(
width: double.infinity,
decoration: BoxDecoration(),
child: Text(
'*注:开启睡眠隐私功能后,在设置的时间段内,将不会采集您的睡眠数据。'.tr,
style: TextStyle(
fontFamily: 'Readex Pro',
color: Color(0xFF9EA4B7),
fontSize: 20.rpx,
letterSpacing: 0,
),
),
),
)
],
),
),
),
),
),
),
)),
);
}
}