Deeplink support for player stats in tournament (#3217)

This commit is contained in:
Fahad Ahmed
2026-05-19 15:21:41 +05:00
committed by GitHub
parent 1f1178cf97
commit 08010614f0
3 changed files with 37 additions and 5 deletions
+3 -1
View File
@@ -157,7 +157,9 @@ class AppLinksService {
}
case 'tournament':
final tournamentId = TournamentId(appLinkUri.pathSegments[1]);
return [TournamentScreen.buildRoute(tournamentId)];
final playerName = appLinkUri.queryParameters['player'];
final playerId = playerName != null ? UserId.fromUserName(playerName) : null;
return [TournamentScreen.buildRoute(tournamentId, initialPlayerId: playerId)];
case 'training':
final id = appLinkUri.pathSegments[1];
return [PuzzleScreen.buildRoute(angle: PuzzleAngle.fromKey('mix'), puzzleId: PuzzleId(id))];
+16 -3
View File
@@ -52,15 +52,16 @@ import 'package:share_plus/share_plus.dart';
import 'package:url_launcher/url_launcher.dart';
class TournamentScreen extends ConsumerStatefulWidget {
const TournamentScreen({required this.id});
const TournamentScreen({required this.id, this.initialPlayerId});
final TournamentId id;
final UserId? initialPlayerId;
static const String routeName = '/tournament';
static Route<void> buildRoute(TournamentId id) {
static Route<void> buildRoute(TournamentId id, {UserId? initialPlayerId}) {
return buildScreenRoute(
screen: TournamentScreen(id: id),
screen: TournamentScreen(id: id, initialPlayerId: initialPlayerId),
settings: const RouteSettings(name: routeName),
);
}
@@ -70,6 +71,18 @@ class TournamentScreen extends ConsumerStatefulWidget {
}
class _TournamentScreenState extends ConsumerState<TournamentScreen> with RouteAware {
@override
void initState() {
super.initState();
if (widget.initialPlayerId != null) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
_showPlayerDetails(context, widget.id, widget.initialPlayerId!);
}
});
}
}
@override
void didChangeDependencies() {
super.didChangeDependencies();