chore: Improve sticker editor UX
This commit is contained in:
parent
726de6e92b
commit
ed945311d9
2 changed files with 42 additions and 45 deletions
|
|
@ -175,8 +175,7 @@ class EmotesSettingsController extends State<EmotesSettings> {
|
||||||
?.tryGetMap<String, Object?>(stateKey ?? '') !=
|
?.tryGetMap<String, Object?>(stateKey ?? '') !=
|
||||||
null;
|
null;
|
||||||
|
|
||||||
bool get readonly =>
|
bool get readonly => room?.canSendEvent('im.ponies.room_emotes') ?? false;
|
||||||
room == null ? false : !(room!.canSendEvent('im.ponies.room_emotes'));
|
|
||||||
|
|
||||||
void resetAction() {
|
void resetAction() {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ class EmotesSettingsView extends StatelessWidget {
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (!controller.readonly)
|
if (!controller.readonly) ...[
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: ElevatedButton.icon(
|
child: ElevatedButton.icon(
|
||||||
|
|
@ -85,8 +85,8 @@ class EmotesSettingsView extends StatelessWidget {
|
||||||
label: Text(L10n.of(context).createSticker),
|
label: Text(L10n.of(context).createSticker),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!controller.readonly || controller.room != null)
|
|
||||||
const Divider(),
|
const Divider(),
|
||||||
|
],
|
||||||
if (controller.room != null && imageKeys.isNotEmpty)
|
if (controller.room != null && imageKeys.isNotEmpty)
|
||||||
SwitchListTile.adaptive(
|
SwitchListTile.adaptive(
|
||||||
title: Text(L10n.of(context).enableEmotesGlobally),
|
title: Text(L10n.of(context).enableEmotesGlobally),
|
||||||
|
|
@ -108,11 +108,8 @@ class EmotesSettingsView extends StatelessWidget {
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
separatorBuilder: (BuildContext context, int i) =>
|
separatorBuilder: (BuildContext context, int i) =>
|
||||||
const SizedBox.shrink(),
|
const SizedBox.shrink(),
|
||||||
itemCount: imageKeys.length + 1,
|
itemCount: imageKeys.length,
|
||||||
itemBuilder: (BuildContext context, int i) {
|
itemBuilder: (BuildContext context, int i) {
|
||||||
if (i >= imageKeys.length) {
|
|
||||||
return Container(height: 70);
|
|
||||||
}
|
|
||||||
final imageCode = imageKeys[i];
|
final imageCode = imageKeys[i];
|
||||||
final image = controller.pack!.images[imageCode]!;
|
final image = controller.pack!.images[imageCode]!;
|
||||||
final textEditingController = TextEditingController();
|
final textEditingController = TextEditingController();
|
||||||
|
|
@ -176,45 +173,46 @@ class EmotesSettingsView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
PopupMenuButton<ImagePackUsage>(
|
if (!controller.readonly)
|
||||||
onSelected: (usage) => controller.toggleUsage(
|
PopupMenuButton<ImagePackUsage>(
|
||||||
imageCode,
|
onSelected: (usage) => controller.toggleUsage(
|
||||||
usage,
|
imageCode,
|
||||||
|
usage,
|
||||||
|
),
|
||||||
|
itemBuilder: (context) => [
|
||||||
|
PopupMenuItem(
|
||||||
|
value: ImagePackUsage.sticker,
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
if (image.usage?.contains(
|
||||||
|
ImagePackUsage.sticker,
|
||||||
|
) ??
|
||||||
|
true)
|
||||||
|
const Icon(Icons.check_outlined),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Text(L10n.of(context).useAsSticker),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
value: ImagePackUsage.emoticon,
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
if (image.usage?.contains(
|
||||||
|
ImagePackUsage.emoticon,
|
||||||
|
) ??
|
||||||
|
true)
|
||||||
|
const Icon(Icons.check_outlined),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Text(L10n.of(context).useAsEmoji),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
icon: const Icon(Icons.edit_outlined),
|
||||||
),
|
),
|
||||||
itemBuilder: (context) => [
|
|
||||||
PopupMenuItem(
|
|
||||||
value: ImagePackUsage.sticker,
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
if (image.usage?.contains(
|
|
||||||
ImagePackUsage.sticker,
|
|
||||||
) ??
|
|
||||||
true)
|
|
||||||
const Icon(Icons.check_outlined),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Text(L10n.of(context).useAsSticker),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
PopupMenuItem(
|
|
||||||
value: ImagePackUsage.emoticon,
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
if (image.usage?.contains(
|
|
||||||
ImagePackUsage.emoticon,
|
|
||||||
) ??
|
|
||||||
true)
|
|
||||||
const Icon(Icons.check_outlined),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Text(L10n.of(context).useAsEmoji),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
icon: const Icon(Icons.edit_outlined),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
leading: _EmoteImage(image.url),
|
leading: _EmoteImage(image.url),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue