diff --git a/lib/models/isar/sw_theme.dart b/lib/models/isar/sw_theme.dart index 87879ba8b..1f006dd83 100644 --- a/lib/models/isar/sw_theme.dart +++ b/lib/models/isar/sw_theme.dart @@ -1643,7 +1643,7 @@ class StackTheme { parseColor(json["colors"]["background"]["background"] as String), backgroundAppBarInt: parseColor( json["colors"]["background"]["backgroundAppBar"] as String), - gradientBackgroundString: jsonEncode(json["gradients"] ?? ["background"]), + gradientBackgroundString: jsonEncode(json["gradients"] as Map), standardBoxShadowString: jsonEncode(json["box_shadows"]["standard"] as Map), homeViewButtonBarBoxShadowString: diff --git a/lib/themes/defaults/dark.dart b/lib/themes/defaults/dark.dart index 19f140003..cc7de678f 100644 --- a/lib/themes/defaults/dark.dart +++ b/lib/themes/defaults/dark.dart @@ -69,6 +69,14 @@ final Map darkJson = { "nav": "0xFF3E4148", }, }, + "gradients": { + // "background": { + // "type": "Linear", + // "begin": {"x": 0.0, "y": 1.0}, + // "end": {"x": -1.0, "y": 1.0}, + // "colors": ["0xFF638227", "0xFF638227"] + // } + }, "overlay": "0xFF111215", "shadow": "0x0F2D3132", "text_subtitles": { diff --git a/lib/themes/theme_template.dart b/lib/themes/theme_template.dart index 3cab020f3..434172fd7 100644 --- a/lib/themes/theme_template.dart +++ b/lib/themes/theme_template.dart @@ -73,8 +73,8 @@ final Map darkJson = { "gradients": { "background": { "type": "Linear", - "begin": {"x": 0, "y": 1}, - "end": {"x": -1, "y": 1}, + "begin": {"x": 0.0, "y": 1.0}, + "end": {"x": -1.0, "y": 1.0}, "colors": ["0xFF638227", "0xFF638227"] } }, diff --git a/lib/utilities/extensions/impl/gradient.dart b/lib/utilities/extensions/impl/gradient.dart index 2ded15684..f34a24fe5 100644 --- a/lib/utilities/extensions/impl/gradient.dart +++ b/lib/utilities/extensions/impl/gradient.dart @@ -34,29 +34,35 @@ final map = { extension GradientExt on Gradient { static Gradient fromJson(Map json) { - switch (json["gradientType"] as String) { - case "linear": - final colorStrings = List.from(json["colors"] as List); - return LinearGradient( - begin: Alignment( - json["begin"]["x"] as double, - json["begin"]["y"] as double, - ), - end: Alignment( - json["end"]["x"] as double, - json["end"]["y"] as double, - ), - colors: colorStrings - .map( - (e) => Color( - e.toBigIntFromHex.toInt(), - ), - ) - .toList(), - ); + print("THIS GRADIENTS IS ${json.isEmpty}"); + if (!json.isEmpty) { + switch (json["background"]["type"]) { + case "Linear": + final colorStrings = + List.from(json["background"]["colors"] as List); + return LinearGradient( + begin: Alignment( + json["background"]["begin"]["x"] as double, + json["background"]["begin"]["y"] as double, + ), + end: Alignment( + json["background"]["end"]["x"] as double, + json["background"]["end"]["y"] as double, + ), + colors: colorStrings + .map( + (e) => Color( + e.toBigIntFromHex.toInt(), + ), + ) + .toList(), + ); - default: - throw ArgumentError("Invalid json gradient: $json"); + default: + throw ArgumentError("Invalid json gradient: $json"); + } } + throw ArgumentError("Invalid json gradient: $json"); + // if () } }