Skip to content

Commit

Permalink
Experimental support for haptic feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
PaperCube committed Feb 16, 2024
1 parent 6b41459 commit 1d8f6be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.VIBRATE" />

<application
android:label="ServerBox"
Expand Down
1 change: 1 addition & 0 deletions lib/core/utils/platform/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ final isWeb = OS.type == OS.web;
final isMobile = OS.type == OS.ios || OS.type == OS.android;
final isDesktop =
OS.type == OS.linux || OS.type == OS.macos || OS.type == OS.windows;
const isDebuggingMobileLayoutOnDesktop = kDebugMode;
8 changes: 6 additions & 2 deletions lib/view/page/ssh/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
_terminalTheme = _isDark ? TerminalThemes.dark : TerminalThemes.light;

// Because the virtual keyboard only displayed on mobile devices
if (isMobile) {
if (isMobile || isDebuggingMobileLayoutOnDesktop) {
_virtKeyWidth = _media.size.width / 7;
_virtKeysHeight = _media.size.height * 0.043 * _virtKeysList.length;
}
Expand All @@ -118,7 +118,9 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
Widget child = Scaffold(
backgroundColor: _terminalTheme.background,
body: _buildBody(),
bottomNavigationBar: isDesktop ? null : _buildBottom(),
bottomNavigationBar: isDesktop && !isDebuggingMobileLayoutOnDesktop
? null
: _buildBottom(),
);
if (isIOS) {
child = AnnotatedRegion(
Expand Down Expand Up @@ -232,10 +234,12 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {

void _doVirtualKey(VirtKey item) {
if (item.func != null) {
HapticFeedback.mediumImpact();
_doVirtualKeyFunc(item.func!);
return;
}
if (item.key != null) {
HapticFeedback.mediumImpact();
_doVirtualKeyInput(item.key!);
}
}
Expand Down

0 comments on commit 1d8f6be

Please sign in to comment.