Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved some text overflow issues and set max tag name #200

Merged
merged 37 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5d9314d
solved some text overflow issues and set max tag name
Akisame-AI Sep 2, 2023
5c60e83
undid edits to arb files with the exception of the English translation
Akisame-AI Sep 3, 2023
76f1b26
Fixed device settings page scaling
Akisame-AI Sep 3, 2023
3902a70
Fixed scaling issues
Akisame-AI Sep 3, 2023
5e38ac3
Fixed the saved cards layout and fixed color scheme issues with too m…
Akisame-AI Sep 3, 2023
ad5c446
Adjusted scrolling behavior in Saved cards
Akisame-AI Sep 3, 2023
eff8ac3
Merge branch 'main' into Text-overflow-fixes
Akisame-AI Sep 3, 2023
a9e48b2
Fixed the error in Saved cards.
Akisame-AI Sep 4, 2023
e8e940d
"fix" darkmode / m3 darkmode
GameTec-live Sep 4, 2023
4782177
Added complementary color for light mode
Akisame-AI Sep 17, 2023
1947e4a
Made saved cards scale down
Akisame-AI Sep 17, 2023
93a08d1
Added scaling for Android for reading cards
Akisame-AI Sep 17, 2023
2e52327
Fixed the recover and dump partial button scaling
Akisame-AI Sep 17, 2023
6eb3fae
Reformat
Foxushka Sep 21, 2023
e4055d4
Merge branch 'main' into test
Foxushka Sep 21, 2023
bb66bd4
Fixes
Foxushka Sep 21, 2023
11f9e59
Add
Foxushka Sep 21, 2023
387207d
This breaks all, revert
Foxushka Sep 21, 2023
84b06ea
Not required anymore
Foxushka Sep 21, 2023
f5cde7e
Not required anymore
Foxushka Sep 21, 2023
9c252bb
Merge branch 'main' into Text-overflow-fixes
Akisame-AI Sep 25, 2023
88477ed
Added height to slot_manager and setup checkmark scaling in read card
Akisame-AI Sep 25, 2023
e5c93d8
Merge branch 'main' into Text-overflow-fixes
Foxushka Sep 25, 2023
b77d796
fix app crashing
GameTec-live Sep 25, 2023
5b11abc
Merge branch 'main' into Text-overflow-fixes
Foxushka Oct 1, 2023
7190863
Change slot status separately (closes #294)
Foxushka Oct 6, 2023
8e8b1de
Fix icon position
Foxushka Oct 6, 2023
f709c8f
Update screenshots on latest version
Foxushka Oct 6, 2023
0103099
Rewrite saved cards page
Foxushka Oct 6, 2023
db226ec
Forgot something
Foxushka Oct 6, 2023
becb664
Charge status in button settings
Foxushka Oct 6, 2023
23de265
Move saveTag
Foxushka Oct 6, 2023
2a1d330
Merge branch 'main' into Text-overflow-fixes
Foxushka Oct 6, 2023
3639879
No expanded title -_-
Foxushka Oct 9, 2023
275d6d4
Remove legacy
Foxushka Oct 9, 2023
b733e56
Revert "Remove legacy"
GameTec-live Oct 9, 2023
ccb8939
make views great again
GameTec-live Oct 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion chameleonultragui/lib/bridge/chameleon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ enum ButtonConfig {
disable(0),
cycleForward(1),
cycleBackward(2),
cloneUID(3);
cloneUID(3),
chargeStatus(4);

const ButtonConfig(this.value);
final int value;
Expand Down
13 changes: 5 additions & 8 deletions chameleonultragui/lib/gui/component/hex_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class HexEdit extends StatefulWidget {
}

class HexEditState extends State<HexEdit> {

@override
void initState() {
super.initState();
Expand All @@ -29,20 +28,18 @@ class HexEditState extends State<HexEdit> {

for (var i = 0, x = 0; i < widget.data.length; i += 4, x++) {
if (widget.data[i].isNotEmpty) {

String data = '';
for (var j = 0; j < 4; j++) {
data += '\n ${bytesToHex(widget.data[i+j])}';
data += '\n ${bytesToHex(widget.data[i + j])}';
}

sectors.add(
TextField(
maxLines: null,
controller: TextEditingController(text: data.toUpperCase()),
decoration: InputDecoration(
labelText: '${localizations.sector} $x',
hintText: localizations.enter_data
),
labelText: '${localizations.sector} $x',
hintText: localizations.enter_data),
),
);
}
Expand All @@ -51,7 +48,7 @@ class HexEditState extends State<HexEdit> {
return AlertDialog(
title: Text(localizations.edit_data),
content: SizedBox(
width: MediaQuery.of(context).size.width / 4,
width: MediaQuery.of(context).size.width / 4,
height: MediaQuery.of(context).size.height,
child: ListView(
children: sectors,
Expand All @@ -60,4 +57,4 @@ class HexEditState extends State<HexEdit> {
actions: const [],
);
}
}
}
130 changes: 130 additions & 0 deletions chameleonultragui/lib/gui/component/saved_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import 'package:chameleonultragui/main.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class SavedCard extends StatefulWidget {
final IconData icon;
final Color iconColor;
final String firstLine;
final String secondLine;
final List<Widget> children;
final int itemIndex;
final VoidCallback? onPressed;

const SavedCard(
{Key? key,
required this.icon,
required this.iconColor,
required this.firstLine,
required this.secondLine,
required this.children,
required this.itemIndex,
required this.onPressed})
: super(key: key);

@override
SavedCardState createState() => SavedCardState();
}

class SavedCardState extends State<SavedCard> {
@override
void initState() {
super.initState();
}

// good luck understanding it
// some values went from Flutter Inspector, some logically calculated
bool shouldMoveIcons() {
double readWidth = MediaQuery.of(context).size.width *
MediaQuery.of(context).devicePixelRatio;
double predictedElementWidth =
readWidth >= 700 ? (readWidth - 118) / 2 : readWidth - 108;
double iconsWidth = widget.children.length * 40 + 8; // 8 - padding
double textWidth = (TextPainter(
text: TextSpan(text: widget.secondLine),
maxLines: 1,
textScaleFactor: MediaQuery.of(context).textScaleFactor,
textDirection: TextDirection.ltr)
..layout())
.size
.width;
double textEndsAt = textWidth + 85; // icon + padding

return textEndsAt + iconsWidth > predictedElementWidth;
}

@override
Widget build(BuildContext context) {
var appState = context.read<ChameleonGUIState>();
return Container(
constraints: BoxConstraints(maxHeight: !shouldMoveIcons() ? 90 : 130),
child: ElevatedButton(
onPressed: widget.onPressed,
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
return appState.sharedPreferencesProvider
.getThemeComplementaryColor();
},
),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
),
),
child: Padding(
padding: const EdgeInsets.only(top: 8.0, left: 8.0, bottom: 6.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
children: [
Transform(
transform: Matrix4.translationValues(-5, 18, 0),
child: Icon(widget.icon, color: widget.iconColor),
),
const SizedBox(width: 5),
Expanded(
child: Text(
widget.firstLine,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
),
if (shouldMoveIcons()) const SizedBox(height: 10),
Row(
children: [
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const SizedBox(width: 30),
Expanded(
child: Text(
widget.secondLine,
maxLines: 1,
overflow: TextOverflow.ellipsis,
))
],
),
),
if (!shouldMoveIcons()) ...widget.children
],
),
...(shouldMoveIcons())
? [
const SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: widget.children,
)
]
: []
],
),
)));
}
}
116 changes: 63 additions & 53 deletions chameleonultragui/lib/gui/menu/card_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class CardEditMenuState extends State<CardEditMenu> {
Widget build(BuildContext context) {
var appState = context.watch<ChameleonGUIState>();
var localizations = AppLocalizations.of(context)!;

return AlertDialog(
title: Text(localizations.edit_card),
content: SingleChildScrollView(
Expand All @@ -70,63 +71,69 @@ 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(
labelText: localizations.name,
hintText: localizations.enter_name,
prefix: IconButton(
icon: Icon(
(chameleonTagToFrequency(widget.tagSave.tag) ==
TagFrequency.hf)
? Icons.credit_card
: Icons.wifi,
color: currentColor),
onPressed: () async {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(localizations.pick_color),
content: SingleChildScrollView(
child: ColorPicker(
pickerColor: pickerColor,
onColorChanged: (Color color) {
setState(() {
pickerColor = color;
});
},
pickerAreaHeightPercent: 0.8,
),
),
actions: <Widget>[
TextButton(
onPressed: () {
setState(() => currentColor =
pickerColor = Colors.deepOrange);
Navigator.pop(context);
},
child: Text(localizations.reset_default),
),
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text(localizations.cancel),
),
TextButton(
child: Text(localizations.ok),
onPressed: () {
setState(() => currentColor = pickerColor);
Navigator.pop(context);
},
),
],
prefix: Transform(
transform: Matrix4.translationValues(0, 7, 0),
child: IconButton(
icon: Icon(
(chameleonTagToFrequency(widget.tagSave.tag) ==
TagFrequency.hf)
? Icons.credit_card
: Icons.wifi,
color: currentColor),
onPressed: () async {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(localizations.pick_color),
content: SingleChildScrollView(
child: ColorPicker(
pickerColor: pickerColor,
onColorChanged: (Color color) {
setState(() {
pickerColor = color;
});
},
pickerAreaHeightPercent: 0.8,
),
),
actions: <Widget>[
TextButton(
onPressed: () {
setState(() => currentColor =
pickerColor = Colors.deepOrange);
Navigator.pop(context);
},
child: Text(localizations.reset_default),
),
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text(localizations.cancel),
),
TextButton(
child: Text(localizations.ok),
onPressed: () {
setState(
() => currentColor = pickerColor);
Navigator.pop(context);
},
),
],
);
},
);
},
);
},
)),
))),
),
DropdownButton<TagType>(
value: selectedType,
Expand All @@ -139,6 +146,7 @@ class CardEditMenuState extends State<CardEditMenu> {
TagType.ntag215,
TagType.ntag216,
TagType.em410X,
TagType.unknown
].map<DropdownMenuItem<TagType>>((TagType type) {
return DropdownMenuItem<TagType>(
value: type,
Expand All @@ -148,9 +156,11 @@ class CardEditMenuState extends State<CardEditMenu> {
);
}).toList(),
onChanged: (TagType? newValue) {
setState(() {
selectedType = newValue!;
});
if (newValue != TagType.unknown) {
setState(() {
selectedType = newValue!;
});
}
appState.changesMade();
},
),
Expand Down
Loading