-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'deeepLink' of https://github.com/tom-anders/lichess-mobile
- Loading branch information
Showing
5 changed files
with
161 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import 'package:dartchess/dartchess.dart'; | ||
import 'package:fast_immutable_collections/fast_immutable_collections.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:lichess_mobile/src/model/common/id.dart'; | ||
import 'package:lichess_mobile/src/model/puzzle/puzzle_angle.dart'; | ||
import 'package:lichess_mobile/src/utils/navigation.dart'; | ||
import 'package:lichess_mobile/src/view/game/archived_game_screen.dart'; | ||
import 'package:lichess_mobile/src/view/puzzle/puzzle_screen.dart'; | ||
import 'package:lichess_mobile/src/view/puzzle/storm_screen.dart'; | ||
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]; | ||
|
||
switch (appLinkUri.pathSegments[0]) { | ||
case 'streak': | ||
return createPlatformRoute(context, screen: const StreakScreen()); | ||
case 'storm': | ||
return createPlatformRoute(context, screen: const StormScreen()); | ||
case 'study': | ||
return createPlatformRoute(context, screen: StudyScreen(id: StudyId(id))); | ||
case 'training': | ||
return createPlatformRoute( | ||
context, | ||
screen: PuzzleScreen(angle: PuzzleAngle.fromKey('mix'), puzzleId: PuzzleId(id)), | ||
); | ||
case _: | ||
{ | ||
final gameId = GameId(appLinkUri.pathSegments[0]); | ||
final orientation = appLinkUri.pathSegments.getOrNull(2); | ||
if (gameId.isValid) { | ||
return createPlatformRoute( | ||
context, | ||
screen: ArchivedGameScreen( | ||
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; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters