fullscreen: context menu
This commit is contained in:
parent
b29b2ed219
commit
fac80d98b9
2 changed files with 43 additions and 18 deletions
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:aves/model/android_app_service.dart';
|
||||||
import 'package:aves/model/image_entry.dart';
|
import 'package:aves/model/image_entry.dart';
|
||||||
import 'package:aves/widgets/fullscreen/info/info_page.dart';
|
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';
|
||||||
|
@ -79,6 +80,7 @@ class FullscreenPageState extends State<FullscreenPage> with SingleTickerProvide
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final entry = entries[_currentHorizontalPage];
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: () {
|
onWillPop: () {
|
||||||
Screen.keepOn(false);
|
Screen.keepOn(false);
|
||||||
|
@ -104,18 +106,10 @@ class FullscreenPageState extends State<FullscreenPage> with SingleTickerProvide
|
||||||
),
|
),
|
||||||
NotificationListener(
|
NotificationListener(
|
||||||
onNotification: (notification) {
|
onNotification: (notification) {
|
||||||
if (notification is BackUpNotification) {
|
if (notification is BackUpNotification) goToVerticalPage(0);
|
||||||
_verticalPager.animateToPage(
|
|
||||||
0,
|
|
||||||
duration: const Duration(milliseconds: 350),
|
|
||||||
curve: Curves.easeInOut,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
child: InfoPage(
|
child: InfoPage(entry: entry),
|
||||||
entry: entries[_currentHorizontalPage],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -126,6 +120,7 @@ class FullscreenPageState extends State<FullscreenPage> with SingleTickerProvide
|
||||||
scale: _topOverlayScale,
|
scale: _topOverlayScale,
|
||||||
viewInsets: _frozenViewInsets,
|
viewInsets: _frozenViewInsets,
|
||||||
viewPadding: _frozenViewPadding,
|
viewPadding: _frozenViewPadding,
|
||||||
|
onActionSelected: (action) => onActionSelected(entry, action),
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
|
@ -175,6 +170,14 @@ class FullscreenPageState extends State<FullscreenPage> with SingleTickerProvide
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
goToVerticalPage(int page) {
|
||||||
|
return _verticalPager.animateToPage(
|
||||||
|
page,
|
||||||
|
duration: Duration(milliseconds: 350),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
onOverlayVisibleChange() async {
|
onOverlayVisibleChange() async {
|
||||||
if (_overlayVisible.value) {
|
if (_overlayVisible.value) {
|
||||||
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
|
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
|
||||||
|
@ -189,8 +192,21 @@ class FullscreenPageState extends State<FullscreenPage> with SingleTickerProvide
|
||||||
_frozenViewPadding = null;
|
_frozenViewPadding = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onActionSelected(ImageEntry entry, FullscreenAction action) {
|
||||||
|
switch (action) {
|
||||||
|
case FullscreenAction.info:
|
||||||
|
goToVerticalPage(1);
|
||||||
|
break;
|
||||||
|
case FullscreenAction.share:
|
||||||
|
AndroidAppService.share(entry.uri, entry.mimeType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum FullscreenAction { info, share }
|
||||||
|
|
||||||
class ImagePage extends StatefulWidget {
|
class ImagePage extends StatefulWidget {
|
||||||
final List<ImageEntry> entries;
|
final List<ImageEntry> entries;
|
||||||
final PageController pageController;
|
final PageController pageController;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import 'package:aves/model/android_app_service.dart';
|
|
||||||
import 'package:aves/model/image_entry.dart';
|
import 'package:aves/model/image_entry.dart';
|
||||||
import 'package:aves/widgets/common/blurred.dart';
|
import 'package:aves/widgets/common/blurred.dart';
|
||||||
|
import 'package:aves/widgets/fullscreen/image_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class FullscreenTopOverlay extends StatelessWidget {
|
class FullscreenTopOverlay extends StatelessWidget {
|
||||||
|
@ -8,6 +8,7 @@ class FullscreenTopOverlay extends StatelessWidget {
|
||||||
final int index;
|
final int index;
|
||||||
final Animation<double> scale;
|
final Animation<double> scale;
|
||||||
final EdgeInsets viewInsets, viewPadding;
|
final EdgeInsets viewInsets, viewPadding;
|
||||||
|
final Function(FullscreenAction value) onActionSelected;
|
||||||
|
|
||||||
ImageEntry get entry => entries[index];
|
ImageEntry get entry => entries[index];
|
||||||
|
|
||||||
|
@ -18,6 +19,7 @@ class FullscreenTopOverlay extends StatelessWidget {
|
||||||
this.scale,
|
this.scale,
|
||||||
this.viewInsets,
|
this.viewInsets,
|
||||||
this.viewPadding,
|
this.viewPadding,
|
||||||
|
this.onActionSelected,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -37,21 +39,28 @@ class FullscreenTopOverlay extends StatelessWidget {
|
||||||
scale: scale,
|
scale: scale,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: Icon(Icons.share),
|
icon: Icon(Icons.share),
|
||||||
onPressed: share,
|
onPressed: () => onActionSelected?.call(FullscreenAction.share),
|
||||||
tooltip: 'Share',
|
tooltip: 'Share',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
OverlayButton(
|
||||||
|
scale: scale,
|
||||||
|
child: PopupMenuButton<FullscreenAction>(
|
||||||
|
itemBuilder: (context) => [
|
||||||
|
PopupMenuItem(
|
||||||
|
value: FullscreenAction.info,
|
||||||
|
child: Text("Info"),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
onSelected: onActionSelected,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete() {}
|
|
||||||
|
|
||||||
share() {
|
|
||||||
AndroidAppService.share(entry.uri, entry.mimeType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class OverlayButton extends StatelessWidget {
|
class OverlayButton extends StatelessWidget {
|
||||||
|
|
Loading…
Reference in a new issue