chore: Follow up emoji picker

This commit is contained in:
krille-chan 2025-06-17 20:57:12 +02:00
commit ba61e3c164
No known key found for this signature in database

View file

@ -424,10 +424,8 @@ class Message extends StatelessWidget {
), ),
Container( Container(
alignment: alignment, alignment: alignment,
padding: EdgeInsets.only( padding:
left: 8, const EdgeInsets.only(left: 8),
bottom: showReactionPicker ? 40 : 0,
),
child: GestureDetector( child: GestureDetector(
onLongPress: longPressSelect onLongPress: longPressSelect
? null ? null
@ -633,64 +631,77 @@ class Message extends StatelessWidget {
), ),
), ),
), ),
], Align(
), alignment: ownMessage
), ? Alignment.bottomRight
], : Alignment.bottomLeft,
),
Positioned(
left:
ownMessage ? null : Avatar.defaultSize + 8,
right: ownMessage ? 0 : null,
bottom: 0,
child: AnimatedSize( child: AnimatedSize(
duration: FluffyThemes.animationDuration, duration:
FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve, curve: FluffyThemes.animationCurve,
alignment: Alignment.bottomCenter,
child: showReactionPicker child: showReactionPicker
? Padding( ? Padding(
padding: const EdgeInsets.only( padding:
top: 8.0, const EdgeInsets.only(
top: 4.0,
bottom: 4.0, bottom: 4.0,
left: 8.0,
), ),
child: Material( child: Material(
elevation: 4, elevation: 4,
borderRadius: BorderRadius.circular( borderRadius:
BorderRadius.circular(
AppConfig.borderRadius, AppConfig.borderRadius,
), ),
shadowColor: theme shadowColor: theme
.colorScheme.surface .colorScheme.surface
.withAlpha(128), .withAlpha(128),
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize:
MainAxisSize.min,
children: [ children: [
...AppConfig.defaultReactions ...AppConfig
.defaultReactions
.map( .map(
(emoji) => IconButton( (emoji) =>
padding: EdgeInsets.zero, IconButton(
padding:
EdgeInsets
.zero,
icon: Center( icon: Center(
child: Opacity( child: Opacity(
opacity: sentReactions opacity:
.contains(emoji) sentReactions
.contains(
emoji,
)
? 0.33 ? 0.33
: 1, : 1,
child: Text( child: Text(
emoji, emoji,
style: style:
const TextStyle( const TextStyle(
fontSize: 20, fontSize:
20,
), ),
textAlign: textAlign:
TextAlign.center, TextAlign
.center,
), ),
), ),
), ),
onPressed: sentReactions onPressed:
.contains(emoji) sentReactions
.contains(
emoji,
)
? null ? null
: () { : () {
onSelect(event); onSelect(
event.room event,
);
event
.room
.sendReaction( .sendReaction(
event.eventId, event.eventId,
emoji, emoji,
@ -700,24 +711,32 @@ class Message extends StatelessWidget {
), ),
IconButton( IconButton(
icon: const Icon( icon: const Icon(
Icons.add_reaction_outlined, Icons
.add_reaction_outlined,
), ),
tooltip: L10n.of(context) tooltip: L10n.of(
.customReaction, context,
onPressed: () async { ).customReaction,
onPressed:
() async {
final emoji = final emoji =
await showAdaptiveBottomSheet< await showAdaptiveBottomSheet<
String>( String>(
context: context, context:
builder: (context) => context,
builder:
(context) =>
Scaffold( Scaffold(
appBar: AppBar( appBar:
AppBar(
title: Text( title: Text(
L10n.of(context) L10n.of(context)
.customReaction, .customReaction,
), ),
leading: CloseButton( leading:
onPressed: () => CloseButton(
onPressed:
() =>
Navigator.of( Navigator.of(
context, context,
).pop( ).pop(
@ -725,10 +744,12 @@ class Message extends StatelessWidget {
), ),
), ),
), ),
body: SizedBox( body:
height: SizedBox(
double.infinity, height: double
child: EmojiPicker( .infinity,
child:
EmojiPicker(
onEmojiSelected: ( onEmojiSelected: (
_, _,
emoji, emoji,
@ -736,24 +757,25 @@ class Message extends StatelessWidget {
Navigator.of( Navigator.of(
context, context,
).pop( ).pop(
emoji.emoji, emoji
.emoji,
), ),
config: Config( config:
Config(
emojiViewConfig: emojiViewConfig:
const EmojiViewConfig( const EmojiViewConfig(
backgroundColor: backgroundColor:
Colors Colors.transparent,
.transparent,
), ),
bottomActionBarConfig: bottomActionBarConfig:
const BottomActionBarConfig( const BottomActionBarConfig(
enabled: false, enabled:
false,
), ),
categoryViewConfig: categoryViewConfig:
CategoryViewConfig( CategoryViewConfig(
initCategory: initCategory:
Category Category.SMILEYS,
.SMILEYS,
backspaceColor: theme backspaceColor: theme
.colorScheme .colorScheme
.primary, .primary,
@ -763,15 +785,13 @@ class Message extends StatelessWidget {
.withAlpha( .withAlpha(
128, 128,
), ),
iconColorSelected: iconColorSelected: theme
theme
.colorScheme .colorScheme
.primary, .primary,
indicatorColor: theme indicatorColor: theme
.colorScheme .colorScheme
.primary, .primary,
backgroundColor: backgroundColor: theme
theme
.colorScheme .colorScheme
.surface, .surface,
), ),
@ -779,12 +799,8 @@ class Message extends StatelessWidget {
SkinToneConfig( SkinToneConfig(
dialogBackgroundColor: dialogBackgroundColor:
Color.lerp( Color.lerp(
theme theme.colorScheme.surface,
.colorScheme theme.colorScheme.primaryContainer,
.surface,
theme
.colorScheme
.primaryContainer,
0.75, 0.75,
)!, )!,
indicatorColor: theme indicatorColor: theme
@ -796,8 +812,12 @@ class Message extends StatelessWidget {
), ),
), ),
); );
if (emoji == null) return; if (emoji ==
if (sentReactions.contains( null) {
return;
}
if (sentReactions
.contains(
emoji, emoji,
)) { )) {
return; return;
@ -820,6 +840,11 @@ class Message extends StatelessWidget {
), ),
], ],
), ),
),
],
),
],
),
); );
}, },
), ),