mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 15:28:55 +03:30
Set search for labels by api
This commit is contained in:
@@ -202,4 +202,8 @@ class Url {
|
|||||||
static String searchMyPackages(String value) {
|
static String searchMyPackages(String value) {
|
||||||
return '$baseUrl/MyPackages?name=$value';
|
return '$baseUrl/MyPackages?name=$value';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String searchLabels(String value) {
|
||||||
|
return '$baseUrl/Labels?package_name=$value';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class LabelsProvider extends ChangeNotifier {
|
|||||||
|
|
||||||
void setLoading() {
|
void setLoading() {
|
||||||
isloading = true;
|
isloading = true;
|
||||||
// notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isloadingButton = false;
|
bool isloadingButton = false;
|
||||||
@@ -223,14 +223,32 @@ class LabelsProvider extends ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
void search(String value) {
|
Future<void> search(String value) async {
|
||||||
items = [];
|
items = [];
|
||||||
searchBoxValue = value;
|
searchBoxValue = value;
|
||||||
originalItems!.forEach((result) {
|
|
||||||
if (result.packageName.toString().contains(searchBoxValue)) {
|
var response = await http.get(
|
||||||
items!.add(result);
|
Uri.parse(Url.searchLabels(value)),
|
||||||
}
|
headers: {
|
||||||
});
|
'Authorization': User.token,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
var testResultData = json.decode(response.body);
|
||||||
|
for (var item in testResultData['data']) {
|
||||||
|
items!.add(
|
||||||
|
LabelResultObject(
|
||||||
|
expireDate: item['expire_date'],
|
||||||
|
id: item['id'].toString(),
|
||||||
|
packageName: item['package'] != null
|
||||||
|
? item['package']['name'].toString()
|
||||||
|
: ' ',
|
||||||
|
packageId:
|
||||||
|
item['package'] != null ? item['package']['id'].toString() : ' ',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
resetLoading();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,7 +299,8 @@ class LabelsProvider extends ChangeNotifier {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
pageNumber += 1;
|
pageNumber += 1;
|
||||||
search('');
|
items = originalItems;
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<LabelDetailsObject> showLabelResult(String id) async {
|
Future<LabelDetailsObject> showLabelResult(String id) async {
|
||||||
|
|||||||
@@ -17,12 +17,13 @@ class LabelSearchBox extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
var searchVal;
|
||||||
return TextField(
|
return TextField(
|
||||||
onEditingComplete: () {
|
onEditingComplete: () {
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
onChanged: (value) {
|
onChanged: (value) async {
|
||||||
Provider.of<LabelsProvider>(context, listen: false).search(value);
|
searchVal = value;
|
||||||
},
|
},
|
||||||
controller: searchCTRL,
|
controller: searchCTRL,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@@ -37,6 +38,27 @@ class LabelSearchBox extends StatelessWidget {
|
|||||||
labelText: 'Search by package name',
|
labelText: 'Search by package name',
|
||||||
isDense: true,
|
isDense: true,
|
||||||
contentPadding: EdgeInsets.symmetric(vertical: 2, horizontal: 3),
|
contentPadding: EdgeInsets.symmetric(vertical: 2, horizontal: 3),
|
||||||
|
suffixIcon: InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
var labels = await Provider.of<LabelsProvider>(
|
||||||
|
context,
|
||||||
|
listen: false);
|
||||||
|
labels.setLoading();
|
||||||
|
await labels.search(searchVal);
|
||||||
|
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
margin: EdgeInsets.all(5),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
Icons.input,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
|
|||||||
Reference in New Issue
Block a user