fullscreen: fixed overlay layout

This commit is contained in:
Thibault Deckers 2019-07-28 15:28:36 +09:00
parent 345fc71ceb
commit 801dd7c8da

View file

@ -72,6 +72,7 @@ class FullscreenBottomOverlay extends StatefulWidget {
class _FullscreenBottomOverlayState extends State<FullscreenBottomOverlay> { class _FullscreenBottomOverlayState extends State<FullscreenBottomOverlay> {
Future<Map> _detailLoader; Future<Map> _detailLoader;
ImageEntry _lastEntry;
Map _lastDetails; Map _lastDetails;
ImageEntry get entry => widget.entries[widget.index]; ImageEntry get entry => widget.entries[widget.index];
@ -97,8 +98,6 @@ class _FullscreenBottomOverlayState extends State<FullscreenBottomOverlay> {
final innerPadding = EdgeInsets.all(8.0); final innerPadding = EdgeInsets.all(8.0);
final mediaQuery = MediaQuery.of(context); final mediaQuery = MediaQuery.of(context);
final overlayContentMaxWidth = mediaQuery.size.width - mediaQuery.viewPadding.horizontal - innerPadding.horizontal; final overlayContentMaxWidth = mediaQuery.size.width - mediaQuery.viewPadding.horizontal - innerPadding.horizontal;
final date = entry.getBestDate();
final subRowWidth = min(400.0, overlayContentMaxWidth);
return Blurred( return Blurred(
child: IgnorePointer( child: IgnorePointer(
child: Padding( child: Padding(
@ -106,7 +105,41 @@ class _FullscreenBottomOverlayState extends State<FullscreenBottomOverlay> {
child: Container( child: Container(
padding: innerPadding, padding: innerPadding,
color: kOverlayBackground, color: kOverlayBackground,
child: DefaultTextStyle( child: FutureBuilder(
future: _detailLoader,
builder: (futureContext, AsyncSnapshot<Map> snapshot) {
if (snapshot.connectionState == ConnectionState.done && !snapshot.hasError) {
_lastDetails = snapshot.data;
_lastEntry = entry;
}
return _lastEntry == null
? SizedBox.shrink()
: _FullscreenBottomOverlayContent(
entry: _lastEntry,
details: _lastDetails,
maxWidth: overlayContentMaxWidth,
);
},
),
),
),
),
);
}
}
class _FullscreenBottomOverlayContent extends StatelessWidget {
final ImageEntry entry;
final Map details;
final double maxWidth;
_FullscreenBottomOverlayContent({this.entry, this.details, this.maxWidth});
@override
Widget build(BuildContext context) {
final subRowWidth = min(400.0, maxWidth);
final date = entry.getBestDate();
return DefaultTextStyle(
style: TextStyle( style: TextStyle(
shadows: [ shadows: [
Shadow( Shadow(
@ -120,7 +153,7 @@ class _FullscreenBottomOverlayState extends State<FullscreenBottomOverlay> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SizedBox( SizedBox(
width: overlayContentMaxWidth, width: maxWidth,
child: Text( child: Text(
entry.title, entry.title,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
@ -138,35 +171,23 @@ class _FullscreenBottomOverlayState extends State<FullscreenBottomOverlay> {
], ],
), ),
), ),
if (details != null && details.isNotEmpty) ...[
SizedBox(height: 4), SizedBox(height: 4),
FutureBuilder( SizedBox(
future: _detailLoader,
builder: (futureContext, AsyncSnapshot<Map> snapshot) {
if (snapshot.connectionState == ConnectionState.done && !snapshot.hasError) {
_lastDetails = snapshot.data;
}
return (_lastDetails == null || _lastDetails.isEmpty)
? SizedBox.shrink()
: SizedBox(
width: subRowWidth, width: subRowWidth,
child: Row( child: Row(
children: [ children: [
Icon(Icons.camera, size: 16), Icon(Icons.camera, size: 16),
SizedBox(width: 8), SizedBox(width: 8),
Expanded(child: Text((_lastDetails['aperture'] as String).replaceAll('f', 'ƒ'))), Expanded(child: Text((details['aperture'] as String).replaceAll('f', 'ƒ'))),
Expanded(child: Text(_lastDetails['exposureTime'])), Expanded(child: Text(details['exposureTime'])),
Expanded(child: Text(_lastDetails['focalLength'])), Expanded(child: Text(details['focalLength'])),
Expanded(child: Text(_lastDetails['iso'])), Expanded(child: Text(details['iso'])),
],
),
);
},
)
], ],
), ),
), ),
), ],
), ],
), ),
); );
} }