Skip to content

Commit

Permalink
fix: fix deck loading
Browse files Browse the repository at this point in the history
  • Loading branch information
3waffel committed Sep 8, 2024
1 parent 98d60d8 commit d23c1d1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lib/common/deck_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DeckLoader {
for (var field in CardField.values) {
int fieldIndex = _columns.indexOf(field);
if (fieldIndex != -1) {
var fieldValue = fields[index][fieldIndex];
var fieldValue = fields[index].elementAtOrNull(fieldIndex);
map.putIfAbsent(field.name, () => fieldValue);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/models/card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class CardModel {
return MapEntry(newKey, 0);
}
}
return MapEntry(newKey, value.toString());
return MapEntry(newKey, (value ?? "").toString());
});

static List<CardModel> fromMapList(List<Map<String, Object?>> maps) {
Expand Down
69 changes: 39 additions & 30 deletions lib/screens/learning.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,46 +161,55 @@ class _LearningScreenState extends State<LearningScreen> {
}

return InkWell(
onTap: () => setState(() => isVisible = !isVisible),
highlightColor: Colors.transparent,
hoverColor: Colors.transparent,
splashColor: Colors.transparent,
child: Center(
child: Column(
children: [
Padding(
padding: EdgeInsets.only(top: 32),
child: SizedBox(
width: min(100, args.learningLimit * 20),
child: StepProgressIndicator(
currentStep: card.fields[CardField.correctTimes] as int,
totalSteps: args.learningLimit,
selectedColor: Theme.of(context).colorScheme.primary,
unselectedColor:
Theme.of(context).colorScheme.inversePrimary,
),
)),
padding: EdgeInsets.only(top: 32),
child: SizedBox(
width: min(100, args.learningLimit * 20),
child: StepProgressIndicator(
currentStep: card.fields[CardField.correctTimes] as int,
totalSteps: args.learningLimit,
selectedColor: Theme.of(context).colorScheme.primary,
unselectedColor: Theme.of(context).colorScheme.inversePrimary,
),
),
),
Padding(
padding: EdgeInsets.only(top: 32),
child: Text(
card.fields[CardField.frontTitle] as String,
style: TextStyle(fontSize: 32, color: cardColor),
)),
padding: EdgeInsets.only(top: 32),
child: Text(
card.fields[CardField.frontTitle] as String,
style: TextStyle(fontSize: 32, color: cardColor),
),
),
Padding(
padding: EdgeInsets.only(top: 32),
child: Text(card.fields[CardField.frontSubtitle] as String)),
padding: EdgeInsets.fromLTRB(16, 32, 16, 16),
child: Text(
card.fields[CardField.frontSubtitle] as String,
style: Theme.of(context).textTheme.bodyMedium,
),
),
Padding(
padding: EdgeInsets.only(top: 32),
child: Visibility(
child: Text(card.fields[CardField.backTitle] as String),
maintainAnimation: true,
maintainSize: true,
maintainState: true,
visible: isVisible,
))
padding: EdgeInsets.all(16),
child: Visibility(
child: Text(
card.fields[CardField.backTitle] as String,
style: Theme.of(context).textTheme.labelLarge,
),
maintainAnimation: true,
maintainSize: true,
maintainState: true,
visible: isVisible,
),
),
],
),
),
onTap: () => setState(() => isVisible = !isVisible),
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
enableFeedback: false,
);
}

Expand Down

0 comments on commit d23c1d1

Please sign in to comment.