|
| 1 | +// ignore_for_file: depend_on_referenced_packages, implementation_imports |
| 2 | + |
| 3 | +import 'package:flutter/material.dart'; |
| 4 | + |
| 5 | +import 'package:flutter_gen/gen_l10n/l10n.dart'; |
| 6 | + |
| 7 | +import 'package:fluffychat/config/app_config.dart'; |
| 8 | +import 'package:fluffychat/config/themes.dart'; |
| 9 | +import 'package:fluffychat/pangea/constructs/construct_identifier.dart'; |
| 10 | +import 'package:fluffychat/pangea/morphs/get_grammar_copy.dart'; |
| 11 | +import 'package:fluffychat/pangea/morphs/morph_icon.dart'; |
| 12 | + |
| 13 | +void showUnlockedMorphsSnackbar( |
| 14 | + Set<ConstructIdentifier> unlockedConstructs, |
| 15 | + BuildContext context, |
| 16 | +) { |
| 17 | + for (final construct in unlockedConstructs) { |
| 18 | + final copy = getGrammarCopy( |
| 19 | + category: construct.category, |
| 20 | + lemma: construct.lemma, |
| 21 | + context: context, |
| 22 | + ); |
| 23 | + ScaffoldMessenger.of(context).showSnackBar( |
| 24 | + SnackBar( |
| 25 | + behavior: FluffyThemes.isColumnMode(context) |
| 26 | + ? SnackBarBehavior.floating |
| 27 | + : SnackBarBehavior.fixed, |
| 28 | + width: FluffyThemes.isColumnMode(context) |
| 29 | + ? MediaQuery.of(context).size.width |
| 30 | + : null, |
| 31 | + showCloseIcon: true, |
| 32 | + duration: const Duration(seconds: 5), |
| 33 | + dismissDirection: DismissDirection.none, |
| 34 | + backgroundColor: Theme.of(context).colorScheme.surface, |
| 35 | + content: Padding( |
| 36 | + padding: const EdgeInsets.all(8.0), |
| 37 | + child: Wrap( |
| 38 | + spacing: 16.0, |
| 39 | + alignment: WrapAlignment.center, |
| 40 | + children: [ |
| 41 | + Text( |
| 42 | + L10n.of(context).youUnlocked, |
| 43 | + style: TextStyle( |
| 44 | + fontSize: FluffyThemes.isColumnMode(context) ? 32.0 : 16.0, |
| 45 | + color: Theme.of(context).colorScheme.onSurface, |
| 46 | + fontWeight: FontWeight.bold, |
| 47 | + ), |
| 48 | + ), |
| 49 | + Row( |
| 50 | + mainAxisSize: MainAxisSize.min, |
| 51 | + spacing: 16.0, |
| 52 | + children: [ |
| 53 | + Flexible( |
| 54 | + child: Text( |
| 55 | + copy ?? construct.lemma, |
| 56 | + style: TextStyle( |
| 57 | + fontSize: |
| 58 | + FluffyThemes.isColumnMode(context) ? 32.0 : 16.0, |
| 59 | + color: AppConfig.gold, |
| 60 | + fontWeight: FontWeight.bold, |
| 61 | + ), |
| 62 | + overflow: TextOverflow.ellipsis, |
| 63 | + ), |
| 64 | + ), |
| 65 | + MorphIcon( |
| 66 | + morphFeature: construct.category, |
| 67 | + morphTag: construct.lemma, |
| 68 | + ), |
| 69 | + ], |
| 70 | + ), |
| 71 | + ], |
| 72 | + ), |
| 73 | + ), |
| 74 | + ), |
| 75 | + ); |
| 76 | + } |
| 77 | +} |
0 commit comments