Merge branch 'design'

This commit is contained in:
guozhigq
2024-12-08 16:52:48 +08:00
3 changed files with 55 additions and 29 deletions

View File

@ -1,5 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'dart:math';
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart'; import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
import 'package:floating/floating.dart'; import 'package:floating/floating.dart';
@ -76,7 +77,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
getStatusHeight(); getStatusHeight();
heroTag = Get.arguments['heroTag']; heroTag = Get.arguments['heroTag'];
vdCtr = Get.put(VideoDetailController(), tag: heroTag); vdCtr = Get.put(VideoDetailController(), tag: heroTag);
vdCtr.sheetHeight.value = localCache.get('sheetHeight'); vdCtr.sheetHeight.value = GlobalDataCache.sheetHeight;
videoIntroController = Get.put( videoIntroController = Get.put(
VideoIntroController(bvid: Get.parameters['bvid']!), VideoIntroController(bvid: Get.parameters['bvid']!),
tag: heroTag); tag: heroTag);
@ -223,8 +224,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
void _extendNestCtrListener() { void _extendNestCtrListener() {
final double offset = _extendNestCtr.position.pixels; final double offset = _extendNestCtr.position.pixels;
if (vdCtr.videoDirection.value == 'horizontal') { if (vdCtr.videoDirection.value == 'horizontal') {
vdCtr.sheetHeight.value = vdCtr.sheetHeight.value = max(GlobalDataCache.sheetHeight,
Get.size.height - videoHeight - statusBarHeight + offset; Get.size.height - videoHeight - statusBarHeight + offset);
appbarStream.add(offset); appbarStream.add(offset);
} else { } else {
if (offset > (Get.size.width * 22 / 16 - videoHeight)) { if (offset > (Get.size.width * 22 / 16 - videoHeight)) {

View File

@ -45,36 +45,44 @@ class WhisperController extends GetxController {
if (isLoading) return; if (isLoading) return;
var res = await MsgHttp.sessionList( var res = await MsgHttp.sessionList(
endTs: type == 'onLoad' ? sessionList.last.sessionTs : null); endTs: type == 'onLoad' ? sessionList.last.sessionTs : null);
if (res['status'] && try {
res['data'].sessionList != null && if (res['status'] &&
res['data'].sessionList.isNotEmpty) { res['data'].sessionList != null &&
await queryAccountList(res['data'].sessionList); res['data'].sessionList.isNotEmpty) {
// 将 accountList 转换为 Map 结构 await queryAccountList(res['data'].sessionList);
Map<int, dynamic> accountMap = {}; // 将 accountList 转换为 Map 结构
for (var j in accountList) { Map<int, dynamic> accountMap = {};
accountMap[j.mid!] = j; for (var j in accountList) {
} accountMap[j.mid!] = j;
}
// 遍历 sessionList通过 mid 查找并赋值 accountInfo // 遍历 sessionList通过 mid 查找并赋值 accountInfo
for (var i in res['data'].sessionList) { for (var i in res['data'].sessionList) {
var accountInfo = accountMap[i.talkerId]; var accountInfo = accountMap[i.talkerId];
if (accountInfo != null) { if (accountInfo != null) {
i.accountInfo = accountInfo; i.accountInfo = accountInfo;
}
if (i.talkerId == 844424930131966) {
i.accountInfo = AccountListModel(
name: 'UP主小助手',
face:
'https://message.biliimg.com/bfs/im/489a63efadfb202366c2f88853d2217b5ddc7a13.png',
);
}
} }
if (i.talkerId == 844424930131966) { if (type == 'onLoad') {
i.accountInfo = AccountListModel( sessionList.addAll(res['data'].sessionList);
name: 'UP主小助手', } else {
face: sessionList.value = res['data'].sessionList;
'https://message.biliimg.com/bfs/im/489a63efadfb202366c2f88853d2217b5ddc7a13.png',
);
} }
} }
if (type == 'onLoad') { } catch (err) {
sessionList.addAll(res['data'].sessionList); res = {
} else { 'status': false,
sessionList.value = res['data'].sessionList; 'message': err.toString(),
} };
} }
isLoading = false; isLoading = false;
return res; return res;
} }

View File

@ -44,7 +44,24 @@ class _WhisperPageState extends State<WhisperPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: const Text('消息')), appBar: AppBar(
title: const Text('消息'),
actions: [
IconButton(
icon: Icon(Icons.open_in_browser_rounded,
color: Theme.of(context).colorScheme.primary),
tooltip: '用浏览器打开',
onPressed: () {
Get.toNamed('/webview', parameters: {
'url': 'https://message.bilibili.com',
'type': 'whisper',
'pageTitle': '消息中心',
});
},
),
const SizedBox(width: 12)
],
),
body: RefreshIndicator( body: RefreshIndicator(
onRefresh: () async { onRefresh: () async {
_whisperController.unread(); _whisperController.unread();