fix: alot
This commit is contained in:
+176
-169
@@ -53,6 +53,12 @@ class _SettingsScreenViewState extends State<SettingsScreenView> {
|
||||
});
|
||||
}
|
||||
|
||||
void _leave() {
|
||||
final adminPinViewModel = context.read<AdminPinViewModel>();
|
||||
context.popOrGo('/bar');
|
||||
adminPinViewModel.lock();
|
||||
}
|
||||
|
||||
void _cancelVersionHold() {
|
||||
_versionHoldTimer?.cancel();
|
||||
_versionHoldTimer = null;
|
||||
@@ -225,7 +231,6 @@ class _SettingsScreenViewState extends State<SettingsScreenView> {
|
||||
return;
|
||||
}
|
||||
|
||||
adminPinViewModel.lock();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -250,10 +255,7 @@ class _SettingsScreenViewState extends State<SettingsScreenView> {
|
||||
|
||||
if (!success) {
|
||||
_showError(l10n.errorText(adminPinViewModel.error));
|
||||
return;
|
||||
}
|
||||
|
||||
adminPinViewModel.lock();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -263,184 +265,189 @@ class _SettingsScreenViewState extends State<SettingsScreenView> {
|
||||
final pinLockViewModel = context.watch<PinLockViewModel>();
|
||||
final adminPinViewModel = context.watch<AdminPinViewModel>();
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
onPressed: () => context.popOrGo('/bar'),
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
return PopScope(
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (didPop) context.read<AdminPinViewModel>().lock();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
onPressed: _leave,
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
),
|
||||
title: Text(l10n.settingsTitle),
|
||||
),
|
||||
title: Text(l10n.settingsTitle),
|
||||
),
|
||||
body: Builder(
|
||||
builder: (context) {
|
||||
final isLoading =
|
||||
settingsViewModel.isLoading ||
|
||||
pinLockViewModel.isLoading ||
|
||||
adminPinViewModel.isLoading;
|
||||
final hasLoaded =
|
||||
settingsViewModel.hasLoaded &&
|
||||
pinLockViewModel.hasLoaded &&
|
||||
adminPinViewModel.hasLoaded;
|
||||
body: Builder(
|
||||
builder: (context) {
|
||||
final isLoading =
|
||||
settingsViewModel.isLoading ||
|
||||
pinLockViewModel.isLoading ||
|
||||
adminPinViewModel.isLoading;
|
||||
final hasLoaded =
|
||||
settingsViewModel.hasLoaded &&
|
||||
pinLockViewModel.hasLoaded &&
|
||||
adminPinViewModel.hasLoaded;
|
||||
|
||||
if (isLoading && !hasLoaded) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(strokeWidth: 2.5),
|
||||
);
|
||||
}
|
||||
if (isLoading && !hasLoaded) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(strokeWidth: 2.5),
|
||||
);
|
||||
}
|
||||
|
||||
final settings = settingsViewModel.settings;
|
||||
final settings = settingsViewModel.settings;
|
||||
|
||||
return ListView(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
children: [
|
||||
_SettingsSection(
|
||||
title: l10n.security,
|
||||
children: [
|
||||
_SettingsSwitchTile(
|
||||
icon: Icons.lock_outline_rounded,
|
||||
title: l10n.pinRequired,
|
||||
value: settings.pinRequired,
|
||||
onChanged: (value) {
|
||||
if (value) {
|
||||
_enablePin();
|
||||
} else {
|
||||
_disablePin();
|
||||
}
|
||||
},
|
||||
),
|
||||
_SettingsSwitchTile(
|
||||
icon: Icons.lock_clock_rounded,
|
||||
title: l10n.autoLockOnExit,
|
||||
value: settings.autoLockEnabled,
|
||||
onChanged: (value) {
|
||||
settingsViewModel.updateAutoLockEnabled(value);
|
||||
},
|
||||
),
|
||||
if (settings.pinRequired)
|
||||
_SettingsTile(
|
||||
icon: Icons.pin_rounded,
|
||||
title: l10n.changePin,
|
||||
onTap: _changePin,
|
||||
),
|
||||
_SettingsTile(
|
||||
icon: Icons.admin_panel_settings_outlined,
|
||||
title: l10n.adminPin,
|
||||
subtitle: adminPinViewModel.isPinSet
|
||||
? l10n.adminPinConfigured
|
||||
: l10n.adminPinNotSet,
|
||||
onTap: _configureAdminPin,
|
||||
),
|
||||
],
|
||||
),
|
||||
_SettingsSection(
|
||||
title: l10n.appearance,
|
||||
children: [
|
||||
_SettingsTile(
|
||||
icon: Icons.language_rounded,
|
||||
title: l10n.language,
|
||||
subtitle: switch (settings.language) {
|
||||
AppLanguage.system => l10n.languageSystem,
|
||||
AppLanguage.english => l10n.languageEnglish,
|
||||
AppLanguage.dutch => l10n.languageDutch,
|
||||
},
|
||||
onTap: () async {
|
||||
final selected = await _pickOption(
|
||||
context,
|
||||
options: AppLanguage.values,
|
||||
selected: settings.language,
|
||||
label: (language) => switch (language) {
|
||||
AppLanguage.system => l10n.languageSystem,
|
||||
AppLanguage.english => l10n.languageEnglish,
|
||||
AppLanguage.dutch => l10n.languageDutch,
|
||||
},
|
||||
);
|
||||
|
||||
if (selected != null) {
|
||||
await settingsViewModel.updateLanguage(selected);
|
||||
}
|
||||
},
|
||||
),
|
||||
_SettingsTile(
|
||||
icon: Icons.grid_view_rounded,
|
||||
title: l10n.productGridRows,
|
||||
subtitle: l10n.rowsCount(settings.barGridRows),
|
||||
onTap: () async {
|
||||
final selected = await _pickOption(
|
||||
context,
|
||||
options: const [2, 3, 4, 5, 6],
|
||||
selected: settings.barGridRows,
|
||||
label: l10n.rowsCount,
|
||||
);
|
||||
|
||||
if (selected != null) {
|
||||
await settingsViewModel.updateBarGridRows(selected);
|
||||
}
|
||||
},
|
||||
),
|
||||
_SettingsTile(
|
||||
icon: Icons.brightness_6_rounded,
|
||||
title: l10n.theme,
|
||||
subtitle: switch (settings.themeMode) {
|
||||
AppThemeMode.system => l10n.system,
|
||||
AppThemeMode.light => l10n.light,
|
||||
AppThemeMode.dark => l10n.dark,
|
||||
AppThemeMode.ugly => l10n.ugly,
|
||||
},
|
||||
onTap: () async {
|
||||
final selected = await _pickOption(
|
||||
context,
|
||||
options: AppThemeMode.values,
|
||||
selected: settings.themeMode,
|
||||
label: (mode) => switch (mode) {
|
||||
AppThemeMode.system => l10n.system,
|
||||
AppThemeMode.light => l10n.light,
|
||||
AppThemeMode.dark => l10n.dark,
|
||||
AppThemeMode.ugly => l10n.ugly,
|
||||
},
|
||||
);
|
||||
|
||||
if (selected != null) {
|
||||
await settingsViewModel.updateThemeMode(selected);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
return ListView(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
children: [
|
||||
_SettingsSection(
|
||||
title: l10n.updates,
|
||||
title: l10n.security,
|
||||
children: [
|
||||
_SettingsSwitchTile(
|
||||
icon: Icons.lock_outline_rounded,
|
||||
title: l10n.pinRequired,
|
||||
value: settings.pinRequired,
|
||||
onChanged: (value) {
|
||||
if (value) {
|
||||
_enablePin();
|
||||
} else {
|
||||
_disablePin();
|
||||
}
|
||||
},
|
||||
),
|
||||
_SettingsSwitchTile(
|
||||
icon: Icons.lock_clock_rounded,
|
||||
title: l10n.autoLockOnExit,
|
||||
value: settings.autoLockEnabled,
|
||||
onChanged: (value) {
|
||||
settingsViewModel.updateAutoLockEnabled(value);
|
||||
},
|
||||
),
|
||||
if (settings.pinRequired)
|
||||
_SettingsTile(
|
||||
icon: Icons.pin_rounded,
|
||||
title: l10n.changePin,
|
||||
onTap: _changePin,
|
||||
),
|
||||
_SettingsTile(
|
||||
icon: Icons.system_update_alt_rounded,
|
||||
title: settingsViewModel.checkingForUpdates
|
||||
? l10n.checkingForUpdates
|
||||
: l10n.checkForUpdates,
|
||||
onTap: settingsViewModel.checkingForUpdates
|
||||
? null
|
||||
: _checkForUpdates,
|
||||
icon: Icons.admin_panel_settings_outlined,
|
||||
title: l10n.adminPin,
|
||||
subtitle: adminPinViewModel.isPinSet
|
||||
? l10n.adminPinConfigured
|
||||
: l10n.adminPinNotSet,
|
||||
onTap: _configureAdminPin,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
GestureDetector(
|
||||
onTapDown: (_) => _startVersionHold(),
|
||||
onTapUp: (_) => _cancelVersionHold(),
|
||||
onTapCancel: _cancelVersionHold,
|
||||
child: Center(
|
||||
child: Text(
|
||||
l10n.version(_appVersion),
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withValues(alpha: 0.5),
|
||||
_SettingsSection(
|
||||
title: l10n.appearance,
|
||||
children: [
|
||||
_SettingsTile(
|
||||
icon: Icons.language_rounded,
|
||||
title: l10n.language,
|
||||
subtitle: switch (settings.language) {
|
||||
AppLanguage.system => l10n.languageSystem,
|
||||
AppLanguage.english => l10n.languageEnglish,
|
||||
AppLanguage.dutch => l10n.languageDutch,
|
||||
},
|
||||
onTap: () async {
|
||||
final selected = await _pickOption(
|
||||
context,
|
||||
options: AppLanguage.values,
|
||||
selected: settings.language,
|
||||
label: (language) => switch (language) {
|
||||
AppLanguage.system => l10n.languageSystem,
|
||||
AppLanguage.english => l10n.languageEnglish,
|
||||
AppLanguage.dutch => l10n.languageDutch,
|
||||
},
|
||||
);
|
||||
|
||||
if (selected != null) {
|
||||
await settingsViewModel.updateLanguage(selected);
|
||||
}
|
||||
},
|
||||
),
|
||||
_SettingsTile(
|
||||
icon: Icons.grid_view_rounded,
|
||||
title: l10n.productGridRows,
|
||||
subtitle: l10n.rowsCount(settings.barGridRows),
|
||||
onTap: () async {
|
||||
final selected = await _pickOption(
|
||||
context,
|
||||
options: const [2, 3, 4, 5, 6],
|
||||
selected: settings.barGridRows,
|
||||
label: l10n.rowsCount,
|
||||
);
|
||||
|
||||
if (selected != null) {
|
||||
await settingsViewModel.updateBarGridRows(selected);
|
||||
}
|
||||
},
|
||||
),
|
||||
_SettingsTile(
|
||||
icon: Icons.brightness_6_rounded,
|
||||
title: l10n.theme,
|
||||
subtitle: switch (settings.themeMode) {
|
||||
AppThemeMode.system => l10n.system,
|
||||
AppThemeMode.light => l10n.light,
|
||||
AppThemeMode.dark => l10n.dark,
|
||||
AppThemeMode.ugly => l10n.ugly,
|
||||
},
|
||||
onTap: () async {
|
||||
final selected = await _pickOption(
|
||||
context,
|
||||
options: AppThemeMode.values,
|
||||
selected: settings.themeMode,
|
||||
label: (mode) => switch (mode) {
|
||||
AppThemeMode.system => l10n.system,
|
||||
AppThemeMode.light => l10n.light,
|
||||
AppThemeMode.dark => l10n.dark,
|
||||
AppThemeMode.ugly => l10n.ugly,
|
||||
},
|
||||
);
|
||||
|
||||
if (selected != null) {
|
||||
await settingsViewModel.updateThemeMode(selected);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
_SettingsSection(
|
||||
title: l10n.updates,
|
||||
children: [
|
||||
_SettingsTile(
|
||||
icon: Icons.system_update_alt_rounded,
|
||||
title: settingsViewModel.checkingForUpdates
|
||||
? l10n.checkingForUpdates
|
||||
: l10n.checkForUpdates,
|
||||
onTap: settingsViewModel.checkingForUpdates
|
||||
? null
|
||||
: _checkForUpdates,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
GestureDetector(
|
||||
onTapDown: (_) => _startVersionHold(),
|
||||
onTapUp: (_) => _cancelVersionHold(),
|
||||
onTapCancel: _cancelVersionHold,
|
||||
child: Center(
|
||||
child: Text(
|
||||
l10n.version(_appVersion),
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
);
|
||||
},
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user