feat(app): show template stage counts
This commit is contained in:
@@ -24,6 +24,7 @@ class TemplateGallery extends StatelessWidget {
|
||||
const TemplateGallery({
|
||||
super.key,
|
||||
required this.templates,
|
||||
required this.stageCounts,
|
||||
required this.loaded,
|
||||
required this.loading,
|
||||
required this.error,
|
||||
@@ -32,6 +33,9 @@ class TemplateGallery extends StatelessWidget {
|
||||
});
|
||||
|
||||
final List<TemplateEntry> templates;
|
||||
|
||||
/// Parsed counts; a present null value means the source could not be parsed.
|
||||
final Map<String, int?> stageCounts;
|
||||
final bool loaded;
|
||||
final bool loading;
|
||||
final String? error;
|
||||
@@ -98,9 +102,7 @@ class TemplateGallery extends StatelessWidget {
|
||||
return ListTile(
|
||||
key: templateRowKey(entry.key),
|
||||
title: Text(templateGalleryName(entry)),
|
||||
subtitle: entry.description.trim().isEmpty
|
||||
? null
|
||||
: Text(entry.description),
|
||||
subtitle: _materialSubtitle(entry),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => onOpen(entry.key),
|
||||
);
|
||||
@@ -118,9 +120,7 @@ class TemplateGallery extends StatelessWidget {
|
||||
CupertinoListTile(
|
||||
key: templateRowKey(entry.key),
|
||||
title: _cupertinoText(templateGalleryName(entry)),
|
||||
subtitle: entry.description.trim().isEmpty
|
||||
? null
|
||||
: _cupertinoText(entry.description),
|
||||
subtitle: _cupertinoSubtitle(entry),
|
||||
trailing: const CupertinoListTileChevron(),
|
||||
onTap: () => onOpen(entry.key),
|
||||
),
|
||||
@@ -135,4 +135,38 @@ class TemplateGallery extends StatelessWidget {
|
||||
/// with the content and nothing else about the tile is restyled.
|
||||
Widget _cupertinoText(String text) =>
|
||||
DefaultTextStyle.merge(maxLines: 3, child: Text(text));
|
||||
|
||||
Widget _materialSubtitle(TemplateEntry entry) {
|
||||
final description = entry.description.trim().isEmpty
|
||||
? null
|
||||
: Text(entry.description);
|
||||
final count = Text(_stageCountLabel(entry.key));
|
||||
if (description == null) return count;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [description, count],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoSubtitle(TemplateEntry entry) {
|
||||
final description = entry.description.trim().isEmpty
|
||||
? null
|
||||
: _cupertinoText(entry.description);
|
||||
final count = _cupertinoText(_stageCountLabel(entry.key));
|
||||
if (description == null) return count;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [description, count],
|
||||
);
|
||||
}
|
||||
|
||||
String _stageCountLabel(String key) {
|
||||
if (!stageCounts.containsKey(key) || stageCounts[key] == null) {
|
||||
return 'stage count unavailable';
|
||||
}
|
||||
final count = stageCounts[key]!;
|
||||
return '$count ${count == 1 ? 'stage' : 'stages'}';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user