mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 08:58:55 +03:30
Set search item by api
This commit is contained in:
@@ -121,7 +121,7 @@ class CyclesProvider extends ChangeNotifier {
|
||||
|
||||
void setLoading() {
|
||||
isloading = true;
|
||||
// notifyListeners();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool isloadingButton = false;
|
||||
|
||||
+28
-24
@@ -51,7 +51,7 @@ class ItemProvider extends ChangeNotifier {
|
||||
|
||||
void setLoading() {
|
||||
isloading = true;
|
||||
// notifyListeners();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool isloadingButton = false;
|
||||
@@ -244,29 +244,33 @@ class ItemProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void search(String value) {
|
||||
Future<void> search(String value) async {
|
||||
items = [];
|
||||
searchBoxValue = value;
|
||||
originalItems!.forEach((result) {
|
||||
if (result.udi
|
||||
.toString()
|
||||
.toLowerCase()
|
||||
.contains(searchBoxValue.toLowerCase()) ||
|
||||
result.udi
|
||||
.toString()
|
||||
.toUpperCase()
|
||||
.contains(searchBoxValue.toUpperCase()) ||
|
||||
result.udi
|
||||
.toString()
|
||||
.toLowerCase()
|
||||
.contains(searchBoxValue.toUpperCase()) ||
|
||||
result.udi
|
||||
.toString()
|
||||
.toUpperCase()
|
||||
.contains(searchBoxValue.toLowerCase())) {
|
||||
items!.add(result);
|
||||
}
|
||||
});
|
||||
var response = await http.get(
|
||||
Uri.parse(Url.searchItems(value)),
|
||||
headers: {
|
||||
'Authorization': User.token,
|
||||
},
|
||||
);
|
||||
|
||||
var itemsData = json.decode(response.body);
|
||||
|
||||
for (var item in itemsData['data']) {
|
||||
items!.add(
|
||||
ItemResultObject(
|
||||
name: item['name'],
|
||||
id: item['id'].toString(),
|
||||
size: item['size'].toString(),
|
||||
userName: item['user'] != null ? item['user']['name'] : '',
|
||||
status: item['status'],
|
||||
udi: item['udi'],
|
||||
packageId:
|
||||
item['package_id'] != null ? item['package_id'].toString() : "",
|
||||
),
|
||||
);
|
||||
}
|
||||
resetLoading();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -319,8 +323,8 @@ class ItemProvider extends ChangeNotifier {
|
||||
);
|
||||
}
|
||||
pageNumber += 1;
|
||||
|
||||
search('');
|
||||
items = originalItems;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<ItemDetailObject> showItemResult(String id) async {
|
||||
|
||||
Reference in New Issue
Block a user