Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions lib/view/page/bmc/credential/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,19 @@ class BmcCredentialsListPage extends ConsumerWidget {

return Scaffold(
body: SafeArea(
bottom: false,
child: creds.isEmpty
? Center(child: Text(libL10n.empty))
: PageColumns(
bottomInset: MediaQuery.paddingOf(context).bottom + 72,
children: [
for (final cred in creds) _buildItem(context, ref, cred),
],
),
),
floatingActionButton: SafeArea(
top: false,
left: false,
right: false,
child: FloatingActionButton(
onPressed: () => BmcCredentialEditPage.route.go(context),
child: const Icon(Icons.add),
),
floatingActionButton: FloatingActionButton(
onPressed: () => BmcCredentialEditPage.route.go(context),
child: const Icon(Icons.add),
),
);
}
Expand Down
18 changes: 8 additions & 10 deletions lib/view/page/private_key/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,10 @@ class _PrivateKeyListState extends ConsumerState<PrivateKeysListPage>
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(child: _buildBody()),
floatingActionButton: SafeArea(
top: false,
left: false,
right: false,
child: FloatingActionButton(
onPressed: _onTapAdd,
child: const Icon(Icons.add),
),
body: SafeArea(bottom: false, child: _buildBody()),
floatingActionButton: FloatingActionButton(
onPressed: _onTapAdd,
child: const Icon(Icons.add),
),
);
}
Expand All @@ -46,7 +41,10 @@ class _PrivateKeyListState extends ConsumerState<PrivateKeysListPage>
}

final children = pkis.map(_buildKeyItem).toList();
return PageColumns(children: children);
return PageColumns(
bottomInset: MediaQuery.paddingOf(context).bottom + 72,
children: children,
);
}

Widget _buildKeyItem(PrivateKeyInfo item) {
Expand Down
5 changes: 5 additions & 0 deletions lib/view/page/setting/layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ extension _SettingsLayout on _SettingsPageState {
padding: mediaQuery.padding.copyWith(
bottom: mediaQuery.padding.bottom + space,
),
// Nested Scaffolds strip `padding` from `floatingActionButton` and
// position the FAB from `viewPadding.bottom`, so keep both aligned.
viewPadding: mediaQuery.viewPadding.copyWith(
bottom: mediaQuery.padding.bottom + space,
),
),
child: content,
),
Expand Down
19 changes: 6 additions & 13 deletions lib/view/page/setting/level.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dart:math' as math;
import 'dart:ui' show ImageFilter;

import 'package:fl_lib/fl_lib.dart';
Expand Down Expand Up @@ -126,21 +125,15 @@ final class SettingsTabs extends StatelessWidget {
// A level wider than the window ends at the window's edge, and a tab cut
// off square there reads as the last one rather than as one of several
// more — hence [EdgeFadeScroll] around it, which says the bar carries on.
return EdgeFadeScroll(
builder: (context, controller) => LayoutBuilder(
builder: (context, constraints) => SingleChildScrollView(
return Align(
alignment: Alignment.bottomCenter,
heightFactor: 1,
child: EdgeFadeScroll(
builder: (context, controller) => SingleChildScrollView(
controller: controller,
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.all(kSettingsTabsMargin),
child: ConstrainedBox(
constraints: BoxConstraints(
minWidth: math.max(0, constraints.maxWidth - kSettingsTabsMargin * 2),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [bar],
),
),
child: bar,
),
),
);
Expand Down
13 changes: 5 additions & 8 deletions lib/view/page/ssh/proxy/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,19 @@ class SshProxiesListPage extends ConsumerWidget {

return Scaffold(
body: SafeArea(
bottom: false,
child: proxies.isEmpty
? Center(child: Text(libL10n.empty))
: PageColumns(
bottomInset: MediaQuery.paddingOf(context).bottom + 72,
children: [
for (final proxy in proxies) _buildItem(context, ref, proxy),
],
),
),
floatingActionButton: SafeArea(
top: false,
left: false,
right: false,
child: FloatingActionButton(
onPressed: () => SshProxyEditPage.route.go(context),
child: const Icon(Icons.add),
),
floatingActionButton: FloatingActionButton(
onPressed: () => SshProxyEditPage.route.go(context),
child: const Icon(Icons.add),
),
);
}
Expand Down
103 changes: 102 additions & 1 deletion test/widget/settings_menu_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,18 @@ void main() {
Future<void> pump(
WidgetTester tester, {
required double width,
double height = 900,
FakeViewPadding? padding,
bool reduceMotion = false,
ThemeData? theme,
bool rail = true,
}) async {
tester.view.devicePixelRatio = 1;
tester.view.physicalSize = Size(width, 900);
tester.view.physicalSize = Size(width, height);
if (padding != null) {
tester.view.padding = padding;
tester.view.viewPadding = padding;
}
addTearDown(tester.view.reset);

await tester.pumpWidget(
Expand Down Expand Up @@ -1305,4 +1311,99 @@ void main() {
}
},
);

testWidgets(
'credentials FABs clear the floating settings tabs and open on tap (#2050)',
(tester) async {
await pump(
tester,
width: 400,
padding: const FakeViewPadding(bottom: 34),
);
await tester.tap(menuRow(l10n.settingsCredentials));
await settle(tester, 20);

final tabsTop = tester.getTopLeft(find.byKey(settingsTabsKey)).dy;
final fab = find.byType(FloatingActionButton);
expect(fab, findsOneWidget);
final fabBottom = tester.getBottomRight(fab).dy;
expect(fabBottom, lessThan(tabsTop));
// Outer SafeArea already cleared the 34px bottom inset, so the gap above
// the pill stays at kSettingsTabsMargin + kFloatingActionButtonMargin
// (~28px) instead of double-counting the home indicator.
expect(tabsTop - fabBottom, lessThan(40));

await tester.tap(fab);
await settle(tester, 20);
expect(find.text(l10n.sshKeyGenerate), findsOneWidget);
expect(find.text(libL10n.import), findsOneWidget);

// Dismiss sheet and verify sibling tabs with FABs also clear the bar.
Navigator.of(tester.element(find.text(l10n.sshKeyGenerate))).pop();
await settle(tester, 20);

for (final tab in [l10n.sshProxies, l10n.bmcAccounts]) {
await tester.ensureVisible(tabRow(tab));
await settle(tester, 10);
await tester.tap(tabRow(tab));
await settle(tester, 20);
final currentFab = find.byType(FloatingActionButton);
expect(currentFab, findsOneWidget);
expect(
tester.getBottomRight(currentFab).dy,
lessThan(tester.getTopLeft(find.byKey(settingsTabsKey)).dy),
reason: '$tab FAB must clear the floating SettingsTabs bar',
);
}
},
);

testWidgets(
'narrow landscape SettingsTabs lets side taps pass through and FAB opens',
(tester) async {
await pump(tester, width: 700, height: 400);
await tester.scrollUntilVisible(
menuRow(l10n.settingsCredentials),
150,
scrollable: find
.descendant(
of: find.byKey(settingsMenuKey),
matching: find.byType(Scrollable),
)
.first,
);
await tester.ensureVisible(menuRow(l10n.settingsCredentials));
await settle(tester, 5);
await tester.tap(menuRow(l10n.settingsCredentials));
await settle(tester, 20);

final pillRect = tester.getRect(find.byKey(settingsTabsKey));
final scroll = find.descendant(
of: find.byType(EdgeFadeScroll),
matching: find.byType(SingleChildScrollView),
);
expect(scroll, findsOneWidget);
expect(tester.getSize(scroll).width, lessThan(700));
expect(tester.getSize(scroll).width, closeTo(pillRect.width + 24, 1));

// Hit-tests beside the pill at the bar's vertical center must not be
// swallowed by SettingsTabs's scroll view.
final scrollRender = tester.renderObject(scroll);
for (final x in [12.0, 700.0 - 12.0]) {
final result = tester.hitTestOnBinding(Offset(x, pillRect.center.dy));
expect(
result.path.any((entry) => identical(entry.target, scrollRender)),
isFalse,
reason: 'side tap at x=$x must pass through past SettingsTabs',
);
}

final fab = find.byType(FloatingActionButton);
expect(fab, findsOneWidget);
expect(tester.getBottomRight(fab).dy, lessThan(pillRect.top));
await tester.tap(fab);
await settle(tester, 20);
expect(find.text(l10n.sshKeyGenerate), findsOneWidget);
},
);
}
Loading