itemview listview

This commit is contained in:
JMARyA 2024-09-18 08:09:08 +02:00
parent ca68b8e951
commit 53bfe1763c
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -11,7 +11,6 @@ Future<void> main() async {
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
const MyApp({super.key}); const MyApp({super.key});
// This widget is the root of your application.
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
@ -36,6 +35,9 @@ class StatsPage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// todo : add global statistics // todo : add global statistics
// todo : demand stat
// todo : stat on origin + destination
return Scaffold( return Scaffold(
body: FutureBuilder( body: FutureBuilder(
future: _fetchData(), future: _fetchData(),
@ -81,7 +83,9 @@ class FlowsPage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// todo : add locations tree view // todo : add flow list
// todo : flows by item produced
// todo : flow page
return const Scaffold(); return const Scaffold();
} }
} }
@ -114,12 +118,10 @@ class ItemsPage extends StatelessWidget {
var items = snapshot.data!; var items = snapshot.data!;
return GridView.count( return ListView(
crossAxisCount: 2, children: items.map((x) {
children: items.map((x) { return ItemTile(x);
return ItemCard(x); }).toList());
}).toList(),
);
}), }),
); );
} }
@ -168,26 +170,19 @@ class _MyHomePageState extends State<MyHomePage> {
} }
} }
class ItemCard extends StatelessWidget { class ItemTile extends StatelessWidget {
final String item; final String item;
const ItemCard(this.item, {super.key}); const ItemTile(this.item, {super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return InkWell( return ListTile(
onTap: () { onTap: () {
API().getItem(item).then((itemInfo) => Navigator.push(context, API().getItem(item).then((itemInfo) => Navigator.push(context,
MaterialPageRoute(builder: (context) => ItemView(item: itemInfo)))); MaterialPageRoute(builder: (context) => ItemView(item: itemInfo))));
}, },
child: Row(children: [ title: Text(item),
/*Image.network(
API().getImageURL(item),
width: 128,
height: 128,
),*/
Text(item)
]),
); );
} }
} }