Skip to content

Commit

Permalink
solved some text overflow issues and set max tag name
Browse files Browse the repository at this point in the history
Text overflow issues on the slot manager should be a lot better now.
Text overflow on saved cards still requires some work. Changed a row to a wrap to get it to handle overflows properly but I need to split the quick buttons to a new row now.
On the card edit page I added a validation for a max name length as supported by the chameleon ultra and added some localization translations for this.
  • Loading branch information
Akisame-AI committed Sep 2, 2023
1 parent 0fe9ef8 commit 5d9314d
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 25 deletions.
3 changes: 3 additions & 0 deletions chameleonultragui/lib/gui/menu/card_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class CardEditMenuState extends State<CardEditMenu> {
if (value == null || value.isEmpty) {
return localizations.please_enter_name;
}
if (value.length>19) {
return localizations.too_long_name;
}
return null;
},
decoration: InputDecoration(
Expand Down
29 changes: 19 additions & 10 deletions chameleonultragui/lib/gui/page/saved_cards.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class SavedCardsPageState extends State<SavedCardsPage> {
itemBuilder: (BuildContext context, int index) {
if (index == 0) {
return Container(
constraints: const BoxConstraints(maxHeight: 100),
constraints: const BoxConstraints(minHeight: 80, maxHeight: 150),
child: ElevatedButton(
onPressed: () async {
FilePickerResult? result =
Expand Down Expand Up @@ -360,14 +360,15 @@ class SavedCardsPageState extends State<SavedCardsPage> {
} else {
final tag = tags[index - 1];
return Container(
constraints: const BoxConstraints(maxHeight: 100),
constraints: const BoxConstraints(minHeight: 80, maxHeight: 150),
child: ElevatedButton(
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(tag.name),

title: Expanded(child: Text(tag.name, maxLines: 3, overflow: TextOverflow.ellipsis)),
content: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expand Down Expand Up @@ -462,6 +463,7 @@ class SavedCardsPageState extends State<SavedCardsPage> {
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),

),
),
child: Stack(
Expand All @@ -479,30 +481,37 @@ class SavedCardsPageState extends State<SavedCardsPage> {
),
Expanded(
flex: 1,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
child: Wrap(
//mainAxisAlignment: MainAxisAlignment.end,
children: [
Column(
children: [
Text(
tag.name,
style: const TextStyle(
fontSize: 24,
fontSize: 16,
overflow: TextOverflow.ellipsis,
),
maxLines: 3,
overflow: TextOverflow.ellipsis,
),

Text(
chameleonTagToString(tag.tag) +
((chameleonTagSaveCheckForMifareClassicEV1(
tag))
? " EV1"
: ""),
style: const TextStyle(
fontSize: 24,
fontSize: 16,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
],
],
),
],

),
),
],
Expand Down Expand Up @@ -603,14 +612,14 @@ class SavedCardsPageState extends State<SavedCardsPage> {
child: StaggeredGridView.countBuilder(
padding: const EdgeInsets.all(20),
crossAxisCount:
MediaQuery.of(context).size.width >= 600 ? 2 : 1,
MediaQuery.of(context).size.width >= 700 ? 2 : 1,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
itemCount: dictionaries.length + 1,
itemBuilder: (BuildContext context, int index) {
if (index == 0) {
return Container(
constraints: const BoxConstraints(maxHeight: 100),
constraints: const BoxConstraints(maxHeight: 150),
child: ElevatedButton(
onPressed: () async {
FilePickerResult? result =
Expand Down
58 changes: 43 additions & 15 deletions chameleonultragui/lib/gui/page/slot_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ class SlotManagerPageState extends State<SlotManagerPage> {
child: AlignedGridView.count(
padding: const EdgeInsets.all(20),
crossAxisCount:
MediaQuery.of(context).size.width >= 600 ? 2 : 1,
MediaQuery.of(context).size.width >= 700 ? 2 : 1,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
itemCount: 8,
itemBuilder: (BuildContext context, int index) {
return Container(
constraints: const BoxConstraints(maxHeight: 120),
constraints: const BoxConstraints(minHeight: 120, maxHeight: 180),
child: ElevatedButton(
onPressed: () {
cardSelectDialog(context, index);
Expand All @@ -173,17 +173,31 @@ class SlotManagerPageState extends State<SlotManagerPage> {
? Colors.green
: Colors.deepOrange),
const SizedBox(width: 5),
Text("${localizations.slot} ${index + 1}")
//Text("${localizations.slot} ${index + 1}"),
Expanded(
child: Text(
"${localizations.slot} ${index + 1}",
maxLines: 2,
overflow: TextOverflow.ellipsis,
)
)
],
),
const SizedBox(height: 10),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Icon(Icons.credit_card),
const SizedBox(width: 5),
Text(
"${slotData[index]['hfName'] ?? localizations.unknown} (${chameleonTagToString(usedSlots[index].$1)})")
Expanded(
child: Text(
"${slotData[index]['hfName'] ?? localizations.unknown} (${chameleonTagToString(usedSlots[index].$1)})",
maxLines: 2,
overflow: TextOverflow.ellipsis,
)
)
//Text(
// "${slotData[index]['hfName'] ?? localizations.unknown} (${chameleonTagToString(usedSlots[index].$1)})")
],
),
Row(
Expand All @@ -195,9 +209,11 @@ class SlotManagerPageState extends State<SlotManagerPage> {
children: [
const Icon(Icons.wifi),
const SizedBox(width: 5),
Text(
"${slotData[index]['lfName'] ?? localizations.unknown} (${chameleonTagToString(usedSlots[index].$2)})",
),
Expanded(child: Text("${slotData[index]['lfName'] ?? localizations.unknown} (${chameleonTagToString(usedSlots[index].$2)})",
//maxLines: 2,
overflow: TextOverflow.clip,
))

],
),
),
Expand Down Expand Up @@ -276,15 +292,21 @@ class CardSearchDelegate extends SearchDelegate<String> {
items: [
DropdownMenuItem(
value: SearchFilter.all,
child: Text(localizations.all),
child: Text(localizations.all,
maxLines: 2,
overflow: TextOverflow.ellipsis,),
),
DropdownMenuItem(
value: SearchFilter.hf,
child: Text(localizations.hf),
child: Text(localizations.hf,
maxLines: 2,
overflow: TextOverflow.ellipsis,),
),
DropdownMenuItem(
value: SearchFilter.lf,
child: Text(localizations.lf),
child: Text(localizations.lf,
maxLines: 2,
overflow: TextOverflow.ellipsis,),
),
],
onChanged: (SearchFilter? value) {
Expand Down Expand Up @@ -343,8 +365,12 @@ class CardSearchDelegate extends SearchDelegate<String> {
},
child: ListTile(
leading: const Icon(Icons.credit_card),
title: Text(card.name),
subtitle: Text(chameleonTagToString(card.tag)),
title: Text(card.name,
maxLines: 2,
overflow: TextOverflow.ellipsis,),
subtitle: Text(chameleonTagToString(card.tag),
maxLines: 2,
overflow: TextOverflow.ellipsis,),
),
),
const SizedBox(height: 10),
Expand Down Expand Up @@ -378,7 +404,9 @@ class CardSearchDelegate extends SearchDelegate<String> {
leading: const Icon(Icons.credit_card),
title: Text(card.name),
subtitle: Text(chameleonTagToString(card.tag) +
((chameleonTagSaveCheckForMifareClassicEV1(card)) ? " EV1" : "")),
((chameleonTagSaveCheckForMifareClassicEV1(card)) ? " EV1" : ""),
maxLines: 2,
overflow: TextOverflow.ellipsis,),
onTap: () async {
if ([
TagType.mifareMini,
Expand Down
1 change: 1 addition & 0 deletions chameleonultragui/lib/l10n/app_da.arb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"sector": "Sektor",
"edit_card": "Rediger kort",
"please_enter_name": "Indtast et navn",
"too_long_name": "Navnet er for langt",
"name": "Navn",
"enter_name": "Indtast navn p\u00e5 kort",
"pick_color": "V\u00e6lg en farve",
Expand Down
1 change: 1 addition & 0 deletions chameleonultragui/lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"sector": "Sektor",
"edit_card": "Karte bearbeiten",
"please_enter_name": "Bitte gebe einen Namen an",
"too_long_name": "Der Name ist zu lang",
"name": "Namen",
"enter_name": "Geben Sie den Namen der Karte ein",
"pick_color": "W\u00e4hlen Sie eine Farbe",
Expand Down
1 change: 1 addition & 0 deletions chameleonultragui/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"sector": "Sector",
"edit_card": "Edit Card",
"please_enter_name": "Please enter a name",
"too_long_name": "The name is too long",
"name": "Name",
"enter_name": "Enter name of card",
"pick_color": "Pick a color",
Expand Down
1 change: 1 addition & 0 deletions chameleonultragui/lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"sector": "Sector",
"edit_card": "Editar tarjeta",
"please_enter_name": "Por favor, introduzca un nombre",
"too_long_name": "El nombre es muy largo",
"name": "Nombre",
"enter_name": "Introduzca el nombre de la tarjeta",
"pick_color": "Elija un color",
Expand Down
1 change: 1 addition & 0 deletions chameleonultragui/lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"sector": "Secteur",
"edit_card": "\u00c9diter carte",
"please_enter_name": "Merci d\u2019indiquer un nom",
"too_long_name": "Le nom est trop long",
"name": "Nom",
"enter_name": "Saisir le nom de la carte",
"pick_color": "Choisis une couleur",
Expand Down
1 change: 1 addition & 0 deletions chameleonultragui/lib/l10n/app_ro.arb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"sector": "Sector",
"edit_card": "Editare card",
"please_enter_name": "Introduce\u021bi un nume",
"too_long_name": "Numele este prea lung",
"name": "Nume",
"enter_name": "Introduce\u021bi numele cardului",
"pick_color": "Alege\u021bi o culoare",
Expand Down

0 comments on commit 5d9314d

Please sign in to comment.