|
|
@ -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,20 +12,18 @@ 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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (state.location == const LoginRoute().location) { |
|
|
|
|
|
|
|
return const HomeRoute().location; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
return null; |
|
|
|
}, |
|
|
|
}, |
|
|
|
routes: $appRoutes, |
|
|
|
routes: $appRoutes, |
|
|
@ -60,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', |
|
|
@ -98,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({ |
|
|
@ -109,7 +120,7 @@ class NextcloudAppSettingsRoute extends GoRouteData { |
|
|
|
@override |
|
|
|
@override |
|
|
|
Widget build(final BuildContext context, final GoRouterState state) { |
|
|
|
Widget build(final BuildContext context, final GoRouterState state) { |
|
|
|
final appImplementations = Provider.of<List<AppImplementation>>(context, listen: false); |
|
|
|
final appImplementations = Provider.of<List<AppImplementation>>(context, listen: false); |
|
|
|
final appImplementation = appImplementations.firstWhere((final app) => app.id == appid); |
|
|
|
final appImplementation = appImplementations.find(appid)!; |
|
|
|
|
|
|
|
|
|
|
|
return NextcloudAppSettingsPage(appImplementation: appImplementation); |
|
|
|
return NextcloudAppSettingsPage(appImplementation: appImplementation); |
|
|
|
} |
|
|
|
} |
|
|
|