feat: add localisation

This commit is contained in:
2026-07-31 21:46:05 +02:00
parent b58c9a8722
commit f5b2041612
30 changed files with 4099 additions and 326 deletions
+23 -27
View File
@@ -5,6 +5,8 @@ import 'package:provider/provider.dart';
import '../app/router.dart';
import '../viewmodels/history_view_model.dart';
import '../l10n/app_localizations.dart';
import '../l10n/app_localizations_helpers.dart';
class HistoryScreenView extends StatefulWidget {
const HistoryScreenView({super.key});
@@ -55,6 +57,7 @@ class _HistoryScreenViewState extends State<HistoryScreenView> with RouteAware {
@override
Widget build(BuildContext context) {
final viewModel = context.watch<HistoryViewModel>();
final l10n = AppLocalizations.of(context);
return Scaffold(
appBar: AppBar(
@@ -65,13 +68,13 @@ class _HistoryScreenViewState extends State<HistoryScreenView> with RouteAware {
icon: const Icon(Icons.arrow_back),
),
const SizedBox(width: 5),
const Text('Tab History'),
Text(l10n.tabHistory),
],
),
actionsPadding: const EdgeInsets.symmetric(horizontal: 8),
actions: [
IconButton(
tooltip: 'Refresh',
tooltip: l10n.refresh,
onPressed: viewModel.load,
icon: const Icon(Icons.refresh_rounded),
),
@@ -100,7 +103,7 @@ class _HistoryScreenViewState extends State<HistoryScreenView> with RouteAware {
),
const SizedBox(height: 12),
Text(
viewModel.errorMessage!,
l10n.localizedError(viewModel.errorMessage),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyLarge,
),
@@ -119,8 +122,8 @@ class _HistoryScreenViewState extends State<HistoryScreenView> with RouteAware {
Expanded(
child: TextField(
onChanged: viewModel.search,
decoration: const InputDecoration(
hintText: 'Search by name…',
decoration: InputDecoration(
hintText: l10n.searchByName,
prefixIcon: Icon(Icons.search_rounded, size: 20),
isDense: true,
),
@@ -141,12 +144,12 @@ class _HistoryScreenViewState extends State<HistoryScreenView> with RouteAware {
: ListView.separated(
controller: _scrollController,
padding: const EdgeInsets.fromLTRB(20, 8, 20, 20),
itemCount: viewModel.closedTabs.length +
itemCount:
viewModel.closedTabs.length +
(viewModel.hasMore || viewModel.isLoadingMore
? 1
: 0),
separatorBuilder: (_, _) =>
const SizedBox(height: 10),
separatorBuilder: (_, _) => const SizedBox(height: 10),
itemBuilder: (context, index) {
if (index == viewModel.closedTabs.length) {
return const Padding(
@@ -189,6 +192,7 @@ class _CustomerDropdown extends StatelessWidget {
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
final l10n = AppLocalizations.of(context);
final isFiltered = selectedCustomer != null;
return PopupMenuButton<String>(
@@ -204,17 +208,13 @@ class _CustomerDropdown extends StatelessWidget {
child: Row(
children: [
Icon(
isFiltered
? Icons.people_outline
: Icons.people_rounded,
isFiltered ? Icons.people_outline : Icons.people_rounded,
size: 18,
color: isFiltered
? null
: scheme.primary,
color: isFiltered ? null : scheme.primary,
),
const SizedBox(width: 10),
Text(
'All customers',
l10n.allCustomers,
style: TextStyle(
fontWeight: isFiltered ? FontWeight.w400 : FontWeight.w700,
color: isFiltered ? null : scheme.primary,
@@ -223,8 +223,7 @@ class _CustomerDropdown extends StatelessWidget {
],
),
),
if (customerNames.isNotEmpty)
const PopupMenuDivider(height: 1),
if (customerNames.isNotEmpty) const PopupMenuDivider(height: 1),
...customerNames.map(
(name) => PopupMenuItem<String>(
value: name,
@@ -237,9 +236,7 @@ class _CustomerDropdown extends StatelessWidget {
size: 18,
),
const SizedBox(width: 10),
Expanded(
child: Text(name, overflow: TextOverflow.ellipsis),
),
Expanded(child: Text(name, overflow: TextOverflow.ellipsis)),
],
),
),
@@ -250,9 +247,7 @@ class _CustomerDropdown extends StatelessWidget {
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
border: Border.all(color: scheme.onSurface.withValues(alpha: 0.12)),
color: isFiltered
? scheme.primary.withValues(alpha: 0.08)
: null,
color: isFiltered ? scheme.primary.withValues(alpha: 0.08) : null,
),
child: Row(
mainAxisSize: MainAxisSize.min,
@@ -267,7 +262,7 @@ class _CustomerDropdown extends StatelessWidget {
const SizedBox(width: 6),
Flexible(
child: Text(
selectedCustomer ?? 'Customer',
selectedCustomer ?? l10n.customer,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: FontWeight.w600,
@@ -297,6 +292,7 @@ class _EmptyState extends StatelessWidget {
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
final l10n = AppLocalizations.of(context);
return Center(
child: Column(
@@ -316,16 +312,16 @@ class _EmptyState extends StatelessWidget {
),
const SizedBox(height: 16),
Text(
'No closed tabs yet',
l10n.noClosedTabs,
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(height: 4),
Text(
'Tabs you close will show up here.',
l10n.tabsYouCloseAppearHere,
style: Theme.of(context).textTheme.bodyMedium,
),
],
),
);
}
}
}