OpenMediacenterMobileFlutter/lib/navigation/categorie_screen.dart
lukas-heiligenbrunner 9ef317f0ba outsourced lots of api calls to api folder
centered error message when failed loading video feed
display server url on settings page
2022-10-15 20:28:31 +02:00

64 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
import '../api/tag_api.dart';
import '../preview/tag_tile.dart';
import '../drawer/my_drawer.dart';
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();
_categories = loadAllTags();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Categories"),
),
body: FutureBuilder(
future: _categories,
builder: (context, AsyncSnapshot<List<Tag>> snapshot) {
if (snapshot.connectionState != ConnectionState.done) {
return ScreenLoading();
}
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(
tag: e,
))
.toList(growable: false),
),
),
);
} else {
return ScreenLoading();
}
},
),
drawer: MyDrawer());
}
}