This commit is contained in:
JMARyA 2024-09-15 15:15:46 +02:00
parent 91beacceb6
commit 549df5ff22
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
4 changed files with 112 additions and 38 deletions

View file

@ -26,11 +26,19 @@ class _ItemViewState extends State<ItemView> {
),
body: Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(width: 28),
const Align(
alignment: Alignment.centerLeft,
child: Placeholder(),
child: Placeholder(
fallbackWidth: 100,
fallbackHeight: 100,
),
), // todo
SizedBox(
width: 16.0,
),
Column(
children: [
Text(

View file

@ -53,8 +53,8 @@ class _SupplyPageState extends State<SupplyPage> {
return const Center(child: CircularProgressIndicator());
}
var data = snapshot.data as Map<String, List<dynamic>>;
var locations = data['locations']!;
var data = snapshot.data as Map<String, dynamic>;
var locations = data['locations']! as Map<String, Location>;
var origins = data['origins']! as List<String>;
return Padding(
@ -144,37 +144,47 @@ class _SupplyPageState extends State<SupplyPage> {
const SizedBox(height: 16),
// Location Dropdown
DropdownButtonFormField<String>(
hint: const Text('Select Location'),
value: _selectedLocation,
onChanged: (value) {
setState(() {
_selectedLocation = value!;
});
},
items: locations.map<DropdownMenuItem<String>>((location) {
return DropdownMenuItem<String>(
value: location,
child: Text(location),
);
}).toList(),
onSaved: (value) {
_selectedLocation = value!;
},
),
IconButton(
onPressed: () {
QrBarCodeScannerDialog().getScannedQrBarCode(
context: context,
onCode: (code) {
setState(() {
_selectedLocation = code!;
});
Row(
children: [
Expanded(
child: DropdownButtonFormField<String>(
hint: const Text('Select Location'),
value: _selectedLocation,
onChanged: (value) {
setState(() {
_selectedLocation = value!;
});
},
items: locations.keys
.map<DropdownMenuItem<String>>((id) {
return DropdownMenuItem<String>(
value: id,
child: Text(
locations[id]!.full_name_path(locations)),
);
}).toList(),
onSaved: (value) {
_selectedLocation = value!;
},
),
),
SizedBox(
width: 12,
),
IconButton(
onPressed: () {
QrBarCodeScannerDialog().getScannedQrBarCode(
context: context,
onCode: (code) {
setState(() {
_selectedLocation = code!;
});
},
);
},
);
},
icon: const Icon(Icons.qr_code),
icon: const Icon(Icons.qr_code),
),
],
),
const SizedBox(height: 20),
@ -193,12 +203,11 @@ class _SupplyPageState extends State<SupplyPage> {
);
}
Future<Map<String, List<dynamic>>> _fetchData() async {
var locations_map = await API().getLocations();
Future<Map<String, dynamic>> _fetchData() async {
var locations = await API().getLocations();
var origins = await API().getUniqueField(widget.item.id, variant, "origin");
origins.insert(0, "");
var locations = locations_map.keys.toList();
locations.insert(0, "");
locations[""] = Location.zero();
return {'locations': locations, 'origins': origins};
}
}