This commit is contained in:
wyf
2025-05-13 11:59:04 +08:00
parent eae7a2284d
commit fb5c3864a3
101 changed files with 8427 additions and 1953 deletions

View File

@@ -5,6 +5,7 @@ import 'package:flutterflow_ui/flutterflow_ui.dart';
import 'package:vbvs_app/common/color/appConstants.dart';
import 'package:vbvs_app/common/color/app_uri_status.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/component/NullDataComponentWidget.dart';
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
import 'package:vbvs_app/controller/message/message_controller.dart';
@@ -21,9 +22,20 @@ class MessagePage extends StatefulWidget {
class _MessagePageState extends State<MessagePage> {
ThemeController themeController = Get.find();
MessageController messageController = Get.find();
late PageController _pageController;
@override
void initState() {
super.initState();
_pageController =
PageController(initialPage: messageController.model.type == 1 ? 0 : 1);
messageController.getMessageStatus();
_fetchMessageData();
}
void _fetchMessageData() {
String type = messageController.model.type == 1 ? "app_vsm" : "app_system";
messageController.updateMessageStatus(type: type);
messageController.getMessageList().then((response) {
if (response.code != HttpStatusCodes.ok) {
TopSlideNotification.show(
@@ -35,44 +47,61 @@ class _MessagePageState extends State<MessagePage> {
});
}
void _onTabChanged(int index) {
messageController.model.type = index == 0 ? 1 : 2;
messageController.updateAll();
_fetchMessageData();
_pageController.animateToPage(index,
duration: const Duration(milliseconds: 300), curve: Curves.easeInOut);
}
void _onPageChanged(int index) {
int newType = index == 0 ? 1 : 2;
if (messageController.model.type != newType) {
messageController.model.type = newType;
messageController.updateAll();
_fetchMessageData();
}
}
@override
void dispose() {
_pageController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.transparent, // 这里设置你希望的颜色
statusBarIconBrightness: Brightness.light, // 状态栏图标的亮度
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.light,
));
return LayoutBuilder(
builder: (context, boxConstraints) => GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Container(
decoration: BoxDecoration(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/img/bgNoImg.png'), // 本地图片
fit: BoxFit.fill, // 填满整个 Container
image: AssetImage('assets/img/bgNoImg.png'),
fit: BoxFit.fill,
),
),
child: Scaffold(
appBar: AppBar(
backgroundColor: themeController.currentColor.sc17,
automaticallyImplyLeading: false,
iconTheme: IconThemeData(
color: themeController.currentColor.sc3,
),
iconTheme: IconThemeData(color: themeController.currentColor.sc3),
toolbarHeight: 140.rpx,
titleSpacing: 0,
title: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
40.rpx,
0.rpx,
0.rpx,
0.rpx,
),
padding: EdgeInsetsDirectional.fromSTEB(40.rpx, 0, 0, 0),
child: Container(
width: double.infinity,
height: 140.rpx, // 👈 明确告诉 Flutter 高度
height: 140.rpx,
child: Column(
children: [
SizedBox(height: 40.rpx), // 上边距
SizedBox(height: 40.rpx),
Expanded(
child: Stack(
alignment: Alignment.bottomLeft,
@@ -82,89 +111,129 @@ class _MessagePageState extends State<MessagePage> {
children: [
Obx(() {
return ClickableContainer(
padding: EdgeInsets.all(0),
backgroundColor: Colors.transparent,
highlightColor:
themeController.currentColor.sc3,
themeController.currentColor.sc21,
borderRadius: 8.rpx,
padding: EdgeInsets.all(0),
onTap: () async {
messageController.model.type = 1;
await messageController.getMessageList();
messageController.updateAll();
},
onTap: () => _onTabChanged(0),
child: Container(
width: 160.rpx,
alignment: Alignment.center,
child: Text(
'体征消息'.tr,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Inter',
fontSize: AppConstants()
.title_text_fontSize,
letterSpacing: 0.0,
color:
messageController
.model.type ==
2
? themeController
.currentColor.sc3
: themeController
.currentColor.sc2,
),
child: Stack(
alignment: Alignment.center,
clipBehavior: Clip.none,
children: [
Text(
'体征消息'.tr,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Inter',
fontSize: AppConstants()
.title_text_fontSize,
color:
messageController
.model.type ==
2
? themeController
.currentColor.sc3
: themeController
.currentColor.sc2,
),
),
Obx(() {
return messageController.model
.body_message_read ==
1
? Positioned(
top: -4,
right: -14,
child: Container(
width: 8,
height: 8,
decoration:
const BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
),
),
)
: const SizedBox.shrink();
}),
],
),
),
);
}),
Obx(() {
return ClickableContainer(
padding: EdgeInsets.all(0),
backgroundColor: Colors.transparent,
highlightColor:
themeController.currentColor.sc3,
themeController.currentColor.sc21,
borderRadius: 8.rpx,
padding: EdgeInsets.all(0),
onTap: () async {
messageController.model.type = 2;
await messageController.getMessageList();
messageController.updateAll();
},
onTap: () => _onTabChanged(1),
child: Container(
width: 160.rpx,
alignment: Alignment.center,
child: Text(
'系统消息'.tr,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Inter',
fontSize: AppConstants()
.title_text_fontSize,
letterSpacing: 0.0,
color:
messageController
.model.type ==
1
? themeController
.currentColor.sc3
: themeController
.currentColor.sc2,
),
child: Stack(
alignment: Alignment.center,
clipBehavior: Clip.none,
children: [
Text(
'系统消息'.tr,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Inter',
fontSize: AppConstants()
.title_text_fontSize,
color:
messageController
.model.type ==
1
? themeController
.currentColor.sc3
: themeController
.currentColor.sc2,
),
),
Obx(() {
return messageController.model
.system_message_read ==
1
? Positioned(
top: -4,
right: -14,
child: Container(
width: 8,
height: 8,
decoration:
const BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
),
),
)
: const SizedBox.shrink();
}),
],
),
),
);
}),
],
].divide(SizedBox(width: 10.rpx)),
),
Obx(() {
double lineWidth = 160.rpx;
double lineWidth = 170.rpx;
return AnimatedPositioned(
duration: Duration(milliseconds: 300),
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
bottom: 0, // 👈 现在 Stack 够大,线能放得下
bottom: 0,
left: messageController.model.type == 1
? 0
: 160.rpx,
: 170.rpx,
child: Container(
width: lineWidth,
height: 4.rpx,
@@ -178,47 +247,33 @@ class _MessagePageState extends State<MessagePage> {
],
),
),
SizedBox(height: 17.rpx), // 上边距
SizedBox(height: 17.rpx),
],
),
),
),
actions: [],
actions: const [],
centerTitle: false,
),
backgroundColor: Colors.transparent,
body: SafeArea(
top: true,
child: Column(
mainAxisSize: MainAxisSize.max,
child: PageView(
controller: _pageController,
onPageChanged: _onPageChanged,
children: [
Expanded(
child: Container(
width: double.infinity,
decoration: BoxDecoration(),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx,
0.rpx,
30.rpx,
0.rpx,
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
MessageWidgetWidget(),
MessageWidgetWidget(),
MessageWidgetWidget(),
]
.divide(SizedBox(height: 30.rpx))
.addToStart(SizedBox(height: 30.rpx))
.addToEnd(SizedBox(height: 30.rpx)),
),
),
),
),
),
Obx(() {
final list = messageController.messageList.value;
return list.isEmpty
? const NullDataWidget()
: _buildMessageListView(list);
}),
Obx(() {
final list = messageController.messageList.value;
return list.isEmpty
? const NullDataWidget()
: _buildMessageListView(list);
}),
],
),
),
@@ -227,4 +282,23 @@ class _MessagePageState extends State<MessagePage> {
),
);
}
Widget _buildMessageListView(List dataList) {
return Container(
width: double.infinity,
padding: EdgeInsets.symmetric(horizontal: 30.rpx),
child: SingleChildScrollView(
child: Column(
children: [
SizedBox(height: 30.rpx),
...dataList
.map((item) => MessageWidgetWidget(data: item))
.toList()
.divide(SizedBox(height: 30.rpx)),
SizedBox(height: 30.rpx),
],
),
),
);
}
}