chore: Display attribution for sticker packs

This commit is contained in:
krille-chan 2025-11-20 20:47:27 +01:00
commit 87ca3c1f1f
No known key found for this signature in database
3 changed files with 53 additions and 4 deletions

View file

@ -3458,5 +3458,7 @@
"useAsSticker": "Use as sticker", "useAsSticker": "Use as sticker",
"useAsEmoji": "Use as emoji", "useAsEmoji": "Use as emoji",
"stickerPackNameAlreadyExists": "Sticker pack name already exists", "stickerPackNameAlreadyExists": "Sticker pack name already exists",
"newStickerPack": "New sticker pack" "newStickerPack": "New sticker pack",
"stickerPackName": "Sticker pack name",
"attribution": "Attribution"
} }

View file

@ -47,12 +47,24 @@ class EmotesSettingsController extends State<EmotesSettings> {
room = widget.roomId != null room = widget.roomId != null
? Matrix.of(context).client.getRoomById(widget.roomId!) ? Matrix.of(context).client.getRoomById(widget.roomId!)
: null; : null;
stateKey = packKeys?.firstOrNull; setStateKey(packKeys?.firstOrNull, reset: false);
} }
void setStateKey(String key) { void setStateKey(String? key, {reset = true}) {
stateKey = key; stateKey = key;
resetAction();
final event = key == null
? null
: room?.getState(
'im.ponies.room_emotes',
key,
);
final eventPack = event?.content.tryGetMap<String, Object?>('pack');
packDisplayNameController.text =
eventPack?.tryGet<String>('display_name') ?? '';
packAttributionController.text =
eventPack?.tryGet<String>('attribution') ?? '';
if (reset) resetAction();
} }
bool showSave = false; bool showSave = false;
@ -139,6 +151,12 @@ class EmotesSettingsController extends State<EmotesSettings> {
setState(() {}); setState(() {});
} }
final TextEditingController packDisplayNameController =
TextEditingController();
final TextEditingController packAttributionController =
TextEditingController();
void removeImageAction(String oldImageCode) => setState(() { void removeImageAction(String oldImageCode) => setState(() {
pack!.images.remove(oldImageCode); pack!.images.remove(oldImageCode);
showSave = true; showSave = true;

View file

@ -152,6 +152,35 @@ class EmotesSettingsView extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[ children: <Widget>[
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) ...[ if (!controller.readonly) ...[
Padding( Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),