Skip to content

Commit

Permalink
fix: ensure save_badge_screen updates on import of badge data (#1138)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZauberNerd authored Jan 3, 2025
1 parent 6c9c0df commit aa8d49c
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions lib/view/save_badge_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,24 @@ class _SaveBadgeScreenState extends State<SaveBadgeScreen> {
index: 2,
actions: [
TextButton(
onPressed: () {
fileHelper.importBadgeData(context).then((value) {
if (value) {
logger.d('value: $value');
toastUtils.showToast('Badge imported successfully');
fileHelper.getBadgeDataFiles();
}
});
onPressed: () async {
final value = await fileHelper.importBadgeData(context);
if (value) {
logger.d('value: $value');
toastUtils.showToast('Badge imported successfully');
await fileHelper.getBadgeDataFiles();
setState(() {});
}
},
child: const Text(
'Import',
style: TextStyle(color: Colors.white),
))
],
body: imageProvider.savedBadgeCache.isEmpty
? Center(
body: Consumer<InlineImageProvider>(
builder: (context, provider, child) {
if (provider.savedBadgeCache.isEmpty) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expand Down Expand Up @@ -109,20 +111,24 @@ class _SaveBadgeScreenState extends State<SaveBadgeScreen> {
),
],
),
)
: Column(
);
} else {
return Column(
children: [
AnimationBadge(),
BadgeListView(
futureBadges: Future.value(imageProvider.savedBadgeCache),
futureBadges: Future.value(provider.savedBadgeCache),
refreshBadgesCallback: (value) {
imageProvider.savedBadgeCache.remove(value);
provider.savedBadgeCache.remove(value);
setState(() {});
return Future.value();
},
),
],
),
);
}
},
),
title: 'Badge Magic',
key: const Key(savedBadgeScreen),
),
Expand Down

0 comments on commit aa8d49c

Please sign in to comment.