diff --git a/app/lib/cubits/settings.dart b/app/lib/cubits/settings.dart index 652e473f52d6..de631ab131fe 100644 --- a/app/lib/cubits/settings.dart +++ b/app/lib/cubits/settings.dart @@ -313,6 +313,8 @@ enum SortOrder { ascending, descending } enum BannerVisibility { always, never, onlyOnUpdates } +enum NavigatorPosition { left, right } + enum ToolbarPosition { inline, top, @@ -395,6 +397,7 @@ class ButterflySettings with _$ButterflySettings, LeapSettings { @Default([]) List starred, @Default('') String defaultTemplate, @Default(NavigatorPage.waypoints) NavigatorPage navigatorPage, + @Default(NavigatorPosition.left) NavigatorPosition navigatorPosition, @Default(ToolbarPosition.inline) ToolbarPosition toolbarPosition, @Default(ToolbarSize.normal) ToolbarSize toolbarSize, @Default(SortBy.name) SortBy sortBy, @@ -493,6 +496,10 @@ class ButterflySettings with _$ButterflySettings, LeapSettings { toolbarRows: prefs.getInt('toolbar_rows') ?? 1, hideCursorWhileDrawing: prefs.getBool('hide_cursor_while_drawing') ?? false, + navigatorPosition: prefs.containsKey('navigator_position') + ? NavigatorPosition.values + .byName(prefs.getString('navigator_position')!) + : NavigatorPosition.left, ); } @@ -557,6 +564,7 @@ class ButterflySettings with _$ButterflySettings, LeapSettings { await prefs.setString('toolbar_size', toolbarSize.name); await prefs.setInt('toolbar_rows', toolbarRows); await prefs.setBool('hide_cursor_while_drawing', hideCursorWhileDrawing); + await prefs.setString('navigator_position', navigatorPosition.name); } ExternalStorage? getRemote(String? identifier) { @@ -1074,4 +1082,12 @@ class SettingsCubit extends Cubit Future resetHideCursorWhileDrawing() => changeHideCursorWhileDrawing(false); + + Future changeNavigatorPosition(NavigatorPosition value) { + emit(state.copyWith(navigatorPosition: value)); + return save(); + } + + Future resetNavigatorPosition() => + changeNavigatorPosition(NavigatorPosition.left); } diff --git a/app/lib/cubits/settings.freezed.dart b/app/lib/cubits/settings.freezed.dart index d7b1f34ae55a..6f9f27e492bc 100644 --- a/app/lib/cubits/settings.freezed.dart +++ b/app/lib/cubits/settings.freezed.dart @@ -993,6 +993,7 @@ mixin _$ButterflySettings { List get starred => throw _privateConstructorUsedError; String get defaultTemplate => throw _privateConstructorUsedError; NavigatorPage get navigatorPage => throw _privateConstructorUsedError; + NavigatorPosition get navigatorPosition => throw _privateConstructorUsedError; ToolbarPosition get toolbarPosition => throw _privateConstructorUsedError; ToolbarSize get toolbarSize => throw _privateConstructorUsedError; SortBy get sortBy => throw _privateConstructorUsedError; @@ -1048,6 +1049,7 @@ abstract class $ButterflySettingsCopyWith<$Res> { List starred, String defaultTemplate, NavigatorPage navigatorPage, + NavigatorPosition navigatorPosition, ToolbarPosition toolbarPosition, ToolbarSize toolbarSize, SortBy sortBy, @@ -1107,6 +1109,7 @@ class _$ButterflySettingsCopyWithImpl<$Res, $Val extends ButterflySettings> Object? starred = null, Object? defaultTemplate = null, Object? navigatorPage = null, + Object? navigatorPosition = null, Object? toolbarPosition = null, Object? toolbarSize = null, Object? sortBy = null, @@ -1232,6 +1235,10 @@ class _$ButterflySettingsCopyWithImpl<$Res, $Val extends ButterflySettings> ? _value.navigatorPage : navigatorPage // ignore: cast_nullable_to_non_nullable as NavigatorPage, + navigatorPosition: null == navigatorPosition + ? _value.navigatorPosition + : navigatorPosition // ignore: cast_nullable_to_non_nullable + as NavigatorPosition, toolbarPosition: null == toolbarPosition ? _value.toolbarPosition : toolbarPosition // ignore: cast_nullable_to_non_nullable @@ -1341,6 +1348,7 @@ abstract class _$$ButterflySettingsImplCopyWith<$Res> List starred, String defaultTemplate, NavigatorPage navigatorPage, + NavigatorPosition navigatorPosition, ToolbarPosition toolbarPosition, ToolbarSize toolbarSize, SortBy sortBy, @@ -1399,6 +1407,7 @@ class __$$ButterflySettingsImplCopyWithImpl<$Res> Object? starred = null, Object? defaultTemplate = null, Object? navigatorPage = null, + Object? navigatorPosition = null, Object? toolbarPosition = null, Object? toolbarSize = null, Object? sortBy = null, @@ -1524,6 +1533,10 @@ class __$$ButterflySettingsImplCopyWithImpl<$Res> ? _value.navigatorPage : navigatorPage // ignore: cast_nullable_to_non_nullable as NavigatorPage, + navigatorPosition: null == navigatorPosition + ? _value.navigatorPosition + : navigatorPosition // ignore: cast_nullable_to_non_nullable + as NavigatorPosition, toolbarPosition: null == toolbarPosition ? _value.toolbarPosition : toolbarPosition // ignore: cast_nullable_to_non_nullable @@ -1620,6 +1633,7 @@ class _$ButterflySettingsImpl extends _ButterflySettings final List starred = const [], this.defaultTemplate = '', this.navigatorPage = NavigatorPage.waypoints, + this.navigatorPosition = NavigatorPosition.left, this.toolbarPosition = ToolbarPosition.inline, this.toolbarSize = ToolbarSize.normal, this.sortBy = SortBy.name, @@ -1742,6 +1756,9 @@ class _$ButterflySettingsImpl extends _ButterflySettings final NavigatorPage navigatorPage; @override @JsonKey() + final NavigatorPosition navigatorPosition; + @override + @JsonKey() final ToolbarPosition toolbarPosition; @override @JsonKey() @@ -1800,7 +1817,7 @@ class _$ButterflySettingsImpl extends _ButterflySettings @override String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { - return 'ButterflySettings(theme: $theme, density: $density, localeTag: $localeTag, documentPath: $documentPath, touchSensitivity: $touchSensitivity, mouseSensitivity: $mouseSensitivity, penSensitivity: $penSensitivity, selectSensitivity: $selectSensitivity, penOnlyInput: $penOnlyInput, inputGestures: $inputGestures, design: $design, bannerVisibility: $bannerVisibility, history: $history, navigatorEnabled: $navigatorEnabled, zoomEnabled: $zoomEnabled, lastVersion: $lastVersion, connections: $connections, defaultRemote: $defaultRemote, nativeTitleBar: $nativeTitleBar, startInFullScreen: $startInFullScreen, navigationRail: $navigationRail, syncMode: $syncMode, inputConfiguration: $inputConfiguration, fallbackPack: $fallbackPack, starred: $starred, defaultTemplate: $defaultTemplate, navigatorPage: $navigatorPage, toolbarPosition: $toolbarPosition, toolbarSize: $toolbarSize, sortBy: $sortBy, sortOrder: $sortOrder, imageScale: $imageScale, pdfQuality: $pdfQuality, platformTheme: $platformTheme, recentColors: $recentColors, flags: $flags, spreadPages: $spreadPages, highContrast: $highContrast, gridView: $gridView, autosave: $autosave, toolbarRows: $toolbarRows, hideCursorWhileDrawing: $hideCursorWhileDrawing)'; + return 'ButterflySettings(theme: $theme, density: $density, localeTag: $localeTag, documentPath: $documentPath, touchSensitivity: $touchSensitivity, mouseSensitivity: $mouseSensitivity, penSensitivity: $penSensitivity, selectSensitivity: $selectSensitivity, penOnlyInput: $penOnlyInput, inputGestures: $inputGestures, design: $design, bannerVisibility: $bannerVisibility, history: $history, navigatorEnabled: $navigatorEnabled, zoomEnabled: $zoomEnabled, lastVersion: $lastVersion, connections: $connections, defaultRemote: $defaultRemote, nativeTitleBar: $nativeTitleBar, startInFullScreen: $startInFullScreen, navigationRail: $navigationRail, syncMode: $syncMode, inputConfiguration: $inputConfiguration, fallbackPack: $fallbackPack, starred: $starred, defaultTemplate: $defaultTemplate, navigatorPage: $navigatorPage, navigatorPosition: $navigatorPosition, toolbarPosition: $toolbarPosition, toolbarSize: $toolbarSize, sortBy: $sortBy, sortOrder: $sortOrder, imageScale: $imageScale, pdfQuality: $pdfQuality, platformTheme: $platformTheme, recentColors: $recentColors, flags: $flags, spreadPages: $spreadPages, highContrast: $highContrast, gridView: $gridView, autosave: $autosave, toolbarRows: $toolbarRows, hideCursorWhileDrawing: $hideCursorWhileDrawing)'; } @override @@ -1835,6 +1852,7 @@ class _$ButterflySettingsImpl extends _ButterflySettings ..add(DiagnosticsProperty('starred', starred)) ..add(DiagnosticsProperty('defaultTemplate', defaultTemplate)) ..add(DiagnosticsProperty('navigatorPage', navigatorPage)) + ..add(DiagnosticsProperty('navigatorPosition', navigatorPosition)) ..add(DiagnosticsProperty('toolbarPosition', toolbarPosition)) ..add(DiagnosticsProperty('toolbarSize', toolbarSize)) ..add(DiagnosticsProperty('sortBy', sortBy)) @@ -1907,6 +1925,8 @@ class _$ButterflySettingsImpl extends _ButterflySettings other.defaultTemplate == defaultTemplate) && (identical(other.navigatorPage, navigatorPage) || other.navigatorPage == navigatorPage) && + (identical(other.navigatorPosition, navigatorPosition) || + other.navigatorPosition == navigatorPosition) && (identical(other.toolbarPosition, toolbarPosition) || other.toolbarPosition == toolbarPosition) && (identical(other.toolbarSize, toolbarSize) || @@ -1967,6 +1987,7 @@ class _$ButterflySettingsImpl extends _ButterflySettings const DeepCollectionEquality().hash(_starred), defaultTemplate, navigatorPage, + navigatorPosition, toolbarPosition, toolbarSize, sortBy, @@ -2021,6 +2042,7 @@ abstract class _ButterflySettings extends ButterflySettings { final List starred, final String defaultTemplate, final NavigatorPage navigatorPage, + final NavigatorPosition navigatorPosition, final ToolbarPosition toolbarPosition, final ToolbarSize toolbarSize, final SortBy sortBy, @@ -2093,6 +2115,8 @@ abstract class _ButterflySettings extends ButterflySettings { @override NavigatorPage get navigatorPage; @override + NavigatorPosition get navigatorPosition; + @override ToolbarPosition get toolbarPosition; @override ToolbarSize get toolbarSize; diff --git a/app/lib/settings/personalization.dart b/app/lib/settings/personalization.dart index b9f36bfdaac7..a57c18a62d11 100644 --- a/app/lib/settings/personalization.dart +++ b/app/lib/settings/personalization.dart @@ -195,8 +195,8 @@ class PersonalizationSettingsPage extends StatelessWidget { .read() .changeToolbarRows(value.round()), ), - SwitchListTile( - secondary: + AdvancedSwitchListTile( + leading: const PhosphorIcon(PhosphorIconsLight.sidebar), title: Text(AppLocalizations.of(context).navigationRail), @@ -204,6 +204,10 @@ class PersonalizationSettingsPage extends StatelessWidget { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ + Text(state.navigatorPosition == + NavigatorPosition.left + ? AppLocalizations.of(context).left + : AppLocalizations.of(context).right), Text( AppLocalizations.of(context) .onlyAvailableLargerScreen, @@ -211,6 +215,34 @@ class PersonalizationSettingsPage extends StatelessWidget { ), ], ), + onTap: () async { + final position = await showLeapBottomSheet( + context: context, + title: AppLocalizations.of(context).position, + childrenBuilder: (context) => [ + ListTile( + title: Text( + AppLocalizations.of(context).left), + selected: state.navigatorPosition == + NavigatorPosition.left, + onTap: () => Navigator.of(context) + .pop(NavigatorPosition.left), + ), + ListTile( + title: Text( + AppLocalizations.of(context).right), + selected: state.navigatorPosition == + NavigatorPosition.right, + onTap: () => Navigator.of(context) + .pop(NavigatorPosition.right), + ), + ]); + if (position != null) { + context + .read() + .changeNavigatorPosition(position); + } + }, value: state.navigationRail, onChanged: (value) => context .read() diff --git a/app/lib/views/main.dart b/app/lib/views/main.dart index 94ce068c50a8..fc808b3785fe 100644 --- a/app/lib/views/main.dart +++ b/app/lib/views/main.dart @@ -497,7 +497,8 @@ class _MainBody extends StatelessWidget { previous.toolbarPosition != current.toolbarPosition || previous.toolbarSize != current.toolbarSize || previous.toolbarRows != current.toolbarRows || - previous.navigationRail != current.navigationRail, + previous.navigationRail != current.navigationRail || + previous.navigatorPosition != current.navigatorPosition, builder: (context, settings) { final pos = settings.toolbarPosition; return LayoutBuilder(builder: (context, constraints) { @@ -510,6 +511,11 @@ class _MainBody extends StatelessWidget { centered: true, direction: pos.axis, ); + final showNavigator = isLarge && + settings.navigationRail && + !windowState.fullScreen && + state is DocumentLoadSuccess && + currentIndex.hideUi == HideState.visible; return Stack( children: [ const MainViewViewport(), @@ -527,11 +533,9 @@ class _MainBody extends StatelessWidget { ), Row( children: [ - if (isLarge && - settings.navigationRail && - !windowState.fullScreen && - state is DocumentLoadSuccess && - currentIndex.hideUi == HideState.visible) + if (showNavigator && + settings.navigatorPosition == + NavigatorPosition.left) const NavigatorView(), if (pos == ToolbarPosition.left && !isMobile && @@ -612,6 +616,10 @@ class _MainBody extends StatelessWidget { if (pos == ToolbarPosition.right && currentIndex.hideUi == HideState.visible) toolbar, + if (showNavigator && + settings.navigatorPosition == + NavigatorPosition.right) + const NavigatorView(), ], ), ], diff --git a/app/lib/views/navigator/view.dart b/app/lib/views/navigator/view.dart index 0977ee984d44..53b49c5ec8f3 100644 --- a/app/lib/views/navigator/view.dart +++ b/app/lib/views/navigator/view.dart @@ -83,7 +83,8 @@ class _NavigatorViewState extends State return BlocBuilder( buildWhen: (previous, current) => previous.navigatorEnabled != current.navigatorEnabled || - previous.navigatorPage != current.navigatorPage, + previous.navigatorPage != current.navigatorPage || + previous.navigatorPosition != current.navigatorPosition, builder: (context, settings) { final selected = NavigatorPage.values.indexOf(settings.navigatorPage); if (settings.navigatorEnabled) { @@ -92,7 +93,13 @@ class _NavigatorViewState extends State _animationController.reverse(); } return Row( - textDirection: TextDirection.rtl, + textDirection: settings.navigatorPosition == NavigatorPosition.left + ? TextDirection.rtl + : TextDirection.ltr, + mainAxisAlignment: + settings.navigatorPosition == NavigatorPosition.left + ? MainAxisAlignment.start + : MainAxisAlignment.end, children: [ SizeTransition( sizeFactor: _animation, diff --git a/app/pubspec.lock b/app/pubspec.lock index cf6061e39dfd..18dad12636e3 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -308,9 +308,9 @@ packages: dependency: transitive description: path: "packages/dart_leap" - ref: "0e04c453c2b6d4aa499f79e54bb1c0b7a9b2c42c" - resolved-ref: "0e04c453c2b6d4aa499f79e54bb1c0b7a9b2c42c" - url: "https://github.com/LinwoodDev/dart_pkgs.git" + ref: d45bd54f2efd6a861d6f44a8b833575b0482dc4c + resolved-ref: d45bd54f2efd6a861d6f44a8b833575b0482dc4c + url: "https://github.com/LinwoodDev/dart_pkgs" source: git version: "1.0.0" dart_style: @@ -841,8 +841,8 @@ packages: dependency: "direct main" description: path: "packages/material_leap" - ref: "0e04c453c2b6d4aa499f79e54bb1c0b7a9b2c42c" - resolved-ref: "0e04c453c2b6d4aa499f79e54bb1c0b7a9b2c42c" + ref: "8dc38c743c8dc3450e5c5a2f64536ef590e8d376" + resolved-ref: "8dc38c743c8dc3450e5c5a2f64536ef590e8d376" url: "https://github.com/LinwoodDev/dart_pkgs.git" source: git version: "0.0.1" diff --git a/app/pubspec.yaml b/app/pubspec.yaml index f5ec5ef3e643..e9ac28159c4b 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -69,7 +69,7 @@ dependencies: material_leap: git: url: https://github.com/LinwoodDev/dart_pkgs.git - ref: 0e04c453c2b6d4aa499f79e54bb1c0b7a9b2c42c + ref: 8dc38c743c8dc3450e5c5a2f64536ef590e8d376 path: packages/material_leap lw_sysapi: git: diff --git a/metadata/en-US/changelogs/110.txt b/metadata/en-US/changelogs/110.txt new file mode 100644 index 000000000000..babefe7d4730 --- /dev/null +++ b/metadata/en-US/changelogs/110.txt @@ -0,0 +1,3 @@ +* Add navigator position to position it to the right (useful for left handed users) + +Read more here: https://linwood.dev/butterfly/2.2.0-beta.0 \ No newline at end of file