mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-09 08:08:14 -06:00
WIP - Provider refactorings
This commit is contained in:
@@ -44,9 +44,10 @@ class SettingsPage extends StatelessWidget {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (ctxt) => BlocProvider.value(
|
||||
value: BlocProvider.of<ApplicationSettingsCubit>(context),
|
||||
child: page),
|
||||
builder: (context) => BlocProvider.value(
|
||||
value: context.read<ApplicationSettingsCubit>(),
|
||||
child: page,
|
||||
),
|
||||
maintainState: true,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -19,8 +19,7 @@ class BiometricAuthenticationSetting extends StatelessWidget {
|
||||
subtitle: Text(
|
||||
S.of(context).appSettingsBiometricAuthenticationDescriptionText),
|
||||
onChanged: (val) async {
|
||||
final settingsBloc =
|
||||
BlocProvider.of<ApplicationSettingsCubit>(context);
|
||||
final settingsBloc = context.read<ApplicationSettingsCubit>();
|
||||
final String localizedReason = val
|
||||
? S
|
||||
.of(context)
|
||||
@@ -28,9 +27,9 @@ class BiometricAuthenticationSetting extends StatelessWidget {
|
||||
: S
|
||||
.of(context)
|
||||
.appSettingsDisableBiometricAuthenticationReasonText;
|
||||
final changeValue =
|
||||
await Provider.of<LocalAuthenticationService>(context)
|
||||
.authenticateLocalUser(localizedReason);
|
||||
final changeValue = await context
|
||||
.read<LocalAuthenticationService>()
|
||||
.authenticateLocalUser(localizedReason);
|
||||
if (changeValue) {
|
||||
settingsBloc.setIsBiometricAuthenticationEnabled(val);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class ClearStorageSetting extends StatelessWidget {
|
||||
subtitle:
|
||||
Text("Remove downloaded files, scans and clear the cache's content"),
|
||||
onTap: () {
|
||||
Provider.of<cm.CacheManager>(context).emptyCache();
|
||||
context.read<cm.CacheManager>().emptyCache();
|
||||
FileService.clearUserData();
|
||||
},
|
||||
);
|
||||
|
||||
@@ -44,12 +44,13 @@ class _LanguageSelectionSettingState extends State<LanguageSelectionSetting> {
|
||||
label: _languageOptions['cs']!,
|
||||
)
|
||||
],
|
||||
initialValue: BlocProvider.of<ApplicationSettingsCubit>(context)
|
||||
initialValue: context
|
||||
.read<ApplicationSettingsCubit>()
|
||||
.state
|
||||
.preferredLocaleSubtag,
|
||||
),
|
||||
).then((value) => BlocProvider.of<ApplicationSettingsCubit>(context)
|
||||
.setLocale(value)),
|
||||
).then((value) =>
|
||||
context.read<ApplicationSettingsCubit>().setLocale(value)),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -38,14 +38,14 @@ class ThemeModeSetting extends StatelessWidget {
|
||||
S.of(context).settingsPageAppearanceSettingDarkThemeLabel,
|
||||
)
|
||||
],
|
||||
initialValue: BlocProvider.of<ApplicationSettingsCubit>(context)
|
||||
initialValue: context
|
||||
.read<ApplicationSettingsCubit>()
|
||||
.state
|
||||
.preferredThemeMode,
|
||||
title: Text(S.of(context).settingsPageAppearanceSettingTitle),
|
||||
),
|
||||
).then((value) {
|
||||
return BlocProvider.of<ApplicationSettingsCubit>(context)
|
||||
.setThemeMode(value);
|
||||
return context.read<ApplicationSettingsCubit>().setThemeMode(value);
|
||||
}),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user