mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Extract db functions out of MyApp
This commit is contained in:
parent
0b6f399570
commit
5b918b81d4
9 changed files with 14 additions and 21 deletions
|
@ -29,7 +29,7 @@ class AppDb {
|
||||||
|
|
||||||
/// Open the database
|
/// Open the database
|
||||||
static Future<Database> _open() async {
|
static Future<Database> _open() async {
|
||||||
final dbFactory = platform.MyApp.getDbFactory();
|
final dbFactory = platform.getDbFactory();
|
||||||
return dbFactory.open(dbName, version: 1, onUpgradeNeeded: (event) {
|
return dbFactory.open(dbName, version: 1, onUpgradeNeeded: (event) {
|
||||||
final db = event.database;
|
final db = event.database;
|
||||||
if (event.oldVersion < 1) {
|
if (event.oldVersion < 1) {
|
||||||
|
|
|
@ -8,9 +8,8 @@ import 'package:kiwi/kiwi.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:nc_photos/k.dart' as k;
|
import 'package:nc_photos/k.dart' as k;
|
||||||
import 'package:nc_photos/metadata_task_manager.dart';
|
import 'package:nc_photos/metadata_task_manager.dart';
|
||||||
import 'package:nc_photos/mobile/platform.dart'
|
|
||||||
if (dart.library.html) 'package:nc_photos/web/platform.dart' as platform;
|
|
||||||
import 'package:nc_photos/pref.dart';
|
import 'package:nc_photos/pref.dart';
|
||||||
|
import 'package:nc_photos/widget/my_app.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
@ -21,7 +20,7 @@ void main() async {
|
||||||
_initKiwi();
|
_initKiwi();
|
||||||
_initEquatable();
|
_initEquatable();
|
||||||
|
|
||||||
runApp(platform.MyApp());
|
runApp(MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
void _initLog() {
|
void _initLog() {
|
||||||
|
|
4
lib/mobile/db_util.dart
Normal file
4
lib/mobile/db_util.dart
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import 'package:idb_sqflite/idb_sqflite.dart';
|
||||||
|
import 'package:sqflite/sqflite.dart';
|
||||||
|
|
||||||
|
IdbFactory getDbFactory() => getIdbFactorySqflite(databaseFactory);
|
|
@ -1,7 +0,0 @@
|
||||||
import 'package:idb_sqflite/idb_sqflite.dart';
|
|
||||||
import 'package:nc_photos/widget/my_app.dart' as itf;
|
|
||||||
import 'package:sqflite/sqflite.dart';
|
|
||||||
|
|
||||||
class MyApp extends itf.MyApp {
|
|
||||||
static IdbFactory getDbFactory() => getIdbFactorySqflite(databaseFactory);
|
|
||||||
}
|
|
|
@ -1,3 +1,3 @@
|
||||||
|
export 'db_util.dart';
|
||||||
export 'downloader.dart';
|
export 'downloader.dart';
|
||||||
export 'metadata_loader.dart';
|
export 'metadata_loader.dart';
|
||||||
export 'my_app.dart';
|
|
||||||
|
|
4
lib/web/db_util.dart
Normal file
4
lib/web/db_util.dart
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import 'package:idb_shim/idb_browser.dart';
|
||||||
|
import 'package:idb_shim/idb_shim.dart';
|
||||||
|
|
||||||
|
IdbFactory getDbFactory() => getIdbFactory();
|
|
@ -1,7 +0,0 @@
|
||||||
import 'package:idb_shim/idb_browser.dart';
|
|
||||||
import 'package:idb_shim/idb_shim.dart';
|
|
||||||
import 'package:nc_photos/widget/my_app.dart' as itf;
|
|
||||||
|
|
||||||
class MyApp extends itf.MyApp {
|
|
||||||
static IdbFactory getDbFactory() => getIdbFactory();
|
|
||||||
}
|
|
|
@ -1,3 +1,3 @@
|
||||||
|
export 'db_util.dart';
|
||||||
export 'downloader.dart';
|
export 'downloader.dart';
|
||||||
export 'metadata_loader.dart';
|
export 'metadata_loader.dart';
|
||||||
export 'my_app.dart';
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import 'package:nc_photos/widget/sign_in.dart';
|
||||||
import 'package:nc_photos/widget/splash.dart';
|
import 'package:nc_photos/widget/splash.dart';
|
||||||
import 'package:nc_photos/widget/viewer.dart';
|
import 'package:nc_photos/widget/viewer.dart';
|
||||||
|
|
||||||
abstract class MyApp extends StatelessWidget implements SnackBarHandler {
|
class MyApp extends StatelessWidget implements SnackBarHandler {
|
||||||
MyApp() {
|
MyApp() {
|
||||||
SnackBarManager().registerHandler(this);
|
SnackBarManager().registerHandler(this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue