diff --git a/android/app/build.gradle b/android/app/build.gradle index cb41471..69f34ff 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,3 +1,11 @@ +plugins { + id 'com.android.application' + id 'kotlin-android' + id "org.jetbrains.kotlin.android" + id 'dev.flutter.flutter-gradle-plugin' + id 'com.google.gms.google-services' +} + def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { @@ -6,11 +14,6 @@ if (localPropertiesFile.exists()) { } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' @@ -27,11 +30,6 @@ if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } -apply plugin: 'com.android.application' -apply plugin: 'com.google.gms.google-services' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - android { compileSdkVersion flutter.compileSdkVersion ndkVersion flutter.ndkVersion @@ -109,6 +107,5 @@ flutter { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.android.support:multidex:1.0.3' } diff --git a/android/build.gradle b/android/build.gradle index e6aaae5..b42eb3a 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,17 +1,3 @@ -buildscript { - ext.kotlin_version = '1.7.10' - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.google.gms:google-services:4.4.1' - } -} - allprojects { repositories { google() diff --git a/android/settings.gradle b/android/settings.gradle index 44e62bc..c07940c 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,11 +1,26 @@ -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.4.2" apply false + id "org.jetbrains.kotlin.android" version "1.7.10" apply false + id "com.google.gms.google-services" version "4.4.0" apply false +} + +include ":app" \ No newline at end of file diff --git a/lib/app/cubit/app_cubit.dart b/lib/app/cubit/app_cubit.dart index 5adfe25..a9825b3 100644 --- a/lib/app/cubit/app_cubit.dart +++ b/lib/app/cubit/app_cubit.dart @@ -8,7 +8,7 @@ class AppCubit extends Cubit { required UserRepository userRepository, }) : _userRepository = userRepository, super( - userRepository.user.isNone + userRepository.user.isEmpty ? const AppState.unauthenticated() : AppState.newlyAuthenticated(userRepository.user), ) { @@ -32,7 +32,7 @@ class AppCubit extends Cubit { } void _onUserChanged(User user) { - if (user.isNone) { + if (user.isEmpty) { emit(const AppState.unauthenticated()); } else if (state.isUnauthenticated) { emit(AppState.newlyAuthenticated(user)); @@ -44,7 +44,7 @@ class AppCubit extends Cubit { void _onUserFailed(UserFailure failure) { final currentState = state; emit(AppState.failure(failure: failure, user: currentState.user)); - if (failure.requiresReauthentication) { + if (failure.needsReauthentication) { emit(const AppState.unauthenticated()); } else { emit(currentState); diff --git a/lib/app/cubit/app_state.dart b/lib/app/cubit/app_state.dart index 3392a27..621c1fb 100644 --- a/lib/app/cubit/app_state.dart +++ b/lib/app/cubit/app_state.dart @@ -17,8 +17,8 @@ extension AppStatusExtensions on AppStatus { final class AppState extends Equatable { const AppState._({ required this.status, - this.user = User.none, - this.failure = UserFailure.none, + this.user = User.empty, + this.failure = UserFailure.empty, }); const AppState.unauthenticated() : this._(status: AppStatus.unauthenticated); diff --git a/lib/login/cubit/login_state.dart b/lib/login/cubit/login_state.dart index ae31c02..8d6aa9d 100644 --- a/lib/login/cubit/login_state.dart +++ b/lib/login/cubit/login_state.dart @@ -18,7 +18,7 @@ final class LoginState extends Equatable { const LoginState._({ this.status = LoginStatus.initial, this.signInMethod = SignInMethod.none, - this.failure = UserFailure.none, + this.failure = UserFailure.empty, }); const LoginState.initial() : this._(); diff --git a/lib/profile/cubit/profile_cubit.dart b/lib/profile/cubit/profile_cubit.dart index b15bc34..a85fe59 100644 --- a/lib/profile/cubit/profile_cubit.dart +++ b/lib/profile/cubit/profile_cubit.dart @@ -4,7 +4,7 @@ import 'package:user_repository/user_repository.dart'; class ProfileCubit extends Cubit { ProfileCubit({required UserRepository userRepository}) : _userRepository = userRepository, - super(User.none) { + super(User.empty) { _watchUser(); } diff --git a/lib/quiz/cubit/quiz_cubit.dart b/lib/quiz/cubit/quiz_cubit.dart index f6ba647..9ea2280 100644 --- a/lib/quiz/cubit/quiz_cubit.dart +++ b/lib/quiz/cubit/quiz_cubit.dart @@ -19,7 +19,7 @@ class QuizCubit extends Cubit { try { emit(state.fromQuizLoading()); final quiz = await _quizzesRepository.getQuiz(quizId); - if (quiz.isNone) { + if (quiz.isEmpty) { emit(state.fromQuizEmpty()); return; } @@ -38,7 +38,7 @@ class QuizCubit extends Cubit { } void unselectOption() { - emit(state.copyWith(selectedOption: Option.none)); + emit(state.copyWith(selectedOption: Option.empty)); } void validateAnswer() { diff --git a/lib/quiz/cubit/quiz_state.dart b/lib/quiz/cubit/quiz_state.dart index 5d300f1..56962cd 100644 --- a/lib/quiz/cubit/quiz_state.dart +++ b/lib/quiz/cubit/quiz_state.dart @@ -5,10 +5,10 @@ enum QuizStatus { initial, loading, empty, loaded, failure } final class QuizState extends Equatable { const QuizState._({ this.status = QuizStatus.initial, - this.quiz = Quiz.none, - this.selectedOption = Option.none, + this.quiz = Quiz.empty, + this.selectedOption = Option.empty, this.step = 0, - this.failure = QuizzesFailure.none, + this.failure = QuizzesFailure.empty, }); const QuizState.initial() : this._(); @@ -57,5 +57,5 @@ extension QuizStateExtensions on QuizState { double get progress => step / steps; Question operator [](int step) => - quiz.questions.isEmpty ? Question.none : quiz.questions[step - 1]; + quiz.questions.isEmpty ? Question.empty : quiz.questions[step - 1]; } diff --git a/lib/quiz/view/quiz_page.dart b/lib/quiz/view/quiz_page.dart index e0f865b..e44257c 100644 --- a/lib/quiz/view/quiz_page.dart +++ b/lib/quiz/view/quiz_page.dart @@ -91,7 +91,7 @@ class _QuizBodyState extends State { listenWhen: (previous, current) => previous.quiz.id != current.quiz.id, listener: (_, state) { - if (state.quiz.isNone) { + if (state.quiz.isEmpty) { context.read()(); } }, @@ -110,7 +110,7 @@ class _QuizBodyState extends State { listenWhen: (previous, current) => previous.selectedOption != current.selectedOption, listener: (_, state) { - if (state.selectedOption.isNotNone) { + if (state.selectedOption.isNotEmpty) { context.showScrollControlledBottomSheet( builder: (_) { return BlocProvider.value( diff --git a/lib/topics/cubit/topics_state.dart b/lib/topics/cubit/topics_state.dart index 88d29b0..5c93f27 100644 --- a/lib/topics/cubit/topics_state.dart +++ b/lib/topics/cubit/topics_state.dart @@ -4,10 +4,10 @@ enum TopicsStatus { initial, loading, empty, loaded, failure } final class TopicsState extends Equatable { const TopicsState._({ - this.user = User.none, + this.user = User.empty, this.status = TopicsStatus.initial, this.topics = const [], - this.failure = TopicsFailure.none, + this.failure = TopicsFailure.empty, }); const TopicsState.initial() : this._(); diff --git a/lib/topics/view/topics_flow.dart b/lib/topics/view/topics_flow.dart index 228ca75..54568c6 100644 --- a/lib/topics/view/topics_flow.dart +++ b/lib/topics/view/topics_flow.dart @@ -27,7 +27,7 @@ List> onGenerateTopicsPages( class TopicsFlowState extends Equatable { const TopicsFlowState._({ - this.selectedTopic = Topic.none, + this.selectedTopic = Topic.empty, this.selectedQuizId = '', }); @@ -36,7 +36,7 @@ class TopicsFlowState extends Equatable { final Topic selectedTopic; final String selectedQuizId; - bool get hasTopicSelected => selectedTopic.isNotNone; + bool get hasTopicSelected => selectedTopic.isNotEmpty; bool get hasQuizSelected => selectedQuizId.isNotEmpty; @override diff --git a/packages/app_core/lib/src/failure.dart b/packages/app_core/lib/src/failure.dart index b2eb624..03d502e 100644 --- a/packages/app_core/lib/src/failure.dart +++ b/packages/app_core/lib/src/failure.dart @@ -1,3 +1,5 @@ abstract class Failure implements Exception { const Failure(); + + bool get needsReauthentication => false; } diff --git a/packages/quizzes_repository/lib/src/failures.dart b/packages/quizzes_repository/lib/src/failures.dart index 955e73c..a792557 100644 --- a/packages/quizzes_repository/lib/src/failures.dart +++ b/packages/quizzes_repository/lib/src/failures.dart @@ -5,11 +5,11 @@ class QuizzesFailure extends Failure { factory QuizzesFailure.fromGetQuiz() => const GetQuizFailure(); - static const none = QuizzesNoFailure(); + static const empty = EmptyQuizzesFailure(); } -class QuizzesNoFailure extends QuizzesFailure { - const QuizzesNoFailure() : super._(); +class EmptyQuizzesFailure extends QuizzesFailure { + const EmptyQuizzesFailure() : super._(); } class GetQuizFailure extends QuizzesFailure { diff --git a/packages/quizzes_repository/lib/src/models/models.dart b/packages/quizzes_repository/lib/src/models/models.dart index db99326..bbbc818 100644 --- a/packages/quizzes_repository/lib/src/models/models.dart +++ b/packages/quizzes_repository/lib/src/models/models.dart @@ -17,7 +17,7 @@ class Option extends Equatable { final String detail; final bool? correct; - static const none = Option(value: '', detail: '', correct: null); + static const empty = Option(value: '', detail: '', correct: null); @override List get props => [value, detail, correct]; @@ -26,7 +26,7 @@ class Option extends Equatable { } extension OptionExtensions on Option { - bool get isNotNone => this != Option.none; + bool get isNotEmpty => this != Option.empty; } @JsonSerializable(createToJson: false) @@ -40,7 +40,7 @@ class Question extends Equatable { @JsonKey(defaultValue: