Skip to content

Commit e54a78a

Browse files
committed
[green] preserve landscape editing space above the keyboard
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th>
1 parent d1f8719 commit e54a78a

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

‎app/lib/app/shell.dart‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ class _LandscapeShell extends ConsumerWidget {
220220
final bool filesCollapsed = ref.watch(filesPaneCollapsedProvider);
221221
final bool blocksFocused = selected == AppSurface.blocks;
222222
final bool blocksConsoleExpanded = ref.watch(blocksConsoleExpandedProvider);
223+
final bool keyboardVisible = MediaQuery.viewInsetsOf(context).bottom > 0;
223224
final AppLocalizations l10n = AppLocalizations.of(context);
224225

225226
final AppSurface centre = _centreSurface(selected);
@@ -331,8 +332,17 @@ class _LandscapeShell extends ConsumerWidget {
331332
),
332333
const Divider(height: 1),
333334
ConsoleStripView(
334-
collapsed: blocksFocused && !blocksConsoleExpanded,
335-
onToggle: blocksFocused
335+
collapsed:
336+
keyboardVisible || (blocksFocused && !blocksConsoleExpanded),
337+
onToggle: keyboardVisible
338+
? () {
339+
if (blocksFocused) {
340+
ref.read(blocksConsoleExpandedProvider.notifier).state =
341+
true;
342+
}
343+
FocusScope.of(context).unfocus();
344+
}
345+
: blocksFocused
336346
? () {
337347
ref.read(blocksConsoleExpandedProvider.notifier).state =
338348
!blocksConsoleExpanded;
@@ -410,6 +420,7 @@ class _SurfaceRail extends ConsumerWidget {
410420
);
411421
final int selectedIndex = _ideNavSurfaces.indexOf(selected);
412422
return NavigationRail(
423+
scrollable: true,
413424
selectedIndex: selectedIndex < 0 ? 0 : selectedIndex,
414425
labelType: NavigationRailLabelType.all,
415426
onDestinationSelected: (int index) {

‎app/test/widget/app_shell_test.dart‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ void main() {
115115
await tester.pumpAndSettle();
116116

117117
expect(tester.takeException(), isNull);
118-
expect(tester.getSize(editor).height, greaterThanOrEqualTo(80));
118+
final Finder viewport = find.byWidgetPredicate(
119+
(Widget widget) => widget is EditorSurface,
120+
);
121+
expect(tester.getSize(viewport).height, greaterThanOrEqualTo(80));
119122
expect(tester.getRect(editor).bottom, lessThanOrEqualTo(800 - inset));
120123
expect(
121124
tester
@@ -131,6 +134,10 @@ void main() {
131134
await tester.ensureVisible(blocks);
132135
expect(blocks.hitTestable(), findsOneWidget);
133136

137+
await tester.tap(find.byTooltip('Expand console'));
138+
await tester.pump();
139+
expect(tester.widget<EditableText>(editor).focusNode.hasFocus, isFalse);
140+
134141
tester.view.resetViewInsets();
135142
await tester.pumpAndSettle();
136143
expect(tester.takeException(), isNull);

0 commit comments

Comments
 (0)