Merge pull request #71 from krawieck/media-view-better-transition
This commit is contained in:
commit
c762aa7239
|
@ -10,14 +10,20 @@ import '../widgets/bottom_modal.dart';
|
|||
/// View to interact with a media object. Zoom in/out, download, share, etc.
|
||||
class MediaViewPage extends HookWidget {
|
||||
final String url;
|
||||
final GlobalKey<ScaffoldState> _key = GlobalKey();
|
||||
|
||||
const MediaViewPage(this.url);
|
||||
MediaViewPage(this.url);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final showButtons = useState(true);
|
||||
final isZoomedOut = useState(true);
|
||||
|
||||
notImplemented() {
|
||||
_key.currentState.showSnackBar(SnackBar(
|
||||
content: Text("this feature hasn't been implemented yet 😰")));
|
||||
}
|
||||
|
||||
useEffect(() {
|
||||
if (showButtons.value) {
|
||||
SystemChrome.setEnabledSystemUIOverlays([
|
||||
|
@ -57,6 +63,7 @@ class MediaViewPage extends HookWidget {
|
|||
title: Text('Share file'),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
notImplemented();
|
||||
// TODO: share file
|
||||
},
|
||||
),
|
||||
|
@ -67,6 +74,7 @@ class MediaViewPage extends HookWidget {
|
|||
}
|
||||
|
||||
return Scaffold(
|
||||
key: _key,
|
||||
extendBodyBehindAppBar: true,
|
||||
extendBody: true,
|
||||
appBar: showButtons.value
|
||||
|
@ -83,7 +91,7 @@ class MediaViewPage extends HookWidget {
|
|||
IconButton(
|
||||
icon: Icon(Icons.file_download),
|
||||
tooltip: 'download',
|
||||
onPressed: () {},
|
||||
onPressed: notImplemented,
|
||||
),
|
||||
],
|
||||
)
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|||
import '../pages/community.dart';
|
||||
import '../pages/full_post.dart';
|
||||
import '../pages/instance.dart';
|
||||
import '../pages/media_view.dart';
|
||||
import '../pages/user.dart';
|
||||
|
||||
/// Pushes onto the navigator stack the given widget
|
||||
|
@ -59,3 +60,13 @@ abstract class goToUser {
|
|||
|
||||
void goToPost(BuildContext context, String instanceUrl, int postId) => goTo(
|
||||
context, (context) => FullPostPage(instanceUrl: instanceUrl, id: postId));
|
||||
|
||||
void goToMedia(BuildContext context, String url) => Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (_, __, ___) => MediaViewPage(url),
|
||||
transitionDuration: const Duration(milliseconds: 300),
|
||||
transitionsBuilder: (_, animation, __, child) =>
|
||||
FadeTransition(opacity: animation, child: child),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -15,13 +15,9 @@ class FullscreenableImage extends StatelessWidget {
|
|||
@required this.child,
|
||||
}) : super(key: key);
|
||||
|
||||
_onTap(BuildContext c) {
|
||||
goTo(c, (context) => MediaViewPage(url));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => InkWell(
|
||||
onTap: () => _onTap(context),
|
||||
onTap: () => goToMedia(context, url),
|
||||
child: Hero(
|
||||
tag: url,
|
||||
child: child,
|
||||
|
|
38
pubspec.lock
38
pubspec.lock
|
@ -28,14 +28,14 @@ packages:
|
|||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.4.2"
|
||||
version: "2.5.0-nullsafety.1"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "2.1.0-nullsafety.1"
|
||||
build:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -105,14 +105,14 @@ packages:
|
|||
name: characters
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
version: "1.1.0-nullsafety.3"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.3"
|
||||
version: "1.2.0-nullsafety.1"
|
||||
checked_yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -133,7 +133,7 @@ packages:
|
|||
name: clock
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
version: "1.1.0-nullsafety.1"
|
||||
code_builder:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -147,7 +147,7 @@ packages:
|
|||
name: collection
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.14.13"
|
||||
version: "1.15.0-nullsafety.3"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -203,7 +203,7 @@ packages:
|
|||
name: fake_async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.2.0-nullsafety.1"
|
||||
ffi:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -400,14 +400,14 @@ packages:
|
|||
name: matcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.8"
|
||||
version: "0.12.10-nullsafety.1"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.8"
|
||||
version: "1.3.0-nullsafety.3"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -477,7 +477,7 @@ packages:
|
|||
name: path
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
version: "1.8.0-nullsafety.1"
|
||||
path_provider:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -664,7 +664,7 @@ packages:
|
|||
name: source_span
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
version: "1.8.0-nullsafety.2"
|
||||
sqflite:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -685,14 +685,14 @@ packages:
|
|||
name: stack_trace
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.5"
|
||||
version: "1.10.0-nullsafety.1"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "2.1.0-nullsafety.1"
|
||||
stream_transform:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -706,7 +706,7 @@ packages:
|
|||
name: string_scanner
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
version: "1.1.0-nullsafety.1"
|
||||
synchronized:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -720,14 +720,14 @@ packages:
|
|||
name: term_glyph
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.2.0-nullsafety.1"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.17"
|
||||
version: "0.2.19-nullsafety.2"
|
||||
timeago:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -748,7 +748,7 @@ packages:
|
|||
name: typed_data
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
version: "1.3.0-nullsafety.3"
|
||||
url_launcher:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -804,7 +804,7 @@ packages:
|
|||
name: vector_math
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.8"
|
||||
version: "2.1.0-nullsafety.3"
|
||||
watcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -841,5 +841,5 @@ packages:
|
|||
source: hosted
|
||||
version: "2.2.1"
|
||||
sdks:
|
||||
dart: ">=2.9.0 <3.0.0"
|
||||
dart: ">=2.10.0-110 <2.11.0"
|
||||
flutter: ">=1.20.0 <2.0.0"
|
||||
|
|
|
@ -3,7 +3,7 @@ description: A new Flutter project.
|
|||
|
||||
# The following line prevents the package from being accidentally published to
|
||||
# pub.dev using `pub publish`. This is preferred for private packages.
|
||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||
|
||||
# The following defines the version and build number for your application.
|
||||
# A version number is three numbers separated by dots, like 1.2.43
|
||||
|
@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||
version: 0.1.0
|
||||
|
||||
environment:
|
||||
sdk: '>=2.7.0 <3.0.0'
|
||||
sdk: ">=2.7.0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
# widgets
|
||||
|
@ -32,7 +32,7 @@ dependencies:
|
|||
# native
|
||||
esys_flutter_share: ^1.0.2
|
||||
url_launcher: ^5.5.1
|
||||
shared_preferences: '>=0.5.0 <2.0.0'
|
||||
shared_preferences: ">=0.5.0 <2.0.0"
|
||||
package_info: ^0.4.3
|
||||
|
||||
# state management
|
||||
|
|
Loading…
Reference in New Issue