Skip to content

Commit

Permalink
Merge branch 'julien4215-fix-deeplink'
Browse files Browse the repository at this point in the history
  • Loading branch information
veloce committed Feb 10, 2025
2 parents 6dbdc6d + bb9e080 commit 88931a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
4 changes: 2 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
<data android:pathPattern="/training/....." />
<data android:pathPattern="/study/........" />

<data android:pathPattern="/storm" />
<data android:pathPattern="/streak" />
<data android:path="/storm" />
<data android:path="/streak" />

<!-- Either game or challenge -->
<data android:pathPattern="/........" />
Expand Down
34 changes: 15 additions & 19 deletions lib/src/app_links.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,36 @@ import 'package:lichess_mobile/src/view/puzzle/streak_screen.dart';
import 'package:lichess_mobile/src/view/study/study_screen.dart';

Route<dynamic>? resolveAppLinkUri(BuildContext context, Uri appLinkUri) {
if (appLinkUri.pathSegments.length < 2 || appLinkUri.pathSegments[1].isEmpty) {
return null;
}

final id = appLinkUri.pathSegments[1];
if (appLinkUri.pathSegments.isEmpty) return null;

switch (appLinkUri.pathSegments[0]) {
case 'streak':
return StreakScreen.buildRoute(context);
case 'storm':
return StormScreen.buildRoute(context);
case 'study':
final id = appLinkUri.pathSegments[1];
return StudyScreen.buildRoute(context, StudyId(id));
case 'training':
final id = appLinkUri.pathSegments[1];
return PuzzleScreen.buildRoute(
context,
angle: PuzzleAngle.fromKey('mix'),
puzzleId: PuzzleId(id),
);
case _:
{
final gameId = GameId(appLinkUri.pathSegments[0]);
final orientation = appLinkUri.pathSegments.getOrNull(2);
if (gameId.isValid) {
return ArchivedGameScreen.buildRoute(
context,
gameId: gameId,
orientation: orientation == 'black' ? Side.black : Side.white,
);
} else {
// TODO if it's not a game, it's a challenge.
// So we should show a accept/decline screen here.
return null;
}
final gameId = GameId(appLinkUri.pathSegments[0]);
final orientation = appLinkUri.pathSegments.getOrNull(2);
if (gameId.isValid) {
return ArchivedGameScreen.buildRoute(
context,
gameId: gameId,
orientation: orientation == 'black' ? Side.black : Side.white,
);
} else {
// TODO if it's not a game, it's a challenge.
// So we should show a accept/decline screen here.
return null;
}
}
}

0 comments on commit 88931a7

Please sign in to comment.