2020-01-04 19:31:52 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/entities/enumerable_item.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
class TradeState extends EnumerableItem<String> with Serializable<String> {
|
2020-01-08 12:26:34 +00:00
|
|
|
const TradeState({@required String raw, @required String title})
|
|
|
|
: super(raw: raw, title: title);
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool operator ==(Object other) => other is TradeState && other.raw == raw;
|
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
static const pending = TradeState(raw: 'pending', title: 'Pending');
|
|
|
|
static const confirming = TradeState(raw: 'confirming', title: 'Confirming');
|
|
|
|
static const trading = TradeState(raw: 'trading', title: 'Trading');
|
|
|
|
static const traded = TradeState(raw: 'traded', title: 'Traded');
|
|
|
|
static const complete = TradeState(raw: 'complete', title: 'Complete');
|
|
|
|
static const toBeCreated =
|
|
|
|
TradeState(raw: 'TO_BE_CREATED', title: 'To be created');
|
|
|
|
static const unpaid = TradeState(raw: 'UNPAID', title: 'Unpaid');
|
|
|
|
static const underpaid = TradeState(raw: 'UNDERPAID', title: 'Underpaid');
|
|
|
|
static const paidUnconfirmed =
|
|
|
|
TradeState(raw: 'PAID_UNCONFIRMED', title: 'Paid unconfirmed');
|
|
|
|
static const paid = TradeState(raw: 'PAID', title: 'Paid');
|
|
|
|
static const btcSent = TradeState(raw: 'BTC_SENT', title: 'Btc sent');
|
|
|
|
static const timeout = TradeState(raw: 'TIMED_OUT', title: 'Timeout');
|
|
|
|
static const notFound = TradeState(raw: 'NOT_FOUND', title: 'Not found');
|
|
|
|
static const created = TradeState(raw: 'created', title: 'Created');
|
|
|
|
static const finished = TradeState(raw: 'finished', title: 'Finished');
|
|
|
|
static const waiting = TradeState(raw: 'waiting', title: 'Waiting');
|
2020-02-07 11:07:58 +00:00
|
|
|
static const processing = TradeState(raw: 'processing', title: 'Processing');
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
static TradeState deserialize({String raw}) {
|
|
|
|
switch (raw) {
|
|
|
|
case 'pending':
|
|
|
|
return pending;
|
|
|
|
case 'confirming':
|
|
|
|
return confirming;
|
|
|
|
case 'trading':
|
|
|
|
return trading;
|
|
|
|
case 'traded':
|
|
|
|
return traded;
|
|
|
|
case 'complete':
|
|
|
|
return complete;
|
|
|
|
case 'TO_BE_CREATED':
|
|
|
|
return toBeCreated;
|
|
|
|
case 'UNPAID':
|
|
|
|
return unpaid;
|
|
|
|
case 'UNDERPAID':
|
|
|
|
return underpaid;
|
|
|
|
case 'PAID_UNCONFIRMED':
|
|
|
|
return paidUnconfirmed;
|
|
|
|
case 'PAID':
|
|
|
|
return paid;
|
|
|
|
case 'BTC_SENT':
|
|
|
|
return btcSent;
|
|
|
|
case 'TIMED_OUT':
|
|
|
|
return timeout;
|
|
|
|
case 'created':
|
|
|
|
return created;
|
|
|
|
case 'finished':
|
|
|
|
return finished;
|
|
|
|
case 'waiting':
|
|
|
|
return waiting;
|
2020-02-07 11:07:58 +00:00
|
|
|
case 'processing':
|
|
|
|
return processing;
|
2020-01-04 19:31:52 +00:00
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
int get hashCode => raw.hashCode ^ title.hashCode;
|
|
|
|
}
|