mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +00:00
added boxShadowExt + boxShadows to ColorTheme
This commit is contained in:
parent
3e36165db5
commit
15c2a8bb29
2 changed files with 70 additions and 11 deletions
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/extensions/impl/box_shadow.dart';
|
||||
import 'package:stackwallet/utilities/extensions/impl/gradient.dart';
|
||||
import 'package:stackwallet/utilities/extensions/impl/string.dart';
|
||||
import 'package:stackwallet/utilities/theme/color_theme.dart';
|
||||
|
@ -70,16 +71,15 @@ class StackTheme {
|
|||
|
||||
// ==== boxShadows =====================================================
|
||||
|
||||
// @ignore
|
||||
// Gradient get boxShadows =>
|
||||
// _boxShadows ??= .fromJson(
|
||||
// Map<String, dynamic>.from(
|
||||
// jsonDecode(boxShadowsString) as Map,
|
||||
// ),
|
||||
// );
|
||||
// @ignore
|
||||
// Gradient? _gradientBackground;
|
||||
// final String gradientBackgroundString;
|
||||
@ignore
|
||||
BoxShadow get boxShadows => _boxShadows ??= BoxShadowExt.fromJson(
|
||||
Map<String, dynamic>.from(
|
||||
jsonDecode(boxShadowsString) as Map,
|
||||
),
|
||||
);
|
||||
@ignore
|
||||
BoxShadow? _boxShadows;
|
||||
final String boxShadowsString;
|
||||
|
||||
// ==== overlay =====================================================
|
||||
|
||||
|
@ -1456,6 +1456,7 @@ class StackTheme {
|
|||
required this.backgroundInt,
|
||||
required this.backgroundAppBarInt,
|
||||
required this.gradientBackgroundString,
|
||||
required this.boxShadowsString,
|
||||
required this.overlayInt,
|
||||
required this.accentColorBlueInt,
|
||||
required this.accentColorGreenInt,
|
||||
|
@ -1622,7 +1623,8 @@ class StackTheme {
|
|||
backgroundAppBarInt: parseColor(
|
||||
json["colors"]["background_colors"]["backgroundAppBar"] as String),
|
||||
gradientBackgroundString:
|
||||
jsonEncode(json["gradients"]["gradientBackground"] as Map),
|
||||
jsonEncode(json["gradients"]["background"] as Map),
|
||||
boxShadowsString: jsonEncode(json["box_shadows"] as Map),
|
||||
coinColorsJsonString: jsonEncode(json["coinColors"] as Map),
|
||||
assets: ThemeAssets.fromJson(
|
||||
json: json,
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
// todo: delete this map (example)
|
||||
final map = {
|
||||
"name": "Dark",
|
||||
"coinColors": {
|
||||
"bitcoin": "0xFF267352",
|
||||
},
|
||||
"assets": {
|
||||
"circleLock": "svg/somerandomnamecreatedbythemecreator.svg",
|
||||
},
|
||||
"colors": {
|
||||
"background": "0xFF848383",
|
||||
},
|
||||
"gradientBackground": {
|
||||
"gradientType": "linear",
|
||||
"begin": {
|
||||
"x": 0.0,
|
||||
"y": 1.0,
|
||||
},
|
||||
"end": {
|
||||
"x": -1.0,
|
||||
"y": 1.0,
|
||||
},
|
||||
"colors": [
|
||||
"0xFF638227",
|
||||
"0xFF632827",
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
extension BoxShadowExt on BoxShadow {
|
||||
static BoxShadow fromJson(Map<String, dynamic> json) {
|
||||
switch (json["boxShadowType"] as String) {
|
||||
case "standard":
|
||||
final colorStrings = (json["colors"]);
|
||||
return BoxShadow(
|
||||
color: Color(
|
||||
colorStrings as int,
|
||||
),
|
||||
spreadRadius: json["spread_radius"] as double,
|
||||
blurRadius: json["blur_radius"] as double,
|
||||
);
|
||||
case "home_view_button_bar":
|
||||
final colorStrings = (json["colors"]);
|
||||
return BoxShadow(
|
||||
color: Color(
|
||||
colorStrings as int,
|
||||
),
|
||||
spreadRadius: json["spread_radius"] as double,
|
||||
blurRadius: json["blur_radius"] as double,
|
||||
);
|
||||
default:
|
||||
throw ArgumentError("Invalid json box shadow: $json");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue