diff --git a/assets/locales/en_us.json b/assets/locales/en_us.json index cf79ec3..79894a5 100644 --- a/assets/locales/en_us.json +++ b/assets/locales/en_us.json @@ -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" } diff --git a/assets/locales/zh_cn.json b/assets/locales/zh_cn.json index d04f578..cd41ba5 100644 --- a/assets/locales/zh_cn.json +++ b/assets/locales/zh_cn.json @@ -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": "在消息列表中禁用动画效果" } diff --git a/lib/screens/channel/channel_chat.dart b/lib/screens/channel/channel_chat.dart index def7460..4fb9d43 100644 --- a/lib/screens/channel/channel_chat.dart +++ b/lib/screens/channel/channel_chat.dart @@ -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 } } + late SharedPreferences _prefs; + @override void initState() { super.initState(); @@ -189,10 +192,13 @@ class _ChannelChatScreenState extends State _chatController = ChatEventController(); _chatController.initialize(); - _getOngoingCall(); - _getChannel().then((_) { - _chatController.getInitialEvents(_channel!, widget.realm); - _listenMessages(); + SharedPreferences.getInstance().then((inst) { + _prefs = inst; + _getOngoingCall(); + _getChannel().then((_) { + _chatController.getInitialEvents(_channel!, widget.realm); + _listenMessages(); + }); }); } @@ -283,6 +289,8 @@ class _ChannelChatScreenState extends State ), Expanded( child: ChatEventList( + noAnimated: + _prefs.getBool('non_animated_message_list') ?? false, scope: widget.realm, channel: _channel!, chatController: _chatController, diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index 56a8acb..5d4a0eb 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -354,7 +354,7 @@ class _DashboardScreenState extends State { IconButton( icon: const Icon(Icons.arrow_forward), onPressed: () { - AppRouter.instance.goNamed('feed'); + AppRouter.instance.goNamed('explore'); }, ), ], diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index 622c217..a74161c 100644 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -181,6 +181,21 @@ class _SettingScreenState extends State { ], ); }), + _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), diff --git a/lib/widgets/chat/chat_event_list.dart b/lib/widgets/chat/chat_event_list.dart index a26d26a..e5e2e66 100644 --- a/lib/widgets/chat/chat_event_list.dart +++ b/lib/widgets/chat/chat_event_list.dart @@ -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,15 +66,32 @@ class ChatEventList extends StatelessWidget { return GestureDetector( behavior: HitTestBehavior.opaque, - child: ChatEvent( - key: Key('m${item!.uuid}'), - item: item, - isMerged: isMerged, - chatController: chatController, - ).paddingOnly( - top: !isMerged ? 8 : 0, - bottom: !hasMerged ? 8 : 0, - ), + child: Builder(builder: (context) { + final widget = ChatEvent( + key: Key('m${item!.uuid}'), + item: item, + isMerged: isMerged, + chatController: chatController, + ).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); },