2025-09-03 09:39:06 +08:00
|
|
|
|
import 'package:carousel_slider/carousel_slider.dart';
|
|
|
|
|
|
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});
|
|
|
|
|
|
|
2025-09-03 09:39:06 +08:00
|
|
|
|
static final GlobalKey<ScaffoldState> _scaffoldKey =
|
|
|
|
|
|
GlobalKey<ScaffoldState>();
|
|
|
|
|
|
|
2025-08-27 18:20:37 +08:00
|
|
|
|
@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%
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
|
key: _scaffoldKey,
|
|
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
|
|
body: SafeArea(
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
width: 1.sw,
|
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 15.w, vertical: 4.h),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
// 固定的上半部分
|
|
|
|
|
|
_buildPageHead(context),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 10.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
_buildSystemNotificationPermissionRow(),
|
|
|
|
|
|
|
|
|
|
|
|
// 可滚动的下半部分
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
|
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,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
drawer: HomeLeftDrawerWidget(
|
|
|
|
|
|
teamList: ['家庭群组', '测试团队1', '测试团队2'],
|
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: () {
|
|
|
|
|
|
_scaffoldKey.currentState?.openDrawer();
|
|
|
|
|
|
},
|
|
|
|
|
|
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
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|