| 1 | import 'package:cw_core/transaction_priority.dart'; |
| 2 | import 'package:flutter/foundation.dart'; |
| 3 | |
| 4 | class MoneroTransactionPriority extends TransactionPriority { |
| 5 | const MoneroTransactionPriority({required String title, required int raw}) |
| 6 | : super(title: title, raw: raw); |
| 7 | |
| 8 | static const all = [ |
| 9 | MoneroTransactionPriority.slow, |
| 10 | MoneroTransactionPriority.automatic, |
| 11 | MoneroTransactionPriority.medium, |
| 12 | MoneroTransactionPriority.fast, |
| 13 | MoneroTransactionPriority.fastest, |
| 14 | ]; |
| 15 | static const automatic = MoneroTransactionPriority(title: 'Automatic', raw: 0); |
| 16 | static const slow = MoneroTransactionPriority(title: 'Slow', raw: 1); |
| 17 | static const medium = MoneroTransactionPriority(title: 'Medium', raw: 2); |
| 18 | static const fast = MoneroTransactionPriority(title: 'Fast', raw: 3); |
| 19 | static const fastest = MoneroTransactionPriority(title: 'Fastest', raw: 4); |
| 20 | |
| 21 | static MoneroTransactionPriority deserialize({required int raw}) { |
| 22 | switch (raw) { |
| 23 | case 0: |
| 24 | return automatic; |
| 25 | case 1: |
| 26 | return slow; |
| 27 | case 2: |
| 28 | return medium; |
| 29 | case 3: |
| 30 | return fast; |
| 31 | case 4: |
| 32 | return fastest; |
| 33 | default: |
| 34 | if (kDebugMode) { |
| 35 | throw Exception('Unexpected token: $raw for MoneroTransactionPriority deserialize'); |
| 36 | } |
| 37 | return medium; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | @override |
| 42 | String toString() { |
| 43 | switch (this) { |
| 44 | case MoneroTransactionPriority.slow: |
| 45 | return 'Slow'; // S.current.transaction_priority_slow; |
| 46 | case MoneroTransactionPriority.automatic: |
| 47 | return 'Automatic'; // S.current.transaction_priority_regular; |
| 48 | case MoneroTransactionPriority.medium: |
| 49 | return 'Medium'; // S.current.transaction_priority_medium; |
| 50 | case MoneroTransactionPriority.fast: |
| 51 | return 'Fast'; // S.current.transaction_priority_fast; |
| 52 | case MoneroTransactionPriority.fastest: |
| 53 | return 'Fastest'; // S.current.transaction_priority_fastest; |
| 54 | default: |
| 55 | return ''; |
| 56 | } |
| 57 | } |
| 58 | } |