added missing grammar copy and reduced some duplicate code

This commit is contained in:
ggurdin 2024-11-07 16:29:29 -05:00
parent 495eb99be1
commit ab5189a66a
No known key found for this signature in database
GPG key ID: A01CB41737CBB478
2 changed files with 37 additions and 21 deletions

View file

@ -141,6 +141,8 @@ String? getGrammarCopy({
return L10n.of(context)!.grammarCopyPRONTYPEart;
case 'grammarCopyPRONTYPEtot':
return L10n.of(context)!.grammarCopyPRONTYPEtot;
case 'grammarCopyPRONTYPEneg':
return L10n.of(context)!.grammarCopyPRONTYPEneg;
case 'grammarCopyPOLITEinfm':
return L10n.of(context)!.grammarCopyPOLITEinfm;
case 'grammarCopyADVTYPEtim':

View file

@ -50,6 +50,13 @@ class AnalyticsPopupState extends State<AnalyticsPopup> {
selectedCategory = category;
});
String categoryCopy(category) =>
widget.constructsModel.type?.getDisplayCopy(
category,
context,
) ??
category;
@override
Widget build(BuildContext context) {
Widget? dialogContent;
@ -60,40 +67,34 @@ class AnalyticsPopupState extends State<AnalyticsPopup> {
widget.constructsModel.categoriesToUses.keys.first == "Other";
if (selectedCategory != null) {
dialogContent = ListView.builder(
itemCount:
widget.constructsModel.categoriesToUses[selectedCategory]!.length,
itemBuilder: (context, index) {
final constructUses =
widget.constructsModel.categoriesToUses[selectedCategory]![index];
return ConstructUsesXPTile(constructUses);
},
dialogContent = Column(
children: [
Text(
categoryCopy(selectedCategory),
style: const TextStyle(fontSize: 16),
),
Expanded(
child: ConstructsTileList(
widget.constructsModel.categoriesToUses[selectedCategory]!,
),
),
],
);
} else if (hasNoData) {
dialogContent = Center(child: Text(L10n.of(context)!.noDataFound));
} else if (hasNoCategories || !widget.showGroups) {
dialogContent = ListView.builder(
itemCount: widget.constructsModel.constructListWithPoints.length,
itemBuilder: (context, index) {
final constructUses =
widget.constructsModel.constructListWithPoints[index];
return ConstructUsesXPTile(constructUses);
},
dialogContent = ConstructsTileList(
widget.constructsModel.constructListWithPoints,
);
} else {
dialogContent = ListView.builder(
itemCount: categoriesToUses.length,
itemBuilder: (context, index) {
final category = categoriesToUses[index];
final copy = widget.constructsModel.type?.getDisplayCopy(
category.key,
context,
) ??
category.key;
return Column(
children: [
ListTile(
title: Text(copy),
title: Text(categoryCopy(category.key)),
trailing: const Icon(Icons.chevron_right_outlined),
onTap: () => setSelectedCategory(category.key),
),
@ -134,3 +135,16 @@ class AnalyticsPopupState extends State<AnalyticsPopup> {
);
}
}
class ConstructsTileList extends StatelessWidget {
final List<ConstructUses> constructs;
const ConstructsTileList(this.constructs, {super.key});
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: constructs.length,
itemBuilder: (context, index) => ConstructUsesXPTile(constructs[index]),
);
}
}