feat(chat): make messagePreviewMaxLines configurable, with default 128
This commit is contained in:
parent
42a8c4d4c6
commit
bcc4d4d204
3 changed files with 11 additions and 2 deletions
|
|
@ -12,6 +12,7 @@
|
|||
"audioRecordingSamplingRate": 44100,
|
||||
"renderHtml": true,
|
||||
"fontSizeFactor": 1,
|
||||
"messagePreviewMaxLines": 128,
|
||||
"hideRedactedEvents": false,
|
||||
"hideUnknownEvents": true,
|
||||
"separateChatTypes": false,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||
|
||||
enum AppSettings<T> {
|
||||
textMessageMaxLength<int>('textMessageMaxLength', 16384),
|
||||
|
||||
/// Max lines for unselected HTML/text bubbles; 0 = unlimited (no fade).
|
||||
messagePreviewMaxLines<int>('chat.fluffy.message_preview_max_lines', 128),
|
||||
audioRecordingNumChannels<int>('audioRecordingNumChannels', 1),
|
||||
audioRecordingAutoGain<bool>('audioRecordingAutoGain', true),
|
||||
audioRecordingEchoCancel<bool>('audioRecordingEchoCancel', false),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:collection/collection.dart';
|
||||
import 'package:fluffychat/config/setting_keys.dart';
|
||||
import 'package:fluffychat/utils/code_highlight_theme.dart';
|
||||
import 'package:fluffychat/utils/event_checkbox_extension.dart';
|
||||
import 'package:fluffychat/widgets/avatar.dart';
|
||||
|
|
@ -509,11 +510,15 @@ class HtmlMessage extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final element = parser.parse(html).body ?? dom.Element.html('');
|
||||
final configuredMaxLines = AppSettings.messagePreviewMaxLines.value;
|
||||
final maxLines = !limitHeight || configuredMaxLines <= 0
|
||||
? null
|
||||
: configuredMaxLines;
|
||||
return Text.rich(
|
||||
_renderHtml(element, context),
|
||||
style: TextStyle(fontSize: fontSize, color: textColor),
|
||||
maxLines: limitHeight ? 64 : null,
|
||||
overflow: TextOverflow.fade,
|
||||
maxLines: maxLines,
|
||||
overflow: maxLines == null ? TextOverflow.visible : TextOverflow.fade,
|
||||
selectionColor: textColor.withAlpha(128),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue