-
Notifications
You must be signed in to change notification settings - Fork 116
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
Showing
33 changed files
with
781 additions
and
703 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
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 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
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
61 changes: 61 additions & 0 deletions
61
lib/presentation/screens/contacts/providers/contact_provider.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,61 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
import 'package:tailor_made/domain.dart'; | ||
|
||
import '../../../state.dart'; | ||
|
||
part 'contact_provider.g.dart'; | ||
|
||
@riverpod | ||
ContactProvider contact(ContactRef ref) { | ||
return ContactProvider( | ||
fetchAccount: () => ref.read(accountProvider.future), | ||
contacts: ref.read(registryProvider).get(), | ||
); | ||
} | ||
|
||
class ContactProvider { | ||
const ContactProvider({ | ||
required AsyncValueGetter<AccountEntity> fetchAccount, | ||
required Contacts contacts, | ||
}) : _fetchAccount = fetchAccount, | ||
_contacts = contacts; | ||
|
||
final AsyncValueGetter<AccountEntity> _fetchAccount; | ||
final Contacts _contacts; | ||
|
||
Future<ContactEntity> create({ | ||
required CreateContactData contact, | ||
}) async { | ||
final String userId = (await _fetchAccount()).uid; | ||
return _contacts.create(userId, contact); | ||
} | ||
|
||
Future<void> update({ | ||
required ReferenceEntity reference, | ||
required CreateContactData contact, | ||
}) async { | ||
final String userId = (await _fetchAccount()).uid; | ||
await _contacts.update( | ||
userId, | ||
reference: reference, | ||
fullname: contact.fullname, | ||
phone: contact.phone, | ||
location: contact.location, | ||
imageUrl: contact.imageUrl, | ||
measurements: contact.measurements, | ||
); | ||
} | ||
|
||
Future<void> modifyMeasurements({ | ||
required ReferenceEntity reference, | ||
required Map<String, double> measurements, | ||
}) async { | ||
final String userId = (await _fetchAccount()).uid; | ||
await _contacts.update( | ||
userId, | ||
reference: reference, | ||
measurements: measurements, | ||
); | ||
} | ||
} |
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.