-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Lenra Application Routes (#178) * This should fix a lot * This is working !!! * update deps * Update application runner * feat: Update dependencies * ci: Releases alpha * feat: Update dependencies * feat: Update dependencies * feat: Update dependencies * fix: Error when building client (no tree shake) * feat: Client on port 4000 and API on 4001 (#187) * feat: Open external links on navTo (#188) * feat: Update dependencies (#189) * build(deps): beta deps --------- Co-authored-by: Thomas DA ROCHA <[email protected]>
- Loading branch information
1 parent
fccfde9
commit f173b5c
Showing
23 changed files
with
305 additions
and
113 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,63 @@ | ||
import 'package:client/main.dart'; | ||
import 'package:client_common/navigator/common_navigator.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:lenra_ui_runner/app.dart'; | ||
import 'package:lenra_ui_runner/io_components/lenra_route.dart'; | ||
import 'package:url_launcher/url_launcher.dart'; | ||
|
||
class AppNavigator extends CommonNavigator { | ||
static GoRoute appRoutes = GoRoute( | ||
name: "appRoutes", | ||
path: "/:path(.*)", | ||
pageBuilder: (_, state) { | ||
return NoTransitionPage( | ||
child: App( | ||
appName: DevTools.appName, | ||
httpEndpoint: "http://localhost:4001", | ||
accessToken: "", | ||
wsEndpoint: "ws://localhost:4001/socket/websocket", | ||
baseRoute: "/", | ||
routeWidget: LenraRoute( | ||
"/${state.params['path']!}", | ||
// Use UniqueKey to make sure that the LenraRoute Widget is properly reloaded with the new route when navigating. | ||
key: UniqueKey(), | ||
), | ||
navTo: (context, route) { | ||
// This regex matches http:// and https:// urls | ||
RegExp exp = RegExp(r"^https?://"); | ||
if (exp.hasMatch(route)) { | ||
_launchURL(route); | ||
} else { | ||
GoRouter.of(context).go(route); | ||
} | ||
}, | ||
), | ||
); | ||
}, | ||
); | ||
|
||
static GoRouter router = GoRouter( | ||
initialLocation: "/", | ||
routes: [appRoutes], | ||
); | ||
} | ||
|
||
class NoTransitionPage extends CustomTransitionPage { | ||
NoTransitionPage({required Widget child, LocalKey? key}) | ||
: super( | ||
child: child, | ||
key: key, | ||
transitionDuration: Duration.zero, | ||
transitionsBuilder: (context, animation, secondaryAnimation, child) { | ||
return child; | ||
}, | ||
); | ||
} | ||
|
||
_launchURL(String url) async { | ||
final Uri uri = Uri.parse(url); | ||
if (!await launchUrl(uri)) { | ||
throw Exception("Could not launch url: $url"); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.