177 lines
6.0 KiB
Dart
177 lines
6.0 KiB
Dart
import 'package:ef/ef.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
|
import 'package:vbvs_app/common/util/FitTool.dart';
|
|
import 'package:vbvs_app/common/util/MyUtils.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/device_type_controller.dart';
|
|
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
|
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
|
import 'package:vbvs_app/controller/user_info_controller.dart';
|
|
|
|
class SleepReportPage extends StatefulWidget {
|
|
var sleepUri;
|
|
SleepReportPage({super.key, required this.sleepUri});
|
|
|
|
@override
|
|
State<SleepReportPage> createState() => _SleepReportPageState();
|
|
}
|
|
|
|
class _SleepReportPageState extends State<SleepReportPage> {
|
|
GlobalController globalController = Get.find();
|
|
UserInfoController userInfoController = Get.find();
|
|
BlueteethBindController blueteethBindController = Get.find();
|
|
ThemeController themeController = Get.find();
|
|
DeviceTypeController deviceTypeController = Get.find();
|
|
|
|
// 使用 ValueNotifier 来管理加载状态
|
|
ValueNotifier<bool> isPageLoading = ValueNotifier<bool>(true);
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
// 清理 ValueNotifier
|
|
isPageLoading.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@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/img/bgNoImg.png'), // 本地图片
|
|
fit: BoxFit.fill, // 填满整个 Container
|
|
),
|
|
),
|
|
child: Scaffold(
|
|
backgroundColor: Colors.transparent, // 背景透明
|
|
appBar: AppBar(
|
|
backgroundColor: themeController.currentColor.sc17,
|
|
automaticallyImplyLeading: false,
|
|
iconTheme: IconThemeData(color: themeController.currentColor.sc3),
|
|
titleSpacing: 0,
|
|
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,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
body: SafeArea(
|
|
top: true,
|
|
child: Stack(
|
|
children: [
|
|
InAppWebView(
|
|
key: UniqueKey(),
|
|
initialUrlRequest: URLRequest(url: WebUri(widget.sleepUri)),
|
|
onLoadStart: (controller, url) {
|
|
// 页面开始加载时显示加载指示器
|
|
isPageLoading.value = true;
|
|
},
|
|
onLoadStop: (controller, url) {
|
|
// 页面加载完成后隐藏加载指示器
|
|
isPageLoading.value = false;
|
|
},
|
|
),
|
|
ValueListenableBuilder<bool>(
|
|
valueListenable: isPageLoading,
|
|
builder: (context, isLoading, child) {
|
|
return isLoading
|
|
? Center(
|
|
child: CircularProgressIndicator(), // 加载指示器
|
|
)
|
|
: SizedBox.shrink();
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildDeviceCard(BuildContext context,
|
|
{required String title, required String imageUrl, required double type}) {
|
|
return CustomCard(
|
|
borderRadius: 20.rpx, // 圆角大小
|
|
onTap: () {
|
|
if (type != null) {
|
|
if (type == 1) {
|
|
Get.toNamed("/bodyDevice");
|
|
}
|
|
if (type == 2) {
|
|
TopSlideNotification.show(
|
|
context,
|
|
text: "待开发.提示".tr,
|
|
textColor: themeController.currentColor.sc2,
|
|
);
|
|
}
|
|
}
|
|
},
|
|
colors: [themeController.currentColor.sc17], // 背景色
|
|
child: Container(
|
|
width: double.infinity,
|
|
height: MediaQuery.sizeOf(context).height * 0.135,
|
|
constraints: BoxConstraints(
|
|
minHeight: 220.rpx,
|
|
),
|
|
padding: EdgeInsetsDirectional.fromSTEB(77.rpx, 0, 21.rpx, 0),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
|
fontFamily: 'Inter',
|
|
color: const Color(0xFFC2CED7),
|
|
fontSize: 30.rpx,
|
|
letterSpacing: 0.0,
|
|
),
|
|
),
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.circular(8.rpx),
|
|
child: Image.network(
|
|
imageUrl,
|
|
width: 212.rpx,
|
|
height: 168.rpx,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|