2022-08-28 16:48:53 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-10-15 18:28:31 +00:00
|
|
|
import '../api/tag_api.dart';
|
|
|
|
import '../preview/tag_tile.dart';
|
2022-08-30 21:37:24 +00:00
|
|
|
import '../drawer/my_drawer.dart';
|
2022-08-28 16:48:53 +00:00
|
|
|
import '../screen_loading.dart';
|
|
|
|
|
|
|
|
import '../types/tag.dart';
|
|
|
|
|
|
|
|
class CategorieScreen extends StatefulWidget {
|
|
|
|
const CategorieScreen({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<CategorieScreen> createState() => _CategorieScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _CategorieScreenState extends State<CategorieScreen> {
|
|
|
|
late Future<List<Tag>> _categories;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
2022-10-15 18:28:31 +00:00
|
|
|
_categories = loadAllTags();
|
2022-08-28 16:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-08-29 15:16:51 +00:00
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
2022-08-30 09:57:50 +00:00
|
|
|
title: Text("Categories"),
|
2022-08-29 15:16:51 +00:00
|
|
|
),
|
|
|
|
body: FutureBuilder(
|
|
|
|
future: _categories,
|
|
|
|
builder: (context, AsyncSnapshot<List<Tag>> snapshot) {
|
|
|
|
if (snapshot.connectionState != ConnectionState.done) {
|
|
|
|
return ScreenLoading();
|
|
|
|
}
|
2022-08-28 16:48:53 +00:00
|
|
|
|
2022-08-29 15:16:51 +00:00
|
|
|
if (snapshot.hasError) {
|
|
|
|
return Text("Error");
|
|
|
|
} else if (snapshot.hasData) {
|
|
|
|
return Padding(
|
|
|
|
padding: EdgeInsets.all(5),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Wrap(
|
|
|
|
spacing: 5,
|
|
|
|
runSpacing: 5,
|
|
|
|
alignment: WrapAlignment.start,
|
|
|
|
children: snapshot.data!
|
|
|
|
.map((e) => TagTile(
|
2022-08-29 15:20:35 +00:00
|
|
|
tag: e,
|
|
|
|
))
|
2022-08-29 15:16:51 +00:00
|
|
|
.toList(growable: false),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return ScreenLoading();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
drawer: MyDrawer());
|
2022-08-28 16:48:53 +00:00
|
|
|
}
|
|
|
|
}
|