mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2026-01-31 08:25:00 -06:00
feat: Add US/GB english discrimination, fix incorrect localizations
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
* Beheben von inkorrekter Lokalisierung in der App
|
||||||
|
* Hinzufügen der Unterscheidung zwischen US und GB Englisch
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
* Fixed incorrect localizations of dates and other texts
|
||||||
|
* Add discrimination between US and GB English (useful for date input)
|
||||||
+2
-2
@@ -146,7 +146,7 @@ class _ExtendedDateRangeDialogState extends State<ExtendedDateRangeDialog> {
|
|||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
format: DateFormat.yMd(),
|
format: DateFormat.yMd(Localizations.localeOf(context).toString()),
|
||||||
lastDate: _dateTimeMax(_before, DateTime.now()),
|
lastDate: _dateTimeMax(_before, DateTime.now()),
|
||||||
inputType: InputType.date,
|
inputType: InputType.date,
|
||||||
onChanged: (after) {
|
onChanged: (after) {
|
||||||
@@ -174,7 +174,7 @@ class _ExtendedDateRangeDialogState extends State<ExtendedDateRangeDialog> {
|
|||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
format: DateFormat.yMd(),
|
format: DateFormat.yMd(Localizations.localeOf(context).toString()),
|
||||||
firstDate: _after,
|
firstDate: _after,
|
||||||
lastDate: DateTime.now(),
|
lastDate: DateTime.now(),
|
||||||
onChanged: (before) {
|
onChanged: (before) {
|
||||||
|
|||||||
+1
-1
@@ -79,7 +79,7 @@ class _FormBuilderExtendedDateRangePickerState
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _dateRangeQueryToString(DateRangeQuery query) {
|
String _dateRangeQueryToString(DateRangeQuery query) {
|
||||||
final df = DateFormat.yMd();
|
final df = DateFormat.yMd(Localizations.localeOf(context).toString());
|
||||||
if (query is UnsetDateRangeQuery) {
|
if (query is UnsetDateRangeQuery) {
|
||||||
return '';
|
return '';
|
||||||
} else if (query is AbsoluteDateRangeQuery) {
|
} else if (query is AbsoluteDateRangeQuery) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:flutter_animate/flutter_animate.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:paperless_mobile/constants.dart';
|
import 'package:paperless_mobile/constants.dart';
|
||||||
|
import 'package:paperless_mobile/core/database/tables/local_user_account.dart';
|
||||||
import 'package:paperless_mobile/core/widgets/paperless_logo.dart';
|
import 'package:paperless_mobile/core/widgets/paperless_logo.dart';
|
||||||
import 'package:paperless_mobile/extensions/flutter_extensions.dart';
|
import 'package:paperless_mobile/extensions/flutter_extensions.dart';
|
||||||
import 'package:paperless_mobile/features/documents/cubit/documents_cubit.dart';
|
import 'package:paperless_mobile/features/documents/cubit/documents_cubit.dart';
|
||||||
@@ -22,6 +23,10 @@ class AppDrawer extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final currentAccount = context.watch<LocalUserAccount>();
|
||||||
|
final username = currentAccount.paperlessUser.username;
|
||||||
|
final serverUrl =
|
||||||
|
currentAccount.serverUrl.replaceAll(RegExp(r'https?://'), '');
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
child: Drawer(
|
child: Drawer(
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -29,13 +34,43 @@ class AppDrawer extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
const PaperlessLogo.green(),
|
const PaperlessLogo.green(
|
||||||
|
width: 32,
|
||||||
|
height: 32,
|
||||||
|
),
|
||||||
Text(
|
Text(
|
||||||
"Paperless Mobile",
|
"Paperless Mobile",
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
).padded(),
|
).paddedLTRB(8, 8, 8, 16),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
S.of(context)!.loggedInAs(username),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: Theme.of(context).textTheme.labelMedium?.copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onBackground
|
||||||
|
.withOpacity(0.5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
serverUrl,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: Theme.of(context).textTheme.labelMedium?.copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onBackground
|
||||||
|
.withOpacity(0.5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).paddedSymmetrically(horizontal: 16),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
ListTile(
|
ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
@@ -43,6 +78,31 @@ class AppDrawer extends StatelessWidget {
|
|||||||
leading: const Icon(Icons.info_outline),
|
leading: const Icon(Icons.info_outline),
|
||||||
onTap: () => _showAboutDialog(context),
|
onTap: () => _showAboutDialog(context),
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
dense: true,
|
||||||
|
leading: const Icon(Icons.favorite_outline),
|
||||||
|
title: Text(S.of(context)!.donate),
|
||||||
|
onTap: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
icon: const Icon(Icons.favorite),
|
||||||
|
title: Text(S.of(context)!.donate),
|
||||||
|
content: Text(
|
||||||
|
S.of(context)!.donationDialogContent,
|
||||||
|
),
|
||||||
|
actionsAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
actions: [
|
||||||
|
Text("~ Anton"),
|
||||||
|
TextButton(
|
||||||
|
onPressed: Navigator.of(context).pop,
|
||||||
|
child: Text(S.of(context)!.gotIt),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
leading: const Icon(Icons.bug_report_outlined),
|
leading: const Icon(Icons.bug_report_outlined),
|
||||||
@@ -63,26 +123,6 @@ class AppDrawer extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
|
||||||
dense: true,
|
|
||||||
leading: const Icon(Icons.favorite_outline),
|
|
||||||
title: Text(S.of(context)!.donate),
|
|
||||||
onTap: () {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => AlertDialog(
|
|
||||||
icon: const Icon(Icons.favorite),
|
|
||||||
title: Text(S.of(context)!.donate),
|
|
||||||
content: Text(
|
|
||||||
S.of(context)!.donationDialogContent,
|
|
||||||
),
|
|
||||||
actions: const [
|
|
||||||
Text("~ Anton"),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
leading: SvgPicture.asset(
|
leading: SvgPicture.asset(
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:intl/date_symbol_data_local.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
import 'package:open_filex/open_filex.dart';
|
import 'package:open_filex/open_filex.dart';
|
||||||
import 'package:paperless_api/paperless_api.dart';
|
import 'package:paperless_api/paperless_api.dart';
|
||||||
import 'package:paperless_mobile/core/bloc/connectivity_cubit.dart';
|
import 'package:paperless_mobile/core/bloc/connectivity_cubit.dart';
|
||||||
@@ -43,6 +45,11 @@ class _DocumentDetailsPageState extends State<DocumentDetailsPage> {
|
|||||||
static const double _itemSpacing = 24;
|
static const double _itemSpacing = 24;
|
||||||
|
|
||||||
final _pagingScrollController = ScrollController();
|
final _pagingScrollController = ScrollController();
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
initializeDateFormatting(Localizations.localeOf(context).toString());
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|||||||
@@ -44,12 +44,14 @@ class _DocumentMetaDataWidgetState extends State<DocumentMetaDataWidget> {
|
|||||||
document: widget.document,
|
document: widget.document,
|
||||||
).paddedOnly(bottom: widget.itemSpacing),
|
).paddedOnly(bottom: widget.itemSpacing),
|
||||||
DetailsItem.text(
|
DetailsItem.text(
|
||||||
DateFormat().format(widget.document.modified),
|
DateFormat.yMMMMd(Localizations.localeOf(context).toString())
|
||||||
|
.format(widget.document.modified),
|
||||||
context: context,
|
context: context,
|
||||||
label: S.of(context)!.modifiedAt,
|
label: S.of(context)!.modifiedAt,
|
||||||
).paddedOnly(bottom: widget.itemSpacing),
|
).paddedOnly(bottom: widget.itemSpacing),
|
||||||
DetailsItem.text(
|
DetailsItem.text(
|
||||||
DateFormat().format(widget.document.added),
|
DateFormat.yMMMMd(Localizations.localeOf(context).toString())
|
||||||
|
.format(widget.document.added),
|
||||||
context: context,
|
context: context,
|
||||||
label: S.of(context)!.addedAt,
|
label: S.of(context)!.addedAt,
|
||||||
).paddedOnly(bottom: widget.itemSpacing),
|
).paddedOnly(bottom: widget.itemSpacing),
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ class DocumentOverviewWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
).paddedOnly(bottom: itemSpacing),
|
).paddedOnly(bottom: itemSpacing),
|
||||||
DetailsItem.text(
|
DetailsItem.text(
|
||||||
DateFormat.yMMMMd().format(document.created),
|
DateFormat.yMMMMd(Localizations.localeOf(context).toString())
|
||||||
|
.format(document.created),
|
||||||
context: context,
|
context: context,
|
||||||
label: S.of(context)!.createdAt,
|
label: S.of(context)!.createdAt,
|
||||||
).paddedOnly(bottom: itemSpacing),
|
).paddedOnly(bottom: itemSpacing),
|
||||||
|
|||||||
@@ -376,14 +376,16 @@ class _DocumentEditPageState extends State<DocumentEditPage> {
|
|||||||
label: Text(S.of(context)!.createdAt),
|
label: Text(S.of(context)!.createdAt),
|
||||||
),
|
),
|
||||||
initialValue: initialCreatedAtDate,
|
initialValue: initialCreatedAtDate,
|
||||||
format: DateFormat.yMMMMd(),
|
format: DateFormat.yMMMMd(Localizations.localeOf(context).toString()),
|
||||||
initialEntryMode: DatePickerEntryMode.calendar,
|
initialEntryMode: DatePickerEntryMode.calendar,
|
||||||
),
|
),
|
||||||
if (filteredSuggestions?.hasSuggestedDates ?? false)
|
if (filteredSuggestions?.hasSuggestedDates ?? false)
|
||||||
_buildSuggestionsSkeleton<DateTime>(
|
_buildSuggestionsSkeleton<DateTime>(
|
||||||
suggestions: filteredSuggestions!.dates,
|
suggestions: filteredSuggestions!.dates,
|
||||||
itemBuilder: (context, itemData) => ActionChip(
|
itemBuilder: (context, itemData) => ActionChip(
|
||||||
label: Text(DateFormat.yMMMd().format(itemData)),
|
label: Text(
|
||||||
|
DateFormat.yMMMMd(Localizations.localeOf(context).toString())
|
||||||
|
.format(itemData)),
|
||||||
onPressed: () => _formKey.currentState?.fields[fkCreatedDate]
|
onPressed: () => _formKey.currentState?.fields[fkCreatedDate]
|
||||||
?.didChange(itemData),
|
?.didChange(itemData),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -10,12 +10,10 @@ import 'package:paperless_mobile/features/settings/view/widgets/user_avatar.dart
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class SliverSearchBar extends StatelessWidget {
|
class SliverSearchBar extends StatelessWidget {
|
||||||
final bool floating;
|
|
||||||
final bool pinned;
|
final bool pinned;
|
||||||
final String titleText;
|
final String titleText;
|
||||||
const SliverSearchBar({
|
const SliverSearchBar({
|
||||||
super.key,
|
super.key,
|
||||||
this.floating = false,
|
|
||||||
this.pinned = false,
|
this.pinned = false,
|
||||||
required this.titleText,
|
required this.titleText,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ class _DocumentUploadPreparationPageState
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_syncTitleAndFilename = widget.filename == null && widget.title == null;
|
_syncTitleAndFilename = widget.filename == null && widget.title == null;
|
||||||
initializeDateFormatting();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -219,7 +218,8 @@ class _DocumentUploadPreparationPageState
|
|||||||
// Created at
|
// Created at
|
||||||
FormBuilderDateTimePicker(
|
FormBuilderDateTimePicker(
|
||||||
autovalidateMode: AutovalidateMode.always,
|
autovalidateMode: AutovalidateMode.always,
|
||||||
format: DateFormat.yMMMMd(),
|
format: DateFormat.yMMMMd(
|
||||||
|
Localizations.localeOf(context).toString()),
|
||||||
inputType: InputType.date,
|
inputType: InputType.date,
|
||||||
name: DocumentModel.createdKey,
|
name: DocumentModel.createdKey,
|
||||||
initialValue: null,
|
initialValue: null,
|
||||||
|
|||||||
@@ -177,13 +177,9 @@ class _DocumentsPageState extends State<DocumentsPage> {
|
|||||||
child: _showExtendedFab
|
child: _showExtendedFab
|
||||||
? Row(
|
? Row(
|
||||||
children: [
|
children: [
|
||||||
const Icon(
|
const Icon(Icons.filter_alt_outlined),
|
||||||
Icons.filter_alt_outlined,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(
|
Text(S.of(context)!.filterDocuments),
|
||||||
S.of(context)!.filterDocuments,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: const Icon(Icons.filter_alt_outlined),
|
: const Icon(Icons.filter_alt_outlined),
|
||||||
@@ -270,7 +266,6 @@ class _DocumentsPageState extends State<DocumentsPage> {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state.selection.isEmpty) {
|
if (state.selection.isEmpty) {
|
||||||
return SliverSearchBar(
|
return SliverSearchBar(
|
||||||
floating: true,
|
|
||||||
titleText: S.of(context)!.documents,
|
titleText: S.of(context)!.documents,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -89,7 +89,8 @@ class DocumentDetailedItem extends DocumentItem {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
DateFormat.yMMMMd().format(document.created),
|
DateFormat.yMMMMd(Localizations.localeOf(context).toString())
|
||||||
|
.format(document.created),
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.bodySmall
|
.bodySmall
|
||||||
|
|||||||
@@ -121,7 +121,9 @@ class DocumentGridItem extends DocumentItem {
|
|||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
Text(
|
Text(
|
||||||
DateFormat.yMMMd().format(document.created),
|
DateFormat.yMMMMd(
|
||||||
|
Localizations.localeOf(context).toString())
|
||||||
|
.format(document.created),
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -81,7 +81,8 @@ class DocumentListItem extends DocumentItem {
|
|||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
text: DateFormat.yMMMd().format(document.created),
|
text: DateFormat.yMMMMd(Localizations.localeOf(context).toString())
|
||||||
|
.format(document.created),
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.labelSmall
|
.labelSmall
|
||||||
|
|||||||
@@ -331,7 +331,8 @@ class _InboxPageState extends State<InboxPage>
|
|||||||
if (doc.added.isYesterday) {
|
if (doc.added.isYesterday) {
|
||||||
return S.of(context)!.yesterday;
|
return S.of(context)!.yesterday;
|
||||||
}
|
}
|
||||||
return DateFormat.yMMMMd().format(doc.added);
|
return DateFormat.yMMMMd(Localizations.localeOf(context).toString())
|
||||||
|
.format(doc.added);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ class _LandingPageState extends State<LandingPage> {
|
|||||||
SliverOverlapAbsorber(
|
SliverOverlapAbsorber(
|
||||||
handle: _searchBarHandle,
|
handle: _searchBarHandle,
|
||||||
sliver: SliverSearchBar(
|
sliver: SliverSearchBar(
|
||||||
floating: true,
|
|
||||||
titleText: S.of(context)!.documents,
|
titleText: S.of(context)!.documents,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ class LanguageSelectionSetting extends StatefulWidget {
|
|||||||
|
|
||||||
class _LanguageSelectionSettingState extends State<LanguageSelectionSetting> {
|
class _LanguageSelectionSettingState extends State<LanguageSelectionSetting> {
|
||||||
static const _languageOptions = {
|
static const _languageOptions = {
|
||||||
'en': LanguageOption('English', true),
|
'en': LanguageOption('English (US)', true),
|
||||||
|
'en_GB': LanguageOption('English (GB)', true),
|
||||||
'de': LanguageOption('Deutsch', true),
|
'de': LanguageOption('Deutsch', true),
|
||||||
'es': LanguageOption("Español", true),
|
'es': LanguageOption("Español", true),
|
||||||
'fr': LanguageOption('Français', true),
|
'fr': LanguageOption('Français', true),
|
||||||
|
|||||||
@@ -40,31 +40,34 @@ class _RadioSettingsDialogState<T> extends State<RadioSettingsDialog<T>> {
|
|||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
actions: [
|
actions: [
|
||||||
const DialogCancelButton(),
|
const DialogCancelButton(),
|
||||||
widget.confirmButton ??
|
widget.confirmButton ?? DialogConfirmButton(returnValue: _groupValue),
|
||||||
DialogConfirmButton(
|
|
||||||
returnValue: _groupValue,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
title: widget.titleText != null ? Text(widget.titleText!) : null,
|
title: widget.titleText != null ? Text(widget.titleText!) : null,
|
||||||
content: Column(
|
content: SingleChildScrollView(
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Column(
|
||||||
children: [
|
mainAxisSize: MainAxisSize.min,
|
||||||
if (widget.descriptionText != null)
|
children: [
|
||||||
Text(widget.descriptionText!,
|
if (widget.descriptionText != null)
|
||||||
style: Theme.of(context).textTheme.bodySmall),
|
Text(
|
||||||
...widget.options.map(_buildOptionListTile),
|
widget.descriptionText!,
|
||||||
if (widget.footer != null) widget.footer!,
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
],
|
),
|
||||||
|
...widget.options.map(_buildOptionListTile).toList(),
|
||||||
|
if (widget.footer != null) widget.footer!,
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildOptionListTile(RadioOption<T> option) => RadioListTile<T>(
|
Widget _buildOptionListTile(RadioOption<T> option) {
|
||||||
groupValue: _groupValue,
|
return RadioListTile<T>(
|
||||||
onChanged: (value) => setState(() => _groupValue = value!),
|
groupValue: _groupValue,
|
||||||
value: option.value,
|
onChanged: (value) => setState(() => _groupValue = value!),
|
||||||
title: Text(option.label),
|
value: option.value,
|
||||||
);
|
title: Text(option.label),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RadioOption<T> {
|
class RadioOption<T> {
|
||||||
|
|||||||
@@ -15,16 +15,26 @@ class UserAvatar extends StatelessWidget {
|
|||||||
Colors.primaries[account.id.hashCode % Colors.primaries.length];
|
Colors.primaries[account.id.hashCode % Colors.primaries.length];
|
||||||
final foregroundColor =
|
final foregroundColor =
|
||||||
backgroundColor.computeLuminance() > 0.5 ? Colors.black : Colors.white;
|
backgroundColor.computeLuminance() > 0.5 ? Colors.black : Colors.white;
|
||||||
return CircleAvatar(
|
return Container(
|
||||||
child: Text(
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
border: Border.all(
|
||||||
|
color: backgroundColor.shade900.withOpacity(0.4),
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: CircleAvatar(
|
||||||
|
child: Text(
|
||||||
(account.paperlessUser.fullName ?? account.paperlessUser.username)
|
(account.paperlessUser.fullName ?? account.paperlessUser.username)
|
||||||
.split(" ")
|
.split(" ")
|
||||||
.take(2)
|
.take(2)
|
||||||
.map((e) => e.substring(0, 1))
|
.map((e) => e.substring(0, 1))
|
||||||
.map((e) => e.toUpperCase())
|
.map((e) => e.toUpperCase())
|
||||||
.join("")),
|
.join(""),
|
||||||
backgroundColor: backgroundColor,
|
),
|
||||||
foregroundColor: foregroundColor,
|
backgroundColor: backgroundColor,
|
||||||
|
foregroundColor: foregroundColor,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+54
-12
@@ -41,19 +41,22 @@ import 'package:paperless_mobile/routes/typed/shells/authenticated_route.dart';
|
|||||||
import 'package:paperless_mobile/routes/typed/top_level/add_account_route.dart';
|
import 'package:paperless_mobile/routes/typed/top_level/add_account_route.dart';
|
||||||
import 'package:paperless_mobile/routes/typed/top_level/logging_out_route.dart';
|
import 'package:paperless_mobile/routes/typed/top_level/logging_out_route.dart';
|
||||||
import 'package:paperless_mobile/routes/typed/top_level/login_route.dart';
|
import 'package:paperless_mobile/routes/typed/top_level/login_route.dart';
|
||||||
import 'package:paperless_mobile/routes/typed/top_level/settings_route.dart';
|
|
||||||
import 'package:paperless_mobile/theme.dart';
|
import 'package:paperless_mobile/theme.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
String get defaultPreferredLocaleSubtag {
|
Locale get defaultPreferredLocale {
|
||||||
String preferredLocale = Platform.localeName.split("_").first;
|
final deviceLocale = _stringToLocale(Platform.localeName);
|
||||||
if (!S.supportedLocales
|
if (S.supportedLocales.contains(deviceLocale)) {
|
||||||
.any((locale) => locale.languageCode == preferredLocale)) {
|
return deviceLocale;
|
||||||
preferredLocale = 'en';
|
} else if (S.supportedLocales
|
||||||
|
.map((e) => e.languageCode)
|
||||||
|
.contains(deviceLocale.languageCode)) {
|
||||||
|
return Locale(deviceLocale.languageCode);
|
||||||
|
} else {
|
||||||
|
return const Locale('en');
|
||||||
}
|
}
|
||||||
return preferredLocale;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Future<void> Function()> _migrations = {
|
Map<String, Future<void> Function()> _migrations = {
|
||||||
@@ -99,7 +102,7 @@ Future<void> _initHive() async {
|
|||||||
|
|
||||||
if (!globalSettingsBox.hasValue) {
|
if (!globalSettingsBox.hasValue) {
|
||||||
await globalSettingsBox.setValue(
|
await globalSettingsBox.setValue(
|
||||||
GlobalSettings(preferredLocaleSubtag: defaultPreferredLocaleSubtag),
|
GlobalSettings(preferredLocaleSubtag: defaultPreferredLocale.toString()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -323,6 +326,7 @@ class _GoRouterShellState extends State<GoRouterShell> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GlobalSettingsBuilder(
|
return GlobalSettingsBuilder(
|
||||||
builder: (context, settings) {
|
builder: (context, settings) {
|
||||||
|
final locale = _stringToLocale(settings.preferredLocaleSubtag);
|
||||||
return DynamicColorBuilder(
|
return DynamicColorBuilder(
|
||||||
builder: (lightDynamic, darkDynamic) {
|
builder: (lightDynamic, darkDynamic) {
|
||||||
return MaterialApp.router(
|
return MaterialApp.router(
|
||||||
@@ -340,10 +344,41 @@ class _GoRouterShellState extends State<GoRouterShell> {
|
|||||||
preferredColorScheme: settings.preferredColorSchemeOption,
|
preferredColorScheme: settings.preferredColorSchemeOption,
|
||||||
),
|
),
|
||||||
themeMode: settings.preferredThemeMode,
|
themeMode: settings.preferredThemeMode,
|
||||||
supportedLocales: S.supportedLocales,
|
supportedLocales: const [
|
||||||
locale: Locale.fromSubtags(
|
Locale('en'),
|
||||||
languageCode: settings.preferredLocaleSubtag,
|
Locale('de'),
|
||||||
),
|
Locale('en', 'GB'),
|
||||||
|
Locale('ca'),
|
||||||
|
Locale('cs'),
|
||||||
|
Locale('es'),
|
||||||
|
Locale('fr'),
|
||||||
|
Locale('pl'),
|
||||||
|
Locale('ru'),
|
||||||
|
Locale('tr'),
|
||||||
|
],
|
||||||
|
localeResolutionCallback: (locale, supportedLocales) {
|
||||||
|
if (locale == null) {
|
||||||
|
return supportedLocales.first;
|
||||||
|
}
|
||||||
|
|
||||||
|
final exactMatch = supportedLocales
|
||||||
|
.where((element) =>
|
||||||
|
element.languageCode == locale.languageCode &&
|
||||||
|
element.countryCode == locale.countryCode)
|
||||||
|
.toList();
|
||||||
|
if (exactMatch.isNotEmpty) {
|
||||||
|
return exactMatch.first;
|
||||||
|
}
|
||||||
|
final superLanguageMatch = supportedLocales
|
||||||
|
.where((element) =>
|
||||||
|
element.languageCode == locale.languageCode)
|
||||||
|
.toList();
|
||||||
|
if (superLanguageMatch.isNotEmpty) {
|
||||||
|
return superLanguageMatch.first;
|
||||||
|
}
|
||||||
|
return supportedLocales.first;
|
||||||
|
},
|
||||||
|
locale: locale,
|
||||||
localizationsDelegates: S.localizationsDelegates,
|
localizationsDelegates: S.localizationsDelegates,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -352,3 +387,10 @@ class _GoRouterShellState extends State<GoRouterShell> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Locale _stringToLocale(String code) {
|
||||||
|
final codes = code.split("_");
|
||||||
|
final languageCode = codes[0];
|
||||||
|
final countryCode = codes.length > 1 ? codes[1] : null;
|
||||||
|
return Locale(languageCode, countryCode);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
import 'package:paperless_api/paperless_api.dart';
|
import 'package:paperless_api/paperless_api.dart';
|
||||||
import 'package:paperless_mobile/core/model/info_message_exception.dart';
|
import 'package:paperless_mobile/core/model/info_message_exception.dart';
|
||||||
import 'package:paperless_mobile/features/login/cubit/authentication_cubit.dart';
|
import 'package:paperless_mobile/features/login/cubit/authentication_cubit.dart';
|
||||||
@@ -39,7 +40,7 @@ class AddAccountRoute extends GoRouteData {
|
|||||||
clientCertificate: clientCertificate,
|
clientCertificate: clientCertificate,
|
||||||
serverUrl: serverUrl,
|
serverUrl: serverUrl,
|
||||||
enableBiometricAuthentication: false,
|
enableBiometricAuthentication: false,
|
||||||
locale: Localizations.localeOf(context).languageCode,
|
locale: Intl.getCurrentLocale(),
|
||||||
);
|
);
|
||||||
final shoudSwitch = await showDialog<bool>(
|
final shoudSwitch = await showDialog<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import 'package:paperless_mobile/generated/l10n/app_localizations_en.dart';
|
||||||
|
|
||||||
|
class SEnGb extends SEn {
|
||||||
|
SEnGb() : super('en_GB');
|
||||||
|
}
|
||||||
|
|
||||||
|
class SEnUs extends SEn {
|
||||||
|
SEnUs() : super('en_US');
|
||||||
|
}
|
||||||
+1
-1
@@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
|||||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||||
# Read more about iOS versioning at
|
# Read more about iOS versioning at
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
version: 3.0.2+49
|
version: 3.0.3+50
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=3.0.0 <4.0.0"
|
sdk: ">=3.0.0 <4.0.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user