improved view insets handling

This commit is contained in:
Thibault Deckers 2019-07-22 00:40:49 +09:00
parent 55ad742847
commit 033f979fb3
2 changed files with 45 additions and 55 deletions

View file

@ -39,11 +39,7 @@ class ImageFullscreenPageState extends State<ImageFullscreenPage> {
@override
Widget build(BuildContext context) {
return MediaQuery.removeViewInsets(
context: context,
// remove bottom view insets to paint underneath the translucent navigation bar
removeBottom: true,
child: Scaffold(
return Scaffold(
backgroundColor: Colors.black,
body: Stack(
alignment: Alignment.bottomCenter,
@ -78,6 +74,7 @@ class ImageFullscreenPageState extends State<ImageFullscreenPage> {
),
],
),
resizeToAvoidBottomInset: false,
// Hero(
// tag: uri,
// child: Stack(
@ -106,7 +103,6 @@ class ImageFullscreenPageState extends State<ImageFullscreenPage> {
// ],
// ),
// ),
),
);
}
}
@ -119,22 +115,20 @@ class FullscreenOverlay extends StatelessWidget {
@override
Widget build(BuildContext context) {
debugPrint('FullscreenOverlay MediaQuery.of(context)=${MediaQuery.of(context)}');
// TODO TLAD find actual value from MediaQuery before insets removal
var viewInsetsBottom = 46.0;
var viewInsets = MediaQuery.of(context).viewInsets;
var date = ImageEntry.getBestDate(entry);
return IgnorePointer(
child: Container(
padding: EdgeInsets.all(8.0).add(EdgeInsets.only(bottom: viewInsetsBottom)),
padding: EdgeInsets.all(8.0).add(EdgeInsets.only(bottom: viewInsets.bottom)),
color: Colors.black45,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('$index / $total - ${entry['title']}'),
Text('${index + 1} / $total - ${entry['title']}'),
Row(
children: [
Expanded(child: Text('${DateFormat.yMMMMd().format(date)} ${DateFormat.Hm().format(date)}')),
Expanded(child: Text('${DateFormat.yMMMd().format(date)} ${DateFormat.Hm().format(date)}')),
Expanded(child: Text('${entry['width']} × ${entry['height']}')),
],
),

View file

@ -44,21 +44,17 @@ class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
debugPrint('MediaQuery.of(context).viewInsets.bottom=${MediaQuery.of(context).viewInsets.bottom}');
return MediaQuery.removeViewInsets(
context: context,
// remove bottom view insets to paint underneath the translucent navigation bar
removeBottom: true,
child: Scaffold(
return Scaffold(
// fake app bar so that content is safe from status bar, even though we use a SliverAppBar
appBar: FakeAppBar(),
body: imageEntryList == null
body: Container(
child: imageEntryList == null
? Center(
child: CircularProgressIndicator(),
)
: ThumbnailCollection(imageEntryList),
),
resizeToAvoidBottomInset: false,
);
}
}