mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 11:58:54 +03:30
Set search my item by api
This commit is contained in:
@@ -190,4 +190,7 @@ class Url {
|
|||||||
static String searchItems(String value) {
|
static String searchItems(String value) {
|
||||||
return '$baseUrl/Items?name=$value';
|
return '$baseUrl/Items?name=$value';
|
||||||
}
|
}
|
||||||
|
static String searchMyItems(String value) {
|
||||||
|
return '$baseUrl/MyItems?name=$value';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ class _ItemResultScreenState extends State<ItemResultScreen> {
|
|||||||
text: 'item',
|
text: 'item',
|
||||||
deviceBlockSize: _deviceBlockSize,
|
deviceBlockSize: _deviceBlockSize,
|
||||||
textInputType: TextInputType.visiblePassword,
|
textInputType: TextInputType.visiblePassword,
|
||||||
text2: "Udi",
|
text2: "name",
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
searchVal = value;
|
searchVal = value;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ class _MyItemsMineScreenState extends State<MyItemsMineScreen> {
|
|||||||
final double _devicewidth = _media.size.width;
|
final double _devicewidth = _media.size.width;
|
||||||
final double _deviceBlockSize = _devicewidth / 100;
|
final double _deviceBlockSize = _devicewidth / 100;
|
||||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||||
|
var searchVal;
|
||||||
return Consumer<ConnectivityProvider>(
|
return Consumer<ConnectivityProvider>(
|
||||||
builder: (ct, connection, _) {
|
builder: (ct, connection, _) {
|
||||||
return connection.conStatus != 'offline'
|
return connection.conStatus != 'offline'
|
||||||
@@ -155,14 +156,18 @@ class _MyItemsMineScreenState extends State<MyItemsMineScreen> {
|
|||||||
ResultSearchBox(
|
ResultSearchBox(
|
||||||
searchCTRL: searchCTRL,
|
searchCTRL: searchCTRL,
|
||||||
text: 'item',
|
text: 'item',
|
||||||
text2: "Udi",
|
text2: "name",
|
||||||
textInputType: TextInputType.visiblePassword,
|
textInputType: TextInputType.visiblePassword,
|
||||||
deviceBlockSize: _deviceBlockSize,
|
deviceBlockSize: _deviceBlockSize,
|
||||||
onChanged: (value) {
|
onChanged: (value) async {
|
||||||
Provider.of<MyItemProvider>(context, listen: false)
|
searchVal = value;
|
||||||
.searchMyItems(value);
|
},
|
||||||
|
onTap: () async {
|
||||||
|
var myItems = await Provider.of<MyItemProvider>(context,
|
||||||
|
listen: false);
|
||||||
|
myItems.setLoading();
|
||||||
|
await myItems.searchMyItems(searchVal);
|
||||||
},
|
},
|
||||||
onTap: () {},
|
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
|
|||||||
@@ -43,17 +43,31 @@ class MyItemProvider extends ChangeNotifier {
|
|||||||
|
|
||||||
void setLoading() {
|
void setLoading() {
|
||||||
isloading = true;
|
isloading = true;
|
||||||
// notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
void searchMyItems(String value) {
|
Future<void> searchMyItems(String value) async {
|
||||||
myItems = [];
|
myItems = [];
|
||||||
searchBoxValue = value;
|
searchBoxValue = value;
|
||||||
originalMyItems!.forEach((result) {
|
var response = await http.get(
|
||||||
if (result.udi.toString().contains(searchBoxValue)) {
|
Uri.parse(Url.searchMyItems(value)),
|
||||||
myItems!.add(result);
|
headers: {'Authorization': User.token, "Accept": "application/json"},
|
||||||
}
|
);
|
||||||
});
|
|
||||||
|
var itemsData = json.decode(response.body);
|
||||||
|
|
||||||
|
for (var item in itemsData['data']) {
|
||||||
|
myItems!.add(
|
||||||
|
MyItemResultObject(
|
||||||
|
name: item['name'],
|
||||||
|
id: item['id'].toString(),
|
||||||
|
size: item['size'].toString(),
|
||||||
|
udi: item['udi'],
|
||||||
|
userName: item['user'] != null ? item['user']['name'] : '',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
resetLoading();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,8 +150,9 @@ class MyItemProvider extends ChangeNotifier {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
myItems = originalMyItems;
|
||||||
pageNumber += 1;
|
pageNumber += 1;
|
||||||
searchMyItems('');
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Future<void> getHospitalItems() async {
|
// Future<void> getHospitalItems() async {
|
||||||
|
|||||||
Reference in New Issue
Block a user