2025-09-03 09:39:06 +08:00
|
|
|
|
import 'package:flutter/cupertino.dart';
|
2025-08-27 18:20:37 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
2025-09-03 09:39:06 +08:00
|
|
|
|
import 'package:flutter/widgets.dart';
|
2025-09-01 10:24:46 +08:00
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
2025-08-27 18:20:37 +08:00
|
|
|
|
import 'package:get/get.dart';
|
2025-09-01 10:24:46 +08:00
|
|
|
|
import 'package:starwork_flutter/base/app_permission.dart';
|
2025-09-03 09:39:06 +08:00
|
|
|
|
import 'package:starwork_flutter/views/home/widget/home_attendance_chart_area_widget.dart';
|
|
|
|
|
|
import 'package:starwork_flutter/views/home/widget/home_carousel_area_widget.dart';
|
|
|
|
|
|
import 'package:starwork_flutter/views/home/widget/home_function_list_area_widget.dart';
|
|
|
|
|
|
import 'package:starwork_flutter/views/home/widget/home_left_drawer_widget.dart';
|
|
|
|
|
|
import 'package:starwork_flutter/views/home/widget/home_one_button_door_opening_widget.dart';
|
|
|
|
|
|
import 'package:starwork_flutter/views/home/widget/home_statistics_row_widget.dart';
|
|
|
|
|
|
import 'package:starwork_flutter/views/home/widget/home_team_notice_row_widget.dart';
|
2025-08-27 18:20:37 +08:00
|
|
|
|
|
|
|
|
|
|
import 'home_controller.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class HomeView extends GetView<HomeController> {
|
|
|
|
|
|
const HomeView({super.key});
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
2025-09-03 09:39:06 +08:00
|
|
|
|
return Obx(
|
|
|
|
|
|
() => Container(
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
gradient: LinearGradient(
|
|
|
|
|
|
begin: Alignment.topCenter, // 渐变起点:顶部中心
|
|
|
|
|
|
end: Alignment.bottomCenter, // 渐变终点:底部中心
|
|
|
|
|
|
colors: [
|
|
|
|
|
|
controller.currentGradientColor.value, // 动态颜色
|
|
|
|
|
|
const Color(0xFFF6F7FB), // 底部颜色保持不变
|
2025-09-01 10:24:46 +08:00
|
|
|
|
],
|
2025-09-03 09:39:06 +08:00
|
|
|
|
stops: const [0.1, 1.0], // 第一个颜色到10%,然后第二个颜色开始直到100%
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
2025-09-03 14:09:32 +08:00
|
|
|
|
child: SafeArea(
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
width: 1.sw,
|
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 15.w, vertical: 4.h),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
// 固定的上半部分
|
|
|
|
|
|
_buildPageHead(context),
|
2025-09-03 14:44:15 +08:00
|
|
|
|
Obx(
|
|
|
|
|
|
() => Visibility(
|
|
|
|
|
|
visible: controller.isOpenNotificationPermission.value,
|
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
|
height: 10.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
2025-09-03 14:09:32 +08:00
|
|
|
|
),
|
|
|
|
|
|
_buildSystemNotificationPermissionRow(),
|
2025-09-03 09:39:06 +08:00
|
|
|
|
|
2025-09-03 14:09:32 +08:00
|
|
|
|
// 可滚动的下半部分(带下拉刷新)
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: _buildRefreshableContent(),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
2025-09-03 09:39:06 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
2025-09-01 10:24:46 +08:00
|
|
|
|
),
|
2025-08-27 18:20:37 +08:00
|
|
|
|
),
|
2025-09-01 10:24:46 +08:00
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-03 09:39:06 +08:00
|
|
|
|
_buildPageHead(BuildContext context) {
|
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
|
onTap: () {
|
2025-09-03 14:09:32 +08:00
|
|
|
|
// 使用MainController的专用方法
|
|
|
|
|
|
controller.mainController.openDrawer();
|
2025-09-03 09:39:06 +08:00
|
|
|
|
},
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Row(
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'19104656的互联',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 18.sp,
|
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
|
),
|
2025-09-01 10:24:46 +08:00
|
|
|
|
),
|
2025-09-03 09:39:06 +08:00
|
|
|
|
Icon(
|
|
|
|
|
|
Icons.arrow_right_rounded,
|
|
|
|
|
|
size: 22.sp,
|
|
|
|
|
|
)
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
Icons.add_circle_outline,
|
|
|
|
|
|
size: 22.sp,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
2025-09-01 10:24:46 +08:00
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_buildSystemNotificationPermissionRow() {
|
2025-09-03 09:39:06 +08:00
|
|
|
|
return Obx(
|
|
|
|
|
|
() => Visibility(
|
|
|
|
|
|
visible: !controller.isOpenNotificationPermission.value,
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 4.h),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: const Color(0xFFFEF2E5),
|
|
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
|
|
Radius.circular(8.r),
|
2025-09-01 10:24:46 +08:00
|
|
|
|
),
|
2025-09-03 09:39:06 +08:00
|
|
|
|
),
|
|
|
|
|
|
margin: EdgeInsets.symmetric(vertical: 8.h),
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'系统通知未开启,报警消息无法通知'.tr,
|
2025-09-01 10:24:46 +08:00
|
|
|
|
style: TextStyle(
|
2025-09-03 09:39:06 +08:00
|
|
|
|
color: const Color(0xFFEE9846),
|
|
|
|
|
|
fontSize: 12.sp,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const Spacer(),
|
|
|
|
|
|
GestureDetector(
|
|
|
|
|
|
onTap: () async {
|
|
|
|
|
|
controller.isOpenNotificationPermission.value =
|
|
|
|
|
|
await AppPermission.requestNotificationPermission();
|
|
|
|
|
|
},
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 6.w, vertical: 4.h),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
|
|
Radius.circular(4.r),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
'去开启'.tr,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: const Color(0xFFEE9846),
|
|
|
|
|
|
fontSize: 12.sp,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
2025-09-01 10:24:46 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
2025-09-03 09:39:06 +08:00
|
|
|
|
SizedBox(
|
|
|
|
|
|
width: 14.w,
|
|
|
|
|
|
),
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
Icons.cancel,
|
|
|
|
|
|
color: const Color(0xFFEE9846),
|
|
|
|
|
|
size: 18.sp,
|
|
|
|
|
|
)
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
2025-09-01 10:24:46 +08:00
|
|
|
|
),
|
2025-08-27 18:20:37 +08:00
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2025-09-03 14:09:32 +08:00
|
|
|
|
|
|
|
|
|
|
// 带下拉刷新的内容区域
|
|
|
|
|
|
Widget _buildRefreshableContent() {
|
|
|
|
|
|
return RefreshIndicator(
|
|
|
|
|
|
onRefresh: _onRefresh,
|
|
|
|
|
|
// 基础样式配置
|
2025-09-03 14:44:15 +08:00
|
|
|
|
color: const Color(0xFF4A90E2),
|
|
|
|
|
|
// 刷新指示器颜色
|
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
|
// 背景颜色
|
|
|
|
|
|
|
2025-09-03 14:09:32 +08:00
|
|
|
|
// 控制下拉触发距离的关键属性
|
2025-09-03 14:44:15 +08:00
|
|
|
|
displacement: 60.0,
|
|
|
|
|
|
// 刷新指示器距离顶部的距离
|
|
|
|
|
|
edgeOffset: 0.0,
|
|
|
|
|
|
// 边缘偏移量
|
|
|
|
|
|
|
2025-09-03 14:09:32 +08:00
|
|
|
|
// 控制下拉幅度的关键属性
|
2025-09-03 14:44:15 +08:00
|
|
|
|
triggerMode: RefreshIndicatorTriggerMode.onEdge,
|
|
|
|
|
|
// 触发模式
|
|
|
|
|
|
|
2025-09-03 14:09:32 +08:00
|
|
|
|
// 描边宽度
|
2025-09-03 14:44:15 +08:00
|
|
|
|
strokeWidth: 2.5,
|
|
|
|
|
|
// 刷新指示器的描边宽度
|
|
|
|
|
|
|
2025-09-03 14:09:32 +08:00
|
|
|
|
// 语义标签(用于无障碍功能)
|
|
|
|
|
|
semanticsLabel: '下拉刷新首页内容',
|
|
|
|
|
|
semanticsValue: '刷新中...',
|
2025-09-03 14:44:15 +08:00
|
|
|
|
|
2025-09-03 14:09:32 +08:00
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
|
physics: const AlwaysScrollableScrollPhysics(
|
|
|
|
|
|
// 添加弹性滚动效果
|
|
|
|
|
|
parent: BouncingScrollPhysics(),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
HomeCarouselAreaWidget(
|
|
|
|
|
|
carouselCurrentIndex: controller.carouselCurrentIndex,
|
|
|
|
|
|
),
|
|
|
|
|
|
HomeTeamNoticeRowWidget(),
|
|
|
|
|
|
HomeStatisticsRowWidget(
|
|
|
|
|
|
personCount: 12,
|
|
|
|
|
|
deviceCount: 1,
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(height: 10.h),
|
|
|
|
|
|
HomeFunctionListAreaWidget(),
|
|
|
|
|
|
SizedBox(height: 10.h),
|
|
|
|
|
|
HomeOnButtonDoorOpeningWidget(
|
|
|
|
|
|
doorList: const [
|
|
|
|
|
|
'主门门禁',
|
|
|
|
|
|
'车库门禁',
|
|
|
|
|
|
'后门门禁',
|
|
|
|
|
|
'单元门门禁',
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(height: 10.h),
|
|
|
|
|
|
HomeAttendanceChartAreaWidget(),
|
|
|
|
|
|
SizedBox(height: 10.h),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 处理下拉刷新
|
|
|
|
|
|
Future<void> _onRefresh() async {
|
|
|
|
|
|
// 调用controller的刷新方法
|
|
|
|
|
|
await controller.refreshHome();
|
|
|
|
|
|
}
|
2025-08-27 18:20:37 +08:00
|
|
|
|
}
|