Skip to content

Commit

Permalink
DEV-42732
Browse files Browse the repository at this point in the history
  • Loading branch information
DCrow committed Apr 17, 2024
1 parent a6bc066 commit eb7b433
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ class ProductSearchViewState extends State<_ProductSearchView> {
textInputAction: TextInputAction.search,
decoration: InputDecoration(
labelText: 'Товар',
suffixIcon: IconButton(icon: const Icon(CupertinoIcons.barcode), onPressed: _onScan)
suffixIcon: IconButton(icon: const Icon(CupertinoIcons.barcode), onPressed: _onScan),
errorText: state.message.isEmpty ? null : state.message
)
),
noItemsFoundBuilder: (BuildContext ctx) {
Expand Down Expand Up @@ -136,7 +137,6 @@ class ProductSearchViewState extends State<_ProductSearchView> {
break;
case ProductSearchStateStatus.success:
case ProductSearchStateStatus.failure:
Misc.showMessage(context, state.message);
_progressDialog.close();
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class ProductSearchViewModel extends PageViewModel<ProductSearchState, ProductSe
ProductSearchStateStatus get status => state.status;

Future<List<Product>> findProductsByName(String name) async {
emit(state.copyWith(message: ''));

try {
return await productsRepository.findProduct(name: name);
} on AppError catch(e) {
Expand All @@ -19,7 +21,7 @@ class ProductSearchViewModel extends PageViewModel<ProductSearchState, ProductSe
}

Future<void> findAndSetProductByCode(String code) async {
emit(state.copyWith(status: ProductSearchStateStatus.inProgress));
emit(state.copyWith(status: ProductSearchStateStatus.inProgress, message: ''));

try {
List<Product> products = await productsRepository.findProduct(code: code);
Expand Down

0 comments on commit eb7b433

Please sign in to comment.