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 'package:desktop_window/desktop_window.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_displaymode/flutter_displaymode.dart';
|
||||
import 'package:wonders/common_libs.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 {
|
||||
static const Duration kDefaultDuration = Duration(milliseconds: 300);
|
||||
|
||||
static Route<T> dialog<T>(Widget child, [Duration duration = kDefaultDuration, bool opaque = false]) {
|
||||
return PageRouteBuilder<T>(
|
||||
transitionDuration: duration,
|
||||
reverseTransitionDuration: duration,
|
||||
pageBuilder: (context, animation, secondaryAnimation) => child,
|
||||
opaque: opaque,
|
||||
fullscreenDialog: true,
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) =>
|
||||
FadeTransition(opacity: animation, child: child),
|
||||
);
|
||||
// Use cupertino routes for all dialogs so we get the 'swipe right to go back' behavior
|
||||
return CupertinoPageRoute(builder: (_) => child);
|
||||
|
||||
// SB: Removed this in favor of Cupertino routes, we could restor with a `useFade` option
|
||||
// return PageRouteBuilder<T>(
|
||||
// transitionDuration: duration,
|
||||
// reverseTransitionDuration: duration,
|
||||
// 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/modals/fullscreen_url_img_viewer.dart';
|
||||
|
||||
part 'widgets/_content.dart';
|
||||
part 'widgets/_header.dart';
|
||||
part 'widgets/_info_column.dart';
|
||||
part 'widgets/_image_btn.dart';
|
||||
|
||||
class ArtifactDetailsScreen extends StatefulWidget {
|
||||
const ArtifactDetailsScreen({Key? key, required this.artifactId}) : super(key: key);
|
||||
@ -36,8 +36,8 @@ class _ArtifactDetailsScreenState extends State<ArtifactDetailsScreen> {
|
||||
} else {
|
||||
content = hzMode
|
||||
? Row(children: [
|
||||
Expanded(child: _Header(data: data!)),
|
||||
Expanded(child: Center(child: SizedBox(width: 600, child: _Content(data: data)))),
|
||||
Expanded(child: _ImageBtn(data: data!)),
|
||||
Expanded(child: Center(child: SizedBox(width: 600, child: _InfoColumn(data: data)))),
|
||||
])
|
||||
: CustomScrollView(
|
||||
slivers: [
|
||||
@ -47,9 +47,9 @@ class _ArtifactDetailsScreenState extends State<ArtifactDetailsScreen> {
|
||||
leading: SizedBox.shrink(),
|
||||
expandedHeight: context.heightPx * .5,
|
||||
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';
|
||||
|
||||
class _Header extends StatelessWidget {
|
||||
const _Header({Key? key, required this.data}) : super(key: key);
|
||||
class _ImageBtn extends StatelessWidget {
|
||||
const _ImageBtn({Key? key, required this.data}) : super(key: key);
|
||||
final ArtifactData data;
|
||||
|
||||
@override
|
@ -1,7 +1,7 @@
|
||||
part of '../artifact_details_screen.dart';
|
||||
|
||||
class _Content extends StatelessWidget {
|
||||
const _Content({Key? key, required this.data}) : super(key: key);
|
||||
class _InfoColumn extends StatelessWidget {
|
||||
const _InfoColumn({Key? key, required this.data}) : super(key: key);
|
||||
final ArtifactData data;
|
||||
|
||||
@override
|
@ -107,15 +107,14 @@ class _PhotoGalleryState extends State<PhotoGallery> {
|
||||
|
||||
Future<void> _handleImageTapped(int index) async {
|
||||
if (_index == index) {
|
||||
int? newIndex = await Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(builder: (_) {
|
||||
final urls = _photoIds.value.map((e) {
|
||||
return UnsplashPhotoData.getSelfHostedUrl(e, UnsplashPhotoSize.med);
|
||||
}).toList();
|
||||
return FullscreenUrlImgViewer(urls: urls, index: _index);
|
||||
}),
|
||||
int? newIndex = await appLogic.showFullscreenDialogRoute(
|
||||
context,
|
||||
FullscreenUrlImgViewer(urls: urls, index: _index),
|
||||
);
|
||||
|
||||
if (newIndex != null) {
|
||||
_setIndex(newIndex, skipAnimation: true);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user