50 lines
1.2 KiB
Dart
50 lines
1.2 KiB
Dart
import 'package:fluent_ui/fluent_ui.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:momo/fluent/home.dart';
|
|
import 'package:momo/fluent/login.dart';
|
|
|
|
class MyFluentRouterConfig {
|
|
late GoRouter router;
|
|
|
|
MyFluentRouterConfig(String? token) {
|
|
router = GoRouter(
|
|
routes: <RouteBase>[
|
|
GoRoute(
|
|
path: '/',
|
|
builder: (BuildContext context, GoRouterState state) {
|
|
return const HomePage();
|
|
},
|
|
redirect: (BuildContext context, GoRouterState state) {
|
|
if (token == null || token.isEmpty) {
|
|
return "/login";
|
|
}
|
|
return null;
|
|
},
|
|
),
|
|
GoRoute(
|
|
path: "/login",
|
|
builder: (BuildContext context, GoRouterState state) {
|
|
return const LoginPage();
|
|
})
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class TextLogin extends StatelessWidget {
|
|
const TextLogin({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ScaffoldPage(
|
|
content: Center(
|
|
child: FilledButton(
|
|
child: Text("logi"),
|
|
onPressed: () {
|
|
context.go("/");
|
|
}),
|
|
),
|
|
);
|
|
}
|
|
}
|