mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +00:00
Clean up
This commit is contained in:
parent
4ed34ad50f
commit
857f0f2acc
3 changed files with 34 additions and 71 deletions
|
@ -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:
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -1,68 +1,32 @@
|
|||
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 =
|
||||
List<String>.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(),
|
||||
);
|
||||
switch (json["background"]["type"]) {
|
||||
case "Linear":
|
||||
final colorStrings =
|
||||
List<String>.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 ()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue