Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ UNTRANSLATED.txt
# Generated code
*.g.dart
*.freezed.dart
# All except the generated code for the realm classes
# Realm and riverpod code generation does not work nicely together.
# Keep the one file from Realm to avoid ongoing code generation issues.
!lib/src/data/book/realm/realm_book.g.dart
3 changes: 1 addition & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ android {
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "at.shockbytes.dantex"
applicationId "at.shockbytes.dante"
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
Expand Down
2 changes: 1 addition & 1 deletion ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
61 changes: 34 additions & 27 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@ PODS:
- Firebase/Storage (10.18.0):
- Firebase/CoreOnly
- FirebaseStorage (~> 10.18.0)
- firebase_analytics (10.7.2):
- firebase_analytics (10.8.0):
- Firebase/Analytics (= 10.18.0)
- firebase_core
- Flutter
- firebase_auth (4.15.0):
- firebase_auth (4.16.0):
- Firebase/Auth (= 10.18.0)
- firebase_core
- Flutter
- firebase_core (2.24.0):
- firebase_core (2.24.2):
- Firebase/CoreOnly (= 10.18.0)
- Flutter
- firebase_crashlytics (3.4.6):
- firebase_crashlytics (3.4.9):
- Firebase/Crashlytics (= 10.18.0)
- firebase_core
- Flutter
- firebase_database (10.3.6):
- firebase_database (10.4.0):
- Firebase/Database (= 10.18.0)
- firebase_core
- Flutter
- firebase_storage (11.5.3):
- firebase_storage (11.6.0):
- Firebase/Storage (= 10.18.0)
- firebase_core
- Flutter
Expand Down Expand Up @@ -123,7 +123,8 @@ PODS:
- FMDB/standard (2.7.5)
- google_sign_in_ios (0.0.1):
- Flutter
- GoogleSignIn (~> 6.2)
- FlutterMacOS
- GoogleSignIn (~> 7.0)
- GoogleAppMeasurement (10.18.0):
- GoogleAppMeasurement/AdIdSupport (= 10.18.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
Expand All @@ -148,10 +149,10 @@ PODS:
- GoogleUtilities/Environment (~> 7.7)
- nanopb (< 2.30910.0, >= 2.30908.0)
- PromisesObjC (< 3.0, >= 1.2)
- GoogleSignIn (6.2.4):
- GoogleSignIn (7.0.0):
- AppAuth (~> 1.5)
- GTMAppAuth (~> 1.3)
- GTMSessionFetcher/Core (< 3.0, >= 1.1)
- GTMAppAuth (< 3.0, >= 1.3)
- GTMSessionFetcher/Core (< 4.0, >= 1.1)
- GoogleUtilities/AppDelegateSwizzler (7.12.0):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
Expand All @@ -171,9 +172,9 @@ PODS:
- GoogleUtilities/Logger
- GoogleUtilities/UserDefaults (7.12.0):
- GoogleUtilities/Logger
- GTMAppAuth (1.3.1):
- GTMAppAuth (2.0.0):
- AppAuth/Core (~> 1.6)
- GTMSessionFetcher/Core (< 3.0, >= 1.5)
- GTMSessionFetcher/Core (< 4.0, >= 1.5)
- GTMSessionFetcher/Core (2.3.0)
- leveldb-library (1.22.2)
- nanopb (2.30909.1):
Expand All @@ -187,6 +188,8 @@ PODS:
- PromisesObjC (2.3.1)
- PromisesSwift (2.3.1):
- PromisesObjC (= 2.3.1)
- realm (1.6.1):
- Flutter
- RecaptchaInterop (100.0.0)
- shared_preferences_foundation (0.0.1):
- Flutter
Expand All @@ -206,8 +209,9 @@ DEPENDENCIES:
- firebase_storage (from `.symlinks/plugins/firebase_storage/ios`)
- Flutter (from `Flutter`)
- flutter_barcode_scanner (from `.symlinks/plugins/flutter_barcode_scanner/ios`)
- google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/ios`)
- google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- realm (from `.symlinks/plugins/realm/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
Expand Down Expand Up @@ -260,9 +264,11 @@ EXTERNAL SOURCES:
flutter_barcode_scanner:
:path: ".symlinks/plugins/flutter_barcode_scanner/ios"
google_sign_in_ios:
:path: ".symlinks/plugins/google_sign_in_ios/ios"
:path: ".symlinks/plugins/google_sign_in_ios/darwin"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
realm:
:path: ".symlinks/plugins/realm/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite:
Expand All @@ -273,12 +279,12 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570
Firebase: 414ad272f8d02dfbf12662a9d43f4bba9bec2a06
firebase_analytics: a8c0d8ba83f213c9b775b5f61d36dadaafb1b239
firebase_auth: 02d1a6340f81020cc302fb8fea8518908c546cec
firebase_core: f802c5c1f6caff9b8d38b591a36e7b25f8878936
firebase_crashlytics: 0db78a5b6badc630f21a833d0c9ab20ab5d81948
firebase_database: 18b34a683c878f836ac5a403ce29242065d5acd0
firebase_storage: 95b470ab32351049dfd3d97b595460ce7a189971
firebase_analytics: b3d6dd14c61549a29abb10e9843446a4d8bb53eb
firebase_auth: 8e9ec02991ca4659111cc671c84d0c010b6bfb26
firebase_core: 0af4a2b24f62071f9bf283691c0ee41556dcb3f5
firebase_crashlytics: 4b91b8ad60ee7c168fe88979f84c9573a729de7a
firebase_database: 5d420ac53c48f3394445c8b83c530a42d149c3d4
firebase_storage: 2b932fa5461f4efac36a2dcfbe240898b190b5b1
FirebaseAnalytics: 4d310b35c48eaa4a058ddc04bdca6bdb5dc0fe80
FirebaseAppCheckInterop: 3cd914842ba46f4304050874cd284de82f154ffd
FirebaseAuth: 12314b438fa76048540c8fb86d6cfc9e08595176
Expand All @@ -292,25 +298,26 @@ SPEC CHECKSUMS:
FirebaseSessions: f90fe9212ee2818641eda051c0835c9c4e30d9ae
FirebaseSharedSwift: 62e248642c0582324d0390706cadd314687c116b
FirebaseStorage: 8333c4b183764cdd170d9539a61322b71c23adff
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_barcode_scanner: 7a1144744c28dc0c57a8de7218ffe5ec59a9e4bf
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
google_sign_in_ios: 1256ff9d941db546373826966720b0c24804bcdd
google_sign_in_ios: 1bfaf6607b44cd1b24c4d4bc39719870440f9ce1
GoogleAppMeasurement: 70ce9aa438cff1cfb31ea3e660bcc67734cb716e
GoogleDataTransport: 57c22343ab29bc686febbf7cbb13bad167c2d8fe
GoogleSignIn: 5651ce3a61e56ca864160e79b484cd9ed3f49b7a
GoogleSignIn: b232380cf495a429b8095d3178a8d5855b42e842
GoogleUtilities: 0759d1a57ebb953965c2dfe0ba4c82e95ccc2e34
GTMAppAuth: 0ff230db599948a9ad7470ca667337803b3fc4dd
GTMAppAuth: 99fb010047ba3973b7026e45393f51f27ab965ae
GTMSessionFetcher: 3a63d75eecd6aa32c2fc79f578064e1214dfdec2
leveldb-library: f03246171cce0484482ec291f88b6d563699ee06
nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
PromisesSwift: 28dca69a9c40779916ac2d6985a0192a5cb4a265
realm: d2cda90107b12761cef58f16a606f4d14333b071
RecaptchaInterop: 7d1a4a01a6b2cb1610a47ef3f85f0c411434cb21
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
url_launcher_ios: bf5ce03e0e2088bad9cc378ea97fa0ed5b49673b
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812

PODFILE CHECKSUM: 7adbc9d59f05e1b01f554ea99b6c79e97f2214a2

Expand Down
18 changes: 18 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
2E18E51AD90C59402E14BDEC /* [CP] Embed Pods Frameworks */,
BE07253FC1FD406B03000781 /* [firebase_crashlytics] Crashlytics Upload Symbols */,
D826D48A3F0835A21664F0B1 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -296,6 +297,23 @@
shellPath = /bin/sh;
shellScript = "\"$PODS_ROOT/FirebaseCrashlytics/upload-symbols\" --flutter-project \"$PROJECT_DIR/firebase_app_id_file.json\" ";
};
D826D48A3F0835A21664F0B1 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import 'package:collection/collection.dart';
import 'package:dantex/src/data/authentication/authentication_repository.dart';
import 'package:dantex/src/data/authentication/entity/dante_user.dart';
import 'package:dantex/src/data/authentication/on_user_authenticated_plugin.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/foundation.dart' show kIsWeb;

class FirebaseAuthenticationRepository implements AuthenticationRepository {
final FirebaseAuth _fbAuth;
final List<OnUserAuthenticatedPlugin> _onUserAuthenticatedPlugins;

FirebaseAuthenticationRepository(this._fbAuth);
FirebaseAuthenticationRepository(
this._fbAuth,
this._onUserAuthenticatedPlugins,
);

@override
Stream<DanteUser?> get authStateChanges =>
Expand Down Expand Up @@ -35,7 +40,7 @@ class FirebaseAuthenticationRepository implements AuthenticationRepository {
return null;
}

return DanteUser(
final DanteUser user = DanteUser(
givenName: fbUser.displayName,
displayName: fbUser.displayName,
email: fbUser.email,
Expand All @@ -44,6 +49,10 @@ class FirebaseAuthenticationRepository implements AuthenticationRepository {
userId: fbUser.uid,
source: _retrieveAuthenticationSource(fbUser),
);

_callOnUserAuthenticatedPlugins(user);

return user;
}

AuthenticationSource _retrieveAuthenticationSource(User user) {
Expand All @@ -58,6 +67,12 @@ class FirebaseAuthenticationRepository implements AuthenticationRepository {
}
}

void _callOnUserAuthenticatedPlugins(DanteUser user) {
for (var plugin in _onUserAuthenticatedPlugins) {
plugin.onUserAuthenticated(user);
}
}

bool _isAnonymous(User user) => user.isAnonymous;

bool _isGoogleUser(User user) =>
Expand Down
8 changes: 8 additions & 0 deletions lib/src/data/authentication/on_user_authenticated_plugin.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


import 'package:dantex/src/data/authentication/entity/dante_user.dart';

abstract class OnUserAuthenticatedPlugin {

void onUserAuthenticated(DanteUser user);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'dart:async';

import 'package:dantex/src/data/authentication/entity/dante_user.dart';
import 'package:dantex/src/data/authentication/on_user_authenticated_plugin.dart';
import 'package:dantex/src/data/book/migration/migration_runner.dart';

class RealmMigrationOnUserAuthenticatedPlugin
implements OnUserAuthenticatedPlugin {
final MigrationRunner _migrationRunner;

RealmMigrationOnUserAuthenticatedPlugin(
this._migrationRunner,
);

@override
void onUserAuthenticated(DanteUser user) {
unawaited(
_migrationRunner.migrateIfRequired(),
);
}
}
23 changes: 23 additions & 0 deletions lib/src/data/book/entity/page_record.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:freezed_annotation/freezed_annotation.dart';

part 'page_record.freezed.dart';
part 'page_record.g.dart';

@freezed
class PageRecord with _$PageRecord {

const PageRecord._();

const factory PageRecord({
required String id,
required String bookId,
required int fromPage,
required int toPage,
required DateTime dateTime,
}) = _PageRecord;

int get diffPages => toPage - fromPage;

factory PageRecord.fromJson(Map<String, Object?> json) =>
_$PageRecordFromJson(json);
}
9 changes: 2 additions & 7 deletions lib/src/data/book/firebase_book_label_repository.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:dantex/src/data/book/book_label_repository.dart';
import 'package:dantex/src/data/book/entity/book_label.dart';
import 'package:dantex/src/data/book/firebase_utils.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_database/firebase_database.dart';

Expand Down Expand Up @@ -49,10 +50,4 @@ class FirebaseBookLabelRepository implements BookLabelRepository {
final user = _fbAuth.currentUser!.uid;
return _fbDb.ref('users/$user/labels/');
}
}

extension DataSnapshotExtension on DataSnapshot {
Map<String, dynamic>? toMap() {
return (value != null) ? (value as Map<dynamic, dynamic>).cast() : null;
}
}
}
7 changes: 1 addition & 6 deletions lib/src/data/book/firebase_book_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:dantex/src/data/book/book_repository.dart';
import 'package:dantex/src/data/book/entity/book.dart';
import 'package:dantex/src/data/book/entity/book_label.dart';
import 'package:dantex/src/data/book/entity/book_state.dart';
import 'package:dantex/src/data/book/firebase_utils.dart';
import 'package:dantex/src/data/book/search_criteria.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_database/firebase_database.dart';
Expand Down Expand Up @@ -217,9 +218,3 @@ class FirebaseBookRepository implements BookRepository {
}
}
}

extension DataSnapshotExtension on DataSnapshot {
Map<String, dynamic>? toMap() {
return (value != null) ? (value as Map<dynamic, dynamic>).cast() : null;
}
}
Loading