Skip to content

Commit

Permalink
refactor(settings): consolidate appearance, network, and localization…
Browse files Browse the repository at this point in the history
… pages
  • Loading branch information
JagandeepBrar committed Sep 26, 2022
1 parent c9bd02b commit ac838f9
Show file tree
Hide file tree
Showing 11 changed files with 258 additions and 269 deletions.
3 changes: 3 additions & 0 deletions assets/localization/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@
"settings.BasicAuthenticationHint1": "The username must not contain a colon",
"settings.BasicAuthenticationHint2": "The password can contain a colon",
"settings.BasicAuthenticationHint3": "The username and password are automatically converted to base64 encoding",
"settings.BootModule": "Boot Module",
"settings.BroadcastAddress": "Broadcast Address",
"settings.BroadcastAddressHint1": "This is the broadcast address of your local network",
"settings.BroadcastAddressHint2": "Typically this is the IP address of your machine with the last octet set to 255",
Expand Down Expand Up @@ -468,6 +469,8 @@
"settings.FilterCategory": "Filter Category",
"settings.ForgotYourPassword": "Forgot Your Password?",
"settings.FutureDays": "Future Days",
"settings.General": "General",
"settings.GeneralDescription": "Customize LunaSea",
"settings.GitHubDescription": "View the Source Code",
"settings.HeaderAdded": "Header Added",
"settings.HeaderDeleted": "Header Deleted",
Expand Down
2 changes: 2 additions & 0 deletions lib/database/tables/bios.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:lunasea/database/table.dart';
import 'package:lunasea/modules.dart';

enum BIOSDatabase<T> with LunaTableMixin<T> {
BOOT_MODULE<LunaModule>(LunaModule.DASHBOARD),
SENTRY_LOGGING<bool>(true),
FIRST_BOOT<bool>(true);

Expand Down
37 changes: 37 additions & 0 deletions lib/modules/settings/core/dialogs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import 'package:email_validator/email_validator.dart';
import 'package:flutter/material.dart';
import 'package:lunasea/database/tables/lunasea.dart';
import 'package:lunasea/firebase/types.dart';
import 'package:lunasea/modules.dart';
import 'package:lunasea/modules/settings/core/types/header.dart';
import 'package:lunasea/state/state.dart';
import 'package:lunasea/system/localization.dart';
import 'package:lunasea/vendor.dart';
import 'package:lunasea/widgets/ui.dart';
Expand Down Expand Up @@ -1353,4 +1355,39 @@ class SettingsDialogs {
contentPadding: LunaDialog.textDialogContentPadding(),
);
}

Future<Tuple2<bool, LunaModule?>> selectBootModule() async {
final context = LunaState.context;
bool _flag = false;
LunaModule? _module;

void _setValues(LunaModule module) {
_flag = true;
_module = module;
Navigator.of(context).pop();
}

final modules = LunaModule.values.filter((m) {
if (m.homeRoute == null) return false;
if (!m.isEnabled) return false;
return true;
}).toList();

await LunaDialog.dialog(
context: context,
title: 'settings.BootModule'.tr(),
content: List.generate(
modules.length,
(index) => LunaDialog.tile(
text: modules[index].title,
icon: modules[index].icon,
iconColor: modules[index].color,
onTap: () => _setValues(modules[index]),
),
),
contentPadding: LunaDialog.listDialogContentPadding(),
);

return Tuple2(_flag, _module);
}
}
20 changes: 3 additions & 17 deletions lib/modules/settings/routes/configuration/route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:lunasea/core.dart';
import 'package:lunasea/modules/settings.dart';
import 'package:lunasea/router/routes/settings.dart';
import 'package:lunasea/system/network/network.dart';
import 'package:lunasea/system/quick_actions/quick_actions.dart';
import 'package:lunasea/utils/profile_tools.dart';

Expand Down Expand Up @@ -73,30 +72,17 @@ class _State extends State<ConfigurationRoute> with LunaScrollControllerMixin {
controller: scrollController,
children: [
LunaBlock(
title: 'settings.Appearance'.tr(),
body: [TextSpan(text: 'settings.AppearanceDescription'.tr())],
title: 'settings.General'.tr(),
body: [TextSpan(text: 'settings.GeneralDescription'.tr())],
trailing: const LunaIconButton(icon: Icons.brush_rounded),
onTap: SettingsRoutes.CONFIGURATION_APPEARANCE.go,
onTap: SettingsRoutes.CONFIGURATION_GENERAL.go,
),
LunaBlock(
title: 'settings.Drawer'.tr(),
body: [TextSpan(text: 'settings.DrawerDescription'.tr())],
trailing: const LunaIconButton(icon: Icons.menu_rounded),
onTap: SettingsRoutes.CONFIGURATION_DRAWER.go,
),
LunaBlock(
title: 'settings.Localization'.tr(),
body: [TextSpan(text: 'settings.LocalizationDescription'.tr())],
trailing: const LunaIconButton(icon: Icons.translate_rounded),
onTap: SettingsRoutes.CONFIGURATION_LOCALIZATION.go,
),
if (LunaNetwork.isSupported)
LunaBlock(
title: 'settings.Network'.tr(),
body: [TextSpan(text: 'settings.NetworkDescription'.tr())],
trailing: const LunaIconButton(icon: Icons.network_check_rounded),
onTap: SettingsRoutes.CONFIGURATION_NETWORK.go,
),
if (LunaQuickActions.isSupported)
LunaBlock(
title: 'settings.QuickActions'.tr(),
Expand Down
104 changes: 0 additions & 104 deletions lib/modules/settings/routes/configuration_appearance/route.dart

This file was deleted.

Loading

0 comments on commit ac838f9

Please sign in to comment.