This repository has been archived by the owner on May 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from pvdthings/fix/list-error-handling
Fix: List error handling
- Loading branch information
Showing
6 changed files
with
110 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:librarian_app/src/features/borrowers/data/borrowers_view_model.dart'; | ||
|
||
import '../data/borrower_model.dart'; | ||
import '../presentation/borrowers_list.dart'; | ||
|
||
class BorrowersView extends StatelessWidget { | ||
const BorrowersView({ | ||
super.key, | ||
required this.model, | ||
required this.searchFilter, | ||
this.onTap, | ||
}); | ||
|
||
final BorrowersViewModel model; | ||
final String searchFilter; | ||
final void Function(BorrowerModel)? onTap; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
if (model.errorMessage != null) { | ||
return Center(child: Text(model.errorMessage!)); | ||
} | ||
|
||
if (model.isLoading) { | ||
return const Center(child: CircularProgressIndicator()); | ||
} | ||
|
||
final borrowers = model.filtered(searchFilter); | ||
|
||
if (borrowers.isEmpty) { | ||
return const Center(child: Text('No results found')); | ||
} | ||
|
||
return BorrowersList( | ||
borrowers: model.filtered(searchFilter), | ||
selected: model.selectedBorrower, | ||
onTap: (borrower) { | ||
model.selectedBorrower = borrower; | ||
onTap?.call(borrower); | ||
}, | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import '../data/loan_model.dart'; | ||
import '../data/loans_view_model.dart'; | ||
import '../presentation/loans_list.dart'; | ||
|
||
class LoansView extends StatelessWidget { | ||
const LoansView({ | ||
super.key, | ||
required this.model, | ||
required this.searchFilter, | ||
this.onTap, | ||
}); | ||
|
||
final LoansViewModel model; | ||
final String searchFilter; | ||
final void Function(LoanModel)? onTap; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
if (model.errorMessage != null) { | ||
return Center(child: Text(model.errorMessage!)); | ||
} | ||
|
||
if (model.isLoading) { | ||
return const Center(child: CircularProgressIndicator()); | ||
} | ||
|
||
final loans = model.filtered(searchFilter); | ||
|
||
if (loans.isEmpty) { | ||
return const Center(child: Text('No results found')); | ||
} | ||
|
||
return LoansList( | ||
loans: loans, | ||
selected: model.selectedLoan, | ||
onTap: (loan) { | ||
model.selectedLoan = loan; | ||
onTap?.call(loan); | ||
}, | ||
); | ||
} | ||
} |
4256d08
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
librarian-app – ./
librarian-app.vercel.app
librarian-app-pvdthings.vercel.app
librarian-app-git-main-pvdthings.vercel.app