feat: add localisation
This commit is contained in:
@@ -4,6 +4,8 @@ import 'package:provider/provider.dart';
|
||||
|
||||
import '../utils/app_update_util.dart';
|
||||
import '../viewmodels/dev_menu_view_model.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../l10n/app_localizations_helpers.dart';
|
||||
|
||||
class DevMenuView extends StatefulWidget {
|
||||
const DevMenuView({super.key});
|
||||
@@ -35,10 +37,11 @@ class _DevMenuViewState extends State<DevMenuView> {
|
||||
|
||||
final message = vm.lastAction;
|
||||
if (message == null) return;
|
||||
final l10n = AppLocalizations.of(context);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(message)),
|
||||
);
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(l10n.devAction(message))));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -50,6 +53,7 @@ class _DevMenuViewState extends State<DevMenuView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final vm = context.watch<DevMenuViewModel>();
|
||||
final l10n = AppLocalizations.of(context);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
@@ -57,109 +61,109 @@ class _DevMenuViewState extends State<DevMenuView> {
|
||||
onPressed: () => context.pop(),
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
),
|
||||
title: const Text('Dev Menu'),
|
||||
title: Text(l10n.devMenu),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
children: [
|
||||
_Section(
|
||||
title: 'Data Management',
|
||||
title: l10n.dataManagement,
|
||||
children: [
|
||||
_Tile(
|
||||
icon: Icons.delete_sweep_rounded,
|
||||
title: 'Clear all open tabs',
|
||||
title: l10n.clearOpenTabs,
|
||||
onTap: vm.isLoading ? null : () => vm.clearOpenTabs(),
|
||||
),
|
||||
_Tile(
|
||||
icon: Icons.history_rounded,
|
||||
title: 'Clear closed tab history',
|
||||
title: l10n.clearClosedHistory,
|
||||
onTap: vm.isLoading ? null : () => vm.clearClosedTabHistory(),
|
||||
),
|
||||
_Tile(
|
||||
icon: Icons.add_box_rounded,
|
||||
title: 'Seed default products',
|
||||
subtitle: 'Only seeds if table is empty',
|
||||
title: l10n.seedDefaultProducts,
|
||||
subtitle: l10n.onlySeedsWhenEmpty,
|
||||
onTap: vm.isLoading ? null : () => vm.seedDefaultProducts(),
|
||||
),
|
||||
_Tile(
|
||||
icon: Icons.restart_alt_rounded,
|
||||
title: 'Clear & reseed products',
|
||||
subtitle: 'Wipes all products, then seeds defaults',
|
||||
title: l10n.clearAndReseedProducts,
|
||||
subtitle: l10n.wipesAndReseeds,
|
||||
onTap: vm.isLoading ? null : () => vm.clearAndReseedProducts(),
|
||||
),
|
||||
_Tile(
|
||||
icon: Icons.delete_forever_rounded,
|
||||
title: 'Clear all products',
|
||||
title: l10n.clearAllProducts,
|
||||
onTap: vm.isLoading ? null : () => vm.clearAllProducts(),
|
||||
),
|
||||
_Tile(
|
||||
icon: Icons.image_rounded,
|
||||
title: 'Clear product images',
|
||||
subtitle: 'Deletes images from product_images folder',
|
||||
title: l10n.clearProductImages,
|
||||
subtitle: l10n.deletesProductImages,
|
||||
onTap: vm.isLoading ? null : () => vm.clearProductImages(),
|
||||
),
|
||||
],
|
||||
),
|
||||
_Section(
|
||||
title: 'Debugging',
|
||||
title: l10n.debugging,
|
||||
children: [
|
||||
_Tile(
|
||||
icon: Icons.lock_reset_rounded,
|
||||
title: 'Reset PIN',
|
||||
subtitle: 'Remove PIN lock',
|
||||
title: l10n.resetPin,
|
||||
subtitle: l10n.removePinLock,
|
||||
onTap: vm.isLoading ? null : () => vm.resetPin(),
|
||||
),
|
||||
_Tile(
|
||||
icon: Icons.bug_report_rounded,
|
||||
title: 'Toggle debug overlay',
|
||||
subtitle: 'Show FPS, memory, widget count',
|
||||
title: l10n.toggleDebugOverlay,
|
||||
subtitle: l10n.showFpsMemoryWidgets,
|
||||
onTap: () => _showDebugOverlayInfo(),
|
||||
),
|
||||
_Tile(
|
||||
icon: Icons.error_outline_rounded,
|
||||
title: 'Error screen',
|
||||
subtitle: 'View the error screen UI',
|
||||
title: l10n.errorScreenMenu,
|
||||
subtitle: l10n.viewErrorScreen,
|
||||
onTap: () => context.push('/error'),
|
||||
),
|
||||
],
|
||||
),
|
||||
_Section(
|
||||
title: 'Feature Toggles',
|
||||
title: l10n.featureToggles,
|
||||
children: [
|
||||
_Tile(
|
||||
icon: Icons.update_rounded,
|
||||
title: 'Simulate update download',
|
||||
subtitle: 'Open the download progress screen',
|
||||
title: l10n.simulateUpdateDownload,
|
||||
subtitle: l10n.openDownloadProgress,
|
||||
onTap: () => _showSimulateUpdateDialog(),
|
||||
),
|
||||
],
|
||||
),
|
||||
_Section(
|
||||
title: 'Testing Helpers',
|
||||
title: l10n.testingHelpers,
|
||||
children: [
|
||||
_Tile(
|
||||
icon: Icons.receipt_long_rounded,
|
||||
title: 'Create test tab',
|
||||
subtitle: 'Add tab with random items',
|
||||
title: l10n.createTestTab,
|
||||
subtitle: l10n.addRandomItems,
|
||||
onTap: vm.isLoading ? null : () => vm.createTestTab(),
|
||||
),
|
||||
_Tile(
|
||||
icon: Icons.grid_view_rounded,
|
||||
title: 'Add 100 test products',
|
||||
subtitle: 'Stress test product grid',
|
||||
title: l10n.addTestProducts,
|
||||
subtitle: l10n.stressTestGrid,
|
||||
onTap: vm.isLoading ? null : () => vm.addTestProducts(),
|
||||
),
|
||||
_Tile(
|
||||
icon: Icons.warning_rounded,
|
||||
title: 'Simulate low stock',
|
||||
subtitle: 'Set all products below threshold',
|
||||
title: l10n.simulateLowStock,
|
||||
subtitle: l10n.setProductsBelowThreshold,
|
||||
onTap: vm.isLoading ? null : () => vm.simulateLowStock(),
|
||||
),
|
||||
_Tile(
|
||||
icon: Icons.history_rounded,
|
||||
title: 'Generate 100 mock orders',
|
||||
subtitle: 'Random customers, items, and amounts',
|
||||
title: l10n.generateMockOrders,
|
||||
subtitle: l10n.randomCustomersItemsAmounts,
|
||||
onTap: vm.isLoading
|
||||
? null
|
||||
: () => vm.generateMockOrders(count: 100),
|
||||
@@ -167,16 +171,16 @@ class _DevMenuViewState extends State<DevMenuView> {
|
||||
],
|
||||
),
|
||||
_Section(
|
||||
title: 'Performance',
|
||||
title: l10n.performance,
|
||||
children: [
|
||||
_Tile(
|
||||
icon: Icons.image_rounded,
|
||||
title: 'Clear image cache',
|
||||
title: l10n.clearImageCache,
|
||||
onTap: vm.isLoading ? null : () => vm.clearImageCache(),
|
||||
),
|
||||
_Tile(
|
||||
icon: Icons.refresh_rounded,
|
||||
title: 'Reload product images',
|
||||
title: l10n.reloadProductImages,
|
||||
onTap: vm.isLoading ? null : () => vm.reloadProductImages(),
|
||||
),
|
||||
],
|
||||
@@ -192,18 +196,17 @@ class _DevMenuViewState extends State<DevMenuView> {
|
||||
}
|
||||
|
||||
void _showDebugOverlayInfo() {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Debug Overlay'),
|
||||
content: const Text(
|
||||
'The debug overlay shows FPS, memory usage, and widget counts. '
|
||||
'Enable it via Flutter DevTools in debug mode.',
|
||||
),
|
||||
title: Text(l10n.debugOverlay),
|
||||
content: Text(l10n.debugOverlayDescription),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('OK'),
|
||||
child: Text(l10n.ok),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -211,10 +214,12 @@ class _DevMenuViewState extends State<DevMenuView> {
|
||||
}
|
||||
|
||||
void _showSimulateUpdateDialog() {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
|
||||
final fakeUpdate = UpdateInfo(
|
||||
update: true,
|
||||
version: '99.0.0',
|
||||
notes: 'Bug fixes and performance improvements.',
|
||||
notes: l10n.simulatedUpdateNotes,
|
||||
mandatory: false,
|
||||
sha256: 'abc123',
|
||||
download: 'https://example.com/fake-update.apk',
|
||||
@@ -223,16 +228,16 @@ class _DevMenuViewState extends State<DevMenuView> {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: const Text('Simulate update'),
|
||||
title: Text(l10n.simulateUpdate),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text('Choose a simulation mode:'),
|
||||
Text(l10n.chooseSimulationMode),
|
||||
const SizedBox(height: 16),
|
||||
_SimOption(
|
||||
icon: Icons.download_rounded,
|
||||
label: 'Successful download',
|
||||
description: 'Progress 0→100%, then install, then done',
|
||||
label: l10n.successfulDownload,
|
||||
description: l10n.progressThenInstall,
|
||||
onTap: () {
|
||||
Navigator.pop(dialogContext);
|
||||
context.push(
|
||||
@@ -244,8 +249,8 @@ class _DevMenuViewState extends State<DevMenuView> {
|
||||
const SizedBox(height: 8),
|
||||
_SimOption(
|
||||
icon: Icons.error_outline_rounded,
|
||||
label: 'Download error',
|
||||
description: 'Fails at 50% with a network timeout',
|
||||
label: l10n.downloadError,
|
||||
description: l10n.failsWithNetworkTimeout,
|
||||
onTap: () {
|
||||
Navigator.pop(dialogContext);
|
||||
context.push(
|
||||
@@ -257,8 +262,8 @@ class _DevMenuViewState extends State<DevMenuView> {
|
||||
const SizedBox(height: 8),
|
||||
_SimOption(
|
||||
icon: Icons.wifi_off_rounded,
|
||||
label: 'Real download (will fail)',
|
||||
description: 'Attempts real OTA with fake URL',
|
||||
label: l10n.realDownloadWillFail,
|
||||
description: l10n.attemptsFakeUrl,
|
||||
onTap: () {
|
||||
Navigator.pop(dialogContext);
|
||||
context.push('/update-progress', extra: fakeUpdate);
|
||||
@@ -269,7 +274,7 @@ class _DevMenuViewState extends State<DevMenuView> {
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: const Text('Cancel'),
|
||||
child: Text(l10n.cancel),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -312,7 +317,9 @@ class _SimOption extends StatelessWidget {
|
||||
Text(
|
||||
description,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -415,8 +422,8 @@ class _Tile extends StatelessWidget {
|
||||
Text(
|
||||
subtitle!,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: scheme.onSurface.withValues(alpha: 0.5),
|
||||
),
|
||||
color: scheme.onSurface.withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user