| 1 | import 'package:cw_core/balance_card_style_settings.dart'; |
| 2 | import 'package:cw_core/crypto_currency.dart'; |
| 3 | import 'package:cw_core/utils/print_verbose.dart'; |
| 4 | import 'package:flutter/material.dart'; |
| 5 | |
| 6 | enum CardDesignBackgroundTypes { image, svgIcon, svgFull, gradientOnly } |
| 7 | |
| 8 | class CardColorCombination { |
| 9 | final Color textColor; |
| 10 | final Color textColorSecondary; |
| 11 | final Color backgroundImageColor; |
| 12 | |
| 13 | const CardColorCombination( |
| 14 | {required this.textColor, |
| 15 | required this.textColorSecondary, |
| 16 | required this.backgroundImageColor}); |
| 17 | |
| 18 | static const light = CardColorCombination( |
| 19 | textColor: Color.fromARGB(200, 255, 255, 255), |
| 20 | textColorSecondary: Colors.white54, |
| 21 | backgroundImageColor: Color.fromARGB(200, 0, 0, 0)); |
| 22 | |
| 23 | static const dark = CardColorCombination( |
| 24 | textColor: Color.fromARGB(200, 0, 0, 0), |
| 25 | textColorSecondary: Colors.black45, |
| 26 | backgroundImageColor: Color.fromARGB(200, 255, 255, 255), |
| 27 | ); |
| 28 | |
| 29 | static const black = CardColorCombination( |
| 30 | textColor: Color.fromARGB(200, 255, 255, 255), |
| 31 | textColorSecondary: Colors.white54, |
| 32 | backgroundImageColor: Color.fromARGB(200, 255, 255, 255), |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | class CardIconPath { |
| 37 | final String path; |
| 38 | final bool preColored; |
| 39 | |
| 40 | const CardIconPath(this.path, {this.preColored = false}); |
| 41 | } |
| 42 | |
| 43 | class CardDesign { |
| 44 | final Gradient gradient; |
| 45 | final String imagePath; |
| 46 | final CardDesignBackgroundTypes backgroundType; |
| 47 | final CardColorCombination colors; |
| 48 | final bool preColoredIcon; |
| 49 | |
| 50 | const CardDesign( |
| 51 | {this.backgroundType = CardDesignBackgroundTypes.svgIcon, |
| 52 | this.gradient = const LinearGradient( |
| 53 | colors: [Colors.black], begin: Alignment.topCenter, end: Alignment.bottomCenter), |
| 54 | this.imagePath = "assets/new-ui/blank.svg", |
| 55 | this.colors = CardColorCombination.dark, |
| 56 | this.preColoredIcon = false}); |
| 57 | |
| 58 | static const LinearGradient gradientOrange = LinearGradient( |
| 59 | colors: <Color>[Color(0xFFFF7C02), Color(0xFFFF5602)], |
| 60 | begin: Alignment.topCenter, |
| 61 | end: Alignment.bottomCenter, |
| 62 | ); |
| 63 | |
| 64 | static const LinearGradient gradientYellow = LinearGradient( |
| 65 | colors: <Color>[Color(0xFFFFD000), Color(0xFFFFAA00)], |
| 66 | begin: Alignment.topCenter, |
| 67 | end: Alignment.bottomCenter, |
| 68 | ); |
| 69 | static const LinearGradient gradientGreen = LinearGradient( |
| 70 | colors: <Color>[Color(0xFF5AA438), Color(0xFF5AA438)], |
| 71 | begin: Alignment.topCenter, |
| 72 | end: Alignment.bottomCenter, |
| 73 | ); |
| 74 | |
| 75 | static const LinearGradient gradientBlue = LinearGradient( |
| 76 | colors: <Color>[Color(0xFF4EBEFF), Color(0xFF1D78FF)], |
| 77 | begin: Alignment.topCenter, |
| 78 | end: Alignment.bottomCenter, |
| 79 | ); |
| 80 | |
| 81 | static const LinearGradient gradientPurple = LinearGradient( |
| 82 | colors: <Color>[Color(0xFF9E30FF), Color(0xFF7100BD)], |
| 83 | begin: Alignment.topCenter, |
| 84 | end: Alignment.bottomCenter, |
| 85 | ); |
| 86 | |
| 87 | static const LinearGradient gradientPink = LinearGradient( |
| 88 | colors: <Color>[Color(0xFFFF6CD3), Color(0xFFF200A9)], |
| 89 | begin: Alignment.topCenter, |
| 90 | end: Alignment.bottomCenter, |
| 91 | ); |
| 92 | |
| 93 | static const LinearGradient gradientRed = LinearGradient( |
| 94 | colors: <Color>[Color(0xFFFF2222), Color(0xFFA10000)], |
| 95 | begin: Alignment.topCenter, |
| 96 | end: Alignment.bottomCenter, |
| 97 | ); |
| 98 | |
| 99 | static const LinearGradient gradientSilver = LinearGradient( |
| 100 | colors: <Color>[Color(0xFFE0E8FF), Color(0xFF6D8ADE)], |
| 101 | begin: Alignment.topCenter, |
| 102 | end: Alignment.bottomCenter, |
| 103 | ); |
| 104 | |
| 105 | static const LinearGradient gradientGold = LinearGradient( |
| 106 | colors: <Color>[Color(0xFFE9CA74), Color(0xFF886A14)], |
| 107 | begin: Alignment.topCenter, |
| 108 | end: Alignment.bottomCenter, |
| 109 | ); |
| 110 | |
| 111 | static const LinearGradient gradientBlack = LinearGradient( |
| 112 | colors: <Color>[Color(0xFF2A2A2A), Color(0xFF000000)], |
| 113 | begin: Alignment.topCenter, |
| 114 | end: Alignment.bottomCenter, |
| 115 | ); |
| 116 | |
| 117 | static const List<Gradient> allGradients = <Gradient>[ |
| 118 | gradientOrange, |
| 119 | gradientYellow, |
| 120 | gradientGreen, |
| 121 | gradientBlue, |
| 122 | gradientPurple, |
| 123 | gradientPink, |
| 124 | gradientRed, |
| 125 | gradientSilver, |
| 126 | gradientGold, |
| 127 | gradientBlack, |
| 128 | ]; |
| 129 | |
| 130 | static const genericDefault = CardDesign(gradient: gradientBlue); |
| 131 | |
| 132 | static const gradientOnlyDesign = |
| 133 | CardDesign(backgroundType: CardDesignBackgroundTypes.gradientOnly, gradient: gradientBlue); |
| 134 | |
| 135 | static const btc = CardDesign(imagePath: "assets/new-ui/balance_card_icons/bitcoin.svg"); |
| 136 | |
| 137 | static const eth = CardDesign(imagePath: "assets/new-ui/balance_card_icons/ethereum.svg"); |
| 138 | |
| 139 | static const btcln = CardDesign(imagePath: "assets/new-ui/balance_card_icons/lightning.svg"); |
| 140 | |
| 141 | static const xmr = CardDesign(imagePath: "assets/new-ui/balance_card_icons/monero.svg"); |
| 142 | |
| 143 | static const ltc = CardDesign(imagePath: "assets/new-ui/balance_card_icons/litecoin.svg"); |
| 144 | |
| 145 | static const bch = CardDesign(imagePath: "assets/new-ui/balance_card_icons/bitcoin_cash.svg"); |
| 146 | |
| 147 | static const doge = CardDesign(imagePath: "assets/new-ui/balance_card_icons/dogecoin.svg"); |
| 148 | |
| 149 | static const base = CardDesign(imagePath: "assets/new-ui/balance_card_icons/base.svg"); |
| 150 | |
| 151 | static const pol = CardDesign(imagePath: "assets/new-ui/balance_card_icons/polygon.svg"); |
| 152 | |
| 153 | static const sol = CardDesign(imagePath: "assets/new-ui/balance_card_icons/solana.svg"); |
| 154 | |
| 155 | static const tron = CardDesign(imagePath: "assets/new-ui/balance_card_icons/tron.svg"); |
| 156 | |
| 157 | static const nano = CardDesign(imagePath: "assets/new-ui/balance_card_icons/nano.svg"); |
| 158 | |
| 159 | static const zano = CardDesign(imagePath: "assets/new-ui/balance_card_icons/zano.svg"); |
| 160 | |
| 161 | static const wow = CardDesign(imagePath: "assets/new-ui/balance_card_icons/wownero.svg"); |
| 162 | |
| 163 | static const dcr = CardDesign(imagePath: "assets/new-ui/balance_card_icons/decred.svg"); |
| 164 | |
| 165 | static const arbitrum = CardDesign(imagePath: "assets/new-ui/balance_card_icons/arbitrum.svg"); |
| 166 | |
| 167 | static const zec = CardDesign(imagePath: "assets/new-ui/balance_card_icons/zcash.svg"); |
| 168 | |
| 169 | static const bnb = CardDesign(imagePath: "assets/new-ui/balance_card_icons/bnb.svg"); |
| 170 | |
| 171 | static const ethSpecial = CardDesign( |
| 172 | gradient: const LinearGradient( |
| 173 | colors: <Color>[Color(0xFF6259FF), Color(0xFF3B20E6)], |
| 174 | begin: Alignment.topCenter, |
| 175 | end: Alignment.bottomCenter), |
| 176 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 177 | colors: CardColorCombination.light, |
| 178 | imagePath: "assets/new-ui/balance_card_backgrounds/ethereum.svg"); |
| 179 | |
| 180 | static const btcSpecial = CardDesign( |
| 181 | gradient: const LinearGradient( |
| 182 | colors: <Color>[Color(0xFFFFBF00), Color(0xFFFF6A00)], |
| 183 | begin: Alignment.topCenter, |
| 184 | end: Alignment.bottomCenter), |
| 185 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 186 | imagePath: "assets/new-ui/balance_card_backgrounds/bitcoin.svg"); |
| 187 | |
| 188 | static const xmrSpecial = CardDesign( |
| 189 | gradient: const LinearGradient( |
| 190 | colors: <Color>[Color(0xFFFF5900), Color(0xFFE62E00)], |
| 191 | begin: Alignment.topCenter, |
| 192 | end: Alignment.bottomCenter), |
| 193 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 194 | imagePath: "assets/new-ui/balance_card_backgrounds/monero.svg"); |
| 195 | |
| 196 | static const ltcSpecial = CardDesign( |
| 197 | gradient: const LinearGradient( |
| 198 | colors: <Color>[Color(0xFF2145BF), Color(0xFF072071)], |
| 199 | begin: Alignment.topCenter, |
| 200 | end: Alignment.bottomCenter), |
| 201 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 202 | colors: CardColorCombination.light, |
| 203 | imagePath: "assets/new-ui/balance_card_backgrounds/litecoin.svg"); |
| 204 | |
| 205 | static const lnSpecial = CardDesign( |
| 206 | gradient: const LinearGradient( |
| 207 | colors: <Color>[Color(0xFFFFBF00), Color(0xFFFF6A00)], |
| 208 | begin: Alignment.topCenter, |
| 209 | end: Alignment.bottomCenter), |
| 210 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 211 | colors: CardColorCombination.dark, |
| 212 | imagePath: "assets/new-ui/balance_card_backgrounds/lightning.svg"); |
| 213 | |
| 214 | static const tronSpecial = CardDesign( |
| 215 | gradient: const LinearGradient( |
| 216 | colors: <Color>[Color(0xFFFF1313), Color(0xFFB40000)], |
| 217 | begin: Alignment.topCenter, |
| 218 | end: Alignment.bottomCenter), |
| 219 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 220 | colors: CardColorCombination.light, |
| 221 | imagePath: "assets/new-ui/balance_card_backgrounds/tron.svg"); |
| 222 | |
| 223 | static const solSpecial = CardDesign( |
| 224 | gradient: const LinearGradient( |
| 225 | colors: <Color>[Color(0xFF4701AA), Color(0xFF19004B)], |
| 226 | begin: Alignment.topCenter, |
| 227 | end: Alignment.bottomCenter), |
| 228 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 229 | colors: CardColorCombination.light, |
| 230 | imagePath: "assets/new-ui/balance_card_backgrounds/solana.svg"); |
| 231 | |
| 232 | static const bchSpecial = CardDesign( |
| 233 | gradient: const LinearGradient( |
| 234 | colors: <Color>[Color(0xFF36DA4C), Color(0xFF008D57)], |
| 235 | begin: Alignment.topCenter, |
| 236 | end: Alignment.bottomCenter), |
| 237 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 238 | imagePath: "assets/new-ui/balance_card_backgrounds/bitcoin-cash.svg"); |
| 239 | |
| 240 | static const wowSpecial = CardDesign( |
| 241 | gradient: const LinearGradient( |
| 242 | colors: <Color>[Color(0xFFFF6CD3), Color(0xFFF200A9)], |
| 243 | begin: Alignment.topCenter, |
| 244 | end: Alignment.bottomCenter), |
| 245 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 246 | imagePath: "assets/new-ui/balance_card_backgrounds/wownero.svg"); |
| 247 | |
| 248 | static const dogeSpecial = CardDesign( |
| 249 | gradient: const LinearGradient( |
| 250 | colors: <Color>[Color(0xFFCBA818), Color(0xFF885D00)], |
| 251 | begin: Alignment.topCenter, |
| 252 | end: Alignment.bottomCenter), |
| 253 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 254 | imagePath: "assets/new-ui/balance_card_backgrounds/dogecoin.svg"); |
| 255 | |
| 256 | static const nanoSpecial = CardDesign( |
| 257 | gradient: const LinearGradient( |
| 258 | colors: <Color>[Color(0xFF209CE9), Color(0xFF0073CB)], |
| 259 | begin: Alignment.topCenter, |
| 260 | end: Alignment.bottomCenter), |
| 261 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 262 | imagePath: "assets/new-ui/balance_card_backgrounds/nano.svg"); |
| 263 | |
| 264 | static const polSpecial = CardDesign( |
| 265 | gradient: const LinearGradient( |
| 266 | colors: <Color>[Color(0xFF863FE3), Color(0xFF59098E)], |
| 267 | begin: Alignment.topCenter, |
| 268 | end: Alignment.bottomCenter), |
| 269 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 270 | colors: CardColorCombination.light, |
| 271 | imagePath: "assets/new-ui/balance_card_backgrounds/polygon.svg"); |
| 272 | |
| 273 | static const dcrSpecial = CardDesign( |
| 274 | gradient: const LinearGradient( |
| 275 | colors: <Color>[Color(0xFF2871FF), Color(0xFF0057FF)], |
| 276 | begin: Alignment.topCenter, |
| 277 | end: Alignment.bottomCenter), |
| 278 | colors: CardColorCombination.light, |
| 279 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 280 | imagePath: "assets/new-ui/balance_card_backgrounds/decred.svg"); |
| 281 | |
| 282 | static const zanoSpecial = CardDesign( |
| 283 | gradient: const LinearGradient( |
| 284 | colors: <Color>[Color(0xFF0004B4), Color(0xFF170069)], |
| 285 | begin: Alignment.topCenter, |
| 286 | end: Alignment.bottomCenter), |
| 287 | colors: CardColorCombination.black, |
| 288 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 289 | imagePath: "assets/new-ui/balance_card_backgrounds/zano.svg"); |
| 290 | |
| 291 | static const baseSpecial = CardDesign( |
| 292 | gradient: const LinearGradient( |
| 293 | colors: <Color>[Color(0xFF003CFF), Color(0xFF000087)], |
| 294 | begin: Alignment.topCenter, |
| 295 | end: Alignment.bottomCenter), |
| 296 | colors: CardColorCombination.light, |
| 297 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 298 | imagePath: "assets/new-ui/balance_card_backgrounds/base.svg"); |
| 299 | |
| 300 | static const arbitrumSpecial = CardDesign( |
| 301 | gradient: const LinearGradient( |
| 302 | colors: <Color>[Color(0xFF173F76), Color(0xFF031A39)], |
| 303 | begin: Alignment.topCenter, |
| 304 | end: Alignment.bottomCenter), |
| 305 | colors: CardColorCombination.light, |
| 306 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 307 | imagePath: "assets/new-ui/balance_card_backgrounds/arbitrum.svg"); |
| 308 | |
| 309 | static const zecSpecial = CardDesign( |
| 310 | gradient: const LinearGradient( |
| 311 | colors: <Color>[Color(0xFFF6C527), Color(0xFFCD8C00)], |
| 312 | begin: Alignment.topCenter, |
| 313 | end: Alignment.bottomCenter), |
| 314 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 315 | imagePath: "assets/new-ui/balance_card_backgrounds/zcash.svg"); |
| 316 | |
| 317 | static const bnbSpecial = CardDesign( |
| 318 | gradient: const LinearGradient( |
| 319 | colors: <Color>[Color(0xFF603000), Color(0xFFF0B90B)], |
| 320 | begin: Alignment.topCenter, |
| 321 | end: Alignment.bottomCenter), |
| 322 | colors: CardColorCombination.light, |
| 323 | backgroundType: CardDesignBackgroundTypes.svgFull, |
| 324 | imagePath: "assets/new-ui/balance_card_backgrounds/bnb.svg"); |
| 325 | |
| 326 | CardDesign withGradient(Gradient gradient) => CardDesign( |
| 327 | gradient: gradient, |
| 328 | colors: preferredColorCombinations[gradient] ?? colors, |
| 329 | imagePath: imagePath, |
| 330 | backgroundType: backgroundType, |
| 331 | preColoredIcon: preColoredIcon); |
| 332 | |
| 333 | CardDesign withGradientAndColorCombination( |
| 334 | Gradient gradient, CardColorCombination cardColorCombination) => |
| 335 | CardDesign( |
| 336 | gradient: gradient, |
| 337 | colors: cardColorCombination, |
| 338 | imagePath: imagePath, |
| 339 | backgroundType: backgroundType, |
| 340 | preColoredIcon: preColoredIcon); |
| 341 | |
| 342 | CardDesign withIcon(CardIconPath icon) => CardDesign( |
| 343 | gradient: gradient, |
| 344 | colors: colors, |
| 345 | imagePath: icon.path, |
| 346 | backgroundType: backgroundType, |
| 347 | preColoredIcon: icon.preColored); |
| 348 | |
| 349 | static const String _balanceCardIconPrefix = "assets/new-ui/balance_card_icons"; |
| 350 | static const String _chainIconPrefix = "assets/new-ui/card_icons/chain_icons"; |
| 351 | static const String _ogIconPrefix = "assets/new-ui/card_icons/og_icons"; |
| 352 | static const String _outlineIconPrefix = "assets/new-ui/card_icons/outline_icons"; |
| 353 | static const String _symbolIconPrefix = "assets/new-ui/card_icons/symbol_icons"; |
| 354 | static const String _genericCakeIcon = "$_balanceCardIconPrefix/cake-card-icon.svg"; |
| 355 | |
| 356 | static const Map<CryptoCurrency, _CurrencyIconNames> _iconNames = { |
| 357 | CryptoCurrency.arbEth: _CurrencyIconNames(ticker: 'arb', longName: 'arbitrum'), |
| 358 | CryptoCurrency.baseEth: |
| 359 | _CurrencyIconNames(ticker: 'base', longName: 'base', chainFile: 'base_icon'), |
| 360 | CryptoCurrency.bch: |
| 361 | _CurrencyIconNames(ticker: 'bch', longName: 'bitcoin_cash', chainFile: 'bitcoin-cash'), |
| 362 | CryptoCurrency.btc: _CurrencyIconNames(ticker: 'btc', longName: 'bitcoin', outlineFile: 'BTC'), |
| 363 | CryptoCurrency.bnb: _CurrencyIconNames(ticker: 'bnb', longName: 'bnb'), |
| 364 | CryptoCurrency.dcr: _CurrencyIconNames(ticker: 'dcr', longName: 'decred'), |
| 365 | CryptoCurrency.doge: _CurrencyIconNames(ticker: 'doge', longName: 'dogecoin'), |
| 366 | CryptoCurrency.eth: _CurrencyIconNames(ticker: 'eth', longName: 'ethereum'), |
| 367 | CryptoCurrency.btcln: _CurrencyIconNames(ticker: 'ln', longName: 'lightning'), |
| 368 | CryptoCurrency.ltc: _CurrencyIconNames(ticker: 'ltc', longName: 'litecoin'), |
| 369 | CryptoCurrency.xmr: |
| 370 | _CurrencyIconNames(ticker: 'xmr', longName: 'monero', ogPath: 'assets/images/xmr-og.webp'), |
| 371 | CryptoCurrency.nano: _CurrencyIconNames(ticker: 'xno', longName: 'nano'), |
| 372 | CryptoCurrency.maticpoly: _CurrencyIconNames(ticker: 'pol', longName: 'polygon'), |
| 373 | CryptoCurrency.sol: _CurrencyIconNames(ticker: 'sol', longName: 'solana'), |
| 374 | CryptoCurrency.trx: |
| 375 | _CurrencyIconNames(ticker: 'trx', longName: 'tron', ogPath: '$_ogIconPrefix/tron-og.svg'), |
| 376 | CryptoCurrency.zano: _CurrencyIconNames(ticker: 'zano', longName: 'zano'), |
| 377 | CryptoCurrency.zec: _CurrencyIconNames(ticker: 'zec', longName: 'zcash'), |
| 378 | }; |
| 379 | |
| 380 | static List<CardIconPath> iconPathsForWalletType(CryptoCurrency currency) { |
| 381 | final n = _iconNames[currency]; |
| 382 | if (n == null) return const []; |
| 383 | |
| 384 | return [ |
| 385 | CardIconPath('$_symbolIconPrefix/${n.ticker}-symbol.svg'), |
| 386 | CardIconPath('$_outlineIconPrefix/${n.outlineFile ?? n.ticker}-outline.svg'), |
| 387 | CardIconPath('$_balanceCardIconPrefix/${n.longName}.svg'), |
| 388 | CardIconPath('$_chainIconPrefix/${n.chainFile ?? n.longName}.svg', preColored: true), |
| 389 | CardIconPath(n.ogPath ?? '$_ogIconPrefix/${n.ticker}-og.svg', preColored: true), |
| 390 | const CardIconPath(_genericCakeIcon), |
| 391 | ]; |
| 392 | } |
| 393 | |
| 394 | static const List<CardDesign> all = [ |
| 395 | genericDefault, |
| 396 | btc, |
| 397 | eth, |
| 398 | xmr, |
| 399 | ltc, |
| 400 | eth, |
| 401 | pol, |
| 402 | doge, |
| 403 | base, |
| 404 | sol, |
| 405 | btcln, |
| 406 | tron, |
| 407 | zano, |
| 408 | dcr, |
| 409 | arbitrum, |
| 410 | zec, |
| 411 | bnb, |
| 412 | ethSpecial, |
| 413 | btcSpecial, |
| 414 | xmrSpecial, |
| 415 | ltcSpecial, |
| 416 | lnSpecial, |
| 417 | tronSpecial, |
| 418 | bchSpecial, |
| 419 | wowSpecial, |
| 420 | dogeSpecial, |
| 421 | polSpecial, |
| 422 | dcrSpecial, |
| 423 | zanoSpecial, |
| 424 | arbitrumSpecial, |
| 425 | zecSpecial, |
| 426 | bnbSpecial |
| 427 | ]; |
| 428 | |
| 429 | static CardDesign forCurrencySpecial(CryptoCurrency currency) { |
| 430 | return specialDesignsForCurrencies[currency] ?? genericDefault; |
| 431 | } |
| 432 | |
| 433 | static CardDesign forCurrencyIcon(CryptoCurrency currency) { |
| 434 | return iconDesignsForCurrencies[currency] ?? genericDefault; |
| 435 | } |
| 436 | |
| 437 | static const Map<CryptoCurrency, CardDesign> iconDesignsForCurrencies = { |
| 438 | CryptoCurrency.xmr: xmr, |
| 439 | CryptoCurrency.btc: btc, |
| 440 | CryptoCurrency.eth: eth, |
| 441 | CryptoCurrency.ltc: ltc, |
| 442 | CryptoCurrency.btcln: btcln, |
| 443 | CryptoCurrency.trx: tron, |
| 444 | CryptoCurrency.sol: sol, |
| 445 | CryptoCurrency.maticpoly: pol, |
| 446 | CryptoCurrency.baseEth: base, |
| 447 | CryptoCurrency.bch: bch, |
| 448 | CryptoCurrency.wow: wow, |
| 449 | CryptoCurrency.doge: doge, |
| 450 | CryptoCurrency.nano: nano, |
| 451 | CryptoCurrency.zano: zano, |
| 452 | CryptoCurrency.arbEth: arbitrum, |
| 453 | CryptoCurrency.zec: zec, |
| 454 | CryptoCurrency.dcr: dcr, |
| 455 | CryptoCurrency.bnb: bnb, |
| 456 | }; |
| 457 | |
| 458 | static const Map<CryptoCurrency, CardDesign> specialDesignsForCurrencies = { |
| 459 | CryptoCurrency.xmr: xmrSpecial, |
| 460 | CryptoCurrency.btc: btcSpecial, |
| 461 | CryptoCurrency.eth: ethSpecial, |
| 462 | CryptoCurrency.ltc: ltcSpecial, |
| 463 | CryptoCurrency.btcln: lnSpecial, |
| 464 | CryptoCurrency.trx: tronSpecial, |
| 465 | CryptoCurrency.sol: solSpecial, |
| 466 | CryptoCurrency.bch: bchSpecial, |
| 467 | CryptoCurrency.wow: wowSpecial, |
| 468 | CryptoCurrency.doge: dogeSpecial, |
| 469 | CryptoCurrency.nano: nanoSpecial, |
| 470 | CryptoCurrency.maticpoly: polSpecial, |
| 471 | CryptoCurrency.dcr: dcrSpecial, |
| 472 | CryptoCurrency.zano: zanoSpecial, |
| 473 | CryptoCurrency.baseEth: baseSpecial, |
| 474 | CryptoCurrency.arbEth: arbitrumSpecial, |
| 475 | CryptoCurrency.zec: zecSpecial, |
| 476 | CryptoCurrency.bnb: bnbSpecial, |
| 477 | }; |
| 478 | |
| 479 | static Map<Gradient, CardColorCombination> preferredColorCombinations = { |
| 480 | CardDesign.gradientOrange: CardColorCombination.dark, |
| 481 | CardDesign.gradientYellow: CardColorCombination.dark, |
| 482 | CardDesign.gradientGreen: CardColorCombination.light, |
| 483 | CardDesign.gradientBlue: CardColorCombination.dark, |
| 484 | CardDesign.gradientPurple: CardColorCombination.light, |
| 485 | CardDesign.gradientPink: CardColorCombination.dark, |
| 486 | CardDesign.gradientRed: CardColorCombination.light, |
| 487 | CardDesign.gradientSilver: CardColorCombination.dark, |
| 488 | CardDesign.gradientGold: CardColorCombination.dark, |
| 489 | CardDesign.gradientBlack: CardColorCombination.black, |
| 490 | }; |
| 491 | |
| 492 | CardDesign withIconStyleIndex(int iconStyleIndex, CryptoCurrency currency) { |
| 493 | final paths = iconPathsForWalletType(currency); |
| 494 | if (paths.isEmpty) return this; |
| 495 | if (iconStyleIndex < 0 || iconStyleIndex >= paths.length) return this; |
| 496 | return withIcon(paths[iconStyleIndex]); |
| 497 | } |
| 498 | |
| 499 | static Gradient gradientForStoredIndex( |
| 500 | int gradientIndex, |
| 501 | CryptoCurrency walletCurrency, |
| 502 | ) { |
| 503 | final n = CardDesign.allGradients.length; |
| 504 | final special = specialDesignsForCurrencies[walletCurrency]; |
| 505 | if (gradientIndex >= 0 && gradientIndex < n) { |
| 506 | return CardDesign.allGradients[gradientIndex]; |
| 507 | } |
| 508 | if (gradientIndex == n && special != null) { |
| 509 | return special.gradient; |
| 510 | } |
| 511 | return gradientBlue; |
| 512 | } |
| 513 | |
| 514 | static CardDesign fromStyleSettings( |
| 515 | BalanceCardStyleSettings? setting, CryptoCurrency walletCurrency) { |
| 516 | if (setting == null) { |
| 517 | return CardDesign.forCurrencySpecial(walletCurrency); |
| 518 | } |
| 519 | |
| 520 | if (setting.isGradientOnly) { |
| 521 | final gradient = gradientForStoredIndex(setting.gradientIndex, walletCurrency); |
| 522 | final textColors = preferredColorCombinations[gradient] ?? |
| 523 | specialDesignsForCurrencies[walletCurrency]?.colors ?? |
| 524 | gradientOnlyDesign.colors; |
| 525 | return gradientOnlyDesign.withGradientAndColorCombination(gradient, textColors); |
| 526 | } |
| 527 | |
| 528 | if (setting.backgroundImagePath.isNotEmpty) { |
| 529 | return CardDesign(imagePath: setting.backgroundImagePath); |
| 530 | } |
| 531 | |
| 532 | if (setting.useSpecialDesign && setting.gradientIndex != -1) { |
| 533 | return CardDesign.forCurrencySpecial(walletCurrency).withGradient( |
| 534 | gradientForStoredIndex(setting.gradientIndex, walletCurrency), |
| 535 | ); |
| 536 | } |
| 537 | |
| 538 | if (!setting.useSpecialDesign && setting.gradientIndex == -1) { |
| 539 | final specialColors = specialDesignsForCurrencies[walletCurrency] ?? genericDefault; |
| 540 | final design = CardDesign.forCurrencyIcon(walletCurrency) |
| 541 | .withGradientAndColorCombination(specialColors.gradient, specialColors.colors); |
| 542 | return design.withIconStyleIndex(setting.iconStyleIndex, walletCurrency); |
| 543 | } |
| 544 | if (setting.useSpecialDesign) { |
| 545 | return CardDesign.forCurrencySpecial(walletCurrency); |
| 546 | } |
| 547 | if (setting.gradientIndex != -1) { |
| 548 | final baseIcon = CardDesign.forCurrencyIcon(walletCurrency); |
| 549 | final gradient = gradientForStoredIndex(setting.gradientIndex, walletCurrency); |
| 550 | final textColors = preferredColorCombinations[gradient] ?? |
| 551 | specialDesignsForCurrencies[walletCurrency]?.colors ?? |
| 552 | baseIcon.colors; |
| 553 | return baseIcon |
| 554 | .withGradientAndColorCombination(gradient, textColors) |
| 555 | .withIconStyleIndex(setting.iconStyleIndex, walletCurrency); |
| 556 | } |
| 557 | printV("somehow, the user saved the design settings with literally no " |
| 558 | "customization?"); |
| 559 | return CardDesign.forCurrencySpecial(walletCurrency); |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | class _CurrencyIconNames { |
| 564 | final String ticker; |
| 565 | final String longName; |
| 566 | final String? outlineFile; |
| 567 | final String? chainFile; |
| 568 | final String? ogPath; |
| 569 | |
| 570 | const _CurrencyIconNames({ |
| 571 | required this.ticker, |
| 572 | required this.longName, |
| 573 | this.outlineFile, |
| 574 | this.chainFile, |
| 575 | this.ogPath, |
| 576 | }); |
| 577 | } |