mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
simplify Currency class and fixed image loading issue
This commit is contained in:
parent
3d01ec8598
commit
18e089179b
9 changed files with 270 additions and 727 deletions
|
@ -1,4 +1,5 @@
|
|||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/isar/exchange_cache/pair.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
|
||||
part 'currency.g.dart';
|
||||
|
@ -33,12 +34,8 @@ class Currency {
|
|||
final bool isFiat;
|
||||
|
||||
/// Indicates if a currency is available on a fixed-rate flow
|
||||
@Index()
|
||||
final bool supportsFixedRate;
|
||||
|
||||
/// Indicates if a currency is available on a fixed-rate flow
|
||||
@Index()
|
||||
final bool supportsEstimatedRate;
|
||||
@enumerated
|
||||
final SupportedRateType rateType;
|
||||
|
||||
/// (Optional - based on api call) Indicates whether the pair is
|
||||
/// currently supported by change now
|
||||
|
@ -55,8 +52,7 @@ class Currency {
|
|||
required this.image,
|
||||
this.externalId,
|
||||
required this.isFiat,
|
||||
required this.supportsFixedRate,
|
||||
required this.supportsEstimatedRate,
|
||||
required this.rateType,
|
||||
this.isAvailable,
|
||||
required this.isStackCoin,
|
||||
});
|
||||
|
@ -64,6 +60,7 @@ class Currency {
|
|||
factory Currency.fromJson(
|
||||
Map<String, dynamic> json, {
|
||||
required String exchangeName,
|
||||
required SupportedRateType rateType,
|
||||
}) {
|
||||
try {
|
||||
final ticker = (json["ticker"] as String).toUpperCase();
|
||||
|
@ -76,8 +73,7 @@ class Currency {
|
|||
image: json["image"] as String,
|
||||
externalId: json["externalId"] as String?,
|
||||
isFiat: json["isFiat"] as bool,
|
||||
supportsFixedRate: json["supportsFixedRate"] as bool,
|
||||
supportsEstimatedRate: json["supportsEstimatedRate"] as bool,
|
||||
rateType: rateType,
|
||||
isAvailable: json["isAvailable"] as bool?,
|
||||
isStackCoin:
|
||||
json["isStackCoin"] as bool? ?? Currency.checkIsStackCoin(ticker),
|
||||
|
@ -97,8 +93,7 @@ class Currency {
|
|||
"image": image,
|
||||
"externalId": externalId,
|
||||
"isFiat": isFiat,
|
||||
"supportsFixedRate": supportsFixedRate,
|
||||
"supportsEstimatedRate": supportsEstimatedRate,
|
||||
"rateType": rateType,
|
||||
"isAvailable": isAvailable,
|
||||
"isStackCoin": isStackCoin,
|
||||
};
|
||||
|
@ -115,8 +110,7 @@ class Currency {
|
|||
String? image,
|
||||
String? externalId,
|
||||
bool? isFiat,
|
||||
bool? supportsFixedRate,
|
||||
bool? supportsEstimatedRate,
|
||||
SupportedRateType? rateType,
|
||||
bool? isAvailable,
|
||||
bool? isStackCoin,
|
||||
}) {
|
||||
|
@ -128,9 +122,7 @@ class Currency {
|
|||
image: image ?? this.image,
|
||||
externalId: externalId ?? this.externalId,
|
||||
isFiat: isFiat ?? this.isFiat,
|
||||
supportsFixedRate: supportsFixedRate ?? this.supportsFixedRate,
|
||||
supportsEstimatedRate:
|
||||
supportsEstimatedRate ?? this.supportsEstimatedRate,
|
||||
rateType: rateType ?? this.rateType,
|
||||
isAvailable: isAvailable ?? this.isAvailable,
|
||||
isStackCoin: isStackCoin ?? this.isStackCoin,
|
||||
)..id = id ?? this.id;
|
||||
|
|
|
@ -57,18 +57,14 @@ const CurrencySchema = CollectionSchema(
|
|||
name: r'network',
|
||||
type: IsarType.string,
|
||||
),
|
||||
r'supportsEstimatedRate': PropertySchema(
|
||||
r'rateType': PropertySchema(
|
||||
id: 8,
|
||||
name: r'supportsEstimatedRate',
|
||||
type: IsarType.bool,
|
||||
),
|
||||
r'supportsFixedRate': PropertySchema(
|
||||
id: 9,
|
||||
name: r'supportsFixedRate',
|
||||
type: IsarType.bool,
|
||||
name: r'rateType',
|
||||
type: IsarType.byte,
|
||||
enumMap: _CurrencyrateTypeEnumValueMap,
|
||||
),
|
||||
r'ticker': PropertySchema(
|
||||
id: 10,
|
||||
id: 9,
|
||||
name: r'ticker',
|
||||
type: IsarType.string,
|
||||
)
|
||||
|
@ -115,32 +111,6 @@ const CurrencySchema = CollectionSchema(
|
|||
)
|
||||
],
|
||||
),
|
||||
r'supportsFixedRate': IndexSchema(
|
||||
id: 444054599534256333,
|
||||
name: r'supportsFixedRate',
|
||||
unique: false,
|
||||
replace: false,
|
||||
properties: [
|
||||
IndexPropertySchema(
|
||||
name: r'supportsFixedRate',
|
||||
type: IndexType.value,
|
||||
caseSensitive: false,
|
||||
)
|
||||
],
|
||||
),
|
||||
r'supportsEstimatedRate': IndexSchema(
|
||||
id: 4184033449468624530,
|
||||
name: r'supportsEstimatedRate',
|
||||
unique: false,
|
||||
replace: false,
|
||||
properties: [
|
||||
IndexPropertySchema(
|
||||
name: r'supportsEstimatedRate',
|
||||
type: IndexType.value,
|
||||
caseSensitive: false,
|
||||
)
|
||||
],
|
||||
),
|
||||
r'isStackCoin': IndexSchema(
|
||||
id: 1994111521912746776,
|
||||
name: r'isStackCoin',
|
||||
|
@ -197,9 +167,8 @@ void _currencySerialize(
|
|||
writer.writeBool(offsets[5], object.isStackCoin);
|
||||
writer.writeString(offsets[6], object.name);
|
||||
writer.writeString(offsets[7], object.network);
|
||||
writer.writeBool(offsets[8], object.supportsEstimatedRate);
|
||||
writer.writeBool(offsets[9], object.supportsFixedRate);
|
||||
writer.writeString(offsets[10], object.ticker);
|
||||
writer.writeByte(offsets[8], object.rateType.index);
|
||||
writer.writeString(offsets[9], object.ticker);
|
||||
}
|
||||
|
||||
Currency _currencyDeserialize(
|
||||
|
@ -217,9 +186,10 @@ Currency _currencyDeserialize(
|
|||
isStackCoin: reader.readBool(offsets[5]),
|
||||
name: reader.readString(offsets[6]),
|
||||
network: reader.readString(offsets[7]),
|
||||
supportsEstimatedRate: reader.readBool(offsets[8]),
|
||||
supportsFixedRate: reader.readBool(offsets[9]),
|
||||
ticker: reader.readString(offsets[10]),
|
||||
rateType:
|
||||
_CurrencyrateTypeValueEnumMap[reader.readByteOrNull(offsets[8])] ??
|
||||
SupportedRateType.fixed,
|
||||
ticker: reader.readString(offsets[9]),
|
||||
);
|
||||
object.id = id;
|
||||
return object;
|
||||
|
@ -249,16 +219,26 @@ P _currencyDeserializeProp<P>(
|
|||
case 7:
|
||||
return (reader.readString(offset)) as P;
|
||||
case 8:
|
||||
return (reader.readBool(offset)) as P;
|
||||
return (_CurrencyrateTypeValueEnumMap[reader.readByteOrNull(offset)] ??
|
||||
SupportedRateType.fixed) as P;
|
||||
case 9:
|
||||
return (reader.readBool(offset)) as P;
|
||||
case 10:
|
||||
return (reader.readString(offset)) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
}
|
||||
}
|
||||
|
||||
const _CurrencyrateTypeEnumValueMap = {
|
||||
'fixed': 0,
|
||||
'estimated': 1,
|
||||
'both': 2,
|
||||
};
|
||||
const _CurrencyrateTypeValueEnumMap = {
|
||||
0: SupportedRateType.fixed,
|
||||
1: SupportedRateType.estimated,
|
||||
2: SupportedRateType.both,
|
||||
};
|
||||
|
||||
Id _currencyGetId(Currency object) {
|
||||
return object.id ?? Isar.autoIncrement;
|
||||
}
|
||||
|
@ -278,22 +258,6 @@ extension CurrencyQueryWhereSort on QueryBuilder<Currency, Currency, QWhere> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterWhere> anySupportsFixedRate() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
const IndexWhereClause.any(indexName: r'supportsFixedRate'),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterWhere> anySupportsEstimatedRate() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
const IndexWhereClause.any(indexName: r'supportsEstimatedRate'),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterWhere> anyIsStackCoin() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
|
@ -552,96 +516,6 @@ extension CurrencyQueryWhere on QueryBuilder<Currency, Currency, QWhereClause> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterWhereClause> supportsFixedRateEqualTo(
|
||||
bool supportsFixedRate) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(IndexWhereClause.equalTo(
|
||||
indexName: r'supportsFixedRate',
|
||||
value: [supportsFixedRate],
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterWhereClause>
|
||||
supportsFixedRateNotEqualTo(bool supportsFixedRate) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(IndexWhereClause.between(
|
||||
indexName: r'supportsFixedRate',
|
||||
lower: [],
|
||||
upper: [supportsFixedRate],
|
||||
includeUpper: false,
|
||||
))
|
||||
.addWhereClause(IndexWhereClause.between(
|
||||
indexName: r'supportsFixedRate',
|
||||
lower: [supportsFixedRate],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
));
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(IndexWhereClause.between(
|
||||
indexName: r'supportsFixedRate',
|
||||
lower: [supportsFixedRate],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
))
|
||||
.addWhereClause(IndexWhereClause.between(
|
||||
indexName: r'supportsFixedRate',
|
||||
lower: [],
|
||||
upper: [supportsFixedRate],
|
||||
includeUpper: false,
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterWhereClause>
|
||||
supportsEstimatedRateEqualTo(bool supportsEstimatedRate) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(IndexWhereClause.equalTo(
|
||||
indexName: r'supportsEstimatedRate',
|
||||
value: [supportsEstimatedRate],
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterWhereClause>
|
||||
supportsEstimatedRateNotEqualTo(bool supportsEstimatedRate) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(IndexWhereClause.between(
|
||||
indexName: r'supportsEstimatedRate',
|
||||
lower: [],
|
||||
upper: [supportsEstimatedRate],
|
||||
includeUpper: false,
|
||||
))
|
||||
.addWhereClause(IndexWhereClause.between(
|
||||
indexName: r'supportsEstimatedRate',
|
||||
lower: [supportsEstimatedRate],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
));
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(IndexWhereClause.between(
|
||||
indexName: r'supportsEstimatedRate',
|
||||
lower: [supportsEstimatedRate],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
))
|
||||
.addWhereClause(IndexWhereClause.between(
|
||||
indexName: r'supportsEstimatedRate',
|
||||
lower: [],
|
||||
upper: [supportsEstimatedRate],
|
||||
includeUpper: false,
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterWhereClause> isStackCoinEqualTo(
|
||||
bool isStackCoin) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
|
@ -1477,26 +1351,59 @@ extension CurrencyQueryFilter
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterFilterCondition>
|
||||
supportsEstimatedRateEqualTo(bool value) {
|
||||
QueryBuilder<Currency, Currency, QAfterFilterCondition> rateTypeEqualTo(
|
||||
SupportedRateType value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'supportsEstimatedRate',
|
||||
property: r'rateType',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterFilterCondition>
|
||||
supportsFixedRateEqualTo(bool value) {
|
||||
QueryBuilder<Currency, Currency, QAfterFilterCondition> rateTypeGreaterThan(
|
||||
SupportedRateType value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'supportsFixedRate',
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'rateType',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterFilterCondition> rateTypeLessThan(
|
||||
SupportedRateType value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'rateType',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterFilterCondition> rateTypeBetween(
|
||||
SupportedRateType lower,
|
||||
SupportedRateType upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.between(
|
||||
property: r'rateType',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterFilterCondition> tickerEqualTo(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
|
@ -1731,28 +1638,15 @@ extension CurrencyQuerySortBy on QueryBuilder<Currency, Currency, QSortBy> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterSortBy> sortBySupportsEstimatedRate() {
|
||||
QueryBuilder<Currency, Currency, QAfterSortBy> sortByRateType() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'supportsEstimatedRate', Sort.asc);
|
||||
return query.addSortBy(r'rateType', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterSortBy>
|
||||
sortBySupportsEstimatedRateDesc() {
|
||||
QueryBuilder<Currency, Currency, QAfterSortBy> sortByRateTypeDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'supportsEstimatedRate', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterSortBy> sortBySupportsFixedRate() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'supportsFixedRate', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterSortBy> sortBySupportsFixedRateDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'supportsFixedRate', Sort.desc);
|
||||
return query.addSortBy(r'rateType', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1879,28 +1773,15 @@ extension CurrencyQuerySortThenBy
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterSortBy> thenBySupportsEstimatedRate() {
|
||||
QueryBuilder<Currency, Currency, QAfterSortBy> thenByRateType() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'supportsEstimatedRate', Sort.asc);
|
||||
return query.addSortBy(r'rateType', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterSortBy>
|
||||
thenBySupportsEstimatedRateDesc() {
|
||||
QueryBuilder<Currency, Currency, QAfterSortBy> thenByRateTypeDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'supportsEstimatedRate', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterSortBy> thenBySupportsFixedRate() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'supportsFixedRate', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QAfterSortBy> thenBySupportsFixedRateDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'supportsFixedRate', Sort.desc);
|
||||
return query.addSortBy(r'rateType', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1972,16 +1853,9 @@ extension CurrencyQueryWhereDistinct
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QDistinct>
|
||||
distinctBySupportsEstimatedRate() {
|
||||
QueryBuilder<Currency, Currency, QDistinct> distinctByRateType() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'supportsEstimatedRate');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, Currency, QDistinct> distinctBySupportsFixedRate() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'supportsFixedRate');
|
||||
return query.addDistinctBy(r'rateType');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2049,16 +1923,10 @@ extension CurrencyQueryProperty
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, bool, QQueryOperations>
|
||||
supportsEstimatedRateProperty() {
|
||||
QueryBuilder<Currency, SupportedRateType, QQueryOperations>
|
||||
rateTypeProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'supportsEstimatedRate');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Currency, bool, QQueryOperations> supportsFixedRateProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'supportsFixedRate');
|
||||
return query.addPropertyName(r'rateType');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -22,39 +22,25 @@ const PairSchema = CollectionSchema(
|
|||
name: r'exchangeName',
|
||||
type: IsarType.string,
|
||||
),
|
||||
r'fixedRate': PropertySchema(
|
||||
id: 1,
|
||||
name: r'fixedRate',
|
||||
type: IsarType.bool,
|
||||
),
|
||||
r'floatingRate': PropertySchema(
|
||||
id: 2,
|
||||
name: r'floatingRate',
|
||||
type: IsarType.bool,
|
||||
),
|
||||
r'from': PropertySchema(
|
||||
id: 3,
|
||||
id: 1,
|
||||
name: r'from',
|
||||
type: IsarType.string,
|
||||
),
|
||||
r'fromNetwork': PropertySchema(
|
||||
id: 4,
|
||||
name: r'fromNetwork',
|
||||
type: IsarType.string,
|
||||
),
|
||||
r'hashCode': PropertySchema(
|
||||
id: 5,
|
||||
id: 2,
|
||||
name: r'hashCode',
|
||||
type: IsarType.long,
|
||||
),
|
||||
r'to': PropertySchema(
|
||||
id: 6,
|
||||
name: r'to',
|
||||
type: IsarType.string,
|
||||
r'rateType': PropertySchema(
|
||||
id: 3,
|
||||
name: r'rateType',
|
||||
type: IsarType.byte,
|
||||
enumMap: _PairrateTypeEnumValueMap,
|
||||
),
|
||||
r'toNetwork': PropertySchema(
|
||||
id: 7,
|
||||
name: r'toNetwork',
|
||||
r'to': PropertySchema(
|
||||
id: 4,
|
||||
name: r'to',
|
||||
type: IsarType.string,
|
||||
)
|
||||
},
|
||||
|
@ -117,9 +103,7 @@ int _pairEstimateSize(
|
|||
var bytesCount = offsets.last;
|
||||
bytesCount += 3 + object.exchangeName.length * 3;
|
||||
bytesCount += 3 + object.from.length * 3;
|
||||
bytesCount += 3 + object.fromNetwork.length * 3;
|
||||
bytesCount += 3 + object.to.length * 3;
|
||||
bytesCount += 3 + object.toNetwork.length * 3;
|
||||
return bytesCount;
|
||||
}
|
||||
|
||||
|
@ -130,13 +114,10 @@ void _pairSerialize(
|
|||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
writer.writeString(offsets[0], object.exchangeName);
|
||||
writer.writeBool(offsets[1], object.fixedRate);
|
||||
writer.writeBool(offsets[2], object.floatingRate);
|
||||
writer.writeString(offsets[3], object.from);
|
||||
writer.writeString(offsets[4], object.fromNetwork);
|
||||
writer.writeLong(offsets[5], object.hashCode);
|
||||
writer.writeString(offsets[6], object.to);
|
||||
writer.writeString(offsets[7], object.toNetwork);
|
||||
writer.writeString(offsets[1], object.from);
|
||||
writer.writeLong(offsets[2], object.hashCode);
|
||||
writer.writeByte(offsets[3], object.rateType.index);
|
||||
writer.writeString(offsets[4], object.to);
|
||||
}
|
||||
|
||||
Pair _pairDeserialize(
|
||||
|
@ -147,12 +128,10 @@ Pair _pairDeserialize(
|
|||
) {
|
||||
final object = Pair(
|
||||
exchangeName: reader.readString(offsets[0]),
|
||||
fixedRate: reader.readBool(offsets[1]),
|
||||
floatingRate: reader.readBool(offsets[2]),
|
||||
from: reader.readString(offsets[3]),
|
||||
fromNetwork: reader.readString(offsets[4]),
|
||||
to: reader.readString(offsets[6]),
|
||||
toNetwork: reader.readString(offsets[7]),
|
||||
from: reader.readString(offsets[1]),
|
||||
rateType: _PairrateTypeValueEnumMap[reader.readByteOrNull(offsets[3])] ??
|
||||
SupportedRateType.fixed,
|
||||
to: reader.readString(offsets[4]),
|
||||
);
|
||||
object.id = id;
|
||||
return object;
|
||||
|
@ -168,24 +147,30 @@ P _pairDeserializeProp<P>(
|
|||
case 0:
|
||||
return (reader.readString(offset)) as P;
|
||||
case 1:
|
||||
return (reader.readBool(offset)) as P;
|
||||
return (reader.readString(offset)) as P;
|
||||
case 2:
|
||||
return (reader.readBool(offset)) as P;
|
||||
case 3:
|
||||
return (reader.readString(offset)) as P;
|
||||
case 4:
|
||||
return (reader.readString(offset)) as P;
|
||||
case 5:
|
||||
return (reader.readLong(offset)) as P;
|
||||
case 6:
|
||||
return (reader.readString(offset)) as P;
|
||||
case 7:
|
||||
case 3:
|
||||
return (_PairrateTypeValueEnumMap[reader.readByteOrNull(offset)] ??
|
||||
SupportedRateType.fixed) as P;
|
||||
case 4:
|
||||
return (reader.readString(offset)) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
}
|
||||
}
|
||||
|
||||
const _PairrateTypeEnumValueMap = {
|
||||
'fixed': 0,
|
||||
'estimated': 1,
|
||||
'both': 2,
|
||||
};
|
||||
const _PairrateTypeValueEnumMap = {
|
||||
0: SupportedRateType.fixed,
|
||||
1: SupportedRateType.estimated,
|
||||
2: SupportedRateType.both,
|
||||
};
|
||||
|
||||
Id _pairGetId(Pair object) {
|
||||
return object.id ?? Isar.autoIncrement;
|
||||
}
|
||||
|
@ -585,25 +570,6 @@ extension PairQueryFilter on QueryBuilder<Pair, Pair, QFilterCondition> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> fixedRateEqualTo(bool value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'fixedRate',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> floatingRateEqualTo(
|
||||
bool value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'floatingRate',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> fromEqualTo(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
|
@ -732,136 +698,6 @@ extension PairQueryFilter on QueryBuilder<Pair, Pair, QFilterCondition> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> fromNetworkEqualTo(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'fromNetwork',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> fromNetworkGreaterThan(
|
||||
String value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'fromNetwork',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> fromNetworkLessThan(
|
||||
String value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'fromNetwork',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> fromNetworkBetween(
|
||||
String lower,
|
||||
String upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.between(
|
||||
property: r'fromNetwork',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> fromNetworkStartsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.startsWith(
|
||||
property: r'fromNetwork',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> fromNetworkEndsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.endsWith(
|
||||
property: r'fromNetwork',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> fromNetworkContains(
|
||||
String value,
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.contains(
|
||||
property: r'fromNetwork',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> fromNetworkMatches(
|
||||
String pattern,
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.matches(
|
||||
property: r'fromNetwork',
|
||||
wildcard: pattern,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> fromNetworkIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'fromNetwork',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> fromNetworkIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
property: r'fromNetwork',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> hashCodeEqualTo(int value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
|
@ -982,6 +818,59 @@ extension PairQueryFilter on QueryBuilder<Pair, Pair, QFilterCondition> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> rateTypeEqualTo(
|
||||
SupportedRateType value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'rateType',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> rateTypeGreaterThan(
|
||||
SupportedRateType value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'rateType',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> rateTypeLessThan(
|
||||
SupportedRateType value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'rateType',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> rateTypeBetween(
|
||||
SupportedRateType lower,
|
||||
SupportedRateType upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.between(
|
||||
property: r'rateType',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> toEqualTo(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
|
@ -1109,136 +998,6 @@ extension PairQueryFilter on QueryBuilder<Pair, Pair, QFilterCondition> {
|
|||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> toNetworkEqualTo(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'toNetwork',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> toNetworkGreaterThan(
|
||||
String value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'toNetwork',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> toNetworkLessThan(
|
||||
String value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'toNetwork',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> toNetworkBetween(
|
||||
String lower,
|
||||
String upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.between(
|
||||
property: r'toNetwork',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> toNetworkStartsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.startsWith(
|
||||
property: r'toNetwork',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> toNetworkEndsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.endsWith(
|
||||
property: r'toNetwork',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> toNetworkContains(
|
||||
String value,
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.contains(
|
||||
property: r'toNetwork',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> toNetworkMatches(
|
||||
String pattern,
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.matches(
|
||||
property: r'toNetwork',
|
||||
wildcard: pattern,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> toNetworkIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'toNetwork',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterFilterCondition> toNetworkIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
property: r'toNetwork',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension PairQueryObject on QueryBuilder<Pair, Pair, QFilterCondition> {}
|
||||
|
@ -1258,30 +1017,6 @@ extension PairQuerySortBy on QueryBuilder<Pair, Pair, QSortBy> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> sortByFixedRate() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'fixedRate', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> sortByFixedRateDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'fixedRate', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> sortByFloatingRate() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'floatingRate', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> sortByFloatingRateDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'floatingRate', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> sortByFrom() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'from', Sort.asc);
|
||||
|
@ -1294,18 +1029,6 @@ extension PairQuerySortBy on QueryBuilder<Pair, Pair, QSortBy> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> sortByFromNetwork() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'fromNetwork', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> sortByFromNetworkDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'fromNetwork', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> sortByHashCode() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'hashCode', Sort.asc);
|
||||
|
@ -1318,6 +1041,18 @@ extension PairQuerySortBy on QueryBuilder<Pair, Pair, QSortBy> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> sortByRateType() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'rateType', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> sortByRateTypeDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'rateType', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> sortByTo() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'to', Sort.asc);
|
||||
|
@ -1329,18 +1064,6 @@ extension PairQuerySortBy on QueryBuilder<Pair, Pair, QSortBy> {
|
|||
return query.addSortBy(r'to', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> sortByToNetwork() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'toNetwork', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> sortByToNetworkDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'toNetwork', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension PairQuerySortThenBy on QueryBuilder<Pair, Pair, QSortThenBy> {
|
||||
|
@ -1356,30 +1079,6 @@ extension PairQuerySortThenBy on QueryBuilder<Pair, Pair, QSortThenBy> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> thenByFixedRate() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'fixedRate', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> thenByFixedRateDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'fixedRate', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> thenByFloatingRate() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'floatingRate', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> thenByFloatingRateDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'floatingRate', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> thenByFrom() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'from', Sort.asc);
|
||||
|
@ -1392,18 +1091,6 @@ extension PairQuerySortThenBy on QueryBuilder<Pair, Pair, QSortThenBy> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> thenByFromNetwork() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'fromNetwork', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> thenByFromNetworkDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'fromNetwork', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> thenByHashCode() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'hashCode', Sort.asc);
|
||||
|
@ -1428,6 +1115,18 @@ extension PairQuerySortThenBy on QueryBuilder<Pair, Pair, QSortThenBy> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> thenByRateType() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'rateType', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> thenByRateTypeDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'rateType', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> thenByTo() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'to', Sort.asc);
|
||||
|
@ -1439,18 +1138,6 @@ extension PairQuerySortThenBy on QueryBuilder<Pair, Pair, QSortThenBy> {
|
|||
return query.addSortBy(r'to', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> thenByToNetwork() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'toNetwork', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QAfterSortBy> thenByToNetworkDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'toNetwork', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension PairQueryWhereDistinct on QueryBuilder<Pair, Pair, QDistinct> {
|
||||
|
@ -1461,18 +1148,6 @@ extension PairQueryWhereDistinct on QueryBuilder<Pair, Pair, QDistinct> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QDistinct> distinctByFixedRate() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'fixedRate');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QDistinct> distinctByFloatingRate() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'floatingRate');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QDistinct> distinctByFrom(
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
|
@ -1480,32 +1155,24 @@ extension PairQueryWhereDistinct on QueryBuilder<Pair, Pair, QDistinct> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QDistinct> distinctByFromNetwork(
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'fromNetwork', caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QDistinct> distinctByHashCode() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'hashCode');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QDistinct> distinctByRateType() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'rateType');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QDistinct> distinctByTo(
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'to', caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, Pair, QDistinct> distinctByToNetwork(
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'toNetwork', caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension PairQueryProperty on QueryBuilder<Pair, Pair, QQueryProperty> {
|
||||
|
@ -1521,45 +1188,27 @@ extension PairQueryProperty on QueryBuilder<Pair, Pair, QQueryProperty> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, bool, QQueryOperations> fixedRateProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'fixedRate');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, bool, QQueryOperations> floatingRateProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'floatingRate');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, String, QQueryOperations> fromProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'from');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, String, QQueryOperations> fromNetworkProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'fromNetwork');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, int, QQueryOperations> hashCodeProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'hashCode');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, SupportedRateType, QQueryOperations> rateTypeProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'rateType');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, String, QQueryOperations> toProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'to');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Pair, String, QQueryOperations> toNetworkProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'toNetwork');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/isar/exchange_cache/currency.dart';
|
||||
import 'package:stackwallet/models/isar/exchange_cache/pair.dart';
|
||||
import 'package:stackwallet/pages/buy_view/sub_widgets/crypto_selection_view.dart';
|
||||
import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
|
@ -53,8 +54,14 @@ class _ExchangeCurrencySelectionViewState
|
|||
.exchangeNameEqualTo(widget.exchangeName)
|
||||
.filter()
|
||||
.group((q) => widget.isFixedRate
|
||||
? q.supportsFixedRateEqualTo(true)
|
||||
: q.supportsEstimatedRateEqualTo(true))
|
||||
? q
|
||||
.rateTypeEqualTo(SupportedRateType.both)
|
||||
.or()
|
||||
.rateTypeEqualTo(SupportedRateType.fixed)
|
||||
: q
|
||||
.rateTypeEqualTo(SupportedRateType.both)
|
||||
.or()
|
||||
.rateTypeEqualTo(SupportedRateType.estimated))
|
||||
.and()
|
||||
.group((q) => q
|
||||
.nameContains(text, caseSensitive: false)
|
||||
|
@ -84,8 +91,14 @@ class _ExchangeCurrencySelectionViewState
|
|||
.exchangeNameEqualTo(widget.exchangeName)
|
||||
.filter()
|
||||
.group((q) => widget.isFixedRate
|
||||
? q.supportsFixedRateEqualTo(true)
|
||||
: q.supportsEstimatedRateEqualTo(true));
|
||||
? q
|
||||
.rateTypeEqualTo(SupportedRateType.both)
|
||||
.or()
|
||||
.rateTypeEqualTo(SupportedRateType.fixed)
|
||||
: q
|
||||
.rateTypeEqualTo(SupportedRateType.both)
|
||||
.or()
|
||||
.rateTypeEqualTo(SupportedRateType.estimated));
|
||||
|
||||
if (widget.paired != null) {
|
||||
_currencies = query
|
||||
|
@ -236,6 +249,8 @@ class _ExchangeCurrencySelectionViewState
|
|||
primary: isDesktop ? false : null,
|
||||
itemCount: items.length,
|
||||
itemBuilder: (builderContext, index) {
|
||||
final bool hasImageUrl =
|
||||
items[index].image.startsWith("http");
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: GestureDetector(
|
||||
|
@ -253,13 +268,18 @@ class _ExchangeCurrencySelectionViewState
|
|||
items[index].ticker,
|
||||
size: 24,
|
||||
)
|
||||
: SvgPicture.network(
|
||||
items[index].image,
|
||||
width: 24,
|
||||
height: 24,
|
||||
placeholderBuilder: (_) =>
|
||||
const LoadingIndicator(),
|
||||
),
|
||||
: hasImageUrl
|
||||
? SvgPicture.network(
|
||||
items[index].image,
|
||||
width: 24,
|
||||
height: 24,
|
||||
placeholderBuilder: (_) =>
|
||||
const LoadingIndicator(),
|
||||
)
|
||||
: const SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
|
@ -315,6 +335,8 @@ class _ExchangeCurrencySelectionViewState
|
|||
primary: isDesktop ? false : null,
|
||||
itemCount: _currencies.length,
|
||||
itemBuilder: (builderContext, index) {
|
||||
final bool hasImageUrl =
|
||||
_currencies[index].image.startsWith("http");
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: GestureDetector(
|
||||
|
@ -332,13 +354,18 @@ class _ExchangeCurrencySelectionViewState
|
|||
_currencies[index].ticker,
|
||||
size: 24,
|
||||
)
|
||||
: SvgPicture.network(
|
||||
_currencies[index].image,
|
||||
width: 24,
|
||||
height: 24,
|
||||
placeholderBuilder: (_) =>
|
||||
const LoadingIndicator(),
|
||||
),
|
||||
: hasImageUrl
|
||||
? SvgPicture.network(
|
||||
_currencies[index].image,
|
||||
width: 24,
|
||||
height: 24,
|
||||
placeholderBuilder: (_) =>
|
||||
const LoadingIndicator(),
|
||||
)
|
||||
: const SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
|
|
|
@ -535,7 +535,10 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
|||
.where()
|
||||
.exchangeNameEqualTo(exchangeName)
|
||||
.filter()
|
||||
.floatingRateEqualTo(true)
|
||||
.group((q) => q
|
||||
.rateTypeEqualTo(SupportedRateType.estimated)
|
||||
.or()
|
||||
.rateTypeEqualTo(SupportedRateType.both))
|
||||
.and()
|
||||
.fromEqualTo(fromTicker, caseSensitive: false)
|
||||
.and()
|
||||
|
|
|
@ -164,10 +164,12 @@ class ChangeNowAPI {
|
|||
for (final json in args.item1) {
|
||||
try {
|
||||
final map = Map<String, dynamic>.from(json as Map);
|
||||
map["supportsEstimatedRate"] = !args.item2;
|
||||
currencies.add(
|
||||
Currency.fromJson(
|
||||
map,
|
||||
rateType: (map["supportsFixedRate"] as bool)
|
||||
? SupportedRateType.both
|
||||
: SupportedRateType.estimated,
|
||||
exchangeName: ChangeNowExchange.exchangeName,
|
||||
),
|
||||
);
|
||||
|
@ -211,10 +213,12 @@ class ChangeNowAPI {
|
|||
for (final json in jsonArray) {
|
||||
try {
|
||||
final map = Map<String, dynamic>.from(json as Map);
|
||||
map["supportsEstimatedRate"] = !(fixedRate == true);
|
||||
currencies.add(
|
||||
Currency.fromJson(
|
||||
map,
|
||||
rateType: (map["supportsFixedRate"] as bool)
|
||||
? SupportedRateType.both
|
||||
: SupportedRateType.estimated,
|
||||
exchangeName: ChangeNowExchange.exchangeName,
|
||||
),
|
||||
);
|
||||
|
|
|
@ -90,7 +90,7 @@ class ExchangeDataLoadingService {
|
|||
.where()
|
||||
.exchangeNameEqualTo(ChangeNowExchange.exchangeName)
|
||||
.filter()
|
||||
.fixedRateEqualTo(true)
|
||||
.rateTypeEqualTo(SupportedRateType.fixed)
|
||||
.idProperty()
|
||||
.findAll();
|
||||
await isar.pairs.deleteAll(idsToDelete2);
|
||||
|
@ -115,7 +115,7 @@ class ExchangeDataLoadingService {
|
|||
.where()
|
||||
.exchangeNameEqualTo(ChangeNowExchange.exchangeName)
|
||||
.filter()
|
||||
.floatingRateEqualTo(true)
|
||||
.rateTypeEqualTo(SupportedRateType.estimated)
|
||||
.idProperty()
|
||||
.findAll();
|
||||
await isar.pairs.deleteAll(idsToDelete);
|
||||
|
|
|
@ -114,8 +114,7 @@ class MajesticBankExchange extends Exchange {
|
|||
network: "",
|
||||
image: "",
|
||||
isFiat: false,
|
||||
supportsFixedRate: true,
|
||||
supportsEstimatedRate: true,
|
||||
rateType: SupportedRateType.both,
|
||||
isAvailable: true,
|
||||
isStackCoin: Currency.checkIsStackCoin(limit.currency),
|
||||
);
|
||||
|
|
|
@ -62,8 +62,9 @@ class SimpleSwapExchange extends Exchange {
|
|||
image: e.image,
|
||||
externalId: e.extraId,
|
||||
isFiat: false,
|
||||
supportsFixedRate: fixedRate,
|
||||
supportsEstimatedRate: true,
|
||||
rateType: fixedRate
|
||||
? SupportedRateType.both
|
||||
: SupportedRateType.estimated,
|
||||
isAvailable: true,
|
||||
isStackCoin: Currency.checkIsStackCoin(e.symbol),
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue