1563-grammar-icon-in-light-mode (#1565)

* fix(morph_svgs): fixing light/dark mode coloring

* dart formatting

---------

Co-authored-by: ggurdin <46800240+ggurdin@users.noreply.github.com>
pull/1593/head
wcjord 10 months ago committed by GitHub
parent c4b35f67c7
commit 387a7aa51a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -211,17 +211,10 @@ class VocabAnalyticsPopupState extends State<VocabAnalyticsPopup> {
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
CircleAvatar( CustomizedSvg(
backgroundColor: svgUrl: type.svgURL,
Theme.of(context).brightness == Brightness.light colorReplacements: const {},
? Colors.white errorIcon: Text(type.emoji),
: Colors.black,
radius: 16,
child: CustomizedSvg(
svgUrl: type.svgURL,
colorReplacements: const {},
errorIcon: Text(type.emoji),
),
), ),
Text( Text(
" ${type.xpString} XP", " ${type.xpString} XP",

@ -5,8 +5,13 @@ import 'package:get_storage/get_storage.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
class CustomizedSvg extends StatelessWidget { class CustomizedSvg extends StatelessWidget {
/// URL of the SVG file
final String svgUrl; final String svgUrl;
/// Map of color replacements
final Map<String, String> colorReplacements; final Map<String, String> colorReplacements;
/// Icon to show in case of error
final Widget errorIcon; final Widget errorIcon;
const CustomizedSvg({ const CustomizedSvg({
@ -38,6 +43,8 @@ class CustomizedSvg extends StatelessWidget {
Future<String> _getModifiedSvg() async { Future<String> _getModifiedSvg() async {
final svgContent = await _fetchSvg(); final svgContent = await _fetchSvg();
String modifiedSvg = svgContent; String modifiedSvg = svgContent;
// find the white and replace with black
// or find black and replace with white
modifiedSvg = modifiedSvg.replaceAll("fill=\"none\"", ''); modifiedSvg = modifiedSvg.replaceAll("fill=\"none\"", '');
for (final entry in colorReplacements.entries) { for (final entry in colorReplacements.entries) {
modifiedSvg = modifiedSvg.replaceAll(entry.key, entry.value); modifiedSvg = modifiedSvg.replaceAll(entry.key, entry.value);

@ -33,6 +33,6 @@ class EmojiPracticeButton extends StatelessWidget {
isSelected: isSelected, isSelected: isSelected,
onPressed: onPressed, onPressed: onPressed,
) )
: const SizedBox(width: 40); : const SizedBox(width: 60);
} }
} }

@ -23,6 +23,7 @@ class WordZoomActivityButton extends StatelessWidget {
Widget buttonContent = IconButton( Widget buttonContent = IconButton(
onPressed: onPressed, onPressed: onPressed,
icon: icon, icon: icon,
iconSize: 24,
color: isSelected ? Theme.of(context).colorScheme.primary : null, color: isSelected ? Theme.of(context).colorScheme.primary : null,
style: IconButton.styleFrom( style: IconButton.styleFrom(
backgroundColor: isSelected backgroundColor: isSelected

@ -36,12 +36,14 @@ class MorphologicalListItem extends StatelessWidget {
icon: svgLink != null icon: svgLink != null
? CustomizedSvg( ? CustomizedSvg(
svgUrl: svgLink!, svgUrl: svgLink!,
colorReplacements: { colorReplacements:
"white": Theme.of(context).cardColor.hexValue.toString(), Theme.of(context).brightness == Brightness.dark
"black": Theme.of(context).brightness == Brightness.dark ? {
? "white" "white":
: "black", Theme.of(context).cardColor.hexValue.toString(),
}, "black": "white",
}
: {},
errorIcon: Icon(icon), errorIcon: Icon(icon),
) )
: Icon(icon), : Icon(icon),

Loading…
Cancel
Save