🐛 Bug fixes and optimization

This commit is contained in:
LittleSheep 2024-10-06 17:31:44 +08:00
parent 11c913af60
commit 43b7059957
6 changed files with 67 additions and 18 deletions

View File

@ -468,5 +468,8 @@
"all": "All",
"unablePreview": "Unable to preview",
"dashboardNav": "Dash",
"accountNav": "You"
"accountNav": "You",
"performance": "Performance",
"animatedMessageList": "Non-animated message list",
"animatedMessageListDesc": "Remove animation effects in message list, to reduce cause lag"
}

View File

@ -266,7 +266,7 @@
"channelMembersAddHint": "到 @channel",
"channelType": "频道类型",
"channelTypeCommon": "普通频道",
"channelTypeDirect": "私信聊天",
"channelTypeDirect": "私信",
"channelAdjust": "调整频道",
"channelDetail": "频道详情",
"channelSettings": "频道设置",
@ -464,5 +464,8 @@
"all": "全部",
"unablePreview": "无法预览",
"dashboardNav": "仪表盘",
"accountNav": "您"
"accountNav": "您",
"performance": "性能",
"animatedMessageList": "无动画消息列表",
"animatedMessageListDesc": "在消息列表中禁用动画效果"
}

View File

@ -3,6 +3,7 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:solian/controllers/chat_events_controller.dart';
import 'package:solian/exts.dart';
import 'package:solian/models/call.dart';
@ -179,6 +180,8 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
}
}
late SharedPreferences _prefs;
@override
void initState() {
super.initState();
@ -189,11 +192,14 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
_chatController = ChatEventController();
_chatController.initialize();
SharedPreferences.getInstance().then((inst) {
_prefs = inst;
_getOngoingCall();
_getChannel().then((_) {
_chatController.getInitialEvents(_channel!, widget.realm);
_listenMessages();
});
});
}
@override
@ -283,6 +289,8 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
),
Expanded(
child: ChatEventList(
noAnimated:
_prefs.getBool('non_animated_message_list') ?? false,
scope: widget.realm,
channel: _channel!,
chatController: _chatController,

View File

@ -354,7 +354,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
IconButton(
icon: const Icon(Icons.arrow_forward),
onPressed: () {
AppRouter.instance.goNamed('feed');
AppRouter.instance.goNamed('explore');
},
),
],

View File

@ -181,6 +181,21 @@ class _SettingScreenState extends State<SettingScreen> {
],
);
}),
_buildCaptionHeader('performance'.tr),
CheckboxListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 22),
secondary: const Icon(Icons.message),
title: Text('animatedMessageList'.tr),
subtitle: Text('animatedMessageListDesc'.tr),
value: _prefs?.getBool('non_animated_message_list') ?? false,
onChanged: (value) {
_prefs
?.setBool('non_animated_message_list', value ?? false)
.then((_) {
setState(() {});
});
},
),
_buildCaptionHeader('more'.tr),
ListTile(
leading: const Icon(Icons.delete_sweep),

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:get/get.dart';
import 'package:solian/controllers/chat_events_controller.dart';
import 'package:solian/models/channel.dart';
@ -9,6 +10,7 @@ import 'package:solian/widgets/chat/chat_event_action.dart';
import 'package:very_good_infinite_list/very_good_infinite_list.dart';
class ChatEventList extends StatelessWidget {
final bool noAnimated;
final String scope;
final Channel channel;
final ChatEventController chatController;
@ -23,6 +25,7 @@ class ChatEventList extends StatelessWidget {
required this.chatController,
required this.onEdit,
required this.onReply,
this.noAnimated = false,
});
bool _checkMessageMergeable(Event? a, Event? b) {
@ -63,7 +66,8 @@ class ChatEventList extends StatelessWidget {
return GestureDetector(
behavior: HitTestBehavior.opaque,
child: ChatEvent(
child: Builder(builder: (context) {
final widget = ChatEvent(
key: Key('m${item!.uuid}'),
item: item,
isMerged: isMerged,
@ -71,7 +75,23 @@ class ChatEventList extends StatelessWidget {
).paddingOnly(
top: !isMerged ? 8 : 0,
bottom: !hasMerged ? 8 : 0,
),
);
if (noAnimated) {
return widget;
} else {
return widget
.animate(
key: Key('animated-m${item.uuid}'),
)
.slideY(
curve: Curves.fastLinearToSlowEaseIn,
duration: 250.ms,
begin: 0.5,
end: 0,
);
}
}),
onLongPress: () {
showModalBottomSheet(
useRootNavigator: true,
@ -79,7 +99,7 @@ class ChatEventList extends StatelessWidget {
builder: (context) => ChatEventAction(
channel: channel,
realm: channel.realm,
item: item,
item: item!,
onEdit: () {
onEdit(item);
},