Switch /video and /maps views to be nested within home, better supporting deeplinks.
This commit is contained in:
parent
00e3dcc234
commit
28734b7f1f
@ -19,28 +19,21 @@ class ScreenPaths {
|
|||||||
|
|
||||||
static String settings = '/settings';
|
static String settings = '/settings';
|
||||||
|
|
||||||
// editorial
|
|
||||||
static String wonderDetails(WonderType type, {required int tabIndex}) => '$home/wonder/${type.name}?t=$tabIndex';
|
static String wonderDetails(WonderType type, {required int tabIndex}) => '$home/wonder/${type.name}?t=$tabIndex';
|
||||||
// add /home/wonderType/
|
|
||||||
static String video(String id, {String? currentPath}) {
|
/// Dynamically nested pages, always added on to the existing path
|
||||||
var value = '${currentPath ?? ''}/video/$id';
|
static String video(String id) => _appendToCurrentPath('/video/$id');
|
||||||
// if(currentPath != null) {
|
static String search(WonderType type) => _appendToCurrentPath('/search/${type.name}');
|
||||||
//
|
static String maps(WonderType type) => _appendToCurrentPath('/maps/${type.name}');
|
||||||
// value = '${context.go}/$value';
|
static String timeline(WonderType? type) => _appendToCurrentPath('/timeline?type=${type?.name ?? ''}');
|
||||||
// }
|
static String artifact(String id) => _appendToCurrentPath('/artifact/$id');
|
||||||
return value;
|
static String collection(String id) => _appendToCurrentPath('/collection?id=$id');
|
||||||
|
|
||||||
|
static String _appendToCurrentPath(String newPath) {
|
||||||
|
final uri = appRouter.routeInformationProvider.value.uri;
|
||||||
|
Uri? loc = Uri(path: '${uri.path}$newPath', queryParameters: uri.queryParameters);
|
||||||
|
return loc.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
static String search(WonderType type) => '/search/${type.name}';
|
|
||||||
static String maps(WonderType type) => '/maps/${type.name}';
|
|
||||||
|
|
||||||
// both home/timeline and /home/wonderType/timeline
|
|
||||||
static String timeline(WonderType? type) => '/timeline?type=${type?.name ?? ''}';
|
|
||||||
|
|
||||||
// /collection, /search, /carousel, this should be a dialog... but then it can't be deep-linked?
|
|
||||||
static String artifact(String id) => '/artifact/$id';
|
|
||||||
|
|
||||||
static String collection(String id) => '/collection?id=$id';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Routes that are used multiple times
|
// Routes that are used multiple times
|
||||||
@ -92,6 +85,7 @@ final appRouter = GoRouter(
|
|||||||
routes: [
|
routes: [
|
||||||
_timelineRoute,
|
_timelineRoute,
|
||||||
_collectionRoute,
|
_collectionRoute,
|
||||||
|
_artifactRoute,
|
||||||
// Youtube Video
|
// Youtube Video
|
||||||
AppRoute('video/:id', (s) {
|
AppRoute('video/:id', (s) {
|
||||||
return FullscreenVideoViewer(id: s.pathParameters['id']!);
|
return FullscreenVideoViewer(id: s.pathParameters['id']!);
|
||||||
|
@ -166,15 +166,19 @@ class _ScrollingContent extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _YouTubeThumbnail extends StatelessWidget {
|
class _YouTubeThumbnail extends StatelessWidget {
|
||||||
const _YouTubeThumbnail({Key? key, required this.id, required this.caption}) : super(key: key);
|
const _YouTubeThumbnail({Key? key, required this.id, required this.caption, this.wonderType}) : super(key: key);
|
||||||
final String id;
|
final String id;
|
||||||
final String caption;
|
final String caption;
|
||||||
|
final WonderType? wonderType;
|
||||||
|
|
||||||
String get imageUrl => 'https://www.wonderous.info/youtube/$id.jpg';
|
String get imageUrl => 'https://www.wonderous.info/youtube/$id.jpg';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
void handlePressed() => context.push(ScreenPaths.video(id));
|
void handlePressed() {
|
||||||
|
context.go(ScreenPaths.video(id));
|
||||||
|
}
|
||||||
|
|
||||||
return MergeSemantics(
|
return MergeSemantics(
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: BoxConstraints(maxWidth: 400),
|
constraints: BoxConstraints(maxWidth: 400),
|
||||||
@ -227,7 +231,7 @@ class _MapsThumbnailState extends State<_MapsThumbnail> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
void handlePressed() => context.push(ScreenPaths.maps(widget.data.type));
|
void handlePressed() => context.go(ScreenPaths.maps(widget.data.type));
|
||||||
if (PlatformInfo.isDesktop) return SizedBox.shrink();
|
if (PlatformInfo.isDesktop) return SizedBox.shrink();
|
||||||
return AspectRatio(
|
return AspectRatio(
|
||||||
aspectRatio: 1.65,
|
aspectRatio: 1.65,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user