simplified code across the app and consolidated duplicated helpers
This commit is contained in:
@@ -50,10 +50,7 @@ class AboutSection extends StatelessWidget {
|
||||
_toggleDeveloperMode(context, settings, state),
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: settings.val().devToolsEnabled,
|
||||
child: DevToolsSection(settings: settings),
|
||||
),
|
||||
if (settings.val().devToolsEnabled) DevToolsSection(settings: settings),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -104,7 +101,9 @@ class AboutSection extends StatelessWidget {
|
||||
Icon(Icons.send_time_extension_outlined),
|
||||
),
|
||||
title: const Text('Infos zu mhsl'),
|
||||
subtitle: const Text('Für Push, Kalendertermine, Marianum Message und mehr'),
|
||||
subtitle: const Text(
|
||||
'Für Push, Kalendertermine, Marianum Message und mehr',
|
||||
),
|
||||
trailing: const Icon(Icons.arrow_right),
|
||||
onTap: () => PrivacyInfo(
|
||||
providerText: 'mhsl',
|
||||
|
||||
@@ -22,21 +22,14 @@ import '../../../../widget/user_avatar.dart';
|
||||
String? _cachedDisplayName;
|
||||
String? _cachedDisplayNameFor;
|
||||
|
||||
class AccountSection extends StatelessWidget {
|
||||
class AccountSection extends StatefulWidget {
|
||||
const AccountSection({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => const _SchoolAccount();
|
||||
State<AccountSection> createState() => _AccountSectionState();
|
||||
}
|
||||
|
||||
class _SchoolAccount extends StatefulWidget {
|
||||
const _SchoolAccount();
|
||||
|
||||
@override
|
||||
State<_SchoolAccount> createState() => _SchoolAccountState();
|
||||
}
|
||||
|
||||
class _SchoolAccountState extends State<_SchoolAccount> {
|
||||
class _AccountSectionState extends State<AccountSection> {
|
||||
int _avatarVersion = 0;
|
||||
bool _avatarBusy = false;
|
||||
String? _displayName;
|
||||
|
||||
@@ -41,25 +41,15 @@ class AppearanceSection extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
IconData _hapticIcon(HapticLevel level) {
|
||||
switch (level) {
|
||||
case HapticLevel.off:
|
||||
return Icons.notifications_off_outlined;
|
||||
case HapticLevel.reduced:
|
||||
return Icons.notifications_paused_outlined;
|
||||
case HapticLevel.full:
|
||||
return Icons.notifications_active_outlined;
|
||||
}
|
||||
}
|
||||
IconData _hapticIcon(HapticLevel level) => switch (level) {
|
||||
HapticLevel.off => Icons.notifications_off_outlined,
|
||||
HapticLevel.reduced => Icons.notifications_paused_outlined,
|
||||
HapticLevel.full => Icons.notifications_active_outlined,
|
||||
};
|
||||
|
||||
String _hapticLabel(HapticLevel level) {
|
||||
switch (level) {
|
||||
case HapticLevel.off:
|
||||
return 'Aus';
|
||||
case HapticLevel.reduced:
|
||||
return 'Reduziert';
|
||||
case HapticLevel.full:
|
||||
return 'Vollständig';
|
||||
}
|
||||
}
|
||||
String _hapticLabel(HapticLevel level) => switch (level) {
|
||||
HapticLevel.off => 'Aus',
|
||||
HapticLevel.reduced => 'Reduziert',
|
||||
HapticLevel.full => 'Vollständig',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -26,15 +26,10 @@ import '../widgets/endpoint_picker.dart';
|
||||
import '../widgets/settings_checkbox_tile.dart';
|
||||
import '../widgets/settings_dropdown_tile.dart';
|
||||
|
||||
class DevToolsSection extends StatefulWidget {
|
||||
class DevToolsSection extends StatelessWidget {
|
||||
final SettingsCubit settings;
|
||||
const DevToolsSection({required this.settings, super.key});
|
||||
|
||||
@override
|
||||
State<DevToolsSection> createState() => _DevToolsSectionState();
|
||||
}
|
||||
|
||||
class _DevToolsSectionState extends State<DevToolsSection> {
|
||||
@override
|
||||
Widget build(BuildContext context) => Column(
|
||||
children: [
|
||||
@@ -54,11 +49,11 @@ class _DevToolsSectionState extends State<DevToolsSection> {
|
||||
context,
|
||||
children: (sheetCtx) => [
|
||||
BlocBuilder<SettingsCubit, model.Settings>(
|
||||
bloc: widget.settings,
|
||||
bloc: settings,
|
||||
builder: (_, _) {
|
||||
final dev = widget.settings.val().devToolsSettings;
|
||||
final dev = settings.val().devToolsSettings;
|
||||
DevToolsSettings write() =>
|
||||
widget.settings.val(write: true).devToolsSettings;
|
||||
settings.val(write: true).devToolsSettings;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -122,17 +117,17 @@ class _DevToolsSectionState extends State<DevToolsSection> {
|
||||
title: const Text('Marianum-Connect-Server'),
|
||||
subtitle: Text(
|
||||
MarianumConnectEndpointPicker.labelFor(
|
||||
widget.settings.val().devToolsSettings,
|
||||
settings.val().devToolsSettings,
|
||||
),
|
||||
),
|
||||
trailing: const Icon(Icons.arrow_right),
|
||||
onTap: () =>
|
||||
MarianumConnectEndpointPicker.show(context, widget.settings),
|
||||
MarianumConnectEndpointPicker.show(context, settings),
|
||||
),
|
||||
BlocBuilder<SettingsCubit, model.Settings>(
|
||||
bloc: widget.settings,
|
||||
bloc: settings,
|
||||
builder: (_, _) {
|
||||
final override = widget.settings
|
||||
final override = settings
|
||||
.val()
|
||||
.devToolsSettings
|
||||
.emergencyNoticeUrl
|
||||
@@ -143,7 +138,7 @@ class _DevToolsSectionState extends State<DevToolsSection> {
|
||||
subtitle: Text(override.isEmpty ? 'Standardquelle' : override),
|
||||
trailing: const Icon(Icons.arrow_right),
|
||||
onTap: () =>
|
||||
_EmergencyNoticeUrlEditor.show(context, widget.settings),
|
||||
_EmergencyNoticeUrlEditor.show(context, settings),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -152,18 +147,18 @@ class _DevToolsSectionState extends State<DevToolsSection> {
|
||||
icon: Icons.settings_applications_outlined,
|
||||
title: 'Einstellungen',
|
||||
describe: () async => filesize(
|
||||
utf8.encode(jsonEncode(widget.settings.val().toJson())).length,
|
||||
utf8.encode(jsonEncode(settings.val().toJson())).length,
|
||||
),
|
||||
onOpen: (_) async => AppRoutes.openJsonViewer(
|
||||
context,
|
||||
widget.settings.val().toJson(),
|
||||
settings.val().toJson(),
|
||||
title: 'Einstellungen',
|
||||
),
|
||||
clearTitle: 'Einstellungen zurücksetzen',
|
||||
clearContent:
|
||||
'Alle Einstellungen gehen verloren! Accountdaten sowie App-Daten '
|
||||
'sind nicht betroffen.',
|
||||
onClear: widget.settings.reset,
|
||||
onClear: settings.reset,
|
||||
),
|
||||
_StorageTile(
|
||||
icon: Icons.account_tree_outlined,
|
||||
|
||||
Reference in New Issue
Block a user