implemented user backups
This commit is contained in:
@@ -73,6 +73,18 @@ part of 'routes.dart';
|
||||
path: 'profiles',
|
||||
routes: [
|
||||
TypedGoRoute<EditProfileRoute>(name: 'ProfileEditScreen', path: 'edit'),
|
||||
TypedGoRoute<ProfileBackupListRoute>(
|
||||
name: 'ProfileBackupListRoute',
|
||||
path: 'backup_list',
|
||||
),
|
||||
TypedGoRoute<RestoreProfileRoute>(
|
||||
name: 'RestoreProfileRoute',
|
||||
path: 'restore',
|
||||
),
|
||||
TypedGoRoute<BackupProfileRoute>(
|
||||
name: 'BackupProfileRoute',
|
||||
path: 'backup',
|
||||
),
|
||||
TypedGoRoute<CreateProfileRoute>(
|
||||
name: 'CreateProfileRoute',
|
||||
path: 'create',
|
||||
@@ -303,6 +315,37 @@ class EditProfileRoute extends GoRouteData with $EditProfileRoute {
|
||||
}
|
||||
}
|
||||
|
||||
class BackupProfileRoute extends GoRouteData with $BackupProfileRoute {
|
||||
final String profile;
|
||||
|
||||
const BackupProfileRoute({required this.profile});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return ProfileBackupScreen(
|
||||
profile: Profile.fromJson(jsonDecode(profile) as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RestoreProfileRoute extends GoRouteData with $RestoreProfileRoute {
|
||||
final String backupFilePath;
|
||||
|
||||
const RestoreProfileRoute({required this.backupFilePath});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return ProfileRestoreScreen(backupFile: File(backupFilePath));
|
||||
}
|
||||
}
|
||||
|
||||
class ProfileBackupListRoute extends GoRouteData with $ProfileBackupListRoute {
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return const ProfileBackupListScreen();
|
||||
}
|
||||
}
|
||||
|
||||
class BookmarkListRoute extends GoRouteData with $BookmarkListRoute {
|
||||
final String entryGuid;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mozilla_components/flutter_mozilla_components.dart';
|
||||
@@ -64,8 +65,11 @@ import 'package:weblibre/features/settings/presentation/screens/web_engine_harde
|
||||
import 'package:weblibre/features/settings/presentation/screens/web_engine_settings.dart';
|
||||
import 'package:weblibre/features/tor/presentation/screens/tor_proxy.dart';
|
||||
import 'package:weblibre/features/user/domain/presentation/dialogs/select_profile.dart';
|
||||
import 'package:weblibre/features/user/domain/presentation/screens/profile_backup.dart';
|
||||
import 'package:weblibre/features/user/domain/presentation/screens/profile_backup_list.dart';
|
||||
import 'package:weblibre/features/user/domain/presentation/screens/profile_edit.dart';
|
||||
import 'package:weblibre/features/user/domain/presentation/screens/profile_list.dart';
|
||||
import 'package:weblibre/features/user/domain/presentation/screens/profile_restore.dart';
|
||||
import 'package:weblibre/features/web_feed/presentation/add_feed_dialog.dart';
|
||||
import 'package:weblibre/features/web_feed/presentation/screens/feed_article.dart';
|
||||
import 'package:weblibre/features/web_feed/presentation/screens/feed_article_list.dart';
|
||||
|
||||
@@ -457,6 +457,21 @@ RouteBase get $browserRoute => GoRouteData.$route(
|
||||
name: 'ProfileEditScreen',
|
||||
factory: $EditProfileRoute._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'backup_list',
|
||||
name: 'ProfileBackupListRoute',
|
||||
factory: $ProfileBackupListRoute._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'restore',
|
||||
name: 'RestoreProfileRoute',
|
||||
factory: $RestoreProfileRoute._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'backup',
|
||||
name: 'BackupProfileRoute',
|
||||
factory: $BackupProfileRoute._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'create',
|
||||
name: 'CreateProfileRoute',
|
||||
@@ -880,6 +895,81 @@ mixin $EditProfileRoute on GoRouteData {
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
mixin $ProfileBackupListRoute on GoRouteData {
|
||||
static ProfileBackupListRoute _fromState(GoRouterState state) =>
|
||||
ProfileBackupListRoute();
|
||||
|
||||
@override
|
||||
String get location => GoRouteData.$location('/browser/profiles/backup_list');
|
||||
|
||||
@override
|
||||
void go(BuildContext context) => context.go(location);
|
||||
|
||||
@override
|
||||
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
|
||||
|
||||
@override
|
||||
void pushReplacement(BuildContext context) =>
|
||||
context.pushReplacement(location);
|
||||
|
||||
@override
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
mixin $RestoreProfileRoute on GoRouteData {
|
||||
static RestoreProfileRoute _fromState(GoRouterState state) =>
|
||||
RestoreProfileRoute(
|
||||
backupFilePath: state.uri.queryParameters['backup-file-path']!,
|
||||
);
|
||||
|
||||
RestoreProfileRoute get _self => this as RestoreProfileRoute;
|
||||
|
||||
@override
|
||||
String get location => GoRouteData.$location(
|
||||
'/browser/profiles/restore',
|
||||
queryParams: {'backup-file-path': _self.backupFilePath},
|
||||
);
|
||||
|
||||
@override
|
||||
void go(BuildContext context) => context.go(location);
|
||||
|
||||
@override
|
||||
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
|
||||
|
||||
@override
|
||||
void pushReplacement(BuildContext context) =>
|
||||
context.pushReplacement(location);
|
||||
|
||||
@override
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
mixin $BackupProfileRoute on GoRouteData {
|
||||
static BackupProfileRoute _fromState(GoRouterState state) =>
|
||||
BackupProfileRoute(profile: state.uri.queryParameters['profile']!);
|
||||
|
||||
BackupProfileRoute get _self => this as BackupProfileRoute;
|
||||
|
||||
@override
|
||||
String get location => GoRouteData.$location(
|
||||
'/browser/profiles/backup',
|
||||
queryParams: {'profile': _self.profile},
|
||||
);
|
||||
|
||||
@override
|
||||
void go(BuildContext context) => context.go(location);
|
||||
|
||||
@override
|
||||
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
|
||||
|
||||
@override
|
||||
void pushReplacement(BuildContext context) =>
|
||||
context.pushReplacement(location);
|
||||
|
||||
@override
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
mixin $CreateProfileRoute on GoRouteData {
|
||||
static CreateProfileRoute _fromState(GoRouterState state) =>
|
||||
CreateProfileRoute();
|
||||
|
||||
Reference in New Issue
Block a user