feat: add an owner + sell screen
This commit is contained in:
parent
d2cbb43bcb
commit
073f8bd334
15 changed files with 354 additions and 82 deletions
|
|
@ -32,15 +32,14 @@ class AddViewModel extends ChangeNotifier {
|
|||
}
|
||||
|
||||
List<Owner> _owners = [];
|
||||
|
||||
List<Owner>? get owners => _owners;
|
||||
|
||||
Future<Result<Owner>> addOwner(
|
||||
String firstName,
|
||||
String lastName,
|
||||
String contact,
|
||||
) async {
|
||||
final result = await _ownerRepository.postOwner(
|
||||
debugPrint("\n\n\n\n(2) TRANFERRING\n\n\n\n");
|
||||
final result = await _ownerRepository.addOwner(
|
||||
firstName,
|
||||
lastName,
|
||||
contact,
|
||||
|
|
@ -52,7 +51,9 @@ class AddViewModel extends ChangeNotifier {
|
|||
|
||||
switch (secondResult) {
|
||||
case Ok():
|
||||
debugPrint("\n\n\n${secondResult.value.length}");
|
||||
_owners = secondResult.value;
|
||||
debugPrint("\n\n\n${_owners.length}");
|
||||
_currentOwner = result.value;
|
||||
notifyListeners();
|
||||
return Result.ok(result.value);
|
||||
|
|
@ -130,16 +131,7 @@ class AddViewModel extends ChangeNotifier {
|
|||
debugPrint("Oupsie daysie, ${result.error}");
|
||||
}
|
||||
notifyListeners();
|
||||
sub = _ownerRepository.liveOwners.listen((Owner owner) {
|
||||
debugPrint("\n\n\n\n[5] Updated UI : $owner\n\n\n\n");
|
||||
_owners.add(owner);
|
||||
_owners.sort(
|
||||
(a, b) => "${a.firstName} ${a.lastName}".compareTo(
|
||||
"${b.firstName} ${b.lastName}",
|
||||
),
|
||||
);
|
||||
notifyListeners();
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue