From 4de4664f7cc984af2c1b1fc92f45565aabe7e076 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Sat, 27 Jul 2019 18:37:08 +0900 Subject: [PATCH] fullscreen: fixed overlay layout --- lib/image_fullscreen_overlay.dart | 129 ++++++++++++++++-------------- 1 file changed, 71 insertions(+), 58 deletions(-) diff --git a/lib/image_fullscreen_overlay.dart b/lib/image_fullscreen_overlay.dart index 61f57203e..51f1f2da0 100644 --- a/lib/image_fullscreen_overlay.dart +++ b/lib/image_fullscreen_overlay.dart @@ -1,3 +1,6 @@ +import 'dart:math'; +import 'dart:ui'; + import 'package:aves/model/image_entry.dart'; import 'package:aves/model/image_fetcher.dart'; import 'package:flutter/material.dart'; @@ -39,67 +42,77 @@ class _FullscreenOverlayState extends State { @override Widget build(BuildContext context) { - final viewInsets = MediaQuery.of(context).viewInsets; + var mediaQuery = MediaQuery.of(context); + final screenWidth = mediaQuery.size.width; + final viewInsets = mediaQuery.viewInsets; final date = ImageEntry.getBestDate(entry); - final subRowConstraints = BoxConstraints(maxWidth: 400); - return IgnorePointer( - child: Container( - padding: EdgeInsets.all(8.0).add(EdgeInsets.only(bottom: viewInsets.bottom)), - color: Colors.black45, - child: DefaultTextStyle( - style: TextStyle( - shadows: [ - Shadow( - color: Colors.black87, - offset: Offset(0.0, 1.0), - ) - ], - ), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - '${widget.index + 1}/$total – ${entry['title']}', - overflow: TextOverflow.ellipsis, + final subRowWidth = min(400.0, screenWidth); + return ClipRect( + child: BackdropFilter( + filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5), + child: IgnorePointer( + child: Container( + padding: EdgeInsets.all(8.0).add(EdgeInsets.only(bottom: viewInsets.bottom)), + color: Colors.black26, + child: DefaultTextStyle( + style: TextStyle( + shadows: [ + Shadow( + color: Colors.black87, + offset: Offset(0.0, 1.0), + ) + ], ), - SizedBox(height: 4), - ConstrainedBox( - constraints: subRowConstraints, - child: Row( - children: [ - Icon(Icons.calendar_today, size: 16), - SizedBox(width: 8), - Expanded(child: Text('${DateFormat.yMMMd().format(date)} – ${DateFormat.Hm().format(date)}')), - Expanded(child: Text('${entry['width']} × ${entry['height']}')), - ], - ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: screenWidth, + child: Text( + '${widget.index + 1}/$total – ${entry['title']}', + overflow: TextOverflow.ellipsis, + ), + ), + SizedBox(height: 4), + SizedBox( + width: subRowWidth, + child: Row( + children: [ + Icon(Icons.calendar_today, size: 16), + SizedBox(width: 8), + Expanded(child: Text('${DateFormat.yMMMd().format(date)} – ${DateFormat.Hm().format(date)}')), + Expanded(child: Text('${entry['width']} × ${entry['height']}')), + ], + ), + ), + SizedBox(height: 4), + FutureBuilder( + future: _detailLoader, + builder: (futureContext, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done && !snapshot.hasError) { + _lastDetails = snapshot.data; + } + return (_lastDetails == null || _lastDetails.isEmpty) + ? Text('') + : SizedBox( + width: subRowWidth, + child: Row( + children: [ + Icon(Icons.camera, size: 16), + SizedBox(width: 8), + Expanded(child: Text((_lastDetails['aperture'] as String).replaceAll('f', 'ƒ'))), + Expanded(child: Text(_lastDetails['exposureTime'])), + Expanded(child: Text(_lastDetails['focalLength'])), + Expanded(child: Text(_lastDetails['iso'])), + ], + ), + ); + }, + ) + ], ), - SizedBox(height: 4), - FutureBuilder( - future: _detailLoader, - builder: (futureContext, AsyncSnapshot snapshot) { - if (snapshot.connectionState == ConnectionState.done && !snapshot.hasError) { - _lastDetails = snapshot.data; - } - return (_lastDetails == null || _lastDetails.isEmpty) - ? Text('') - : ConstrainedBox( - constraints: subRowConstraints, - child: Row( - children: [ - Icon(Icons.camera, size: 16), - SizedBox(width: 8), - Expanded(child: Text((_lastDetails['aperture'] as String).replaceAll('f', 'ƒ'))), - Expanded(child: Text(_lastDetails['exposureTime'])), - Expanded(child: Text(_lastDetails['focalLength'])), - Expanded(child: Text(_lastDetails['iso'])), - ], - ), - ); - }, - ) - ], + ), ), ), ),