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

View file

@ -69,14 +69,6 @@ final Map<String, dynamic> darkJson = {
"nav": "0xFF3E4148", "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", "overlay": "0xFF111215",
"shadow": "0x0F2D3132", "shadow": "0x0F2D3132",
"text_subtitles": { "text_subtitles": {

View file

@ -1,68 +1,32 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:stackwallet/utilities/extensions/impl/string.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 { extension GradientExt on Gradient {
static Gradient fromJson(Map<String, dynamic> json) { static Gradient fromJson(Map<String, dynamic> json) {
print("THIS GRADIENTS IS ${json.isEmpty}"); switch (json["background"]["type"]) {
if (!json.isEmpty) { case "Linear":
switch (json["background"]["type"]) { final colorStrings =
case "Linear": List<String>.from(json["background"]["colors"] as List);
final colorStrings = return LinearGradient(
List<String>.from(json["background"]["colors"] as List); begin: Alignment(
return LinearGradient( json["background"]["begin"]["x"] as double,
begin: Alignment( json["background"]["begin"]["y"] as double,
json["background"]["begin"]["x"] as double, ),
json["background"]["begin"]["y"] as double, end: Alignment(
), json["background"]["end"]["x"] as double,
end: Alignment( json["background"]["end"]["y"] as double,
json["background"]["end"]["x"] as double, ),
json["background"]["end"]["y"] as double, colors: colorStrings
), .map(
colors: colorStrings (e) => Color(
.map( e.toBigIntFromHex.toInt(),
(e) => Color( ),
e.toBigIntFromHex.toInt(), )
), .toList(),
) );
.toList(),
);
default: default:
throw ArgumentError("Invalid json gradient: $json"); throw ArgumentError("Invalid json gradient: $json");
}
} }
throw ArgumentError("Invalid json gradient: $json");
// if ()
} }
} }