feat: add remote pull and push
This commit is contained in:
+28
-2
@@ -14,6 +14,7 @@ import '../views/import_names_view.dart';
|
||||
import '../views/pin_lock_view.dart';
|
||||
import '../views/product_form_view.dart';
|
||||
import '../views/product_list_view.dart';
|
||||
import '../views/registration_view.dart';
|
||||
import '../views/settings_view.dart';
|
||||
import '../views/update_progress_view.dart';
|
||||
import '../utils/app_update_util.dart';
|
||||
@@ -23,6 +24,7 @@ final RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();
|
||||
String? _redirectApp({
|
||||
required PinLockViewModel pinLockViewModel,
|
||||
required AdminPinViewModel adminPinViewModel,
|
||||
required ValueNotifier<bool> isConfiguredNotifier,
|
||||
required GoRouterState state,
|
||||
}) {
|
||||
if (!pinLockViewModel.hasLoaded || !adminPinViewModel.hasLoaded) {
|
||||
@@ -30,6 +32,18 @@ String? _redirectApp({
|
||||
}
|
||||
|
||||
final location = state.uri.path;
|
||||
final isConfigured = isConfiguredNotifier.value;
|
||||
|
||||
if (!isConfigured && location != '/register') {
|
||||
return '/register';
|
||||
}
|
||||
|
||||
if (isConfigured && location == '/register') {
|
||||
return '/bar';
|
||||
}
|
||||
|
||||
if (!isConfigured) return null;
|
||||
|
||||
final goingToLock = location == '/lock';
|
||||
final goingToAdminLock = location == '/admin/lock';
|
||||
final mustBeOnLock = _mustBeOnLock(pinLockViewModel);
|
||||
@@ -83,19 +97,31 @@ bool _isDebugShortcutArea(String location) {
|
||||
|
||||
GoRouter createAppRouter(PinLockViewModel pinLockViewModel, {
|
||||
required AdminPinViewModel adminPinViewModel,
|
||||
required ValueNotifier<bool> isConfiguredNotifier,
|
||||
}) {
|
||||
return GoRouter(
|
||||
initialLocation: '/bar',
|
||||
observers: [routeObserver, SentryNavigatorObserver()],
|
||||
refreshListenable: Listenable.merge([pinLockViewModel, adminPinViewModel]),
|
||||
refreshListenable: Listenable.merge([
|
||||
pinLockViewModel,
|
||||
adminPinViewModel,
|
||||
isConfiguredNotifier,
|
||||
]),
|
||||
redirect: (_, state) =>
|
||||
_redirectApp(
|
||||
pinLockViewModel: pinLockViewModel,
|
||||
adminPinViewModel: adminPinViewModel,
|
||||
isConfiguredNotifier: isConfiguredNotifier,
|
||||
state: state,
|
||||
),
|
||||
routes: [
|
||||
GoRoute(path: '/', redirect: (context, state) => '/bar'),
|
||||
|
||||
GoRoute(
|
||||
path: '/register',
|
||||
builder: (context, state) => const RegistrationView(),
|
||||
),
|
||||
|
||||
GoRoute(
|
||||
path: '/lock',
|
||||
builder: (context, state) =>
|
||||
@@ -187,4 +213,4 @@ GoRouter createAppRouter(PinLockViewModel pinLockViewModel, {
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user