Skip to content

Commit

Permalink
wip: Update settings layout sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
lijy91 committed Sep 25, 2024
1 parent c7770fe commit 148a3e5
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 391 deletions.
2 changes: 1 addition & 1 deletion apps/biyi_app/lib/app/home/desktop_popup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import 'package:flutter/services.dart';
import 'package:hotkey_manager/hotkey_manager.dart';
import 'package:protocol_handler/protocol_handler.dart';
import 'package:provider/provider.dart';
import 'package:reflect_ui/reflect_ui.dart';
import 'package:reflect_ui/reflect_ui.dart' hide Menu;
import 'package:screen_capturer/screen_capturer.dart';
import 'package:screen_retriever/screen_retriever.dart';
import 'package:screen_text_extractor/screen_text_extractor.dart';
Expand Down
1 change: 0 additions & 1 deletion apps/biyi_app/lib/app/settings/keybinds/page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:biyi_app/generated/locale_keys.g.dart';
import 'package:biyi_app/states/settings.dart';
import 'package:biyi_app/widgets/customized_app_bar/customized_app_bar.dart';
import 'package:biyi_app/widgets/kbd/kbd.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:go_router/go_router.dart';
import 'package:hotkey_manager/hotkey_manager.dart';
Expand Down
171 changes: 75 additions & 96 deletions apps/biyi_app/lib/app/settings/layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:async';

import 'package:biyi_app/app/router_config.dart';
import 'package:biyi_app/generated/locale_keys.g.dart';
import 'package:biyi_app/widgets/navigation_rail/navigation_rail.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
Expand All @@ -11,34 +10,6 @@ import 'package:reflect_ui/reflect_ui.dart';
import 'package:uni_platform/uni_platform.dart';
import 'package:window_manager/window_manager.dart';

class _NavigationRailLeading extends StatelessWidget {
const _NavigationRailLeading({required this.label});

final String label;

@override
Widget build(BuildContext context) {
ThemeData themeData = Theme.of(context);
TextTheme textTheme = themeData.textTheme;
return Container(
padding: const EdgeInsets.symmetric(
vertical: 2,
horizontal: 8,
),
margin: const EdgeInsets.only(
left: 12,
right: 12,
),
child: Text(
label,
style: textTheme.bodySmall!.copyWith(
color: themeData.colorScheme.onSurfaceVariant,
),
),
);
}
}

class SettingsLayout extends StatefulWidget {
const SettingsLayout({
super.key,
Expand Down Expand Up @@ -131,80 +102,88 @@ class _SettingsLayoutState extends State<SettingsLayout> with WindowListener {
),
width: 200,
height: double.infinity,
child: SingleChildScrollView(
child: GappedColumn(
gap: 12,
children: [
NavigationRail(
leading: _NavigationRailLeading(
label: LocaleKeys.app_settings__layout_navgroup_client.tr(),
child: NavList(
children: [
NavListSection(
header: Text(
LocaleKeys.app_settings__layout_navgroup_client.tr(),
),
children: [
NavListItem(
selected: _selectedDestination == PageId.settingsGeneral,
leading: const Icon(FluentIcons.app_generic_20_regular),
title: Text(LocaleKeys.app_settings_general_title.tr()),
onTap: () => _handleDestinationSelected(PageId.settingsGeneral),
),
destinations: [
NavigationRailDestination(
value: PageId.settingsGeneral,
icon: FluentIcons.app_generic_20_regular,
label: LocaleKeys.app_settings_general_title.tr(),
),
NavigationRailDestination(
value: PageId.settingsAppearance,
icon: FluentIcons.style_guide_20_regular,
label: LocaleKeys.app_settings_appearance_title.tr(),
),
NavigationRailDestination(
value: PageId.settingsKeybinds,
icon: FluentIcons.keyboard_20_regular,
label: LocaleKeys.app_settings_keybinds_title.tr(),
),
NavigationRailDestination(
value: PageId.settingsLanguage,
icon: FluentIcons.local_language_20_regular,
label: LocaleKeys.app_settings_language_title.tr(),
),
NavigationRailDestination(
value: PageId.settingsAdvanced,
icon: FluentIcons.settings_20_regular,
label: LocaleKeys.app_settings_advanced_title.tr(),
),
],
selectedValue: _selectedDestination,
onDestinationSelected: _handleDestinationSelected,
NavListItem(
selected: _selectedDestination == PageId.settingsAppearance,
leading: const Icon(FluentIcons.style_guide_20_regular),
title: Text(LocaleKeys.app_settings_appearance_title.tr()),
onTap: () =>
_handleDestinationSelected(PageId.settingsAppearance),
),
NavListItem(
selected: _selectedDestination == PageId.settingsKeybinds,
leading: const Icon(FluentIcons.keyboard_20_regular),
title: Text(LocaleKeys.app_settings_keybinds_title.tr()),
onTap: () =>
_handleDestinationSelected(PageId.settingsKeybinds),
),
NavListItem(
selected: _selectedDestination == PageId.settingsLanguage,
leading: const Icon(FluentIcons.local_language_20_regular),
title: Text(LocaleKeys.app_settings_language_title.tr()),
onTap: () =>
_handleDestinationSelected(PageId.settingsLanguage),
),
NavListItem(
selected: _selectedDestination == PageId.settingsAdvanced,
leading: const Icon(FluentIcons.settings_20_regular),
title: Text(LocaleKeys.app_settings_advanced_title.tr()),
onTap: () =>
_handleDestinationSelected(PageId.settingsAdvanced),
),
],
),
NavListSection(
header: Text(
LocaleKeys.app_settings__layout_navgroup_integrations.tr(),
),
NavigationRail(
leading: _NavigationRailLeading(
label:
LocaleKeys.app_settings__layout_navgroup_integrations.tr(),
children: [
NavListItem(
selected: _selectedDestination == PageId.settingsOcrEngines,
leading: const Icon(FluentIcons.scan_20_regular),
title: Text(LocaleKeys.app_settings_ocr_engines_title.tr()),
onTap: () =>
_handleDestinationSelected(PageId.settingsOcrEngines),
),
destinations: [
NavigationRailDestination(
value: PageId.settingsOcrEngines,
icon: FluentIcons.scan_20_regular,
label: LocaleKeys.app_settings_ocr_engines_title.tr(),
NavListItem(
selected:
_selectedDestination == PageId.settingsTranslationEngines,
leading: const Icon(FluentIcons.translate_20_regular),
title: Text(
LocaleKeys.app_settings_translation_engines_title.tr(),
),
NavigationRailDestination(
value: PageId.settingsTranslationEngines,
icon: FluentIcons.translate_20_regular,
label: LocaleKeys.app_settings_translation_engines_title.tr(),
onTap: () => _handleDestinationSelected(
PageId.settingsTranslationEngines,
),
],
selectedValue: _selectedDestination,
onDestinationSelected: _handleDestinationSelected,
),
NavigationRail(
leading: _NavigationRailLeading(
label: LocaleKeys.app_settings__layout_navgroup_resources.tr(),
),
destinations: [
NavigationRailDestination(
value: PageId.settingsAbout,
icon: FluentIcons.info_20_regular,
label: LocaleKeys.app_settings_about_title.tr(),
),
],
selectedValue: _selectedDestination,
onDestinationSelected: _handleDestinationSelected,
],
),
NavListSection(
header: Text(
LocaleKeys.app_settings__layout_navgroup_resources.tr(),
),
],
),
children: [
NavListItem(
selected: _selectedDestination == PageId.settingsAbout,
leading: const Icon(FluentIcons.info_20_regular),
title: Text(LocaleKeys.app_settings_about_title.tr()),
onTap: () => _handleDestinationSelected(PageId.settingsAbout),
),
],
),
],
),
);
}
Expand Down
79 changes: 0 additions & 79 deletions apps/biyi_app/lib/widgets/kbd/kbd.dart

This file was deleted.

Loading

0 comments on commit 148a3e5

Please sign in to comment.