70 lines
1.7 KiB
Dart
70 lines
1.7 KiB
Dart
part of 'index.dart';
|
|
|
|
List<Document> generateDocuments(int count) {
|
|
String str() => randomString(8, 8, true, true, true);
|
|
Color color() => randomColor();
|
|
|
|
return List<Document>.generate(
|
|
count,
|
|
(index) => Document(
|
|
title: 'Lorem Ipsum et Cetera $index',
|
|
category: Category(color: color(), title: str()),
|
|
to: str(),
|
|
from: str(),
|
|
createdAt: '00/00/0000',
|
|
updatedAt: '00/00/0000',
|
|
),
|
|
);
|
|
}
|
|
|
|
List<Category> generateCategories(List<Document> documents) {
|
|
final Map<String, Category> categoryMap = {};
|
|
|
|
for (var document in documents) {
|
|
final category = document.category;
|
|
if (!categoryMap.containsKey(category.title)) {
|
|
categoryMap[category.title] = category;
|
|
}
|
|
}
|
|
|
|
return categoryMap.values.toList();
|
|
}
|
|
|
|
class FREDocumentPage extends StatefulPage {
|
|
const FREDocumentPage({super.key});
|
|
|
|
@override
|
|
State<FREDocumentPage> createState() => _FREDocumentPageState();
|
|
}
|
|
|
|
class _FREDocumentPageState extends PageState<FREDocumentPage> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final String title = FFLocalizations.of(context)
|
|
.getVariableText(enText: 'Documents', ptText: 'Documentos');
|
|
|
|
return Scaffold(
|
|
appBar: buildAppBar(title, context),
|
|
body: buildBody(context),
|
|
);
|
|
}
|
|
|
|
late List<Document> documents;
|
|
late List<Category> categories;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
documents = generateDocuments(20);
|
|
categories = generateCategories(documents);
|
|
}
|
|
|
|
Widget buildBody(BuildContext context) {
|
|
return DocumentManagerScreen(
|
|
documents: documents,
|
|
categories: categories,
|
|
);
|
|
// return DocumentViewScreen(document: documents.first);
|
|
}
|
|
}
|