| 1 | import 'package:cw_core/enumerable_item.dart'; |
| 2 | |
| 3 | class BitcoinAmountDisplayMode extends EnumerableItem<int> with Serializable<int> { |
| 4 | const BitcoinAmountDisplayMode({required String title, required int raw}) |
| 5 | : super(title: title, raw: raw); |
| 6 | |
| 7 | static const all = [ |
| 8 | BitcoinAmountDisplayMode.satoshi, |
| 9 | BitcoinAmountDisplayMode.satoshiForLightning, |
| 10 | BitcoinAmountDisplayMode.bitcoin, |
| 11 | ]; |
| 12 | static const satoshiForLightning = BitcoinAmountDisplayMode(raw: 0, title: 'sats (LN)'); |
| 13 | static const bitcoin = BitcoinAmountDisplayMode(raw: 1, title: 'BTC'); |
| 14 | static const satoshi = BitcoinAmountDisplayMode(raw: 2, title: 'sats'); |
| 15 | |
| 16 | static BitcoinAmountDisplayMode deserialize({required int raw}) { |
| 17 | switch (raw) { |
| 18 | case 0: |
| 19 | return satoshiForLightning; |
| 20 | case 1: |
| 21 | return bitcoin; |
| 22 | case 2: |
| 23 | return satoshi; |
| 24 | default: |
| 25 | throw Exception('Unexpected token: $raw for BalanceDisplayMode deserialize'); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | @override |
| 30 | String toString() => title; |
| 31 | } |