fullscreen: fixed scaffold and snackbar

This commit is contained in:
Thibault Deckers 2019-08-15 14:21:29 +09:00
parent c78241e204
commit a3ac7d8f22
3 changed files with 91 additions and 84 deletions

View file

@ -7,6 +7,7 @@ import 'package:aves/widgets/fullscreen/info/info_page.dart';
import 'package:aves/widgets/fullscreen/overlay_bottom.dart'; import 'package:aves/widgets/fullscreen/overlay_bottom.dart';
import 'package:aves/widgets/fullscreen/overlay_top.dart'; import 'package:aves/widgets/fullscreen/overlay_top.dart';
import 'package:aves/widgets/fullscreen/video.dart'; import 'package:aves/widgets/fullscreen/video.dart';
import 'package:flushbar/flushbar.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -38,6 +39,35 @@ class FullscreenPage extends StatelessWidget {
entries: entries, entries: entries,
initialUri: initialUri, initialUri: initialUri,
), ),
resizeToAvoidBottomInset: false,
// Hero(
// tag: uri,
// child: Stack(
// children: [
// Center(
// child: widget.thumbnail == null
// ? CircularProgressIndicator()
// : Image.memory(
// widget.thumbnail,
// width: requestWidth,
// height: requestHeight,
// fit: BoxFit.contain,
// ),
// ),
// Center(
// child: FadeInImage(
// placeholder: MemoryImage(kTransparentImage),
// image: FileImage(File(path)),
// fadeOutDuration: Duration(milliseconds: 1),
// fadeInDuration: Duration(milliseconds: 200),
// width: requestWidth,
// height: requestHeight,
// fit: BoxFit.contain,
// ),
// ),
// ],
// ),
// ),
), ),
); );
} }
@ -110,92 +140,53 @@ class FullscreenBodyState extends State<FullscreenBody> with SingleTickerProvide
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final entry = entries[_currentHorizontalPage]; final entry = entries[_currentHorizontalPage];
return WillPopScope( return Stack(
onWillPop: () { children: [
Screen.keepOn(false); PageView(
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values); scrollDirection: Axis.vertical,
return Future.value(true); controller: _verticalPager,
}, physics: _isInitialScale ? PageScrollPhysics() : NeverScrollableScrollPhysics(),
child: Scaffold( onPageChanged: (page) => setState(() => _currentVerticalPage = page),
backgroundColor: Colors.black,
body: Stack(
children: [ children: [
PageView( ImagePage(
scrollDirection: Axis.vertical, entries: entries,
controller: _verticalPager, pageController: _horizontalPager,
physics: _isInitialScale ? PageScrollPhysics() : NeverScrollableScrollPhysics(), onTap: () => _overlayVisible.value = !_overlayVisible.value,
onPageChanged: (page) => setState(() => _currentVerticalPage = page), onPageChanged: (page) => setState(() => _currentHorizontalPage = page),
children: [ onScaleChanged: (state) => setState(() => _isInitialScale = state == PhotoViewScaleState.initial),
ImagePage( ),
entries: entries, NotificationListener(
pageController: _horizontalPager, onNotification: (notification) {
onTap: () => _overlayVisible.value = !_overlayVisible.value, if (notification is BackUpNotification) goToVerticalPage(0);
onPageChanged: (page) => setState(() => _currentHorizontalPage = page), return false;
onScaleChanged: (state) => setState(() => _isInitialScale = state == PhotoViewScaleState.initial), },
), child: InfoPage(entry: entry),
NotificationListener(
onNotification: (notification) {
if (notification is BackUpNotification) goToVerticalPage(0);
return false;
},
child: InfoPage(entry: entry),
),
],
), ),
if (_currentHorizontalPage != null && _currentVerticalPage == 0) ...[
FullscreenTopOverlay(
entries: entries,
index: _currentHorizontalPage,
scale: _topOverlayScale,
viewInsets: _frozenViewInsets,
viewPadding: _frozenViewPadding,
onActionSelected: (action) => onActionSelected(entry, action),
),
Positioned(
bottom: 0,
child: SlideTransition(
position: _bottomOverlayOffset,
child: FullscreenBottomOverlay(
entries: entries,
index: _currentHorizontalPage,
viewInsets: _frozenViewInsets,
viewPadding: _frozenViewPadding,
),
),
)
]
], ],
), ),
resizeToAvoidBottomInset: false, if (_currentHorizontalPage != null && _currentVerticalPage == 0) ...[
// Hero( FullscreenTopOverlay(
// tag: uri, entries: entries,
// child: Stack( index: _currentHorizontalPage,
// children: [ scale: _topOverlayScale,
// Center( viewInsets: _frozenViewInsets,
// child: widget.thumbnail == null viewPadding: _frozenViewPadding,
// ? CircularProgressIndicator() onActionSelected: (action) => onActionSelected(entry, action),
// : Image.memory( ),
// widget.thumbnail, Positioned(
// width: requestWidth, bottom: 0,
// height: requestHeight, child: SlideTransition(
// fit: BoxFit.contain, position: _bottomOverlayOffset,
// ), child: FullscreenBottomOverlay(
// ), entries: entries,
// Center( index: _currentHorizontalPage,
// child: FadeInImage( viewInsets: _frozenViewInsets,
// placeholder: MemoryImage(kTransparentImage), viewPadding: _frozenViewPadding,
// image: FileImage(File(path)), ),
// fadeOutDuration: Duration(milliseconds: 1), ),
// fadeInDuration: Duration(milliseconds: 200), )
// width: requestWidth, ]
// height: requestHeight, ],
// fit: BoxFit.contain,
// ),
// ),
// ],
// ),
// ),
),
); );
} }
@ -247,8 +238,16 @@ class FullscreenBodyState extends State<FullscreenBody> with SingleTickerProvide
}); });
if (newName == null || newName.isEmpty) return; if (newName == null || newName.isEmpty) return;
final success = await entry.rename(newName); final success = await entry.rename(newName);
final snackBar = SnackBar(content: Text(success ? 'Done!' : 'Failed')); Flushbar(
Scaffold.of(context).showSnackBar(snackBar); message: success ? 'Done!' : 'Failed',
margin: EdgeInsets.all(8),
borderRadius: 8,
borderColor: Colors.white30,
borderWidth: 0.5,
duration: Duration(seconds: 2),
flushbarPosition: FlushbarPosition.TOP,
animationDuration: Duration(milliseconds: 600),
)..show(context);
} }
onActionSelected(ImageEntry entry, FullscreenAction action) { onActionSelected(ImageEntry entry, FullscreenAction action) {

View file

@ -43,6 +43,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.14.11" version: "1.14.11"
flushbar:
dependency: "direct main"
description:
name: flushbar
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter

View file

@ -21,6 +21,7 @@ dependencies:
sdk: flutter sdk: flutter
chewie: chewie:
collection: collection:
flushbar:
flutter_sticky_header: flutter_sticky_header:
geocoder: geocoder:
google_maps_flutter: google_maps_flutter: