-
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.
- Loading branch information
1 parent
c36fd6c
commit 9a5a24b
Showing
14 changed files
with
162 additions
and
84 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
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,3 +1,4 @@ | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
import '../../../../domain/entities/user.dart'; | ||
|
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
32 changes: 32 additions & 0 deletions
32
lib/presentation/common/user/view_model/profile_picture_view_model.dart
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 @@ | ||
import 'dart:typed_data'; | ||
|
||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
|
||
import '../../../../data/repositories/user_repository_impl.dart'; | ||
import 'state/profile_picture_state.dart'; | ||
|
||
/// Provider for the profile picture view model. | ||
final profilePictureViewModelProvider = StateNotifierProvider.family< | ||
ProfilePictureViewModel, | ||
ProfilePictureState, | ||
String>((ref, userId) => ProfilePictureViewModel(ref, userId)); | ||
|
||
class ProfilePictureViewModel extends StateNotifier<ProfilePictureState> { | ||
late final Ref ref; | ||
final String userId; | ||
|
||
ProfilePictureViewModel(this.ref, this.userId) | ||
: super(ProfilePictureState.initial()); | ||
|
||
Future<void> getProfilePicture(String userId) async { | ||
if (state.loaded == false) { | ||
ref.read(userRepositoryProvider).downloadProfilePicture(userId).then( | ||
(value) => | ||
state = state.copyWith(profilePicture: value, loaded: true)); | ||
} | ||
} | ||
|
||
void editProfilePicture(Uint8List? image) { | ||
state = state.copyWith(profilePicture: image); | ||
} | ||
} |
Oops, something went wrong.