refactor: Migrate to new keyboard shortcuts package
This commit is contained in:
parent
b2e1accf9d
commit
f564dbc575
6 changed files with 87 additions and 89 deletions
|
|
@ -3,7 +3,7 @@ import 'package:flutter/services.dart';
|
||||||
|
|
||||||
import 'package:animations/animations.dart';
|
import 'package:animations/animations.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
import 'package:keyboard_shortcuts/keyboard_shortcuts.dart';
|
import 'package:keymap/keymap.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/config/app_config.dart';
|
import 'package:fluffychat/config/app_config.dart';
|
||||||
|
|
@ -96,14 +96,15 @@ class ChatInputRow extends StatelessWidget {
|
||||||
]
|
]
|
||||||
: <Widget>[
|
: <Widget>[
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
KeyBoardShortcuts(
|
KeyboardWidget(
|
||||||
keysToPress: {
|
bindings: [
|
||||||
LogicalKeyboardKey.altLeft,
|
KeyAction(
|
||||||
LogicalKeyboardKey.keyA,
|
LogicalKeyboardKey.keyA,
|
||||||
},
|
L10n.of(context).sendFile,
|
||||||
onKeysPressed: () =>
|
() => controller.onAddPopupMenuButtonSelected('file'),
|
||||||
controller.onAddPopupMenuButtonSelected('file'),
|
isAltPressed: true,
|
||||||
helpLabel: L10n.of(context).sendFile,
|
),
|
||||||
|
],
|
||||||
child: AnimatedContainer(
|
child: AnimatedContainer(
|
||||||
duration: FluffyThemes.animationDuration,
|
duration: FluffyThemes.animationDuration,
|
||||||
curve: FluffyThemes.animationCurve,
|
curve: FluffyThemes.animationCurve,
|
||||||
|
|
@ -188,13 +189,15 @@ class ChatInputRow extends StatelessWidget {
|
||||||
height: height,
|
height: height,
|
||||||
width: height,
|
width: height,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: KeyBoardShortcuts(
|
child: KeyboardWidget(
|
||||||
keysToPress: {
|
bindings: [
|
||||||
LogicalKeyboardKey.altLeft,
|
KeyAction(
|
||||||
LogicalKeyboardKey.keyE,
|
LogicalKeyboardKey.keyE,
|
||||||
},
|
L10n.of(context).emojis,
|
||||||
onKeysPressed: controller.emojiPickerAction,
|
controller.emojiPickerAction,
|
||||||
helpLabel: L10n.of(context).emojis,
|
isAltPressed: true,
|
||||||
|
),
|
||||||
|
],
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
tooltip: L10n.of(context).emojis,
|
tooltip: L10n.of(context).emojis,
|
||||||
icon: PageTransitionSwitcher(
|
icon: PageTransitionSwitcher(
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import 'package:flutter/services.dart';
|
||||||
|
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:keyboard_shortcuts/keyboard_shortcuts.dart';
|
import 'package:keymap/keymap.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/config/app_config.dart';
|
import 'package:fluffychat/config/app_config.dart';
|
||||||
|
|
@ -138,13 +138,15 @@ class ChatListView extends StatelessWidget {
|
||||||
behavior: HitTestBehavior.translucent,
|
behavior: HitTestBehavior.translucent,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
body: ChatListViewBody(controller),
|
body: ChatListViewBody(controller),
|
||||||
floatingActionButton: KeyBoardShortcuts(
|
floatingActionButton: KeyboardWidget(
|
||||||
keysToPress: {
|
bindings: [
|
||||||
LogicalKeyboardKey.controlLeft,
|
KeyAction(
|
||||||
LogicalKeyboardKey.keyN,
|
LogicalKeyboardKey.keyN,
|
||||||
},
|
L10n.of(context).newChat,
|
||||||
onKeysPressed: () => context.go('/rooms/newprivatechat'),
|
() => context.go('/rooms/newprivatechat'),
|
||||||
helpLabel: L10n.of(context).newChat,
|
isControlPressed: true,
|
||||||
|
),
|
||||||
|
],
|
||||||
child: selectMode == SelectMode.normal &&
|
child: selectMode == SelectMode.normal &&
|
||||||
!controller.isSearchMode &&
|
!controller.isSearchMode &&
|
||||||
controller.activeSpaceId == null
|
controller.activeSpaceId == null
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import 'package:flutter/services.dart';
|
||||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:keyboard_shortcuts/keyboard_shortcuts.dart';
|
import 'package:keymap/keymap.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/widgets/avatar.dart';
|
import 'package:fluffychat/widgets/avatar.dart';
|
||||||
|
|
@ -166,34 +166,43 @@ class ClientChooserButton extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
...List.generate(
|
...List.generate(
|
||||||
clientCount,
|
clientCount,
|
||||||
(index) => KeyBoardShortcuts(
|
(index) => KeyboardWidget(
|
||||||
keysToPress: _buildKeyboardShortcut(index + 1),
|
bindings: [
|
||||||
helpLabel: L10n.of(context).switchToAccount(index + 1),
|
KeyAction(
|
||||||
onKeysPressed: () => _handleKeyboardShortcut(
|
LogicalKeyboardKey(0x00000000030 + index),
|
||||||
|
L10n.of(context).switchToAccount(index + 1),
|
||||||
|
() => _handleKeyboardShortcut(
|
||||||
matrix,
|
matrix,
|
||||||
index,
|
index,
|
||||||
context,
|
context,
|
||||||
),
|
),
|
||||||
|
isAltPressed: true,
|
||||||
|
),
|
||||||
|
],
|
||||||
child: const SizedBox.shrink(),
|
child: const SizedBox.shrink(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
KeyBoardShortcuts(
|
KeyboardWidget(
|
||||||
keysToPress: {
|
bindings: [
|
||||||
LogicalKeyboardKey.controlLeft,
|
KeyAction(
|
||||||
LogicalKeyboardKey.tab,
|
LogicalKeyboardKey.tab,
|
||||||
},
|
L10n.of(context).nextAccount,
|
||||||
helpLabel: L10n.of(context).nextAccount,
|
() => _nextAccount(matrix, context),
|
||||||
onKeysPressed: () => _nextAccount(matrix, context),
|
isControlPressed: true,
|
||||||
|
),
|
||||||
|
],
|
||||||
child: const SizedBox.shrink(),
|
child: const SizedBox.shrink(),
|
||||||
),
|
),
|
||||||
KeyBoardShortcuts(
|
KeyboardWidget(
|
||||||
keysToPress: {
|
bindings: [
|
||||||
LogicalKeyboardKey.controlLeft,
|
KeyAction(
|
||||||
LogicalKeyboardKey.shiftLeft,
|
|
||||||
LogicalKeyboardKey.tab,
|
LogicalKeyboardKey.tab,
|
||||||
},
|
L10n.of(context).previousAccount,
|
||||||
helpLabel: L10n.of(context).previousAccount,
|
() => _previousAccount(matrix, context),
|
||||||
onKeysPressed: () => _previousAccount(matrix, context),
|
isControlPressed: true,
|
||||||
|
isShiftPressed: true,
|
||||||
|
),
|
||||||
|
],
|
||||||
child: const SizedBox.shrink(),
|
child: const SizedBox.shrink(),
|
||||||
),
|
),
|
||||||
PopupMenuButton<Object>(
|
PopupMenuButton<Object>(
|
||||||
|
|
@ -215,17 +224,6 @@ class ClientChooserButton extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<LogicalKeyboardKey>? _buildKeyboardShortcut(int index) {
|
|
||||||
if (index > 0 && index < 10) {
|
|
||||||
return {
|
|
||||||
LogicalKeyboardKey.altLeft,
|
|
||||||
LogicalKeyboardKey(0x00000000030 + index),
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _clientSelected(
|
void _clientSelected(
|
||||||
Object object,
|
Object object,
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import 'package:flutter/services.dart';
|
||||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:keyboard_shortcuts/keyboard_shortcuts.dart';
|
import 'package:keymap/keymap.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||||
|
|
@ -52,13 +52,15 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
||||||
return Stack(
|
return Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
KeyBoardShortcuts(
|
KeyboardWidget(
|
||||||
keysToPress: {
|
bindings: [
|
||||||
LogicalKeyboardKey.controlLeft,
|
KeyAction(
|
||||||
LogicalKeyboardKey.keyI,
|
LogicalKeyboardKey.keyI,
|
||||||
},
|
L10n.of(context).chatDetails,
|
||||||
helpLabel: L10n.of(context).chatDetails,
|
_showChatDetails,
|
||||||
onKeysPressed: _showChatDetails,
|
isControlPressed: true,
|
||||||
|
),
|
||||||
|
],
|
||||||
child: const SizedBox.shrink(),
|
child: const SizedBox.shrink(),
|
||||||
),
|
),
|
||||||
PopupMenuButton<ChatPopupMenuActions>(
|
PopupMenuButton<ChatPopupMenuActions>(
|
||||||
|
|
|
||||||
29
pubspec.lock
29
pubspec.lock
|
|
@ -629,6 +629,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.2.1"
|
version: "6.2.1"
|
||||||
|
flutter_markdown:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_markdown
|
||||||
|
sha256: "04c4722cc36ec5af38acc38ece70d22d3c2123c61305d555750a091517bbe504"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.6.23"
|
||||||
flutter_math_fork:
|
flutter_math_fork:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
@ -1090,15 +1098,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.13"
|
version: "0.4.13"
|
||||||
keyboard_shortcuts:
|
keymap:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
name: keymap
|
||||||
ref: null-safety
|
sha256: "837f37bce794bb41c3a49cd122718544921afec348f34c78f6153c72b43f3c10"
|
||||||
resolved-ref: a3d4020911860ff091d90638ab708604b71d2c5a
|
url: "https://pub.dev"
|
||||||
url: "https://github.com/TheOneWithTheBraid/keyboard_shortcuts.git"
|
source: hosted
|
||||||
source: git
|
version: "0.0.92"
|
||||||
version: "0.1.4"
|
|
||||||
latlong2:
|
latlong2:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
@ -2312,14 +2319,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.2"
|
version: "2.3.2"
|
||||||
visibility_detector:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: visibility_detector
|
|
||||||
sha256: "15c54a459ec2c17b4705450483f3d5a2858e733aee893dcee9d75fd04814940d"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.3.3"
|
|
||||||
vm_service:
|
vm_service:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ dependencies:
|
||||||
image_picker: ^1.1.0
|
image_picker: ^1.1.0
|
||||||
intl: any
|
intl: any
|
||||||
just_audio: ^0.9.39
|
just_audio: ^0.9.39
|
||||||
keyboard_shortcuts: ^0.1.4
|
keymap: ^0.0.92
|
||||||
latlong2: ^0.9.1
|
latlong2: ^0.9.1
|
||||||
linkify: ^5.0.0
|
linkify: ^5.0.0
|
||||||
matrix: ^0.34.0
|
matrix: ^0.34.0
|
||||||
|
|
@ -156,10 +156,4 @@ dependency_overrides:
|
||||||
geolocator_android:
|
geolocator_android:
|
||||||
hosted: https://hanntech-gmbh.gitlab.io/free2pass/flutter-geolocator-floss
|
hosted: https://hanntech-gmbh.gitlab.io/free2pass/flutter-geolocator-floss
|
||||||
version: ^1.0.1
|
version: ^1.0.1
|
||||||
# waiting for null safety
|
|
||||||
# Upstream pull request: https://github.com/AntoineMarcel/keyboard_shortcuts/pull/13
|
|
||||||
keyboard_shortcuts:
|
|
||||||
git:
|
|
||||||
url: https://github.com/TheOneWithTheBraid/keyboard_shortcuts.git
|
|
||||||
ref: null-safety
|
|
||||||
win32: 5.5.3
|
win32: 5.5.3
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue