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 '../../controller/mh_controller/sleeping_habit_controller.dart'; //睡眠隐私 class Smys extends GetView { Smys({super.key}); // get glController => Get.find(); // 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( '睡眠隐私'.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, ), ), 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; }); }, )), ], ), )), // 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: 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.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, ), ), ), ) ], ), ), ), ), ), ), )), ); } }