mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 09:18:56 +03:30
Set search for my package & package by api
This commit is contained in:
+28
-23
@@ -166,7 +166,7 @@ class PackageProvider extends ChangeNotifier {
|
||||
|
||||
void setLoading() {
|
||||
isloading = true;
|
||||
// notifyListeners();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool isloadingButton = false;
|
||||
@@ -341,29 +341,32 @@ class PackageProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void search(String value) {
|
||||
Future<void> search(String value) async {
|
||||
items = [];
|
||||
searchBoxValue = value;
|
||||
originalItems!.forEach((result) {
|
||||
if (result.id
|
||||
.toString()
|
||||
.toLowerCase()
|
||||
.contains(searchBoxValue.toLowerCase()) ||
|
||||
result.id
|
||||
.toString()
|
||||
.toUpperCase()
|
||||
.contains(searchBoxValue.toUpperCase()) ||
|
||||
result.id
|
||||
.toString()
|
||||
.toLowerCase()
|
||||
.contains(searchBoxValue.toUpperCase()) ||
|
||||
result.id
|
||||
.toString()
|
||||
.toUpperCase()
|
||||
.contains(searchBoxValue.toLowerCase())) {
|
||||
items!.add(result);
|
||||
}
|
||||
});
|
||||
var response = await http.get(
|
||||
Uri.parse(Url.searchPackages(value)),
|
||||
headers: {
|
||||
'Authorization': User.token,
|
||||
},
|
||||
);
|
||||
|
||||
var testResultData = json.decode(response.body);
|
||||
for (var item in testResultData['data']) {
|
||||
List<String> itemsId =
|
||||
(item['items'] as List).map((item) => item['id'].toString()).toList();
|
||||
items!.add(
|
||||
PackageResultObject(
|
||||
createdAt: item['created_at'],
|
||||
id: item['id'].toString(),
|
||||
name: item['name'],
|
||||
status: item['status'],
|
||||
userName: item['user']['name'],
|
||||
itemsId: itemsId,
|
||||
),
|
||||
);
|
||||
}
|
||||
resetLoading();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -409,8 +412,10 @@ class PackageProvider extends ChangeNotifier {
|
||||
),
|
||||
);
|
||||
}
|
||||
items = originalItems;
|
||||
pageNumber += 1;
|
||||
search('');
|
||||
// search('');
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<PackageDetailObject> showPackageResult(String id) async {
|
||||
|
||||
Reference in New Issue
Block a user