-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Prepare model & setting UI * Add functionality & UI including PIN/Forget * Draft save security question * Initial on main to avoid UI initial glitch * Refactor setting pin code ; make it smooth * Add basic analytics * Required PIN when go to app lock page * Use old data as initial
- Loading branch information
Showing
52 changed files
with
1,732 additions
and
183 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:copy_with_extension/copy_with_extension.dart'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
import 'package:storypad/core/types/app_lock_question.dart' show AppLockQuestion; | ||
|
||
part 'app_lock_object.g.dart'; | ||
|
||
@CopyWith() | ||
@JsonSerializable() | ||
class AppLockObject { | ||
final String? pin; | ||
final bool? enabledBiometric; | ||
final Map<AppLockQuestion, String>? securityAnswers; | ||
|
||
AppLockObject({ | ||
required this.pin, | ||
required this.enabledBiometric, | ||
required this.securityAnswers, | ||
}); | ||
|
||
factory AppLockObject.init() { | ||
return AppLockObject( | ||
pin: null, | ||
enabledBiometric: false, | ||
securityAnswers: null, | ||
); | ||
} | ||
|
||
Map<String, dynamic> toJson() => _$AppLockObjectToJson(this); | ||
factory AppLockObject.fromJson(Map<String, dynamic> json) => _$AppLockObjectFromJson(json); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:storypad/core/objects/app_lock_object.dart'; | ||
import 'package:storypad/core/storages/base_object_storages/object_storage.dart'; | ||
import 'package:storypad/core/storages/base_object_storages/bool_storage.dart'; | ||
|
||
class AppLockStorage extends ObjectStorage<AppLockObject> { | ||
@override | ||
AppLockObject decode(Map<String, dynamic> json) { | ||
return AppLockObject.fromJson(json); | ||
} | ||
|
||
@override | ||
Map<String, dynamic> encode(AppLockObject object) { | ||
return object.toJson(); | ||
} | ||
|
||
@override | ||
Future<AppLockObject?> readObject() async { | ||
AppLockObject? data = await super.readObject(); | ||
|
||
// TODO: remove this after a while. | ||
// ignore: deprecated_member_use_from_same_package | ||
bool? deprecatedData = await LocalAuthEnabledStorage().read(); | ||
|
||
if (deprecatedData != null) { | ||
data = (data ?? AppLockObject.init()).copyWith(enabledBiometric: deprecatedData); | ||
|
||
// ignore: deprecated_member_use_from_same_package | ||
LocalAuthEnabledStorage().remove(); | ||
} | ||
|
||
return data; | ||
} | ||
} | ||
|
||
@Deprecated('Will be removed soon.') | ||
class LocalAuthEnabledStorage extends BoolStorage {} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// ignore_for_file: constant_identifier_names | ||
|
||
import 'package:easy_localization/easy_localization.dart' show tr; | ||
|
||
enum AppLockQuestion { | ||
name_of_your_first_pet, | ||
city_or_town_your_were_born, | ||
favorite_childhood_friend, | ||
favorite_color, | ||
name_of_elementary_school, | ||
city_or_town_your_parent_met, | ||
name_of_your_first_teacher; | ||
|
||
String get translatedQuestion { | ||
switch (this) { | ||
case name_of_your_first_pet: | ||
return tr('general.security_question.name_of_your_first_pet'); | ||
case city_or_town_your_were_born: | ||
return tr('general.security_question.city_or_town_your_were_born'); | ||
case favorite_childhood_friend: | ||
return tr('general.security_question.favorite_childhood_friend'); | ||
case favorite_color: | ||
return tr('general.security_question.favorite_color'); | ||
case name_of_elementary_school: | ||
return tr('general.security_question.name_of_elementary_school'); | ||
case city_or_town_your_parent_met: | ||
return tr('general.security_question.city_or_town_your_parent_met'); | ||
case name_of_your_first_teacher: | ||
return tr('general.security_question.name_of_your_first_teacher'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// ignore_for_file: library_private_types_in_public_api | ||
|
||
import 'package:storypad/core/objects/app_lock_object.dart'; | ||
import 'package:storypad/core/services/local_auth_service.dart'; | ||
import 'package:storypad/core/storages/app_lock_storage.dart'; | ||
|
||
class _AppLockInitialData { | ||
final LocalAuthService localAuth; | ||
final AppLockObject appLock; | ||
|
||
_AppLockInitialData({ | ||
required this.localAuth, | ||
required this.appLock, | ||
}); | ||
} | ||
|
||
class AppLockInitializer { | ||
static _AppLockInitialData? _initialData; | ||
|
||
static Future<void> call() async { | ||
final localAuth = LocalAuthService(); | ||
await localAuth.load(); | ||
final appLock = await AppLockStorage().readObject() ?? AppLockObject.init(); | ||
|
||
_initialData = _AppLockInitialData( | ||
localAuth: localAuth, | ||
appLock: appLock, | ||
); | ||
} | ||
|
||
static _AppLockInitialData? getAndClear() { | ||
final tmp = _initialData; | ||
_initialData = null; | ||
return tmp; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.