simplify Currency class and fixed image loading issue

This commit is contained in:
julian 2023-02-06 09:23:31 -06:00
parent 3d01ec8598
commit 18e089179b
9 changed files with 270 additions and 727 deletions

View file

@ -1,4 +1,5 @@
import 'package:isar/isar.dart'; import 'package:isar/isar.dart';
import 'package:stackwallet/models/isar/exchange_cache/pair.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
part 'currency.g.dart'; part 'currency.g.dart';
@ -33,12 +34,8 @@ class Currency {
final bool isFiat; final bool isFiat;
/// Indicates if a currency is available on a fixed-rate flow /// Indicates if a currency is available on a fixed-rate flow
@Index() @enumerated
final bool supportsFixedRate; final SupportedRateType rateType;
/// Indicates if a currency is available on a fixed-rate flow
@Index()
final bool supportsEstimatedRate;
/// (Optional - based on api call) Indicates whether the pair is /// (Optional - based on api call) Indicates whether the pair is
/// currently supported by change now /// currently supported by change now
@ -55,8 +52,7 @@ class Currency {
required this.image, required this.image,
this.externalId, this.externalId,
required this.isFiat, required this.isFiat,
required this.supportsFixedRate, required this.rateType,
required this.supportsEstimatedRate,
this.isAvailable, this.isAvailable,
required this.isStackCoin, required this.isStackCoin,
}); });
@ -64,6 +60,7 @@ class Currency {
factory Currency.fromJson( factory Currency.fromJson(
Map<String, dynamic> json, { Map<String, dynamic> json, {
required String exchangeName, required String exchangeName,
required SupportedRateType rateType,
}) { }) {
try { try {
final ticker = (json["ticker"] as String).toUpperCase(); final ticker = (json["ticker"] as String).toUpperCase();
@ -76,8 +73,7 @@ class Currency {
image: json["image"] as String, image: json["image"] as String,
externalId: json["externalId"] as String?, externalId: json["externalId"] as String?,
isFiat: json["isFiat"] as bool, isFiat: json["isFiat"] as bool,
supportsFixedRate: json["supportsFixedRate"] as bool, rateType: rateType,
supportsEstimatedRate: json["supportsEstimatedRate"] as bool,
isAvailable: json["isAvailable"] as bool?, isAvailable: json["isAvailable"] as bool?,
isStackCoin: isStackCoin:
json["isStackCoin"] as bool? ?? Currency.checkIsStackCoin(ticker), json["isStackCoin"] as bool? ?? Currency.checkIsStackCoin(ticker),
@ -97,8 +93,7 @@ class Currency {
"image": image, "image": image,
"externalId": externalId, "externalId": externalId,
"isFiat": isFiat, "isFiat": isFiat,
"supportsFixedRate": supportsFixedRate, "rateType": rateType,
"supportsEstimatedRate": supportsEstimatedRate,
"isAvailable": isAvailable, "isAvailable": isAvailable,
"isStackCoin": isStackCoin, "isStackCoin": isStackCoin,
}; };
@ -115,8 +110,7 @@ class Currency {
String? image, String? image,
String? externalId, String? externalId,
bool? isFiat, bool? isFiat,
bool? supportsFixedRate, SupportedRateType? rateType,
bool? supportsEstimatedRate,
bool? isAvailable, bool? isAvailable,
bool? isStackCoin, bool? isStackCoin,
}) { }) {
@ -128,9 +122,7 @@ class Currency {
image: image ?? this.image, image: image ?? this.image,
externalId: externalId ?? this.externalId, externalId: externalId ?? this.externalId,
isFiat: isFiat ?? this.isFiat, isFiat: isFiat ?? this.isFiat,
supportsFixedRate: supportsFixedRate ?? this.supportsFixedRate, rateType: rateType ?? this.rateType,
supportsEstimatedRate:
supportsEstimatedRate ?? this.supportsEstimatedRate,
isAvailable: isAvailable ?? this.isAvailable, isAvailable: isAvailable ?? this.isAvailable,
isStackCoin: isStackCoin ?? this.isStackCoin, isStackCoin: isStackCoin ?? this.isStackCoin,
)..id = id ?? this.id; )..id = id ?? this.id;

View file

@ -57,18 +57,14 @@ const CurrencySchema = CollectionSchema(
name: r'network', name: r'network',
type: IsarType.string, type: IsarType.string,
), ),
r'supportsEstimatedRate': PropertySchema( r'rateType': PropertySchema(
id: 8, id: 8,
name: r'supportsEstimatedRate', name: r'rateType',
type: IsarType.bool, type: IsarType.byte,
), enumMap: _CurrencyrateTypeEnumValueMap,
r'supportsFixedRate': PropertySchema(
id: 9,
name: r'supportsFixedRate',
type: IsarType.bool,
), ),
r'ticker': PropertySchema( r'ticker': PropertySchema(
id: 10, id: 9,
name: r'ticker', name: r'ticker',
type: IsarType.string, 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( r'isStackCoin': IndexSchema(
id: 1994111521912746776, id: 1994111521912746776,
name: r'isStackCoin', name: r'isStackCoin',
@ -197,9 +167,8 @@ void _currencySerialize(
writer.writeBool(offsets[5], object.isStackCoin); writer.writeBool(offsets[5], object.isStackCoin);
writer.writeString(offsets[6], object.name); writer.writeString(offsets[6], object.name);
writer.writeString(offsets[7], object.network); writer.writeString(offsets[7], object.network);
writer.writeBool(offsets[8], object.supportsEstimatedRate); writer.writeByte(offsets[8], object.rateType.index);
writer.writeBool(offsets[9], object.supportsFixedRate); writer.writeString(offsets[9], object.ticker);
writer.writeString(offsets[10], object.ticker);
} }
Currency _currencyDeserialize( Currency _currencyDeserialize(
@ -217,9 +186,10 @@ Currency _currencyDeserialize(
isStackCoin: reader.readBool(offsets[5]), isStackCoin: reader.readBool(offsets[5]),
name: reader.readString(offsets[6]), name: reader.readString(offsets[6]),
network: reader.readString(offsets[7]), network: reader.readString(offsets[7]),
supportsEstimatedRate: reader.readBool(offsets[8]), rateType:
supportsFixedRate: reader.readBool(offsets[9]), _CurrencyrateTypeValueEnumMap[reader.readByteOrNull(offsets[8])] ??
ticker: reader.readString(offsets[10]), SupportedRateType.fixed,
ticker: reader.readString(offsets[9]),
); );
object.id = id; object.id = id;
return object; return object;
@ -249,16 +219,26 @@ P _currencyDeserializeProp<P>(
case 7: case 7:
return (reader.readString(offset)) as P; return (reader.readString(offset)) as P;
case 8: case 8:
return (reader.readBool(offset)) as P; return (_CurrencyrateTypeValueEnumMap[reader.readByteOrNull(offset)] ??
SupportedRateType.fixed) as P;
case 9: case 9:
return (reader.readBool(offset)) as P;
case 10:
return (reader.readString(offset)) as P; return (reader.readString(offset)) as P;
default: default:
throw IsarError('Unknown property with id $propertyId'); 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) { Id _currencyGetId(Currency object) {
return object.id ?? Isar.autoIncrement; 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() { QueryBuilder<Currency, Currency, QAfterWhere> anyIsStackCoin() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addWhereClause( 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( QueryBuilder<Currency, Currency, QAfterWhereClause> isStackCoinEqualTo(
bool isStackCoin) { bool isStackCoin) {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
@ -1477,26 +1351,59 @@ extension CurrencyQueryFilter
}); });
} }
QueryBuilder<Currency, Currency, QAfterFilterCondition> QueryBuilder<Currency, Currency, QAfterFilterCondition> rateTypeEqualTo(
supportsEstimatedRateEqualTo(bool value) { SupportedRateType value) {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo( return query.addFilterCondition(FilterCondition.equalTo(
property: r'supportsEstimatedRate', property: r'rateType',
value: value, value: value,
)); ));
}); });
} }
QueryBuilder<Currency, Currency, QAfterFilterCondition> QueryBuilder<Currency, Currency, QAfterFilterCondition> rateTypeGreaterThan(
supportsFixedRateEqualTo(bool value) { SupportedRateType value, {
bool include = false,
}) {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo( return query.addFilterCondition(FilterCondition.greaterThan(
property: r'supportsFixedRate', include: include,
property: r'rateType',
value: value, 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( QueryBuilder<Currency, Currency, QAfterFilterCondition> tickerEqualTo(
String value, { String value, {
bool caseSensitive = true, 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 QueryBuilder.apply(this, (query) {
return query.addSortBy(r'supportsEstimatedRate', Sort.asc); return query.addSortBy(r'rateType', Sort.asc);
}); });
} }
QueryBuilder<Currency, Currency, QAfterSortBy> QueryBuilder<Currency, Currency, QAfterSortBy> sortByRateTypeDesc() {
sortBySupportsEstimatedRateDesc() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'supportsEstimatedRate', Sort.desc); return query.addSortBy(r'rateType', 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);
}); });
} }
@ -1879,28 +1773,15 @@ extension CurrencyQuerySortThenBy
}); });
} }
QueryBuilder<Currency, Currency, QAfterSortBy> thenBySupportsEstimatedRate() { QueryBuilder<Currency, Currency, QAfterSortBy> thenByRateType() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'supportsEstimatedRate', Sort.asc); return query.addSortBy(r'rateType', Sort.asc);
}); });
} }
QueryBuilder<Currency, Currency, QAfterSortBy> QueryBuilder<Currency, Currency, QAfterSortBy> thenByRateTypeDesc() {
thenBySupportsEstimatedRateDesc() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'supportsEstimatedRate', Sort.desc); return query.addSortBy(r'rateType', 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);
}); });
} }
@ -1972,16 +1853,9 @@ extension CurrencyQueryWhereDistinct
}); });
} }
QueryBuilder<Currency, Currency, QDistinct> QueryBuilder<Currency, Currency, QDistinct> distinctByRateType() {
distinctBySupportsEstimatedRate() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(r'supportsEstimatedRate'); return query.addDistinctBy(r'rateType');
});
}
QueryBuilder<Currency, Currency, QDistinct> distinctBySupportsFixedRate() {
return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(r'supportsFixedRate');
}); });
} }
@ -2049,16 +1923,10 @@ extension CurrencyQueryProperty
}); });
} }
QueryBuilder<Currency, bool, QQueryOperations> QueryBuilder<Currency, SupportedRateType, QQueryOperations>
supportsEstimatedRateProperty() { rateTypeProperty() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'supportsEstimatedRate'); return query.addPropertyName(r'rateType');
});
}
QueryBuilder<Currency, bool, QQueryOperations> supportsFixedRateProperty() {
return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'supportsFixedRate');
}); });
} }

View file

@ -22,39 +22,25 @@ const PairSchema = CollectionSchema(
name: r'exchangeName', name: r'exchangeName',
type: IsarType.string, 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( r'from': PropertySchema(
id: 3, id: 1,
name: r'from', name: r'from',
type: IsarType.string, type: IsarType.string,
), ),
r'fromNetwork': PropertySchema(
id: 4,
name: r'fromNetwork',
type: IsarType.string,
),
r'hashCode': PropertySchema( r'hashCode': PropertySchema(
id: 5, id: 2,
name: r'hashCode', name: r'hashCode',
type: IsarType.long, type: IsarType.long,
), ),
r'to': PropertySchema( r'rateType': PropertySchema(
id: 6, id: 3,
name: r'to', name: r'rateType',
type: IsarType.string, type: IsarType.byte,
enumMap: _PairrateTypeEnumValueMap,
), ),
r'toNetwork': PropertySchema( r'to': PropertySchema(
id: 7, id: 4,
name: r'toNetwork', name: r'to',
type: IsarType.string, type: IsarType.string,
) )
}, },
@ -117,9 +103,7 @@ int _pairEstimateSize(
var bytesCount = offsets.last; var bytesCount = offsets.last;
bytesCount += 3 + object.exchangeName.length * 3; bytesCount += 3 + object.exchangeName.length * 3;
bytesCount += 3 + object.from.length * 3; bytesCount += 3 + object.from.length * 3;
bytesCount += 3 + object.fromNetwork.length * 3;
bytesCount += 3 + object.to.length * 3; bytesCount += 3 + object.to.length * 3;
bytesCount += 3 + object.toNetwork.length * 3;
return bytesCount; return bytesCount;
} }
@ -130,13 +114,10 @@ void _pairSerialize(
Map<Type, List<int>> allOffsets, Map<Type, List<int>> allOffsets,
) { ) {
writer.writeString(offsets[0], object.exchangeName); writer.writeString(offsets[0], object.exchangeName);
writer.writeBool(offsets[1], object.fixedRate); writer.writeString(offsets[1], object.from);
writer.writeBool(offsets[2], object.floatingRate); writer.writeLong(offsets[2], object.hashCode);
writer.writeString(offsets[3], object.from); writer.writeByte(offsets[3], object.rateType.index);
writer.writeString(offsets[4], object.fromNetwork); writer.writeString(offsets[4], object.to);
writer.writeLong(offsets[5], object.hashCode);
writer.writeString(offsets[6], object.to);
writer.writeString(offsets[7], object.toNetwork);
} }
Pair _pairDeserialize( Pair _pairDeserialize(
@ -147,12 +128,10 @@ Pair _pairDeserialize(
) { ) {
final object = Pair( final object = Pair(
exchangeName: reader.readString(offsets[0]), exchangeName: reader.readString(offsets[0]),
fixedRate: reader.readBool(offsets[1]), from: reader.readString(offsets[1]),
floatingRate: reader.readBool(offsets[2]), rateType: _PairrateTypeValueEnumMap[reader.readByteOrNull(offsets[3])] ??
from: reader.readString(offsets[3]), SupportedRateType.fixed,
fromNetwork: reader.readString(offsets[4]), to: reader.readString(offsets[4]),
to: reader.readString(offsets[6]),
toNetwork: reader.readString(offsets[7]),
); );
object.id = id; object.id = id;
return object; return object;
@ -168,24 +147,30 @@ P _pairDeserializeProp<P>(
case 0: case 0:
return (reader.readString(offset)) as P; return (reader.readString(offset)) as P;
case 1: case 1:
return (reader.readBool(offset)) as P; return (reader.readString(offset)) as P;
case 2: 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; return (reader.readLong(offset)) as P;
case 6: case 3:
return (reader.readString(offset)) as P; return (_PairrateTypeValueEnumMap[reader.readByteOrNull(offset)] ??
case 7: SupportedRateType.fixed) as P;
case 4:
return (reader.readString(offset)) as P; return (reader.readString(offset)) as P;
default: default:
throw IsarError('Unknown property with id $propertyId'); 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) { Id _pairGetId(Pair object) {
return object.id ?? Isar.autoIncrement; 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( QueryBuilder<Pair, Pair, QAfterFilterCondition> fromEqualTo(
String value, { String value, {
bool caseSensitive = true, 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) { QueryBuilder<Pair, Pair, QAfterFilterCondition> hashCodeEqualTo(int value) {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo( 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( QueryBuilder<Pair, Pair, QAfterFilterCondition> toEqualTo(
String value, { String value, {
bool caseSensitive = true, 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> {} 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() { QueryBuilder<Pair, Pair, QAfterSortBy> sortByFrom() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'from', Sort.asc); 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() { QueryBuilder<Pair, Pair, QAfterSortBy> sortByHashCode() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'hashCode', Sort.asc); 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() { QueryBuilder<Pair, Pair, QAfterSortBy> sortByTo() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'to', Sort.asc); 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); 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> { 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() { QueryBuilder<Pair, Pair, QAfterSortBy> thenByFrom() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'from', Sort.asc); 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() { QueryBuilder<Pair, Pair, QAfterSortBy> thenByHashCode() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'hashCode', Sort.asc); 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() { QueryBuilder<Pair, Pair, QAfterSortBy> thenByTo() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'to', Sort.asc); 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); 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> { 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( QueryBuilder<Pair, Pair, QDistinct> distinctByFrom(
{bool caseSensitive = true}) { {bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) { 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() { QueryBuilder<Pair, Pair, QDistinct> distinctByHashCode() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(r'hashCode'); 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( QueryBuilder<Pair, Pair, QDistinct> distinctByTo(
{bool caseSensitive = true}) { {bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(r'to', caseSensitive: caseSensitive); 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> { 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() { QueryBuilder<Pair, String, QQueryOperations> fromProperty() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'from'); 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() { QueryBuilder<Pair, int, QQueryOperations> hashCodeProperty() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'hashCode'); 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() { QueryBuilder<Pair, String, QQueryOperations> toProperty() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'to'); return query.addPropertyName(r'to');
}); });
} }
QueryBuilder<Pair, String, QQueryOperations> toNetworkProperty() {
return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'toNetwork');
});
}
} }

View file

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:isar/isar.dart'; import 'package:isar/isar.dart';
import 'package:stackwallet/models/isar/exchange_cache/currency.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/pages/buy_view/sub_widgets/crypto_selection_view.dart';
import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
@ -53,8 +54,14 @@ class _ExchangeCurrencySelectionViewState
.exchangeNameEqualTo(widget.exchangeName) .exchangeNameEqualTo(widget.exchangeName)
.filter() .filter()
.group((q) => widget.isFixedRate .group((q) => widget.isFixedRate
? q.supportsFixedRateEqualTo(true) ? q
: q.supportsEstimatedRateEqualTo(true)) .rateTypeEqualTo(SupportedRateType.both)
.or()
.rateTypeEqualTo(SupportedRateType.fixed)
: q
.rateTypeEqualTo(SupportedRateType.both)
.or()
.rateTypeEqualTo(SupportedRateType.estimated))
.and() .and()
.group((q) => q .group((q) => q
.nameContains(text, caseSensitive: false) .nameContains(text, caseSensitive: false)
@ -84,8 +91,14 @@ class _ExchangeCurrencySelectionViewState
.exchangeNameEqualTo(widget.exchangeName) .exchangeNameEqualTo(widget.exchangeName)
.filter() .filter()
.group((q) => widget.isFixedRate .group((q) => widget.isFixedRate
? q.supportsFixedRateEqualTo(true) ? q
: q.supportsEstimatedRateEqualTo(true)); .rateTypeEqualTo(SupportedRateType.both)
.or()
.rateTypeEqualTo(SupportedRateType.fixed)
: q
.rateTypeEqualTo(SupportedRateType.both)
.or()
.rateTypeEqualTo(SupportedRateType.estimated));
if (widget.paired != null) { if (widget.paired != null) {
_currencies = query _currencies = query
@ -236,6 +249,8 @@ class _ExchangeCurrencySelectionViewState
primary: isDesktop ? false : null, primary: isDesktop ? false : null,
itemCount: items.length, itemCount: items.length,
itemBuilder: (builderContext, index) { itemBuilder: (builderContext, index) {
final bool hasImageUrl =
items[index].image.startsWith("http");
return Padding( return Padding(
padding: const EdgeInsets.symmetric(vertical: 4), padding: const EdgeInsets.symmetric(vertical: 4),
child: GestureDetector( child: GestureDetector(
@ -253,13 +268,18 @@ class _ExchangeCurrencySelectionViewState
items[index].ticker, items[index].ticker,
size: 24, size: 24,
) )
: SvgPicture.network( : hasImageUrl
items[index].image, ? SvgPicture.network(
width: 24, items[index].image,
height: 24, width: 24,
placeholderBuilder: (_) => height: 24,
const LoadingIndicator(), placeholderBuilder: (_) =>
), const LoadingIndicator(),
)
: const SizedBox(
width: 24,
height: 24,
),
), ),
const SizedBox( const SizedBox(
width: 10, width: 10,
@ -315,6 +335,8 @@ class _ExchangeCurrencySelectionViewState
primary: isDesktop ? false : null, primary: isDesktop ? false : null,
itemCount: _currencies.length, itemCount: _currencies.length,
itemBuilder: (builderContext, index) { itemBuilder: (builderContext, index) {
final bool hasImageUrl =
_currencies[index].image.startsWith("http");
return Padding( return Padding(
padding: const EdgeInsets.symmetric(vertical: 4), padding: const EdgeInsets.symmetric(vertical: 4),
child: GestureDetector( child: GestureDetector(
@ -332,13 +354,18 @@ class _ExchangeCurrencySelectionViewState
_currencies[index].ticker, _currencies[index].ticker,
size: 24, size: 24,
) )
: SvgPicture.network( : hasImageUrl
_currencies[index].image, ? SvgPicture.network(
width: 24, _currencies[index].image,
height: 24, width: 24,
placeholderBuilder: (_) => height: 24,
const LoadingIndicator(), placeholderBuilder: (_) =>
), const LoadingIndicator(),
)
: const SizedBox(
width: 24,
height: 24,
),
), ),
const SizedBox( const SizedBox(
width: 10, width: 10,

View file

@ -535,7 +535,10 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
.where() .where()
.exchangeNameEqualTo(exchangeName) .exchangeNameEqualTo(exchangeName)
.filter() .filter()
.floatingRateEqualTo(true) .group((q) => q
.rateTypeEqualTo(SupportedRateType.estimated)
.or()
.rateTypeEqualTo(SupportedRateType.both))
.and() .and()
.fromEqualTo(fromTicker, caseSensitive: false) .fromEqualTo(fromTicker, caseSensitive: false)
.and() .and()

View file

@ -164,10 +164,12 @@ class ChangeNowAPI {
for (final json in args.item1) { for (final json in args.item1) {
try { try {
final map = Map<String, dynamic>.from(json as Map); final map = Map<String, dynamic>.from(json as Map);
map["supportsEstimatedRate"] = !args.item2;
currencies.add( currencies.add(
Currency.fromJson( Currency.fromJson(
map, map,
rateType: (map["supportsFixedRate"] as bool)
? SupportedRateType.both
: SupportedRateType.estimated,
exchangeName: ChangeNowExchange.exchangeName, exchangeName: ChangeNowExchange.exchangeName,
), ),
); );
@ -211,10 +213,12 @@ class ChangeNowAPI {
for (final json in jsonArray) { for (final json in jsonArray) {
try { try {
final map = Map<String, dynamic>.from(json as Map); final map = Map<String, dynamic>.from(json as Map);
map["supportsEstimatedRate"] = !(fixedRate == true);
currencies.add( currencies.add(
Currency.fromJson( Currency.fromJson(
map, map,
rateType: (map["supportsFixedRate"] as bool)
? SupportedRateType.both
: SupportedRateType.estimated,
exchangeName: ChangeNowExchange.exchangeName, exchangeName: ChangeNowExchange.exchangeName,
), ),
); );

View file

@ -90,7 +90,7 @@ class ExchangeDataLoadingService {
.where() .where()
.exchangeNameEqualTo(ChangeNowExchange.exchangeName) .exchangeNameEqualTo(ChangeNowExchange.exchangeName)
.filter() .filter()
.fixedRateEqualTo(true) .rateTypeEqualTo(SupportedRateType.fixed)
.idProperty() .idProperty()
.findAll(); .findAll();
await isar.pairs.deleteAll(idsToDelete2); await isar.pairs.deleteAll(idsToDelete2);
@ -115,7 +115,7 @@ class ExchangeDataLoadingService {
.where() .where()
.exchangeNameEqualTo(ChangeNowExchange.exchangeName) .exchangeNameEqualTo(ChangeNowExchange.exchangeName)
.filter() .filter()
.floatingRateEqualTo(true) .rateTypeEqualTo(SupportedRateType.estimated)
.idProperty() .idProperty()
.findAll(); .findAll();
await isar.pairs.deleteAll(idsToDelete); await isar.pairs.deleteAll(idsToDelete);

View file

@ -114,8 +114,7 @@ class MajesticBankExchange extends Exchange {
network: "", network: "",
image: "", image: "",
isFiat: false, isFiat: false,
supportsFixedRate: true, rateType: SupportedRateType.both,
supportsEstimatedRate: true,
isAvailable: true, isAvailable: true,
isStackCoin: Currency.checkIsStackCoin(limit.currency), isStackCoin: Currency.checkIsStackCoin(limit.currency),
); );

View file

@ -62,8 +62,9 @@ class SimpleSwapExchange extends Exchange {
image: e.image, image: e.image,
externalId: e.extraId, externalId: e.extraId,
isFiat: false, isFiat: false,
supportsFixedRate: fixedRate, rateType: fixedRate
supportsEstimatedRate: true, ? SupportedRateType.both
: SupportedRateType.estimated,
isAvailable: true, isAvailable: true,
isStackCoin: Currency.checkIsStackCoin(e.symbol), isStackCoin: Currency.checkIsStackCoin(e.symbol),
), ),