47 lines
1.3 KiB
Dart
47 lines
1.3 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:yokutango_mobile_reader/screens/misc/error.dart';
|
|
import 'package:yokutango_mobile_reader/screens/misc/loading.dart';
|
|
|
|
class TangoSetList extends StatelessWidget {
|
|
final String route;
|
|
final Future<Map<File, List>> files;
|
|
|
|
const TangoSetList({
|
|
super.key,
|
|
required this.route,
|
|
required this.files,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) => FutureBuilder(
|
|
future: files,
|
|
builder: (context, snapshot) {
|
|
if (snapshot.hasError) {
|
|
debugPrint(snapshot.error.toString());
|
|
return const ErrorScreen();
|
|
} else if (!snapshot.hasData) {
|
|
return const LoadingScreen();
|
|
}
|
|
|
|
return ListView(
|
|
children: (snapshot.data as Map<File, List>)
|
|
.entries
|
|
.map(
|
|
(e) => ListTile(
|
|
title: Text(
|
|
"${e.key.uri.pathSegments.last} - ${e.value.length} cards"),
|
|
onTap: () => Navigator.pushNamed(
|
|
context,
|
|
route,
|
|
arguments: e.key,
|
|
),
|
|
),
|
|
)
|
|
.toList(),
|
|
);
|
|
},
|
|
);
|
|
}
|