Add support for deeplinking into specific tabs for wonder details.
This commit is contained in:
parent
a347718577
commit
68c937a73d
@ -19,7 +19,7 @@ class ScreenPaths {
|
||||
static String intro = '/welcome';
|
||||
static String home = '/home';
|
||||
static String settings = '/settings';
|
||||
static String wonderDetails(WonderType type) => '/wonder/${type.name}';
|
||||
static String wonderDetails(WonderType type, {int tabIndex = 0}) => '/wonder/${type.name}?t=$tabIndex';
|
||||
static String video(String id) => '/video/$id';
|
||||
static String highlights(WonderType type) => '/highlights/${type.name}';
|
||||
static String search(WonderType type) => '/search/${type.name}';
|
||||
@ -39,7 +39,11 @@ final appRouter = GoRouter(
|
||||
AppRoute(ScreenPaths.home, (_) => HomeScreen()),
|
||||
AppRoute(ScreenPaths.intro, (_) => IntroScreen()),
|
||||
AppRoute('/wonder/:type', (s) {
|
||||
return WonderDetailsScreen(type: _parseWonderType(s.params['type']!));
|
||||
int tab = int.tryParse(s.queryParams['t'] ?? '') ?? 0;
|
||||
return WonderDetailsScreen(
|
||||
type: _parseWonderType(s.params['type']!),
|
||||
initialTabIndex: tab,
|
||||
);
|
||||
}, useFade: true),
|
||||
AppRoute('/timeline', (s) {
|
||||
return TimelineScreen(type: _tryParseWonderType(s.queryParams['type']!));
|
||||
|
@ -8,8 +8,9 @@ import 'package:wonders/ui/screens/wonder_details/wonder_details_tab_menu.dart';
|
||||
import 'package:wonders/ui/screens/wonder_events/wonder_events.dart';
|
||||
|
||||
class WonderDetailsScreen extends StatefulWidget with GetItStatefulWidgetMixin {
|
||||
WonderDetailsScreen({Key? key, required this.type}) : super(key: key);
|
||||
WonderDetailsScreen({Key? key, required this.type, this.initialTabIndex = 0}) : super(key: key);
|
||||
final WonderType type;
|
||||
final int initialTabIndex;
|
||||
|
||||
@override
|
||||
State<WonderDetailsScreen> createState() => _WonderDetailsScreenState();
|
||||
@ -17,7 +18,11 @@ class WonderDetailsScreen extends StatefulWidget with GetItStatefulWidgetMixin {
|
||||
|
||||
class _WonderDetailsScreenState extends State<WonderDetailsScreen>
|
||||
with GetItStateMixin, SingleTickerProviderStateMixin {
|
||||
late final _tabController = TabController(length: 4, vsync: this)..addListener(_handleTabChanged);
|
||||
late final _tabController = TabController(
|
||||
length: 4,
|
||||
vsync: this,
|
||||
initialIndex: widget.initialTabIndex,
|
||||
)..addListener(_handleTabChanged);
|
||||
AnimationController? _fade;
|
||||
|
||||
final _detailsHasScrolled = ValueNotifier(false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user