Move action buttons to the right hand side of the tile

This commit is contained in:
zontreck 2024-07-21 04:35:43 -07:00
parent 391826df62
commit 812b216c86
13 changed files with 50 additions and 38 deletions

View file

@ -23,8 +23,9 @@ extension ByteArrayTagExt on ByteArrayTag {
return ListTile(
title: Text("TAG_ByteArray (${getKey()})"),
leading: const Image(image: AssetImage("Icons/PNG/ByteArray.png")),
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
false, canBeNamed(this), this, context),
subtitle: TagExt.getElementDescriptor("${value.length} entries"),
trailing: TagExt.getElementButtons(
true, canBeNamed(this), false, this, context),
);
}
}

View file

@ -12,8 +12,11 @@ extension ByteTagExt on ByteTag {
return ListTile(
title: Text("TAG_Byte (${getKey()})"),
subtitle: TagExt.getElementDescriptor(
"$value", false, true, canBeNamed(this), this, context),
"$value",
),
leading: const Image(image: AssetImage("Icons/PNG/Byte.png")),
trailing: TagExt.getElementButtons(
false, canBeNamed(this), true, this, context),
);
}
}

View file

@ -8,13 +8,11 @@ extension CompoundTagExt on CompoundTag {
return ListTile(
title: Text("TAG_Compound (${getKey()})"),
subtitle: TagExt.getElementDescriptor(
"${value.length} tag${value.length > 1 ? "s" : ""}",
true,
false,
canBeNamed(this),
this,
context),
"${value.length} tag${value.length > 1 ? "s" : ""}",
),
leading: const Image(image: AssetImage("Icons/PNG/Compound.png")),
trailing: TagExt.getElementButtons(
true, canBeNamed(this), false, this, context),
);
}

View file

@ -11,9 +11,10 @@ extension DoubleTagExt on DoubleTag {
Widget render(BuildContext context) {
return ListTile(
title: Text("TAG_Double (${getKey()})"),
subtitle: TagExt.getElementDescriptor(
"$value", false, true, canBeNamed(this), this, context),
subtitle: TagExt.getElementDescriptor("$value"),
leading: const Image(image: AssetImage("Icons/PNG/Double.png")),
trailing: TagExt.getElementButtons(
false, canBeNamed(this), true, this, context),
);
}
}

View file

@ -12,9 +12,10 @@ extension FloatTagExt on FloatTag {
Widget render(BuildContext context) {
return ListTile(
title: Text("TAG_Float (${getKey()})"),
subtitle: TagExt.getElementDescriptor(
"$value", false, true, canBeNamed(this), this, context),
subtitle: TagExt.getElementDescriptor("$value"),
leading: const Image(image: AssetImage("Icons/PNG/Float.png")),
trailing: TagExt.getElementButtons(
false, canBeNamed(this), true, this, context),
);
}
}

View file

@ -23,9 +23,10 @@ extension IntArrayTagExt on IntArrayTag {
Widget render(BuildContext context) {
return ListTile(
title: Text("TAG_IntArray (${getKey()})"),
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
false, canBeNamed(this), this, context),
subtitle: TagExt.getElementDescriptor("${value.length} entries"),
leading: const Image(image: AssetImage("Icons/PNG/IntegerArray.png")),
trailing: TagExt.getElementButtons(
true, canBeNamed(this), false, this, context),
);
}
}

View file

@ -12,9 +12,10 @@ extension IntTagExt on IntTag {
Widget render(BuildContext context) {
return ListTile(
title: Text("TAG_Int (${getKey()})"),
subtitle: TagExt.getElementDescriptor(
"$value", false, true, canBeNamed(this), this, context),
subtitle: TagExt.getElementDescriptor("$value"),
leading: const Image(image: AssetImage("Icons/PNG/Integer.png")),
trailing: TagExt.getElementButtons(
false, canBeNamed(this), true, this, context),
);
}
}

View file

@ -23,9 +23,10 @@ extension ListTagExt on ListTag {
return ListTile(
title: Text("TAG_List (${getKey()}) ($type)"),
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
false, canBeNamed(this), this, context),
subtitle: TagExt.getElementDescriptor("${value.length} entries"),
leading: const Image(image: AssetImage("Icons/PNG/List.png")),
trailing: TagExt.getElementButtons(
true, canBeNamed(this), false, this, context),
);
}
}

View file

@ -23,9 +23,10 @@ extension LongArrayTagExt on LongArrayTag {
Widget render(BuildContext context) {
return ListTile(
title: Text("TAG_LongArray (${getKey()})"),
subtitle: TagExt.getElementDescriptor("${value.length} entries", true,
false, canBeNamed(this), this, context),
subtitle: TagExt.getElementDescriptor("${value.length} entries"),
leading: const Image(image: AssetImage("Icons/PNG/LongArray.png")),
trailing: TagExt.getElementButtons(
true, canBeNamed(this), false, this, context),
);
}
}

View file

@ -12,9 +12,10 @@ extension LongTagExt on LongTag {
Widget render(BuildContext context) {
return ListTile(
title: Text("TAG_Long (${getKey()})"),
subtitle: TagExt.getElementDescriptor(
"$value", false, true, canBeNamed(this), this, context),
subtitle: TagExt.getElementDescriptor("$value"),
leading: const Image(image: AssetImage("Icons/PNG/Long.png")),
trailing: TagExt.getElementButtons(
false, canBeNamed(this), true, this, context),
);
}
}

View file

@ -12,9 +12,10 @@ extension ShortTagExt on ShortTag {
Widget render(BuildContext context) {
return ListTile(
title: Text("TAG_Short (${getKey()})"),
subtitle: TagExt.getElementDescriptor(
"$value", false, true, canBeNamed(this), this, context),
subtitle: TagExt.getElementDescriptor("$value"),
leading: const Image(image: AssetImage("Icons/PNG/Short.png")),
trailing: TagExt.getElementButtons(
false, canBeNamed(this), true, this, context),
);
}
}

View file

@ -12,9 +12,10 @@ extension StringTagExt on StringTag {
Widget render(BuildContext context) {
return ListTile(
title: Text("TAG_String (${getKey()})"),
subtitle: TagExt.getElementDescriptor(
value, false, true, canBeNamed(this), this, context),
subtitle: TagExt.getElementDescriptor(value),
leading: const Image(image: AssetImage("Icons/PNG/String.png")),
trailing: TagExt.getElementButtons(
false, canBeNamed(this), true, this, context),
);
}
}

View file

@ -144,16 +144,13 @@ class TagExt {
}
}
static Widget getElementDescriptor(String descript, bool canAddElements,
bool editableValue, bool isNamed, Tag tag, BuildContext ctx) {
static Widget getElementButtons(bool canAddElements, bool isNamed,
bool editableValue, Tag tag, BuildContext ctx) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(descript),
const SizedBox(
width: 100,
),
if (canAddElements)
ElevatedButton(
IconButton(
onPressed: () async {
bool allowAllTagTypes = true;
bool isArray = false;
@ -193,9 +190,9 @@ class TagExt {
isArray: isArray,
allowedTagTypes: allowedTypes));
},
child: const Icon(Icons.add)),
icon: Icon(Icons.add)),
if (isNamed)
ElevatedButton(
IconButton(
onPressed: () async {
var response = await showDialog(
context: ctx,
@ -211,12 +208,16 @@ class TagExt {
state.update();
}
},
child: const Text("R E N A M E")),
icon: Icon(Icons.drive_file_rename_outline)),
if (editableValue)
ElevatedButton(onPressed: () {}, child: const Text("E D I T"))
IconButton(onPressed: () {}, icon: Icon(Icons.edit_document))
],
);
}
static Widget getElementDescriptor(String descript) {
return Text(descript);
}
}
bool canBeNamed(Tag tag) {