added boxShadowExt + boxShadows to ColorTheme

This commit is contained in:
ryleedavis 2023-04-21 09:57:20 -06:00
parent 3e36165db5
commit 15c2a8bb29
2 changed files with 70 additions and 11 deletions

View file

@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:isar/isar.dart'; import 'package:isar/isar.dart';
import 'package:stackwallet/utilities/enums/coin_enum.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/gradient.dart';
import 'package:stackwallet/utilities/extensions/impl/string.dart'; import 'package:stackwallet/utilities/extensions/impl/string.dart';
import 'package:stackwallet/utilities/theme/color_theme.dart'; import 'package:stackwallet/utilities/theme/color_theme.dart';
@ -70,16 +71,15 @@ class StackTheme {
// ==== boxShadows ===================================================== // ==== boxShadows =====================================================
// @ignore @ignore
// Gradient get boxShadows => BoxShadow get boxShadows => _boxShadows ??= BoxShadowExt.fromJson(
// _boxShadows ??= .fromJson( Map<String, dynamic>.from(
// Map<String, dynamic>.from( jsonDecode(boxShadowsString) as Map,
// jsonDecode(boxShadowsString) as Map, ),
// ), );
// ); @ignore
// @ignore BoxShadow? _boxShadows;
// Gradient? _gradientBackground; final String boxShadowsString;
// final String gradientBackgroundString;
// ==== overlay ===================================================== // ==== overlay =====================================================
@ -1456,6 +1456,7 @@ class StackTheme {
required this.backgroundInt, required this.backgroundInt,
required this.backgroundAppBarInt, required this.backgroundAppBarInt,
required this.gradientBackgroundString, required this.gradientBackgroundString,
required this.boxShadowsString,
required this.overlayInt, required this.overlayInt,
required this.accentColorBlueInt, required this.accentColorBlueInt,
required this.accentColorGreenInt, required this.accentColorGreenInt,
@ -1622,7 +1623,8 @@ class StackTheme {
backgroundAppBarInt: parseColor( backgroundAppBarInt: parseColor(
json["colors"]["background_colors"]["backgroundAppBar"] as String), json["colors"]["background_colors"]["backgroundAppBar"] as String),
gradientBackgroundString: 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), coinColorsJsonString: jsonEncode(json["coinColors"] as Map),
assets: ThemeAssets.fromJson( assets: ThemeAssets.fromJson(
json: json, json: json,

View file

@ -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");
}
}
}