消息样式修改

This commit is contained in:
2026-02-09 17:57:00 +08:00
parent 9cd87b0535
commit 26c5f9d67a
3 changed files with 152 additions and 91 deletions

View File

@@ -36,7 +36,7 @@ class ReservationPage extends GetView<ReservationController> {
_buildSystemTips(),
SizedBox(height: 24),
_buildLogoutButton(),
SizedBox(height: 75.h),
SizedBox(height: 95.h),
],
),
),

View File

@@ -80,10 +80,10 @@ class MallPage extends GetView<MallController> {
],
),
),
IconButton(
/*IconButton(
onPressed: () {},
icon: const Icon(Icons.notifications_none, color: Color(0xFF333333)),
),
),*/
],
),
);

View File

@@ -12,40 +12,63 @@ class MessagePage extends GetView<MessageController> {
Get.put(MessageController());
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
appBar: AppBar(title: const Text('消息通知'), centerTitle: true),
body: Column(
backgroundColor: const Color(0xFFF7F9FB),
appBar: AppBar(
title: const Text('消息通知'),
centerTitle: true,
backgroundColor: Colors.white,
foregroundColor: Colors.black,
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back_ios, size: 20),
onPressed: () => Get.back(),
),
),
body: Stack(
children: [
Expanded(
child: Obx(() => SmartRefresher(
controller: controller.refreshController,
enablePullUp: true,
onRefresh: controller.onRefresh,
onLoading: controller.onLoading,
child: ListView.separated(
padding: const EdgeInsets.all(12),
itemCount: controller.messageList.length,
separatorBuilder: (_, __) => const SizedBox(height: 12),
itemBuilder: (context, index) {
return _buildMessageItem(context, controller.messageList[index]);
},
),
)),
),
Obx(() => SmartRefresher(
controller: controller.refreshController,
enablePullUp: true,
onRefresh: controller.onRefresh,
onLoading: controller.onLoading,
child: ListView.builder(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
itemCount: controller.messageList.length,
itemBuilder: (context, index) {
return _buildMessageItem(context, controller.messageList[index]);
},
),
)),
Obx(() => !controller.allRead.value
? Container(
padding: const EdgeInsets.all(16),
color: Colors.white,
child: ElevatedButton(
onPressed: controller.markAllRead,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
minimumSize: const Size(double.infinity, 44),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
),
child: const Text('全部标为已读', style: TextStyle(fontSize: 16, color: Colors.white)),
),
)
? Positioned(
right: 20,
bottom: 50,
child: GestureDetector(
onTap: controller.markAllRead,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 14),
decoration: BoxDecoration(
color: const Color(0xFF007A45),
borderRadius: BorderRadius.circular(30),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: const Text(
'全部已读',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 14,
),
),
),
),
)
: const SizedBox.shrink()),
],
),
@@ -53,54 +76,92 @@ class MessagePage extends GetView<MessageController> {
}
Widget _buildMessageItem(BuildContext context, MessageModel item) {
return GestureDetector(
onTap: () {
controller.markRead(item);
_showMessageDialog(context, item);
},
child: Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: const EdgeInsets.only(top: 6, right: 12),
width: 8,
height: 8,
decoration: BoxDecoration(
color: item.isRead == 1 ? Colors.grey[300] : const Color(0xFFFAAD14),
shape: BoxShape.circle,
return IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// 左侧时间轴线条和圆点
SizedBox(
width: 40,
child: Stack(
alignment: Alignment.topCenter,
children: [
Container(
width: 1.5,
color: const Color(0xFFD8E2EE),
),
Positioned(
top: 25,
child: Container(
width: 12,
height: 12,
decoration: BoxDecoration(
color: item.isRead == 1
? const Color(0xFFAAB6C3)
: const Color(0xFF4CAF50),
shape: BoxShape.circle,
border: Border.all(color: Colors.white, width: 2),
),
),
),
],
),
),
// 右侧内容卡片
Expanded(
child: GestureDetector(
onTap: () {
controller.markRead(item);
_showMessageDialog(context, item);
},
child: Container(
margin: const EdgeInsets.only(bottom: 16),
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.02),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item.title,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Color(0xFF333333),
),
),
const SizedBox(height: 10),
Text(
item.content,
style: const TextStyle(
fontSize: 14,
color: Color(0xFF666666),
height: 1.4,
),
),
const SizedBox(height: 12),
Text(
item.createTime,
style: const TextStyle(
fontSize: 12,
color: Color(0xFFCCCCCC),
),
),
],
),
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item.title,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.black87),
),
const SizedBox(height: 8),
Text(
item.content,
style: TextStyle(fontSize: 14, color: Colors.grey[600]),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 8),
Text(
item.createTime,
style: TextStyle(fontSize: 12, color: Colors.grey[400]),
),
],
),
),
],
),
),
],
),
);
}
@@ -111,7 +172,7 @@ class MessagePage extends GetView<MessageController> {
barrierDismissible: true,
builder: (context) {
return Dialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
child: Container(
padding: const EdgeInsets.all(24),
child: Column(
@@ -122,22 +183,22 @@ class MessagePage extends GetView<MessageController> {
item.title,
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(height: 12),
const SizedBox(height: 16),
Text(
item.content,
style: const TextStyle(fontSize: 15, height: 1.5, color: Colors.black87),
style: const TextStyle(
fontSize: 15, height: 1.5, color: Color(0xFF333333)),
),
const SizedBox(height: 24),
Align(
alignment: Alignment.centerRight,
child: OutlinedButton(
child: TextButton(
onPressed: () => Navigator.pop(context),
style: OutlinedButton.styleFrom(
side: const BorderSide(color: Colors.blue),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)),
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
style: TextButton.styleFrom(
foregroundColor: const Color(0xFF007A45),
),
child: const Text('确认', style: TextStyle(color: Colors.blue)),
child: const Text('确认',
style: TextStyle(fontWeight: FontWeight.bold)),
),
),
],