forked from Nexus/nexus
Make reactions flexible to fix overflow issues
This commit is contained in:
parent
b701da19dc
commit
b93f4c979c
1 changed files with 56 additions and 50 deletions
|
|
@ -31,17 +31,17 @@ class ReactionRow extends ConsumerWidget {
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
final enabled = useState(true);
|
final enabled = useState(true);
|
||||||
final selected = reactors.contains(clientState!.userId);
|
final selected = reactors.contains(clientState!.userId);
|
||||||
return SizedBox(
|
return Tooltip(
|
||||||
child: Tooltip(
|
message: reactors.join(", "),
|
||||||
message: reactors.join(", "),
|
child: ChoiceChip(
|
||||||
child: ChoiceChip(
|
showCheckmark: false,
|
||||||
showCheckmark: false,
|
selected: selected,
|
||||||
selected: selected,
|
label: Row(
|
||||||
label: Row(
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisSize: MainAxisSize.min,
|
spacing: 8,
|
||||||
spacing: 8,
|
children: [
|
||||||
children: [
|
Flexible(
|
||||||
reaction.startsWith("mxc://")
|
child: reaction.startsWith("mxc://")
|
||||||
? Image(
|
? Image(
|
||||||
height: 20,
|
height: 20,
|
||||||
image: CachedNetworkImage(
|
image: CachedNetworkImage(
|
||||||
|
|
@ -56,49 +56,55 @@ class ReactionRow extends ConsumerWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Text(reaction),
|
: Text(
|
||||||
Text(reactors.length.toString()),
|
reaction,
|
||||||
],
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
onSelected: enabled.value
|
),
|
||||||
? (value) async {
|
Text(
|
||||||
enabled.value = false;
|
reactors.length.toString(),
|
||||||
try {
|
overflow: TextOverflow.ellipsis,
|
||||||
final roomId = ref.watch(
|
),
|
||||||
SelectedRoomController.provider.select(
|
],
|
||||||
(value) => value?.metadata?.id,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (roomId == null ||
|
|
||||||
clientState.userId == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final controller = ref.watch(
|
|
||||||
RoomChatController.provider(
|
|
||||||
roomId,
|
|
||||||
).notifier,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (selected) {
|
|
||||||
await controller
|
|
||||||
.removeReaction(
|
|
||||||
reaction,
|
|
||||||
message,
|
|
||||||
clientState.userId!,
|
|
||||||
)
|
|
||||||
.onError(showError);
|
|
||||||
} else {
|
|
||||||
await controller
|
|
||||||
.sendReaction(reaction, message)
|
|
||||||
.onError(showError);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
enabled.value = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
),
|
),
|
||||||
|
onSelected: enabled.value
|
||||||
|
? (value) async {
|
||||||
|
enabled.value = false;
|
||||||
|
try {
|
||||||
|
final roomId = ref.watch(
|
||||||
|
SelectedRoomController.provider.select(
|
||||||
|
(value) => value?.metadata?.id,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (roomId == null ||
|
||||||
|
clientState.userId == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final controller = ref.watch(
|
||||||
|
RoomChatController.provider(
|
||||||
|
roomId,
|
||||||
|
).notifier,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (selected) {
|
||||||
|
await controller
|
||||||
|
.removeReaction(
|
||||||
|
reaction,
|
||||||
|
message,
|
||||||
|
clientState.userId!,
|
||||||
|
)
|
||||||
|
.onError(showError);
|
||||||
|
} else {
|
||||||
|
await controller
|
||||||
|
.sendReaction(reaction, message)
|
||||||
|
.onError(showError);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
enabled.value = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue