Skip to content

Commit

Permalink
Fix text truncation, improved text scailing at saved cards (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxushka authored Oct 13, 2023
1 parent 1b56618 commit b4fc91a
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 45 deletions.
73 changes: 45 additions & 28 deletions chameleonultragui/lib/gui/component/saved_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ class SavedCardState extends State<SavedCard> {
bool shouldMoveIcons() {
var appState = context.read<ChameleonGUIState>();

double readWidth = MediaQuery.of(context).size.width *
MediaQuery.of(context).devicePixelRatio;
double readWidth = MediaQuery.of(context).size.width;
double predictedElementWidth = readWidth >= 700
? (readWidth - appState.navigationRailSize!.width - 38) / 2
: (readWidth - appState.navigationRailSize!.width - 28);
Expand Down Expand Up @@ -82,49 +81,67 @@ class SavedCardState extends State<SavedCard> {
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,
),
),
],
),
Row(children: [
Expanded(
child: FittedBox(
alignment: Alignment.centerLeft,
fit: BoxFit.scaleDown,
child: Row(
children: [
Transform(
transform:
Matrix4.translationValues(-5, 18, 0),
child: Icon(widget.icon,
color: widget.iconColor),
),
const SizedBox(width: 5),
FittedBox(
alignment: Alignment.centerLeft,
fit: BoxFit.scaleDown,
child: Text(
widget.firstLine,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
)))
]),
if (shouldMoveIcons()) const SizedBox(height: 10),
Row(
children: [
Expanded(
child: FittedBox(
alignment: Alignment.centerLeft,
fit: BoxFit.scaleDown,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const SizedBox(width: 30),
Expanded(
FittedBox(
alignment: Alignment.centerLeft,
fit: BoxFit.scaleDown,
child: Text(
widget.secondLine,
maxLines: 1,
overflow: TextOverflow.ellipsis,
))
widget.secondLine,
maxLines: 1,
overflow: TextOverflow.ellipsis,
))
],
),
),
)),
if (!shouldMoveIcons()) ...widget.children
],
),
...(shouldMoveIcons())
? [
const SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: widget.children,
)
FittedBox(
alignment: Alignment.centerRight,
fit: BoxFit.scaleDown,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: widget.children,
))
]
: []
],
Expand Down
8 changes: 3 additions & 5 deletions chameleonultragui/lib/helpers/general.dart
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,12 @@ Future<void> saveTag(CardSave tag, BuildContext context, bool bin) async {
}
}

void updateNavigationRailWidth(BuildContext context,
{bool skipWait = false}) async {
void updateNavigationRailWidth(BuildContext context) async {
if (context.mounted) {
var appState = Provider.of<ChameleonGUIState>(context, listen: false);
if (!skipWait) {
await asyncSleep(500);
}
await asyncSleep(500);
appState.navigationRailSize =
appState.navigationRailKey.currentContext!.size;
appState.changesMade();
}
}
2 changes: 1 addition & 1 deletion chameleonultragui/lib/l10n/updateCrowdin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def fetch(url):
projectId = 611911
sourceId = 33

current_translation = fetch('https://raw.githubusercontent.com/GameTec-live/ChameleonUltraGUI/main/chameleonultragui/lib/l10n/app_en.arb')
current_translation = fetch('https://raw.githubusercontent.com/GameTec-live/ChameleonUltraGUI/main~1/chameleonultragui/lib/l10n/app_en.arb')
branch_translation = json.load(open('chameleonultragui/lib/l10n/app_en.arb'))
strings = request('GET', f'https://api.crowdin.com/api/v2/projects/{projectId}/strings?limit=500')

Expand Down
4 changes: 2 additions & 2 deletions chameleonultragui/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class _MainPageState extends State<MainPage> {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback(
(_) => updateNavigationRailWidth(context, skipWait: true));
WidgetsBinding.instance
.addPostFrameCallback((_) => updateNavigationRailWidth(context));
}

@override
Expand Down
16 changes: 8 additions & 8 deletions chameleonultragui/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,18 @@ packages:
dependency: "direct main"
description:
name: ffigen
sha256: d3e76c2ad48a4e7f93a29a162006f00eba46ce7c08194a77bb5c5e97d1b5ff0a
sha256: "3a80687577e7e51ba915114742f389a128e8aa241c52ce69a0f70aecb8e14365"
url: "https://pub.dev"
source: hosted
version: "8.0.2"
version: "9.0.1"
file:
dependency: transitive
description:
name: file
sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "6.1.4"
version: "7.0.0"
file_picker:
dependency: "direct main"
description:
Expand Down Expand Up @@ -585,10 +585,10 @@ packages:
dependency: transitive
description:
name: shared_preferences_linux
sha256: c2eb5bf57a2fe9ad6988121609e47d3e07bb3bdca5b6f8444e4cf302428a128a
sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa"
url: "https://pub.dev"
source: hosted
version: "2.3.1"
version: "2.3.2"
shared_preferences_platform_interface:
dependency: transitive
description:
Expand All @@ -609,10 +609,10 @@ packages:
dependency: transitive
description:
name: shared_preferences_windows
sha256: f763a101313bd3be87edffe0560037500967de9c394a714cd598d945517f694f
sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59"
url: "https://pub.dev"
source: hosted
version: "2.3.1"
version: "2.3.2"
sky_engine:
dependency: transitive
description: flutter
Expand Down
2 changes: 1 addition & 1 deletion chameleonultragui/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies:
logger: ^2.0.1
convert: ^3.1.1
shared_preferences: ^2.2.1
ffigen: ^8.0.2
ffigen: ^9.0.1
dylib: ^0.3.3
ffi: ^2.1.0
usb_serial:
Expand Down

0 comments on commit b4fc91a

Please sign in to comment.