Skip to content

Commit 2536e17

Browse files
committed
fix(mobile): extend Duo terminal keyboard toolbar across the rail
1 parent c4fa462 commit 2536e17

2 files changed

Lines changed: 55 additions & 3 deletions

File tree

‎apps/mobile/src/Stack.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ const SOLID_HEADER_OPTIONS: AppScreenOptions = {
194194
unstable_navigationItemStyle: Platform.OS === "ios" ? "editor" : undefined,
195195
};
196196

197+
const TERMINAL_SCREEN_OPTIONS = {
198+
...SOLID_HEADER_OPTIONS,
199+
nativeContentInsetHorizontally: false,
200+
};
201+
197202
const SHEET_SOLID_HEADER_OPTIONS: AppScreenOptions = {
198203
...SOLID_HEADER_OPTIONS,
199204
unstable_navigationItemStyle: undefined,
@@ -819,7 +824,7 @@ const RootStackConfig = createWorkspaceStackNavigator({
819824
ThreadTerminal: createNativeStackScreen({
820825
screen: ThreadTerminalRouteScreen,
821826
linking: `${THREAD_LINKING_PREFIX}/terminal`,
822-
options: SOLID_HEADER_OPTIONS,
827+
options: TERMINAL_SCREEN_OPTIONS,
823828
}),
824829
ThreadDevicePreview: createNativeStackScreen({
825830
screen: DevicePreviewRouteScreen,

‎apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx‎

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,39 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)
585585
height: state.height,
586586
isVisible: state.isVisible,
587587
}));
588+
const accessoryInsets = { left: insets.left, right: insets.right };
589+
if (
590+
Platform.OS === "ios" &&
591+
nativeColumnMetrics?.hasHinge &&
592+
nativeColumnMetrics.verticalBarEdge !== "none" &&
593+
// In short landscape columns, UIKit's floating tabs sit beside this row.
594+
nativeColumnMetrics.width < nativeColumnMetrics.height
595+
) {
596+
const edge = nativeColumnMetrics.verticalBarEdge;
597+
const top = nativeColumnMetrics.height - keyboardState.height - TERMINAL_ACCESSORY_HEIGHT;
598+
// UIKit reserves the whole rail in its safe area. At keyboard height, keep
599+
// clearance only for occlusions that actually overlap the accessory row.
600+
accessoryInsets[edge] = 0;
601+
for (const region of nativeColumnMetrics.reservedRegions) {
602+
if (
603+
region.kind !== "occlusion" ||
604+
region.y >= top + TERMINAL_ACCESSORY_HEIGHT ||
605+
region.y + region.height <= top
606+
)
607+
continue;
608+
if (edge === "left" && region.x < insets.left) {
609+
accessoryInsets.left = Math.max(accessoryInsets.left, region.x + region.width);
610+
} else if (
611+
edge === "right" &&
612+
region.x + region.width > nativeColumnMetrics.width - insets.right
613+
) {
614+
accessoryInsets.right = Math.max(
615+
accessoryInsets.right,
616+
nativeColumnMetrics.width - region.x,
617+
);
618+
}
619+
}
620+
}
588621
const isAccessoryVisible = canOperateTerminal && keyboardState.isVisible && !isAccessoryDismissed;
589622
// Android's terminal owns an EditText; turning off autoFocus also clears its native focus.
590623
const terminalAutoFocus =
@@ -1173,6 +1206,8 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)
11731206
// reservation is zero when UIKit has already inset the body or moved the bar.
11741207
paddingTop:
11751208
Platform.OS === "ios" ? (nativeColumnMetrics?.safeArea.top ?? insets.top) : 0,
1209+
paddingLeft: Platform.OS === "ios" ? insets.left : 0,
1210+
paddingRight: Platform.OS === "ios" ? insets.right : 0,
11761211
paddingBottom:
11771212
Platform.OS === "android" && !keyboardState.isVisible ? insets.bottom : 0,
11781213
}}
@@ -1304,7 +1339,19 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)
13041339
minHeight: TERMINAL_ACCESSORY_HEIGHT,
13051340
}}
13061341
>
1307-
<ComposerToolbarRow paddingBottom={4} paddingHorizontal={8} paddingTop={4}>
1342+
<ComposerToolbarRow
1343+
paddingBottom={4}
1344+
paddingHorizontal={8}
1345+
paddingTop={4}
1346+
style={
1347+
Platform.OS === "ios"
1348+
? {
1349+
paddingLeft: 8 + accessoryInsets.left,
1350+
paddingRight: 8 + accessoryInsets.right,
1351+
}
1352+
: undefined
1353+
}
1354+
>
13081355
<ComposerToolbarScroller
13091356
contentPaddingRight={2}
13101357
fadeOpaque={terminalTheme.background}
@@ -1351,7 +1398,7 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)
13511398
borderRadius: 28,
13521399
opacity: pressed ? 0.72 : 1,
13531400
position: "absolute",
1354-
right: 16,
1401+
right: 16 + insets.right,
13551402
})}
13561403
>
13571404
<GlassSurface

0 commit comments

Comments
 (0)