diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 22d4190ae..99e856036 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -3458,5 +3458,7 @@ "useAsSticker": "Use as sticker", "useAsEmoji": "Use as emoji", "stickerPackNameAlreadyExists": "Sticker pack name already exists", - "newStickerPack": "New sticker pack" + "newStickerPack": "New sticker pack", + "stickerPackName": "Sticker pack name", + "attribution": "Attribution" } diff --git a/lib/pages/settings_emotes/settings_emotes.dart b/lib/pages/settings_emotes/settings_emotes.dart index e412c1b9d..0dc860ea3 100644 --- a/lib/pages/settings_emotes/settings_emotes.dart +++ b/lib/pages/settings_emotes/settings_emotes.dart @@ -47,12 +47,24 @@ class EmotesSettingsController extends State { room = widget.roomId != null ? Matrix.of(context).client.getRoomById(widget.roomId!) : null; - stateKey = packKeys?.firstOrNull; + setStateKey(packKeys?.firstOrNull, reset: false); } - void setStateKey(String key) { + void setStateKey(String? key, {reset = true}) { stateKey = key; - resetAction(); + + final event = key == null + ? null + : room?.getState( + 'im.ponies.room_emotes', + key, + ); + final eventPack = event?.content.tryGetMap('pack'); + packDisplayNameController.text = + eventPack?.tryGet('display_name') ?? ''; + packAttributionController.text = + eventPack?.tryGet('attribution') ?? ''; + if (reset) resetAction(); } bool showSave = false; @@ -139,6 +151,12 @@ class EmotesSettingsController extends State { setState(() {}); } + final TextEditingController packDisplayNameController = + TextEditingController(); + + final TextEditingController packAttributionController = + TextEditingController(); + void removeImageAction(String oldImageCode) => setState(() { pack!.images.remove(oldImageCode); showSave = true; diff --git a/lib/pages/settings_emotes/settings_emotes_view.dart b/lib/pages/settings_emotes/settings_emotes_view.dart index 8a55d8bfe..58dc5ffac 100644 --- a/lib/pages/settings_emotes/settings_emotes_view.dart +++ b/lib/pages/settings_emotes/settings_emotes_view.dart @@ -152,6 +152,35 @@ class EmotesSettingsView extends StatelessWidget { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ + if (controller.room != null) ...[ + const SizedBox(height: 16), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: TextField( + maxLength: 256, + controller: controller.packDisplayNameController, + readOnly: true, //controller.readonly, + decoration: InputDecoration( + counter: const SizedBox.shrink(), + hintText: controller.stateKey, + labelText: L10n.of(context).stickerPackName, + ), + ), + ), + const SizedBox(height: 8), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: TextField( + maxLength: 256, + controller: controller.packAttributionController, + readOnly: true, //controller.readonly, + decoration: InputDecoration( + counter: const SizedBox.shrink(), + labelText: L10n.of(context).attribution, + ), + ), + ), + ], if (!controller.readonly) ...[ Padding( padding: const EdgeInsets.all(16.0),