💄 Optimization of UX in messages
This commit is contained in:
@ -35,7 +35,8 @@ class _CallRoomScreenState extends State<CallRoomScreen> {
|
||||
return Stack(
|
||||
children: [
|
||||
Container(
|
||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||
color:
|
||||
Theme.of(context).colorScheme.surfaceContainer.withOpacity(0.75),
|
||||
child: call.focusTrack != null
|
||||
? InteractiveParticipantWidget(
|
||||
isFixedAvatar: false,
|
||||
@ -113,7 +114,10 @@ class _CallRoomScreenState extends State<CallRoomScreen> {
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
child: InteractiveParticipantWidget(
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.surfaceContainerHigh
|
||||
.withOpacity(0.75),
|
||||
participant: track,
|
||||
onTap: () {
|
||||
if (track.participant.sid !=
|
||||
|
@ -138,6 +138,12 @@ class _ChatRoomScreenState extends State<ChatRoomScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
bool _checkMessageMergeable(SnChatMessage? a, SnChatMessage? b) {
|
||||
if (a == null || b == null) return false;
|
||||
if (a.sender.accountId != b.sender.accountId) return false;
|
||||
return a.createdAt.difference(b.createdAt).inMinutes <= 3;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -248,27 +254,20 @@ class _ChatRoomScreenState extends State<ChatRoomScreen> {
|
||||
},
|
||||
itemBuilder: (context, idx) {
|
||||
final message = _messageController.messages[idx];
|
||||
final nextMessage =
|
||||
idx < _messageController.messages.length - 1
|
||||
? _messageController.messages[idx + 1]
|
||||
: null;
|
||||
final previousMessage =
|
||||
idx > 0 ? _messageController.messages[idx - 1] : null;
|
||||
|
||||
final canMerge = nextMessage != null &&
|
||||
nextMessage.senderId == message.senderId &&
|
||||
message.createdAt
|
||||
.difference(nextMessage.createdAt)
|
||||
.inMinutes
|
||||
.abs() <=
|
||||
3;
|
||||
final canMergePrevious = previousMessage != null &&
|
||||
previousMessage.senderId == message.senderId &&
|
||||
message.createdAt
|
||||
.difference(previousMessage.createdAt)
|
||||
.inMinutes
|
||||
.abs() <=
|
||||
3;
|
||||
bool canMerge = false, canMergePrevious = false;
|
||||
if (idx > 0) {
|
||||
canMergePrevious = _checkMessageMergeable(
|
||||
_messageController.messages[idx - 1],
|
||||
_messageController.messages[idx],
|
||||
);
|
||||
}
|
||||
if (idx + 1 < _messageController.messages.length) {
|
||||
canMerge = _checkMessageMergeable(
|
||||
_messageController.messages[idx],
|
||||
_messageController.messages[idx + 1],
|
||||
);
|
||||
}
|
||||
|
||||
return ChatMessage(
|
||||
data: message,
|
||||
|
@ -86,22 +86,28 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
||||
GoRouter.of(context).replaceNamed('explore');
|
||||
},
|
||||
),
|
||||
flexibleSpace: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
if (_data?.body['title'] != null)
|
||||
Text(_data?.body['title'] ?? 'postNoun'.tr())
|
||||
.textStyle(Theme.of(context).textTheme.titleLarge!)
|
||||
.textColor(Colors.white),
|
||||
if (_data?.body['title'] != null)
|
||||
Text('postDetail'.tr())
|
||||
.textColor(Colors.white.withAlpha((255 * 0.9).round()))
|
||||
else
|
||||
Text('postDetail'.tr())
|
||||
.textStyle(Theme.of(context).textTheme.titleLarge!)
|
||||
.textColor(Colors.white),
|
||||
],
|
||||
).padding(top: math.max(MediaQuery.of(context).padding.top, 8)),
|
||||
title: _data?.body['title'] != null
|
||||
? RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(children: [
|
||||
TextSpan(
|
||||
text: _data?.body['title'] ?? 'postNoun'.tr(),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleLarge!
|
||||
.copyWith(color: Colors.white),
|
||||
),
|
||||
const TextSpan(text: '\n'),
|
||||
TextSpan(
|
||||
text: 'postDetail'.tr(),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(color: Colors.white),
|
||||
),
|
||||
]),
|
||||
)
|
||||
: Text('postDetail').tr(),
|
||||
),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
|
@ -1,5 +1,3 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:dropdown_button2/dropdown_button2.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
@ -129,18 +127,28 @@ class _PostEditorScreenState extends State<PostEditorScreen> {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
flexibleSpace: Column(
|
||||
children: [
|
||||
Text(_writeController.title.isNotEmpty
|
||||
? _writeController.title
|
||||
: 'untitled'.tr())
|
||||
.textStyle(Theme.of(context).textTheme.titleLarge!)
|
||||
.textColor(Colors.white),
|
||||
Text(PostWriteController.kTitleMap[widget.mode]!)
|
||||
.tr()
|
||||
.textColor(Colors.white.withAlpha((255 * 0.9).round())),
|
||||
],
|
||||
).padding(top: math.max(MediaQuery.of(context).padding.top, 8)),
|
||||
title: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(children: [
|
||||
TextSpan(
|
||||
text: _writeController.title.isNotEmpty
|
||||
? _writeController.title
|
||||
: 'untitled'.tr(),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleLarge!
|
||||
.copyWith(color: Colors.white),
|
||||
),
|
||||
const TextSpan(text: '\n'),
|
||||
TextSpan(
|
||||
text: PostWriteController.kTitleMap[widget.mode]!,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(color: Colors.white),
|
||||
),
|
||||
]),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Symbols.tune),
|
||||
|
Reference in New Issue
Block a user