cake_wallet/lib/entities/action_list_display_mode.dart

33 lines
666 B
Dart
Raw Normal View History

2020-01-04 19:31:52 +00:00
enum ActionListDisplayMode { transactions, trades }
int serializeActionlistDisplayModes(List<ActionListDisplayMode> modes) {
var i = 0;
for (final mode in modes) {
switch (mode) {
case ActionListDisplayMode.trades:
i += 1;
break;
case ActionListDisplayMode.transactions:
i += 10;
break;
}
}
return i;
}
List<ActionListDisplayMode> deserializeActionlistDisplayModes(int raw) {
2020-01-08 12:26:34 +00:00
final modes = List<ActionListDisplayMode>();
2020-01-04 19:31:52 +00:00
if (raw == 1 || raw - 10 == 1) {
modes.add(ActionListDisplayMode.trades);
}
if (raw >= 10) {
modes.add(ActionListDisplayMode.transactions);
}
return modes;
}