This commit is contained in:
likho 2023-04-25 15:58:51 +02:00
parent 4ed34ad50f
commit 857f0f2acc
3 changed files with 34 additions and 71 deletions

View file

@ -59,15 +59,22 @@ class StackTheme {
// ==== gradientBackground =====================================================
@ignore
Gradient get gradientBackground =>
Gradient? get gradientBackground {
if (gradientBackgroundString == null) {
_gradientBackground = null;
} else {
_gradientBackground ??= GradientExt.fromJson(
Map<String, dynamic>.from(
jsonDecode(gradientBackgroundString) as Map,
jsonDecode(gradientBackgroundString!) as Map,
),
);
}
return _gradientBackground;
}
@ignore
Gradient? _gradientBackground;
final String gradientBackgroundString;
final String? gradientBackgroundString;
// ==== boxShadows =====================================================
@ -1643,7 +1650,7 @@ class StackTheme {
parseColor(json["colors"]["background"]["background"] as String),
backgroundAppBarInt: parseColor(
json["colors"]["background"]["backgroundAppBar"] as String),
gradientBackgroundString: jsonEncode(json["gradients"] as Map),
gradientBackgroundString: json["gradients"] as String?,
standardBoxShadowString:
jsonEncode(json["box_shadows"]["standard"] as Map),
homeViewButtonBarBoxShadowString:

View file

@ -69,14 +69,6 @@ final Map<String, dynamic> 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": {

View file

@ -1,41 +1,8 @@
import 'package:flutter/material.dart';
import 'package:stackwallet/utilities/extensions/impl/string.dart';
// todo: delete this map (example)
final map = {
"name": "Dark",
"coinColors": {
"bitcoin": "0xFF267352",
},
"assets": {
"circleLock": "svg/somerandomnamecreatedbythemecreator.svg",
},
"colors": {
"background": "0xFF848383",
},
"gradients": {
"gradientBackground": {
"gradientType": "linear",
"begin": {
"x": 0.0,
"y": 1.0,
},
"end": {
"x": -1.0,
"y": 1.0,
},
"colors": [
"0xFF638227",
"0xFF632827",
]
}
}
};
extension GradientExt on Gradient {
static Gradient fromJson(Map<String, dynamic> json) {
print("THIS GRADIENTS IS ${json.isEmpty}");
if (!json.isEmpty) {
switch (json["background"]["type"]) {
case "Linear":
final colorStrings =
@ -62,7 +29,4 @@ extension GradientExt on Gradient {
throw ArgumentError("Invalid json gradient: $json");
}
}
throw ArgumentError("Invalid json gradient: $json");
// if ()
}
}