fix(mobile): keep file manager bottom sheet above system navigation bar (#17393)

This commit is contained in:
Xzar authored and GitHub committed 2026-12-04 11:36:13 +08:00
1 parent b67c5279f9
commit 26f17dff05
2 files changed
+121 -28

No files matched your search

+52 -28
View File
@@ -1015,40 +1015,64 @@ class BottomSheetBody extends StatelessWidget {
final _actions = actions ?? [];
return BottomSheet(
builder: (BuildContext context) {
final mediaQuery = MediaQuery.of(context);
final view = View.maybeOf(context);
final viewBottomPadding = view != null && view.devicePixelRatio > 0
? view.padding.bottom / view.devicePixelRatio
: 0.0;
final bottomInset = mediaQuery.padding.bottom > viewBottomPadding
? mediaQuery.padding.bottom
: viewBottomPadding;
return Container(
height: 65,
alignment: Alignment.centerLeft,
decoration: BoxDecoration(
color: MyTheme.accent50,
borderRadius: BorderRadius.vertical(top: Radius.circular(10))),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
leading,
SizedBox(width: 16),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
child: SafeArea(
top: false,
minimum: EdgeInsets.only(bottom: bottomInset),
child: Container(
height: 65,
alignment: Alignment.centerLeft,
padding: EdgeInsets.symmetric(horizontal: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Row(
children: [
Text(title, style: TextStyle(fontSize: 18)),
Text(text,
style: TextStyle(fontSize: 14)) // TODO color
leading,
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 18)),
Text(text,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 14)) // TODO color
],
),
)
],
)
],
),
Row(children: () {
_actions.add(IconButton(
icon: Icon(Icons.cancel_outlined),
onPressed: onCanceled,
));
return _actions;
}())
],
),
),
Row(
mainAxisSize: MainAxisSize.min,
children: [
..._actions,
IconButton(
icon: Icon(Icons.cancel_outlined),
onPressed: onCanceled,
),
],
)
],
),
),
));
},
@@ -0,0 +1,69 @@
import 'package:flutter/material.dart';
import 'package:flutter_hbb/mobile/pages/file_manager_page.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
Widget buildSubject({
VoidCallback? onCanceled,
List<IconButton>? actions,
}) {
return MaterialApp(
home: Scaffold(
bottomSheet: BottomSheetBody(
leading: const Icon(Icons.check),
title: 'Wybrano',
text: '1 elementów [Lokalny]',
onCanceled: onCanceled,
actions: actions,
),
),
);
}
testWidgets('keeps action buttons above bottom system navigation bar',
(tester) async {
tester.view.physicalSize = const Size(360, 800);
tester.view.devicePixelRatio = 1.0;
tester.view.padding = const FakeViewPadding(bottom: 48);
tester.view.viewPadding = const FakeViewPadding(bottom: 48);
addTearDown(tester.view.reset);
var canceled = false;
await tester.pumpWidget(buildSubject(
onCanceled: () => canceled = true,
actions: [
IconButton(icon: const Icon(Icons.save_alt), onPressed: () {}),
IconButton(icon: const Icon(Icons.compare_arrows), onPressed: () {}),
IconButton(icon: const Icon(Icons.delete_forever), onPressed: () {}),
],
));
expect(tester.takeException(), isNull);
expect(tester.getSize(find.byType(BottomSheetBody)).height, 113.0);
for (final icon in const [
Icons.save_alt,
Icons.compare_arrows,
Icons.delete_forever,
Icons.cancel_outlined,
]) {
expect(tester.getBottomRight(find.byIcon(icon)).dy,
lessThanOrEqualTo(752.0));
}
await tester.tap(find.byIcon(Icons.cancel_outlined));
await tester.pump();
expect(canceled, isTrue);
});
testWidgets('preserves default height when bottom inset is zero',
(tester) async {
tester.view.physicalSize = const Size(360, 800);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.reset);
await tester.pumpWidget(buildSubject());
expect(tester.takeException(), isNull);
expect(tester.getSize(find.byType(BottomSheetBody)).height, 65.0);
});
}