mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-23 19:05:51 +00:00
Correctly parse gradient
This commit is contained in:
parent
d42f48ceee
commit
4ed34ad50f
4 changed files with 39 additions and 25 deletions
|
@ -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:
|
||||
|
|
|
@ -69,6 +69,14 @@ 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": {
|
||||
|
|
|
@ -73,8 +73,8 @@ final Map<String, dynamic> 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"]
|
||||
}
|
||||
},
|
||||
|
|
|
@ -34,17 +34,20 @@ final map = {
|
|||
|
||||
extension GradientExt on Gradient {
|
||||
static Gradient fromJson(Map<String, dynamic> json) {
|
||||
switch (json["gradientType"] as String) {
|
||||
case "linear":
|
||||
final colorStrings = List<String>.from(json["colors"] as List);
|
||||
print("THIS GRADIENTS IS ${json.isEmpty}");
|
||||
if (!json.isEmpty) {
|
||||
switch (json["background"]["type"]) {
|
||||
case "Linear":
|
||||
final colorStrings =
|
||||
List<String>.from(json["background"]["colors"] as List);
|
||||
return LinearGradient(
|
||||
begin: Alignment(
|
||||
json["begin"]["x"] as double,
|
||||
json["begin"]["y"] as double,
|
||||
json["background"]["begin"]["x"] as double,
|
||||
json["background"]["begin"]["y"] as double,
|
||||
),
|
||||
end: Alignment(
|
||||
json["end"]["x"] as double,
|
||||
json["end"]["y"] as double,
|
||||
json["background"]["end"]["x"] as double,
|
||||
json["background"]["end"]["y"] as double,
|
||||
),
|
||||
colors: colorStrings
|
||||
.map(
|
||||
|
@ -59,4 +62,7 @@ extension GradientExt on Gradient {
|
|||
throw ArgumentError("Invalid json gradient: $json");
|
||||
}
|
||||
}
|
||||
throw ArgumentError("Invalid json gradient: $json");
|
||||
// if ()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue