-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
developed sharing feature & solved issue #36
- Loading branch information
1 parent
89bdd65
commit cfe7a33
Showing
68 changed files
with
2,257 additions
and
1,175 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,11 +1,25 @@ | ||
include ':app' | ||
pluginManagement { | ||
def flutterSdkPath = { | ||
def properties = new Properties() | ||
file("local.properties").withInputStream { properties.load(it) } | ||
def flutterSdkPath = properties.getProperty("flutter.sdk") | ||
assert flutterSdkPath != null, "flutter.sdk not set in local.properties" | ||
return flutterSdkPath | ||
}() | ||
|
||
def localPropertiesFile = new File(rootProject.projectDir, "local.properties") | ||
def properties = new Properties() | ||
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") | ||
|
||
assert localPropertiesFile.exists() | ||
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } | ||
repositories { | ||
google() | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
def flutterSdkPath = properties.getProperty("flutter.sdk") | ||
assert flutterSdkPath != null, "flutter.sdk not set in local.properties" | ||
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" | ||
plugins { | ||
id "dev.flutter.flutter-plugin-loader" version "1.0.0" | ||
id "com.android.application" version "7.2.0" apply false | ||
id "org.jetbrains.kotlin.android" version "1.9.10" apply false | ||
} | ||
|
||
include ":app" |
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,39 +1,42 @@ | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:otp_manager/bloc/account_details/account_details_event.dart'; | ||
import 'package:otp_manager/bloc/account_details/account_details_state.dart'; | ||
import 'package:otp_manager/models/account.dart'; | ||
import 'package:otp_manager/repository/local_repository.dart'; | ||
import 'package:otp_manager/repository/interface/account_repository.dart'; | ||
import 'package:otp_manager/repository/interface/shared_account_repository.dart'; | ||
import 'package:otp_manager/repository/interface/user_repository.dart'; | ||
import 'package:otp_manager/routing/constants.dart'; | ||
|
||
import '../../domain/account_service.dart'; | ||
import '../../routing/navigation_service.dart'; | ||
|
||
class AccountDetailsBloc | ||
extends Bloc<AccountDetailsEvent, AccountDetailsState> { | ||
final LocalRepositoryImpl localRepositoryImpl; | ||
final Account account; | ||
final UserRepository userRepository; | ||
final AccountRepository accountRepository; | ||
final AccountService accountService; | ||
final SharedAccountRepository sharedAccountRepository; | ||
final dynamic account; // Account | SharedAccount | ||
|
||
final NavigationService _navigationService = NavigationService(); | ||
|
||
AccountDetailsBloc({ | ||
required this.localRepositoryImpl, | ||
required this.userRepository, | ||
required this.accountRepository, | ||
required this.accountService, | ||
required this.sharedAccountRepository, | ||
required this.account, | ||
}) : super( | ||
AccountDetailsState.initial(account, localRepositoryImpl.getUser()!), | ||
AccountDetailsState.initial(account, userRepository.get()!), | ||
) { | ||
on<DeleteAccount>(_onDeleteAccount); | ||
} | ||
|
||
void _onDeleteAccount( | ||
DeleteAccount event, Emitter<AccountDetailsState> emit) { | ||
if (localRepositoryImpl.setAccountAsDeleted(state.account.id)) { | ||
emit(state.copyWith( | ||
accountDeleted: | ||
"${state.account.type == "totp" ? "TOTP" : "HOTP"} has been removed")); | ||
_navigationService.resetToScreen(homeRoute); | ||
} else { | ||
emit(state.copyWith( | ||
accountDeleted: "There was an error while deleting the account")); | ||
_navigationService.goBack(); | ||
} | ||
accountService.setAsDeleted(state.account); | ||
|
||
emit(state.copyWith( | ||
message: "${state.account.type.toUpperCase()} has been removed")); | ||
_navigationService.resetToScreen(homeRoute); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,31 +1,33 @@ | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:otp_manager/models/user.dart'; | ||
|
||
import '../../models/account.dart'; | ||
|
||
class AccountDetailsState extends Equatable { | ||
final Account account; | ||
final String accountDeleted; | ||
final dynamic account; // Account | ShareAccount | ||
final String message; | ||
final String password; | ||
final String serverUrl; | ||
|
||
const AccountDetailsState({ | ||
required this.account, | ||
required this.accountDeleted, | ||
required this.message, | ||
required this.password, | ||
required this.serverUrl, | ||
}); | ||
|
||
AccountDetailsState.initial(this.account, User user) | ||
: accountDeleted = "", | ||
password = user.password ?? ""; | ||
: message = "", | ||
password = user.password!, | ||
serverUrl = user.url; | ||
|
||
AccountDetailsState copyWith({String? accountDeleted}) { | ||
AccountDetailsState copyWith({String? message}) { | ||
return AccountDetailsState( | ||
account: account, | ||
accountDeleted: accountDeleted ?? this.accountDeleted, | ||
message: message ?? this.message, | ||
password: password, | ||
serverUrl: serverUrl, | ||
); | ||
} | ||
|
||
@override | ||
List<Object> get props => [accountDeleted]; | ||
List<Object> get props => [message]; | ||
} |
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 |
---|---|---|
@@ -1,45 +1,38 @@ | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:otp_manager/models/user.dart'; | ||
|
||
class AuthState extends Equatable { | ||
final int attempts; | ||
final String password; | ||
final String message; | ||
final bool isError; | ||
final bool canShowFingerAuth; | ||
|
||
const AuthState({ | ||
required this.attempts, | ||
required this.password, | ||
required this.message, | ||
required this.isError, | ||
required this.canShowFingerAuth, | ||
}); | ||
|
||
AuthState.initial(User user) | ||
const AuthState.initial() | ||
: attempts = 3, | ||
password = user.password ?? "", | ||
password = "", | ||
message = "", | ||
isError = false, | ||
canShowFingerAuth = false; | ||
|
||
AuthState copyWith({ | ||
int? attempts, | ||
String? password, | ||
String? message, | ||
bool? isError, | ||
bool? canShowFingerAuth, | ||
}) { | ||
return AuthState( | ||
attempts: attempts ?? this.attempts, | ||
password: password ?? this.password, | ||
message: message ?? this.message, | ||
isError: isError ?? this.isError, | ||
canShowFingerAuth: canShowFingerAuth ?? this.canShowFingerAuth, | ||
); | ||
} | ||
|
||
@override | ||
List<Object> get props => | ||
[attempts, password, message, isError, canShowFingerAuth]; | ||
List<Object> get props => [attempts, password, message, canShowFingerAuth]; | ||
} |
Oops, something went wrong.