app/lib/screens/products.dart

48 lines
1.3 KiB
Dart
Raw Normal View History

2022-04-22 22:08:59 +02:00
import 'package:flutter/material.dart';
import 'package:nekoya_flutter/api/products.dart';
import 'package:nekoya_flutter/components/product_box.dart';
class Products extends StatefulWidget {
const Products({Key? key}) : super(key: key);
@override
State<Products> createState() => _ProductsState();
}
class _ProductsState extends State<Products> {
@override
Widget build(BuildContext context) {
return Scaffold(
2022-04-22 22:48:59 +02:00
backgroundColor: const Color(0xff1b1c1e),
2022-04-22 22:08:59 +02:00
appBar: AppBar(
2022-04-22 22:23:28 +02:00
title: const Text('Nekoya'),
centerTitle: true,
2022-04-22 22:48:59 +02:00
backgroundColor: const Color(0xff212226),
2022-04-22 22:08:59 +02:00
),
body: FutureBuilder<dynamic>(
future: getProducts(),
builder: (context, snapshot) {
if (snapshot.hasData) {
var data = snapshot.data;
2022-04-23 20:37:25 +02:00
return GridView.count(
crossAxisCount: 2,
children: List.generate(data!.length, (index) {
2022-04-22 22:08:59 +02:00
return ProductBox(
2022-04-22 22:23:28 +02:00
imageUrl:
'https://nekoya.moe.team/img/' + data[index]['IMAGE'],
2022-04-23 20:37:25 +02:00
title: data[index]['TITLE']
);
}),
2022-04-22 22:08:59 +02:00
);
}
2022-04-23 20:37:25 +02:00
2022-04-22 22:08:59 +02:00
return const Center(
child: CircularProgressIndicator(
2022-04-23 19:51:51 +02:00
color: Color(0xff8B0000),
),
2022-04-22 22:08:59 +02:00
);
},
2022-04-22 22:23:28 +02:00
),
2022-04-22 22:08:59 +02:00
);
}
2022-04-23 20:37:25 +02:00
}