feat: 消息分页

This commit is contained in:
guozhigq
2023-12-17 14:55:52 +08:00
parent a43c071eb5
commit a6ab72cadd
8 changed files with 259 additions and 144 deletions

View File

@ -4,14 +4,18 @@ import 'package:pilipala/models/msg/session.dart';
class WhisperDetailController extends GetxController {
late int talkerId;
RxString name = ''.obs;
late String name;
late String face;
late String mid;
RxList<MessageItem> messageList = <MessageItem>[].obs;
@override
void onInit() {
super.onInit();
talkerId = int.parse(Get.parameters['talkerId']!);
name.value = Get.parameters['name']!;
name = Get.parameters['name']!;
face = Get.parameters['face']!;
mid = Get.parameters['mid']!;
}
Future querySessionMsg() async {

View File

@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/pages/whisperDetail/controller.dart';
import 'package:pilipala/utils/feed_back.dart';
import 'widget/chat_item.dart';
@ -27,7 +29,6 @@ class _WhisperDetailPageState extends State<WhisperDetailPage> {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
scrolledUnderElevation: 0,
title: SizedBox(
width: double.infinity,
height: 50,
@ -52,14 +53,35 @@ class _WhisperDetailPageState extends State<WhisperDetailPage> {
icon: Icon(
Icons.arrow_back_outlined,
size: 18,
color: Theme.of(context).colorScheme.primary,
color: Theme.of(context).colorScheme.onPrimaryContainer,
),
),
),
Obx(
() => Text(
_whisperDetailController.name.value,
style: Theme.of(context).textTheme.titleMedium,
GestureDetector(
onTap: () {
feedBack();
Get.toNamed(
'/member?mid=${_whisperDetailController.mid}',
arguments: {
'face': _whisperDetailController.face,
'heroTag': null
},
);
},
child: Row(
children: [
NetworkImgLayer(
width: 34,
height: 34,
type: 'avatar',
src: _whisperDetailController.face,
),
const SizedBox(width: 6),
Text(
_whisperDetailController.name,
style: Theme.of(context).textTheme.titleMedium,
),
],
),
),
const SizedBox(width: 36, height: 36),
@ -105,12 +127,14 @@ class _WhisperDetailPageState extends State<WhisperDetailPage> {
}
},
),
// resizeToAvoidBottomInset: true,
bottomNavigationBar: Container(
width: double.infinity,
height: MediaQuery.of(context).padding.bottom + 70,
padding: EdgeInsets.only(
left: 8,
right: 12,
top: 12,
bottom: MediaQuery.of(context).padding.bottom,
),
decoration: BoxDecoration(
@ -124,6 +148,7 @@ class _WhisperDetailPageState extends State<WhisperDetailPage> {
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// IconButton(
// onPressed: () {},
@ -139,25 +164,26 @@ class _WhisperDetailPageState extends State<WhisperDetailPage> {
color: Theme.of(context).colorScheme.outline,
),
),
// Expanded(
// child: Container(
// height: 42,
// decoration: BoxDecoration(
// color: Theme.of(context).colorScheme.primary.withOpacity(0.1),
// borderRadius: BorderRadius.circular(40.0),
// ),
// child: TextField(
// readOnly: true,
// style: Theme.of(context).textTheme.titleMedium,
// decoration: const InputDecoration(
// border: InputBorder.none, // 移除默认边框
// hintText: '请输入内容', // 提示文本
// contentPadding: EdgeInsets.symmetric(
// horizontal: 12.0, vertical: 12.0), // 内边距
// ),
// ),
// ),
// ),
Expanded(
child: Container(
height: 45,
decoration: BoxDecoration(
color:
Theme.of(context).colorScheme.primary.withOpacity(0.08),
borderRadius: BorderRadius.circular(40.0),
),
child: TextField(
readOnly: true,
style: Theme.of(context).textTheme.titleMedium,
decoration: const InputDecoration(
border: InputBorder.none, // 移除默认边框
hintText: '开发中 ...', // 提示文本
contentPadding: EdgeInsets.symmetric(
horizontal: 16.0, vertical: 12.0), // 内边距
),
),
),
),
const SizedBox(width: 16),
],
),

View File

@ -17,6 +17,9 @@ class ChatItem extends StatelessWidget {
bool isOwner = item.senderUid == 17340771;
bool isPic = item.msgType == 2;
bool isText = item.msgType == 1;
bool isAchive = item.msgType == 11;
bool isArticle = item.msgType == 12;
bool isSystem =
item.msgType == 18 || item.msgType == 10 || item.msgType == 13;
int msgType = item.msgType;
@ -115,7 +118,10 @@ class SystemNotice extends StatelessWidget {
maxWidth: 300.0, // 设置最大宽度为200.0
),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.secondaryContainer,
color: Theme.of(context)
.colorScheme
.secondaryContainer
.withOpacity(0.4),
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16),
@ -128,25 +134,20 @@ class SystemNotice extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(content['title'],
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontWeight: FontWeight.bold)),
Text(
Utils.dateFormat(item.timestamp),
style: Theme.of(context)
.textTheme
.labelSmall!
.copyWith(color: Theme.of(context).colorScheme.outline),
)
],
Text(content['title'],
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontWeight: FontWeight.bold)),
Text(
Utils.dateFormat(item.timestamp),
style: Theme.of(context)
.textTheme
.labelSmall!
.copyWith(color: Theme.of(context).colorScheme.outline),
),
Divider(
color: Theme.of(context).colorScheme.primary.withOpacity(0.1),
color: Theme.of(context).colorScheme.primary.withOpacity(0.05),
),
Text(
content['text'],