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