Add cupertino page routes for all full-screen dialogs
This commit is contained in:
parent
4205cc0b00
commit
a4f2daffec
@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:desktop_window/desktop_window.dart';
|
import 'package:desktop_window/desktop_window.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter_displaymode/flutter_displaymode.dart';
|
import 'package:flutter_displaymode/flutter_displaymode.dart';
|
||||||
import 'package:wonders/common_libs.dart';
|
import 'package:wonders/common_libs.dart';
|
||||||
import 'package:wonders/logic/common/platform_info.dart';
|
import 'package:wonders/logic/common/platform_info.dart';
|
||||||
|
@ -1,17 +1,21 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
class PageRoutes {
|
class PageRoutes {
|
||||||
static const Duration kDefaultDuration = Duration(milliseconds: 300);
|
static const Duration kDefaultDuration = Duration(milliseconds: 300);
|
||||||
|
|
||||||
static Route<T> dialog<T>(Widget child, [Duration duration = kDefaultDuration, bool opaque = false]) {
|
static Route<T> dialog<T>(Widget child, [Duration duration = kDefaultDuration, bool opaque = false]) {
|
||||||
return PageRouteBuilder<T>(
|
// Use cupertino routes for all dialogs so we get the 'swipe right to go back' behavior
|
||||||
transitionDuration: duration,
|
return CupertinoPageRoute(builder: (_) => child);
|
||||||
reverseTransitionDuration: duration,
|
|
||||||
pageBuilder: (context, animation, secondaryAnimation) => child,
|
// SB: Removed this in favor of Cupertino routes, we could restor with a `useFade` option
|
||||||
opaque: opaque,
|
// return PageRouteBuilder<T>(
|
||||||
fullscreenDialog: true,
|
// transitionDuration: duration,
|
||||||
transitionsBuilder: (context, animation, secondaryAnimation, child) =>
|
// reverseTransitionDuration: duration,
|
||||||
FadeTransition(opacity: animation, child: child),
|
// pageBuilder: (context, animation, secondaryAnimation) => child,
|
||||||
);
|
// opaque: opaque,
|
||||||
|
// fullscreenDialog: true,
|
||||||
|
// transitionsBuilder: (context, animation, secondaryAnimation, child) =>
|
||||||
|
// FadeTransition(opacity: animation, child: child),
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import 'package:wonders/ui/common/controls/app_loading_indicator.dart';
|
|||||||
import 'package:wonders/ui/common/gradient_container.dart';
|
import 'package:wonders/ui/common/gradient_container.dart';
|
||||||
import 'package:wonders/ui/common/modals/fullscreen_url_img_viewer.dart';
|
import 'package:wonders/ui/common/modals/fullscreen_url_img_viewer.dart';
|
||||||
|
|
||||||
part 'widgets/_content.dart';
|
part 'widgets/_info_column.dart';
|
||||||
part 'widgets/_header.dart';
|
part 'widgets/_image_btn.dart';
|
||||||
|
|
||||||
class ArtifactDetailsScreen extends StatefulWidget {
|
class ArtifactDetailsScreen extends StatefulWidget {
|
||||||
const ArtifactDetailsScreen({Key? key, required this.artifactId}) : super(key: key);
|
const ArtifactDetailsScreen({Key? key, required this.artifactId}) : super(key: key);
|
||||||
@ -36,8 +36,8 @@ class _ArtifactDetailsScreenState extends State<ArtifactDetailsScreen> {
|
|||||||
} else {
|
} else {
|
||||||
content = hzMode
|
content = hzMode
|
||||||
? Row(children: [
|
? Row(children: [
|
||||||
Expanded(child: _Header(data: data!)),
|
Expanded(child: _ImageBtn(data: data!)),
|
||||||
Expanded(child: Center(child: SizedBox(width: 600, child: _Content(data: data)))),
|
Expanded(child: Center(child: SizedBox(width: 600, child: _InfoColumn(data: data)))),
|
||||||
])
|
])
|
||||||
: CustomScrollView(
|
: CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
@ -47,9 +47,9 @@ class _ArtifactDetailsScreenState extends State<ArtifactDetailsScreen> {
|
|||||||
leading: SizedBox.shrink(),
|
leading: SizedBox.shrink(),
|
||||||
expandedHeight: context.heightPx * .5,
|
expandedHeight: context.heightPx * .5,
|
||||||
collapsedHeight: context.heightPx * .35,
|
collapsedHeight: context.heightPx * .35,
|
||||||
flexibleSpace: _Header(data: data!),
|
flexibleSpace: _ImageBtn(data: data!),
|
||||||
),
|
),
|
||||||
SliverToBoxAdapter(child: _Content(data: data)),
|
SliverToBoxAdapter(child: _InfoColumn(data: data)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
part of '../artifact_details_screen.dart';
|
part of '../artifact_details_screen.dart';
|
||||||
|
|
||||||
class _Header extends StatelessWidget {
|
class _ImageBtn extends StatelessWidget {
|
||||||
const _Header({Key? key, required this.data}) : super(key: key);
|
const _ImageBtn({Key? key, required this.data}) : super(key: key);
|
||||||
final ArtifactData data;
|
final ArtifactData data;
|
||||||
|
|
||||||
@override
|
@override
|
@ -1,7 +1,7 @@
|
|||||||
part of '../artifact_details_screen.dart';
|
part of '../artifact_details_screen.dart';
|
||||||
|
|
||||||
class _Content extends StatelessWidget {
|
class _InfoColumn extends StatelessWidget {
|
||||||
const _Content({Key? key, required this.data}) : super(key: key);
|
const _InfoColumn({Key? key, required this.data}) : super(key: key);
|
||||||
final ArtifactData data;
|
final ArtifactData data;
|
||||||
|
|
||||||
@override
|
@override
|
@ -107,15 +107,14 @@ class _PhotoGalleryState extends State<PhotoGallery> {
|
|||||||
|
|
||||||
Future<void> _handleImageTapped(int index) async {
|
Future<void> _handleImageTapped(int index) async {
|
||||||
if (_index == index) {
|
if (_index == index) {
|
||||||
int? newIndex = await Navigator.push(
|
final urls = _photoIds.value.map((e) {
|
||||||
|
return UnsplashPhotoData.getSelfHostedUrl(e, UnsplashPhotoSize.med);
|
||||||
|
}).toList();
|
||||||
|
int? newIndex = await appLogic.showFullscreenDialogRoute(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(builder: (_) {
|
FullscreenUrlImgViewer(urls: urls, index: _index),
|
||||||
final urls = _photoIds.value.map((e) {
|
|
||||||
return UnsplashPhotoData.getSelfHostedUrl(e, UnsplashPhotoSize.med);
|
|
||||||
}).toList();
|
|
||||||
return FullscreenUrlImgViewer(urls: urls, index: _index);
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (newIndex != null) {
|
if (newIndex != null) {
|
||||||
_setIndex(newIndex, skipAnimation: true);
|
_setIndex(newIndex, skipAnimation: true);
|
||||||
}
|
}
|
||||||
@ -148,7 +147,7 @@ class _PhotoGalleryState extends State<PhotoGallery> {
|
|||||||
gridOffset += Offset(0, -context.mq.padding.top / 2);
|
gridOffset += Offset(0, -context.mq.padding.top / 2);
|
||||||
final offsetTweenDuration = _skipNextOffsetTween ? Duration.zero : swipeDuration;
|
final offsetTweenDuration = _skipNextOffsetTween ? Duration.zero : swipeDuration;
|
||||||
final cutoutTweenDuration = _skipNextOffsetTween ? Duration.zero : swipeDuration * .5;
|
final cutoutTweenDuration = _skipNextOffsetTween ? Duration.zero : swipeDuration * .5;
|
||||||
return _AnimatedCutoutOverlay(
|
return _AnimatedCutoutOverlay(
|
||||||
animationKey: ValueKey(_index),
|
animationKey: ValueKey(_index),
|
||||||
cutoutSize: imgSize,
|
cutoutSize: imgSize,
|
||||||
swipeDir: _lastSwipeDir,
|
swipeDir: _lastSwipeDir,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user