|
|
@ -1,5 +1,6 @@ |
|
|
|
// ignore: prefer_mixin |
|
|
|
// ignore: prefer_mixin |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter/foundation.dart'; |
|
|
|
|
|
|
|
import 'package:flutter/widgets.dart'; |
|
|
|
import 'package:go_router/go_router.dart'; |
|
|
|
import 'package:go_router/go_router.dart'; |
|
|
|
import 'package:neon/neon.dart'; |
|
|
|
import 'package:neon/neon.dart'; |
|
|
|
import 'package:provider/provider.dart'; |
|
|
|
import 'package:provider/provider.dart'; |
|
|
@ -11,12 +12,14 @@ class AppRouter extends GoRouter { |
|
|
|
required final GlobalKey<NavigatorState> navigatorKey, |
|
|
|
required final GlobalKey<NavigatorState> navigatorKey, |
|
|
|
required final AccountsBloc accountsBloc, |
|
|
|
required final AccountsBloc accountsBloc, |
|
|
|
}) : super( |
|
|
|
}) : super( |
|
|
|
|
|
|
|
debugLogDiagnostics: kDebugMode, |
|
|
|
refreshListenable: StreamListenable.behaviorSubject(accountsBloc.activeAccount), |
|
|
|
refreshListenable: StreamListenable.behaviorSubject(accountsBloc.activeAccount), |
|
|
|
navigatorKey: navigatorKey, |
|
|
|
navigatorKey: navigatorKey, |
|
|
|
initialLocation: const HomeRoute().location, |
|
|
|
initialLocation: const HomeRoute().location, |
|
|
|
redirect: (final context, final state) { |
|
|
|
redirect: (final context, final state) { |
|
|
|
final account = accountsBloc.activeAccount.valueOrNull; |
|
|
|
final account = accountsBloc.activeAccount.valueOrNull; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// redirect to loginscreen when no account is logged in |
|
|
|
if (account == null) { |
|
|
|
if (account == null) { |
|
|
|
return const LoginRoute().location; |
|
|
|
return const LoginRoute().location; |
|
|
|
} |
|
|
|
} |
|
|
@ -56,9 +59,13 @@ class AccountSettingsRoute extends GoRouteData { |
|
|
|
name: 'Settings', |
|
|
|
name: 'Settings', |
|
|
|
routes: [ |
|
|
|
routes: [ |
|
|
|
TypedGoRoute<NextcloudAppSettingsRoute>( |
|
|
|
TypedGoRoute<NextcloudAppSettingsRoute>( |
|
|
|
path: ':appid', |
|
|
|
path: 'apps/:appid', |
|
|
|
name: 'NextcloudAppSettings', |
|
|
|
name: 'NextcloudAppSettings', |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
TypedGoRoute<AddAccountRoute>( |
|
|
|
|
|
|
|
path: 'account/add', |
|
|
|
|
|
|
|
name: 'addAccount', |
|
|
|
|
|
|
|
), |
|
|
|
TypedGoRoute<AccountSettingsRoute>( |
|
|
|
TypedGoRoute<AccountSettingsRoute>( |
|
|
|
path: 'account/:accountid', |
|
|
|
path: 'account/:accountid', |
|
|
|
name: 'AccountSettings', |
|
|
|
name: 'AccountSettings', |
|
|
@ -94,6 +101,14 @@ class LoginRoute extends GoRouteData { |
|
|
|
Widget build(final BuildContext context, final GoRouterState state) => LoginPage(serverURL: server); |
|
|
|
Widget build(final BuildContext context, final GoRouterState state) => LoginPage(serverURL: server); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@immutable |
|
|
|
|
|
|
|
class AddAccountRoute extends GoRouteData { |
|
|
|
|
|
|
|
const AddAccountRoute(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
|
|
|
Widget build(final BuildContext context, final GoRouterState state) => const LoginPage(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@immutable |
|
|
|
@immutable |
|
|
|
class NextcloudAppSettingsRoute extends GoRouteData { |
|
|
|
class NextcloudAppSettingsRoute extends GoRouteData { |
|
|
|
const NextcloudAppSettingsRoute({ |
|
|
|
const NextcloudAppSettingsRoute({ |
|
|
|