Skip to content

Commit

Permalink
⚡ Improved Focusability & Shortcut invocation in power mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
omegaui committed Jan 24, 2024
1 parent be7cb69 commit 4215216
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 38 deletions.
7 changes: 4 additions & 3 deletions lib/app/powermode/presentation/panels/images_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ class _ImagesPanelState extends State<ImagesPanel> {
PowerDataHandler.dateFilterChangeListeners.add(rebuild);
PowerDataHandler.searchTypeChangeListeners.add(rebuild);
PowerDataHandler.searchTextChangeListeners.add(rebuild);
setState(() {
initialized = true;
});
initialized = true;
if (mounted) {
setState(() {});
}
},
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:cliptopia/app/powermode/domain/entity/typedefs.dart';
import 'package:cliptopia/app/powermode/presentation/states/power_mode_loaded_state_view.dart';
import 'package:cliptopia/config/themes/app_theme.dart';
import 'package:cliptopia/core/powermode/power_data_handler.dart';
import 'package:cliptopia/core/storage/storage.dart';
Expand All @@ -12,7 +13,7 @@ class PowerSearchField extends StatefulWidget {
}

class _PowerSearchFieldState extends State<PowerSearchField> {
final focusNode = FocusNode();
final focusNode = appFocusNode;

final TextEditingController controller = TextEditingController();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,43 +130,44 @@ class _PowerModeLoadedStateViewState extends State<PowerModeLoadedStateView> {
final defaultViewMode = Storage.get(StorageKeys.viewMode,
fallback: StorageValues.defaultViewMode) ==
StorageValues.defaultViewMode;
return CallbackShortcuts(
bindings: {
const SingleActivator(LogicalKeyboardKey.escape): () =>
Injector.find<AppSession>().endSession(),
const SingleActivator(LogicalKeyboardKey.keyI, control: true): () {
if (Storage.get(StorageKeys.hideImagePanelKey, fallback: false)) {
TempStorage.toggle(StorageKeys.hideImagePanelKey, fallback: false);
return Focus(
autofocus: true,
child: CallbackShortcuts(
bindings: {
const SingleActivator(LogicalKeyboardKey.escape): () =>
Injector.find<AppSession>().endSession(),
const SingleActivator(LogicalKeyboardKey.keyI, control: true): () {
if (Storage.get(StorageKeys.hideImagePanelKey, fallback: false)) {
TempStorage.toggle(StorageKeys.hideImagePanelKey,
fallback: false);
rebuild();
}
},
const SingleActivator(LogicalKeyboardKey.keyI,
control: true, shift: true): () {
if (Storage.isSensitivityOn()) {
TempStorage.set(StorageKeys.sensitivity,
!TempStorage.canShowSensitiveContent());
rebuild();
}
},
const SingleActivator(LogicalKeyboardKey.keyT, alt: true): () {
PowerDataHandler.searchTypeUpdate(PowerSearchType.Text);
rebuild();
}
},
const SingleActivator(LogicalKeyboardKey.keyI,
control: true, shift: true): () {
if (Storage.isSensitivityOn()) {
TempStorage.set(StorageKeys.sensitivity,
!TempStorage.canShowSensitiveContent());
},
const SingleActivator(LogicalKeyboardKey.keyR, alt: true): () {
PowerDataHandler.searchTypeUpdate(PowerSearchType.Regex);
rebuild();
}
},
const SingleActivator(LogicalKeyboardKey.keyT, alt: true): () {
PowerDataHandler.searchTypeUpdate(PowerSearchType.Text);
rebuild();
},
const SingleActivator(LogicalKeyboardKey.keyR, alt: true): () {
PowerDataHandler.searchTypeUpdate(PowerSearchType.Regex);
rebuild();
},
const SingleActivator(LogicalKeyboardKey.keyI, alt: true): () {
PowerDataHandler.searchTypeUpdate(PowerSearchType.Image);
rebuild();
},
const SingleActivator(LogicalKeyboardKey.keyC, alt: true): () {
PowerDataHandler.searchTypeUpdate(PowerSearchType.Comment);
rebuild();
},
const SingleActivator(LogicalKeyboardKey.keyI, alt: true): () {
PowerDataHandler.searchTypeUpdate(PowerSearchType.Image);
rebuild();
},
const SingleActivator(LogicalKeyboardKey.keyC, alt: true): () {
PowerDataHandler.searchTypeUpdate(PowerSearchType.Comment);
rebuild();
},
},
},
child: Focus(
focusNode: appFocusNode,
child: Scaffold(
backgroundColor: Colors.transparent,
body: GestureDetector(
Expand Down

0 comments on commit 4215216

Please sign in to comment.