mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-09 20:07:51 -06:00
Updated onboarding, reformatted files, improved referenced documents view, updated error handling
This commit is contained in:
@@ -8,11 +8,12 @@ import 'package:injectable/injectable.dart';
|
||||
class ApplicationSettingsCubit extends Cubit<ApplicationSettingsState> {
|
||||
final LocalVault localVault;
|
||||
|
||||
ApplicationSettingsCubit(this.localVault) : super(ApplicationSettingsState.defaultSettings);
|
||||
ApplicationSettingsCubit(this.localVault)
|
||||
: super(ApplicationSettingsState.defaultSettings);
|
||||
|
||||
Future<void> initialize() async {
|
||||
final settings =
|
||||
(await localVault.loadApplicationSettings()) ?? ApplicationSettingsState.defaultSettings;
|
||||
final settings = (await localVault.loadApplicationSettings()) ??
|
||||
ApplicationSettingsState.defaultSettings;
|
||||
emit(settings);
|
||||
}
|
||||
|
||||
@@ -22,7 +23,8 @@ class ApplicationSettingsCubit extends Cubit<ApplicationSettingsState> {
|
||||
}
|
||||
|
||||
Future<void> setIsBiometricAuthenticationEnabled(bool isEnabled) async {
|
||||
final updatedSettings = state.copyWith(isLocalAuthenticationEnabled: isEnabled);
|
||||
final updatedSettings =
|
||||
state.copyWith(isLocalAuthenticationEnabled: isEnabled);
|
||||
_updateSettings(updatedSettings);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:paperless_mobile/core/type/json.dart';
|
||||
import 'package:paperless_mobile/core/type/types.dart';
|
||||
|
||||
///
|
||||
/// State holding the current application settings such as selected language, theme mode and more.
|
||||
@@ -38,10 +38,10 @@ class ApplicationSettingsState {
|
||||
}
|
||||
|
||||
ApplicationSettingsState.fromJson(JSON json)
|
||||
: isLocalAuthenticationEnabled =
|
||||
json[isLocalAuthenticationEnabledKey] ?? defaultSettings.isLocalAuthenticationEnabled,
|
||||
preferredLocaleSubtag =
|
||||
json[preferredLocaleSubtagKey] ?? Platform.localeName.split("_").first,
|
||||
: isLocalAuthenticationEnabled = json[isLocalAuthenticationEnabledKey] ??
|
||||
defaultSettings.isLocalAuthenticationEnabled,
|
||||
preferredLocaleSubtag = json[preferredLocaleSubtagKey] ??
|
||||
Platform.localeName.split("_").first,
|
||||
preferredThemeMode = json[preferredThemeModeKey] != null
|
||||
? ThemeMode.values[(json[preferredThemeModeKey])]
|
||||
: defaultSettings.preferredThemeMode;
|
||||
@@ -54,7 +54,8 @@ class ApplicationSettingsState {
|
||||
return ApplicationSettingsState(
|
||||
isLocalAuthenticationEnabled:
|
||||
isLocalAuthenticationEnabled ?? this.isLocalAuthenticationEnabled,
|
||||
preferredLocaleSubtag: preferredLocaleSubtag ?? this.preferredLocaleSubtag,
|
||||
preferredLocaleSubtag:
|
||||
preferredLocaleSubtag ?? this.preferredLocaleSubtag,
|
||||
preferredThemeMode: preferredThemeMode ?? this.preferredThemeMode,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:paperless_mobile/features/settings/view/widgets/language_selection_setting.dart';
|
||||
import 'package:paperless_mobile/features/settings/view/widgets/theme_mode_setting.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
|
||||
class ApplicationSettingsPage extends StatelessWidget {
|
||||
const ApplicationSettingsPage({super.key});
|
||||
@@ -9,7 +10,7 @@ class ApplicationSettingsPage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Application"),
|
||||
title: Text(S.of(context).settingsPageApplicationSettingsLabel),
|
||||
),
|
||||
body: ListView(
|
||||
children: const [
|
||||
|
||||
@@ -8,7 +8,8 @@ class SecuritySettingsPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(S.of(context).settingsPageSecuritySettingsLabel)),
|
||||
appBar:
|
||||
AppBar(title: Text(S.of(context).settingsPageSecuritySettingsLabel)),
|
||||
body: ListView(
|
||||
children: const [
|
||||
BiometricAuthenticationSetting(),
|
||||
|
||||
@@ -23,12 +23,14 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(S.of(context).settingsPageApplicationSettingsLabel),
|
||||
subtitle: Text(S.of(context).settingsPageApplicationSettingsDescriptionText),
|
||||
subtitle: Text(
|
||||
S.of(context).settingsPageApplicationSettingsDescriptionText),
|
||||
onTap: () => _goto(const ApplicationSettingsPage()),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(S.of(context).settingsPageSecuritySettingsLabel),
|
||||
subtitle: Text(S.of(context).settingsPageSecuritySettingsDescriptionText),
|
||||
subtitle:
|
||||
Text(S.of(context).settingsPageSecuritySettingsDescriptionText),
|
||||
onTap: () => _goto(const SecuritySettingsPage()),
|
||||
),
|
||||
],
|
||||
@@ -41,7 +43,8 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (ctxt) => BlocProvider.value(
|
||||
value: BlocProvider.of<ApplicationSettingsCubit>(context), child: page),
|
||||
value: BlocProvider.of<ApplicationSettingsCubit>(context),
|
||||
child: page),
|
||||
maintainState: true,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -16,14 +16,20 @@ class BiometricAuthenticationSetting extends StatelessWidget {
|
||||
return SwitchListTile(
|
||||
value: settings.isLocalAuthenticationEnabled,
|
||||
title: Text(S.of(context).appSettingsBiometricAuthenticationLabel),
|
||||
subtitle: Text(S.of(context).appSettingsBiometricAuthenticationDescriptionText),
|
||||
subtitle: Text(
|
||||
S.of(context).appSettingsBiometricAuthenticationDescriptionText),
|
||||
onChanged: (val) async {
|
||||
final settingsBloc = BlocProvider.of<ApplicationSettingsCubit>(context);
|
||||
final settingsBloc =
|
||||
BlocProvider.of<ApplicationSettingsCubit>(context);
|
||||
final String localizedReason = val
|
||||
? S.of(context).appSettingsEnableBiometricAuthenticationReasonText
|
||||
: S.of(context).appSettingsDisableBiometricAuthenticationReasonText;
|
||||
final changeValue =
|
||||
await getIt<AuthenticationService>().authenticateLocalUser(localizedReason);
|
||||
? S
|
||||
.of(context)
|
||||
.appSettingsEnableBiometricAuthenticationReasonText
|
||||
: S
|
||||
.of(context)
|
||||
.appSettingsDisableBiometricAuthenticationReasonText;
|
||||
final changeValue = await getIt<AuthenticationService>()
|
||||
.authenticateLocalUser(localizedReason);
|
||||
if (changeValue) {
|
||||
settingsBloc.setIsBiometricAuthenticationEnabled(val);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ class LanguageSelectionSetting extends StatefulWidget {
|
||||
const LanguageSelectionSetting({super.key});
|
||||
|
||||
@override
|
||||
State<LanguageSelectionSetting> createState() => _LanguageSelectionSettingState();
|
||||
State<LanguageSelectionSetting> createState() =>
|
||||
_LanguageSelectionSettingState();
|
||||
}
|
||||
|
||||
class _LanguageSelectionSettingState extends State<LanguageSelectionSetting> {
|
||||
@@ -34,10 +35,12 @@ class _LanguageSelectionSettingState extends State<LanguageSelectionSetting> {
|
||||
label: _mapSubtagToLanguage('de'),
|
||||
),
|
||||
],
|
||||
initialValue:
|
||||
BlocProvider.of<ApplicationSettingsCubit>(context).state.preferredLocaleSubtag,
|
||||
initialValue: BlocProvider.of<ApplicationSettingsCubit>(context)
|
||||
.state
|
||||
.preferredLocaleSubtag,
|
||||
),
|
||||
).then((value) => BlocProvider.of<ApplicationSettingsCubit>(context).setLocale(value)),
|
||||
).then((value) => BlocProvider.of<ApplicationSettingsCubit>(context)
|
||||
.setLocale(value)),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -14,30 +14,38 @@ class ThemeModeSetting extends StatelessWidget {
|
||||
builder: (context, settings) {
|
||||
return ListTile(
|
||||
title: Text(S.of(context).settingsPageAppearanceSettingTitle),
|
||||
subtitle: Text(_mapThemeModeToLocalizedString(settings.preferredThemeMode, context)),
|
||||
subtitle: Text(_mapThemeModeToLocalizedString(
|
||||
settings.preferredThemeMode, context)),
|
||||
onTap: () => showDialog<ThemeMode>(
|
||||
context: context,
|
||||
builder: (_) => RadioSettingsDialog<ThemeMode>(
|
||||
options: [
|
||||
RadioOption(
|
||||
value: ThemeMode.system,
|
||||
label: S.of(context).settingsPageAppearanceSettingSystemThemeLabel,
|
||||
label: S
|
||||
.of(context)
|
||||
.settingsPageAppearanceSettingSystemThemeLabel,
|
||||
),
|
||||
RadioOption(
|
||||
value: ThemeMode.light,
|
||||
label: S.of(context).settingsPageAppearanceSettingLightThemeLabel,
|
||||
label: S
|
||||
.of(context)
|
||||
.settingsPageAppearanceSettingLightThemeLabel,
|
||||
),
|
||||
RadioOption(
|
||||
value: ThemeMode.dark,
|
||||
label: S.of(context).settingsPageAppearanceSettingDarkThemeLabel,
|
||||
label:
|
||||
S.of(context).settingsPageAppearanceSettingDarkThemeLabel,
|
||||
)
|
||||
],
|
||||
initialValue:
|
||||
BlocProvider.of<ApplicationSettingsCubit>(context).state.preferredThemeMode,
|
||||
initialValue: BlocProvider.of<ApplicationSettingsCubit>(context)
|
||||
.state
|
||||
.preferredThemeMode,
|
||||
title: Text(S.of(context).settingsPageAppearanceSettingTitle),
|
||||
),
|
||||
).then((value) {
|
||||
return BlocProvider.of<ApplicationSettingsCubit>(context).setThemeMode(value);
|
||||
return BlocProvider.of<ApplicationSettingsCubit>(context)
|
||||
.setThemeMode(value);
|
||||
}),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user