cdb_ui/lib/itemview.dart

70 lines
1.6 KiB
Dart
Raw Normal View History

2024-09-04 18:05:04 +00:00
import 'package:cdb_ui/api.dart';
import 'package:flutter/material.dart';
import 'api.dart';
class ItemView extends StatelessWidget {
Item item;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(children: [
Text(item.category),
SizedBox(height: 10),
FutureBuilder(
future: API().getInventory(item.id),
builder: (context, snapshot) {
if (snapshot.hasData) {
var data = snapshot.data!;
return Column(
children: data.map((x) {
return Row(
children: [
Text(x["uuid"]),
Text(x["origin"]),
Text(x["price"]),
Text(x["timestamp"])
],
);
}).toList());
}
return CircularProgressIndicator();
},
)
]),
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => SupplyPage(item)));
},
child: Icon(Icons.add)),
);
}
ItemView({super.key, required this.item});
}
class SupplyPage extends StatefulWidget {
Item item;
SupplyPage(this.item);
@override
State<SupplyPage> createState() => _SupplyPageState();
}
class _SupplyPageState extends State<SupplyPage> {
String? variant;
void _supply() async {}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Text("Add item ${widget.item.name}"),
);
}
}