diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index bdf2de8c..9ea2b09c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -17,7 +17,7 @@ on:
workflow_dispatch:
env:
- flutter_version: "3.3.4"
+ flutter_version: "3.7.1"
flutter_channel: "stable"
java_version: "12.x"
@@ -61,7 +61,7 @@ jobs:
- name: Statically analyze the Dart code
run: |
- echo ${{ github.ref == 'refs/heads/master' && secrets.ENV_PROD || secrets.ENV_DEV }} | base64 -d > .env
+ echo "" | base64 -d > .env
flutter analyze .
test:
@@ -96,7 +96,7 @@ jobs:
- name: Run tests and generate coverage
run: |
- echo ${{ github.ref == 'refs/heads/master' && secrets.ENV_PROD || secrets.ENV_DEV }} | base64 -d > .env
+ echo "" | base64 -d > .env
flutter test --coverage -r expanded .
- name: Upload coverage to codecov
@@ -107,6 +107,7 @@ jobs:
build_android:
if: ${{ github.ref == 'refs/heads/development' || github.ref == 'refs/heads/master' }}
+ environment: ${{ github.ref == 'refs/heads/master' && 'production' || 'development' }}
needs: [analyze, test]
runs-on: macos-latest
timeout-minutes: 60
@@ -159,9 +160,9 @@ jobs:
- name: Build appbundle
env:
- GOOGLE_SERVICES_JSON: ${{ github.ref == 'refs/heads/master' && secrets.ANDROID_GOOGLE_SERVICES_JSON || secrets.ANDROID_GOOGLE_SERVICES_JSON_DEV }}
+ GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
run: |
- echo ${{ github.ref == 'refs/heads/master' && secrets.ENV_PROD || secrets.ENV_DEV }} | base64 -d > .env
+ echo ${{ secrets.ENV }} | base64 -d > .env
echo $GOOGLE_SERVICES_JSON | base64 -d > android/app/google-services.json
flutter build appbundle --release --build-number $GITHUB_RUN_NUMBER --no-tree-shake-icons
cp release_notes.txt build/app/outputs/
@@ -189,6 +190,7 @@ jobs:
build_ios:
if: ${{ github.ref == 'refs/heads/development' || github.ref == 'refs/heads/master' }}
+ environment: ${{ github.ref == 'refs/heads/master' && 'production' || 'development' }}
needs: [analyze, test]
runs-on: macos-latest
timeout-minutes: 60
@@ -324,7 +326,7 @@ jobs:
- name: Build web
run: |
- echo ${{ github.ref == 'refs/heads/master' && secrets.ENV_PROD || secrets.ENV_DEV }} | base64 -d > .env
+ echo ${{ secrets.ENV }} | base64 -d > .env
flutter build web -t lib/widgetbook/app.widgetbook.dart
- name: Publish to Widgetbook
@@ -332,6 +334,7 @@ jobs:
run: widgetbook publish --api-key $WIDGETBOOK_API_KEY
distribute_android:
+ environment: ${{ github.ref == 'refs/heads/master' && 'production' || 'development' }}
needs: [build_android]
runs-on: ubuntu-latest
steps:
@@ -350,6 +353,7 @@ jobs:
releaseNotesFile: release_notes.txt
distribute_ios:
+ environment: ${{ github.ref == 'refs/heads/master' && 'production' || 'development' }}
needs: [build_ios]
runs-on: macos-latest
steps:
diff --git a/android/build.gradle b/android/build.gradle
index 2a330ec6..6b74e344 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -6,10 +6,10 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:4.2.0'
+ classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
- classpath 'com.google.gms:google-services:4.3.10'
- classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
+ classpath 'com.google.gms:google-services:4.3.15'
+ classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.4'
}
}
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
index 939efa29..cb24abda 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
diff --git a/assets/images/logo.png b/assets/images/logo.png
new file mode 100644
index 00000000..92bdb93d
Binary files /dev/null and b/assets/images/logo.png differ
diff --git a/assets/images/unauthenticated_bg.png b/assets/images/unauthenticated_bg.png
new file mode 100644
index 00000000..3a8f1b83
Binary files /dev/null and b/assets/images/unauthenticated_bg.png differ
diff --git a/ios/Podfile.lock b/ios/Podfile.lock
index 7a085a69..b41523c5 100644
--- a/ios/Podfile.lock
+++ b/ios/Podfile.lock
@@ -1,80 +1,74 @@
PODS:
- country_codes (0.0.1):
- Flutter
- - Firebase/Auth (9.6.0):
+ - Firebase/Auth (10.3.0):
- Firebase/CoreOnly
- - FirebaseAuth (~> 9.6.0)
- - Firebase/CoreOnly (9.6.0):
- - FirebaseCore (= 9.6.0)
- - Firebase/Crashlytics (9.6.0):
+ - FirebaseAuth (~> 10.3.0)
+ - Firebase/CoreOnly (10.3.0):
+ - FirebaseCore (= 10.3.0)
+ - Firebase/Crashlytics (10.3.0):
- Firebase/CoreOnly
- - FirebaseCrashlytics (~> 9.6.0)
- - firebase_auth (3.11.2):
- - Firebase/Auth (= 9.6.0)
+ - FirebaseCrashlytics (~> 10.3.0)
+ - firebase_auth (4.2.2):
+ - Firebase/Auth (= 10.3.0)
- firebase_core
- Flutter
- - firebase_core (1.24.0):
- - Firebase/CoreOnly (= 9.6.0)
+ - firebase_core (2.4.1):
+ - Firebase/CoreOnly (= 10.3.0)
- Flutter
- - firebase_crashlytics (2.9.0):
- - Firebase/Crashlytics (= 9.6.0)
+ - firebase_crashlytics (3.0.11):
+ - Firebase/Crashlytics (= 10.3.0)
- firebase_core
- Flutter
- - FirebaseAuth (9.6.0):
- - FirebaseCore (~> 9.0)
- - GoogleUtilities/AppDelegateSwizzler (~> 7.7)
- - GoogleUtilities/Environment (~> 7.7)
- - GTMSessionFetcher/Core (< 3.0, >= 1.7)
- - FirebaseCore (9.6.0):
- - FirebaseCoreDiagnostics (~> 9.0)
- - FirebaseCoreInternal (~> 9.0)
- - GoogleUtilities/Environment (~> 7.7)
- - GoogleUtilities/Logger (~> 7.7)
- - FirebaseCoreDiagnostics (9.6.0):
- - GoogleDataTransport (< 10.0.0, >= 9.1.4)
- - GoogleUtilities/Environment (~> 7.7)
- - GoogleUtilities/Logger (~> 7.7)
- - nanopb (< 2.30910.0, >= 2.30908.0)
- - FirebaseCoreInternal (9.6.0):
- - "GoogleUtilities/NSData+zlib (~> 7.7)"
- - FirebaseCrashlytics (9.6.0):
- - FirebaseCore (~> 9.0)
- - FirebaseInstallations (~> 9.0)
- - GoogleDataTransport (< 10.0.0, >= 9.1.4)
- - GoogleUtilities/Environment (~> 7.7)
+ - FirebaseAuth (10.3.0):
+ - FirebaseCore (~> 10.0)
+ - GoogleUtilities/AppDelegateSwizzler (~> 7.8)
+ - GoogleUtilities/Environment (~> 7.8)
+ - GTMSessionFetcher/Core (< 4.0, >= 2.1)
+ - FirebaseCore (10.3.0):
+ - FirebaseCoreInternal (~> 10.0)
+ - GoogleUtilities/Environment (~> 7.8)
+ - GoogleUtilities/Logger (~> 7.8)
+ - FirebaseCoreInternal (10.5.0):
+ - "GoogleUtilities/NSData+zlib (~> 7.8)"
+ - FirebaseCrashlytics (10.3.0):
+ - FirebaseCore (~> 10.0)
+ - FirebaseInstallations (~> 10.0)
+ - GoogleDataTransport (~> 9.2)
+ - GoogleUtilities/Environment (~> 7.8)
- nanopb (< 2.30910.0, >= 2.30908.0)
- PromisesObjC (~> 2.1)
- - FirebaseInstallations (9.6.0):
- - FirebaseCore (~> 9.0)
- - GoogleUtilities/Environment (~> 7.7)
- - GoogleUtilities/UserDefaults (~> 7.7)
+ - FirebaseInstallations (10.5.0):
+ - FirebaseCore (~> 10.0)
+ - GoogleUtilities/Environment (~> 7.8)
+ - GoogleUtilities/UserDefaults (~> 7.8)
- PromisesObjC (~> 2.1)
- Flutter (1.0.0)
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
- - GoogleDataTransport (9.2.0):
+ - GoogleDataTransport (9.2.1):
- GoogleUtilities/Environment (~> 7.7)
- nanopb (< 2.30910.0, >= 2.30908.0)
- PromisesObjC (< 3.0, >= 1.2)
- - GoogleUtilities/AppDelegateSwizzler (7.10.0):
+ - GoogleUtilities/AppDelegateSwizzler (7.11.0):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- - GoogleUtilities/Environment (7.10.0):
+ - GoogleUtilities/Environment (7.11.0):
- PromisesObjC (< 3.0, >= 1.2)
- - GoogleUtilities/Logger (7.10.0):
+ - GoogleUtilities/Logger (7.11.0):
- GoogleUtilities/Environment
- - GoogleUtilities/Network (7.10.0):
+ - GoogleUtilities/Network (7.11.0):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Reachability
- - "GoogleUtilities/NSData+zlib (7.10.0)"
- - GoogleUtilities/Reachability (7.10.0):
+ - "GoogleUtilities/NSData+zlib (7.11.0)"
+ - GoogleUtilities/Reachability (7.11.0):
- GoogleUtilities/Logger
- - GoogleUtilities/UserDefaults (7.10.0):
+ - GoogleUtilities/UserDefaults (7.11.0):
- GoogleUtilities/Logger
- - GTMSessionFetcher/Core (2.3.0)
+ - GTMSessionFetcher/Core (3.1.0)
- image_cropper (0.0.4):
- Flutter
- TOCropViewController (~> 2.6.1)
@@ -87,17 +81,21 @@ PODS:
- nanopb/encode (2.30909.0)
- package_info_plus (0.4.5):
- Flutter
- - path_provider_ios (0.0.1):
+ - path_provider_foundation (0.0.1):
- Flutter
+ - FlutterMacOS
- phone_number (1.0.0):
- Flutter
- PhoneNumberKit/PhoneNumberKitCore (= 3.3.4)
- PhoneNumberKit/PhoneNumberKitCore (3.3.4)
- PromisesObjC (2.1.1)
+ - rive_common (0.0.1):
+ - Flutter
- share_plus (0.0.1):
- Flutter
- - shared_preferences_ios (0.0.1):
+ - shared_preferences_foundation (0.0.1):
- Flutter
+ - FlutterMacOS
- sqflite (0.0.2):
- Flutter
- FMDB (>= 2.7.5)
@@ -116,10 +114,11 @@ DEPENDENCIES:
- image_cropper (from `.symlinks/plugins/image_cropper/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- - path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
+ - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`)
- phone_number (from `.symlinks/plugins/phone_number/ios`)
+ - rive_common (from `.symlinks/plugins/rive_common/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- - shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`)
+ - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`)
@@ -129,7 +128,6 @@ SPEC REPOS:
- Firebase
- FirebaseAuth
- FirebaseCore
- - FirebaseCoreDiagnostics
- FirebaseCoreInternal
- FirebaseCrashlytics
- FirebaseInstallations
@@ -159,14 +157,16 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/image_picker_ios/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
- path_provider_ios:
- :path: ".symlinks/plugins/path_provider_ios/ios"
+ path_provider_foundation:
+ :path: ".symlinks/plugins/path_provider_foundation/ios"
phone_number:
:path: ".symlinks/plugins/phone_number/ios"
+ rive_common:
+ :path: ".symlinks/plugins/rive_common/ios"
share_plus:
:path: ".symlinks/plugins/share_plus/ios"
- shared_preferences_ios:
- :path: ".symlinks/plugins/shared_preferences_ios/ios"
+ shared_preferences_foundation:
+ :path: ".symlinks/plugins/shared_preferences_foundation/ios"
sqflite:
:path: ".symlinks/plugins/sqflite/ios"
url_launcher_ios:
@@ -176,34 +176,34 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
country_codes: b0900f46ad686281d5dab438e354e44ad10f5941
- Firebase: 5ae8b7cf8efce559a653aef0ad95bab3f427c351
- firebase_auth: 07a4db69cfa447ac42cb7faa560fc100708b707c
- firebase_core: 7c28ecc1e5dd74e03829ac3e9ff5ba3314e737a9
- firebase_crashlytics: 520a59314eaaadb34f9be4c2a285d99cfa88ebdb
- FirebaseAuth: e4a5d3c36e778e41141b91cc861103a441d80bcc
- FirebaseCore: 2082fffcd855f95f883c0a1641133eb9bbe76d40
- FirebaseCoreDiagnostics: 99a495094b10a57eeb3ae8efa1665700ad0bdaa6
- FirebaseCoreInternal: bca76517fe1ed381e989f5e7d8abb0da8d85bed3
- FirebaseCrashlytics: 3210572ddb77801e5a0bd9d7bc890769f2066a0c
- FirebaseInstallations: 0a115432c4e223c5ab20b0dbbe4cbefa793a0e8e
+ Firebase: f92fc551ead69c94168d36c2b26188263860acd9
+ firebase_auth: d1a0302ad8f1d642fc1cb53c43d25a951d70e190
+ firebase_core: bf59c32d2e53814f558efa20840c1902fa2fe461
+ firebase_crashlytics: b19405931669c882e0d08542e69ae9e86633c636
+ FirebaseAuth: 0e415d29d846c1dce2fb641e46f35e9888d9bec6
+ FirebaseCore: 988754646ab3bd4bdcb740f1bfe26b9f6c0d5f2a
+ FirebaseCoreInternal: e463f41bb935cd049505bf7e9a5bdd7dcea90df6
+ FirebaseCrashlytics: f20d956f8229010b645e534693c39e0b7843c268
+ FirebaseInstallations: 935bc4abb6f7a035cab7a0c31cb777b2be3dd254
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
- GoogleDataTransport: 1c8145da7117bd68bbbed00cf304edb6a24de00f
- GoogleUtilities: bad72cb363809015b1f7f19beb1f1cd23c589f95
- GTMSessionFetcher: 3a63d75eecd6aa32c2fc79f578064e1214dfdec2
+ GoogleDataTransport: ea169759df570f4e37bdee1623ec32a7e64e67c4
+ GoogleUtilities: c2bdc4cf2ce786c4d2e6b3bcfd599a25ca78f06f
+ GTMSessionFetcher: c9e714f7eec91a55641e2bab9f45fd83a219b882
image_cropper: 60c2789d1f1a78c873235d4319ca0c34a69f2d98
image_picker_ios: b786a5dcf033a8336a657191401bfdf12017dabb
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
- path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02
+ path_provider_foundation: 37748e03f12783f9de2cb2c4eadfaa25fe6d4852
phone_number: ad6f917e4fd2e507a198b93dca5eadcb463ec8c2
PhoneNumberKit: 441e8b26ec88d598e3591de9061eff18f5dd12e8
PromisesObjC: ab77feca74fa2823e7af4249b8326368e61014cb
+ rive_common: e35144d3b86972f8760b6c9f8b120dfd5fadfa13
share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68
- shared_preferences_ios: 548a61f8053b9b8a49ac19c1ffbc8b92c50d68ad
+ shared_preferences_foundation: 297b3ebca31b34ec92be11acd7fb0ba932c822ca
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
TOCropViewController: edfd4f25713d56905ad1e0b9f5be3fbe0f59c863
- url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de
+ url_launcher_ios: fb12c43172927bb5cf75aeebd073f883801f1993
webview_flutter_wkwebview: b7e70ef1ddded7e69c796c7390ee74180182971f
PODFILE CHECKSUM: f10c0438b63bc24e6bbc207956dc27d16c4408f2
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index 81e97647..4da0fede 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 51;
+ objectVersion = 54;
objects = {
/* Begin PBXBuildFile section */
@@ -208,6 +208,7 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
+ alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
@@ -222,6 +223,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
+ alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index a986a2a3..1e5b133b 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -70,5 +70,7 @@
com.apple.developer.associated-domains
-
-
\ No newline at end of file
+ UIApplicationSupportsIndirectInputEvents
+
+
+
diff --git a/lib/application/auth/auth_bloc.dart b/lib/application/auth/auth_bloc.dart
index 973fd1bf..fb746907 100644
--- a/lib/application/auth/auth_bloc.dart
+++ b/lib/application/auth/auth_bloc.dart
@@ -26,6 +26,7 @@ class AuthBloc extends Bloc {
String? _phone;
StreamSubscription>?
_verifyStreamSubscription;
+ StreamSubscription? _authenticationStateSubscription;
AuthBloc(
this._authRepository,
@@ -34,6 +35,7 @@ class AuthBloc extends Bloc {
on(
(event, emit) async {
await event.map(
+ initial: (event) async => await _mapObserveUserToState(emit, event),
verifyPhone: (event) async =>
await _mapVerifyPhoneToState(emit, event),
signInWithPhone: (event) async =>
@@ -51,6 +53,18 @@ class AuthBloc extends Bloc {
);
}
+ Future _mapObserveUserToState(
+ Emitter emit,
+ _InitialEvent event,
+ ) async {
+ _authenticationStateSubscription =
+ _authRepository.observeUser().listen((event) {
+ if (event is User && event.isAnonymous) {
+ emit(const AuthState.unauthenticated());
+ }
+ });
+ }
+
FutureOr _mapResendCodeToState(
Emitter emit,
_ResendCode event,
@@ -181,6 +195,7 @@ class AuthBloc extends Bloc {
@override
Future close() async {
_verifyStreamSubscription?.cancel();
+ _authenticationStateSubscription?.cancel();
super.close();
}
}
diff --git a/lib/application/auth/auth_event.dart b/lib/application/auth/auth_event.dart
index 6b11b16f..ed9a3f2a 100644
--- a/lib/application/auth/auth_event.dart
+++ b/lib/application/auth/auth_event.dart
@@ -2,6 +2,8 @@ part of 'auth_bloc.dart';
@freezed
class AuthEvent with _$AuthEvent {
+ const factory AuthEvent.initial() = _InitialEvent;
+
const factory AuthEvent.verifyPhone(String phoneNumber) = _VerifyPhone;
const factory AuthEvent.updated(
diff --git a/lib/application/participation/participation_bloc.dart b/lib/application/participation/participation_bloc.dart
index 6716d617..c9befcf7 100644
--- a/lib/application/participation/participation_bloc.dart
+++ b/lib/application/participation/participation_bloc.dart
@@ -31,12 +31,12 @@ class ParticipationBloc extends Bloc {
checkIn: () {
// TODO: Implement once the backend has implemented it
},
- toggleParticipation: (crowdActionId, commitmentOptions) async {
+ toggleParticipation: (crowdActionId, commitments) async {
emit(const ParticipationState.loading());
await participationRepository.toggleParticipation(
crowdActionId: crowdActionId,
- commitmentOptions: commitmentOptions,
+ commitments: commitments,
);
add(
diff --git a/lib/application/participation/participation_event.dart b/lib/application/participation/participation_event.dart
index a2306840..587341b2 100644
--- a/lib/application/participation/participation_event.dart
+++ b/lib/application/participation/participation_event.dart
@@ -8,6 +8,6 @@ class ParticipationEvent with _$ParticipationEvent {
const factory ParticipationEvent.checkIn() = _CheckIn;
const factory ParticipationEvent.toggleParticipation({
required String crowdActionId,
- List? commitmentOptions,
+ List? commitments,
}) = _ToggleParticipation;
}
diff --git a/lib/application/user/profile/profile_bloc.dart b/lib/application/user/profile/profile_bloc.dart
index 99784a81..fe7ce549 100644
--- a/lib/application/user/profile/profile_bloc.dart
+++ b/lib/application/user/profile/profile_bloc.dart
@@ -25,24 +25,45 @@ class ProfileBloc extends Bloc {
await userOrFailure.fold(
(failure) => const ProfileState(
userProfile: null,
- isEditing: false,
+ isPicEditing: false,
+ isBioEditing: false,
),
(userProfile) => state.copyWith(
userProfile: userProfile,
- isEditing: false,
+ isPicEditing: false,
+ isBioEditing: false,
),
),
);
});
- on((event, emit) {
- emit(state.copyWith(isEditing: true));
+ on((event, emit) {
+ emit(state.copyWith(isBioEditing: true));
});
- on((event, emit) async {
+ on((event, emit) {
+ emit(state.copyWith(isPicEditing: true));
+ });
+
+ on((event, emit) async {
if (event.bio != null) {
await _profileRepository.saveProfile(bio: event.bio);
}
+
+ final userOrFailure = await _profileRepository.getUserProfile();
+
+ emit(
+ userOrFailure.fold(
+ (failure) => state.copyWith(isBioEditing: false),
+ (userProfile) => state.copyWith(
+ userProfile: userProfile,
+ isBioEditing: false,
+ ),
+ ),
+ );
+ });
+
+ on((event, emit) async {
final wasImageUpdated = event.image != null;
if (wasImageUpdated) {
await _avatarRepository.uploadAvatar(event.image!);
@@ -53,18 +74,18 @@ class ProfileBloc extends Bloc {
emit(
userOrFailure.fold(
- (failure) => state.copyWith(isEditing: false),
+ (failure) => state.copyWith(isPicEditing: false),
(userProfile) => state.copyWith(
userProfile: userProfile,
- isEditing: false,
+ isPicEditing: false,
wasProfilePictureUpdated: wasImageUpdated,
),
),
);
});
- on((event, emit) {
- emit(state.copyWith(isEditing: false));
+ on((event, emit) {
+ emit(state.copyWith(isPicEditing: false));
});
}
}
diff --git a/lib/application/user/profile/profile_event.dart b/lib/application/user/profile/profile_event.dart
index 4780c65e..a7f0dac6 100644
--- a/lib/application/user/profile/profile_event.dart
+++ b/lib/application/user/profile/profile_event.dart
@@ -4,16 +4,25 @@ abstract class ProfileEvent {}
class GetUserProfile extends ProfileEvent {}
-class EditProfile extends ProfileEvent {}
+class EditBio extends ProfileEvent {}
-class SaveProfile extends ProfileEvent {
+class SaveBio extends ProfileEvent {
final String? bio;
+ SaveBio({
+ this.bio,
+ });
+}
+
+class CancelBio extends ProfileEvent {}
+
+class EditProfilePic extends ProfileEvent {}
+
+class SaveProfilePic extends ProfileEvent {
final File? image;
- SaveProfile({
- this.bio,
+ SaveProfilePic({
this.image,
});
}
-class CancelEditProfile extends ProfileEvent {}
+class CancelEditProfilePic extends ProfileEvent {}
diff --git a/lib/application/user/profile/profile_state.dart b/lib/application/user/profile/profile_state.dart
index 57646fcf..da4fbbd1 100644
--- a/lib/application/user/profile/profile_state.dart
+++ b/lib/application/user/profile/profile_state.dart
@@ -3,33 +3,39 @@ part of 'profile_bloc.dart';
class ProfileState extends Equatable {
const ProfileState({
required this.userProfile,
- this.isEditing,
+ this.isPicEditing,
+ this.isBioEditing,
this.wasProfilePictureUpdated,
});
final UserProfile? userProfile;
- final bool? isEditing;
+ final bool? isPicEditing;
+ final bool? isBioEditing;
final bool? wasProfilePictureUpdated;
factory ProfileState.initial() => const ProfileState(
userProfile: null,
- isEditing: false,
+ isPicEditing: false,
+ isBioEditing: false,
wasProfilePictureUpdated: false,
);
ProfileState copyWith({
UserProfile? userProfile,
- bool? isEditing,
+ bool? isPicEditing,
+ bool? isBioEditing,
bool? wasProfilePictureUpdated,
}) {
return ProfileState(
userProfile: userProfile ?? this.userProfile,
- isEditing: isEditing ?? this.isEditing,
+ isPicEditing: isPicEditing ?? this.isPicEditing,
+ isBioEditing: isBioEditing ?? this.isBioEditing,
wasProfilePictureUpdated:
wasProfilePictureUpdated ?? false, // Reset state implicitly
);
}
@override
- List