fix: restore loop & opt.

This commit is contained in:
lollipopkit
2023-12-12 16:16:15 +08:00
parent 2200ff98d7
commit 54c75ecbe5
3 changed files with 8 additions and 39 deletions

View File

@@ -13,14 +13,6 @@ import 'data/res/color.dart';
import 'view/page/full_screen.dart'; import 'view/page/full_screen.dart';
import 'view/page/home.dart'; import 'view/page/home.dart';
/// After upgrading to flutter 3.13,
/// the shadow color of the drawer is white (maybe a bug).
/// Only on [iOS].
/// TODO: remember to remove it after the bug is fixed.
const _drawerTheme = DrawerThemeData(
shadowColor: Colors.black12,
);
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
const MyApp({super.key}); const MyApp({super.key});
@@ -54,7 +46,6 @@ class MyApp extends StatelessWidget {
useMaterial3: true, useMaterial3: true,
brightness: Brightness.dark, brightness: Brightness.dark,
colorSchemeSeed: primaryColor, colorSchemeSeed: primaryColor,
drawerTheme: _drawerTheme,
); );
return MaterialApp( return MaterialApp(
@@ -92,7 +83,7 @@ class MyApp extends StatelessWidget {
ThemeData _getAmoledTheme(ThemeData darkTheme) => darkTheme.copyWith( ThemeData _getAmoledTheme(ThemeData darkTheme) => darkTheme.copyWith(
scaffoldBackgroundColor: Colors.black, scaffoldBackgroundColor: Colors.black,
dialogBackgroundColor: Colors.black, dialogBackgroundColor: Colors.black,
drawerTheme: _drawerTheme.copyWith(backgroundColor: Colors.black), drawerTheme: const DrawerThemeData(backgroundColor: Colors.black),
appBarTheme: const AppBarTheme(backgroundColor: Colors.black), appBarTheme: const AppBarTheme(backgroundColor: Colors.black),
dialogTheme: const DialogTheme(backgroundColor: Colors.black), dialogTheme: const DialogTheme(backgroundColor: Colors.black),
bottomSheetTheme: bottomSheetTheme:

View File

@@ -1,10 +1,8 @@
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:hive_flutter/hive_flutter.dart'; import 'package:hive_flutter/hive_flutter.dart';
import 'package:toolbox/core/utils/misc.dart'; import 'package:toolbox/core/utils/misc.dart';
import 'package:toolbox/data/res/path.dart';
// abstract final class SecureStore { // abstract final class SecureStore {
// static const _secureStorage = FlutterSecureStorage(); // static const _secureStorage = FlutterSecureStorage();
@@ -42,32 +40,6 @@ class PersistentStore {
boxName, boxName,
//encryptionCipher: SecureStore._cipher, //encryptionCipher: SecureStore._cipher,
); );
/// Get all db filenames.
///
/// - [suffixs] defaults to ['.hive']
///
/// - If [hideSetting] is true, hide 'setting.hive'
static Future<List<String>> getFileNames({
bool hideSetting = false,
List<String>? suffixs,
}) async {
final docPath = await Paths.doc;
final dir = Directory(docPath);
final files = await dir.list().toList();
if (suffixs != null) {
files.removeWhere((e) => !suffixs.contains(e.path.split('.').last));
} else {
// filter out non-hive(db) files
files.removeWhere((e) => !e.path.endsWith('.hive'));
}
if (hideSetting) {
files.removeWhere((e) => e.path.endsWith('setting.hive'));
}
final paths =
files.map((e) => e.path.replaceFirst('$docPath/', '')).toList();
return paths;
}
} }
extension BoxX on Box { extension BoxX on Box {
@@ -85,7 +57,10 @@ extension BoxX on Box {
return val; return val;
} }
Future<void> updateLastModified() => put(lastModifiedKey, timeStamp); Future<void> updateLastModified([int? time]) => put(
lastModifiedKey,
time ?? timeStamp,
);
/// Convert db to json /// Convert db to json
Map<String, dynamic> toJson({bool includeInternal = true}) { Map<String, dynamic> toJson({bool includeInternal = true}) {

View File

@@ -117,6 +117,9 @@ class Backup {
} }
} }
// update last modified time, avoid restore again
Stores.setting.box.updateLastModified(lastModTime);
Pros.reload(); Pros.reload();
RebuildNodes.app.rebuild(); RebuildNodes.app.rebuild();