CAKE-185 | added title property to TradeIsCreatedFailure class; applied title property in the createTrade() method (exchange_view_model.dart); applied title property as alert title in the exchange_page.dart
OleksandrSobol committed
Dec 2, 2020 at 21:51 UTC
458079d3aea64b6a3ffc3a89569bbeefae378978
3 files changed
+9
-3
lib/exchange/exchange_trade_state.dart
+2
-1
@@ -14,7 +14,8 @@ class TradeIsCreatedSuccessfully extends ExchangeTradeState {
14
}
15
16
class TradeIsCreatedFailure extends ExchangeTradeState {
17
- TradeIsCreatedFailure({@required this.error});
17
+ TradeIsCreatedFailure({@required this.title, @required this.error});
18
19
+ final String title;
20
final String error;
21
}
\ No newline at end of file
lib/src/screens/exchange/exchange_page.dart
+1
-1
@@ -558,7 +558,7 @@ class ExchangePage extends BasePage {
558
context: context,
559
builder: (BuildContext context) {
560
return AlertWithOneAction(
561
- alertTitle: S.of(context).error,
561
+ alertTitle: state.title,
562
alertContent: state.error,
563
buttonText: S.of(context).ok,
564
buttonAction: () => Navigator.of(context).pop());
lib/view_model/exchange/exchange_view_model.dart
+6
-1
@@ -247,10 +247,12 @@ abstract class ExchangeViewModelBase with Store {
247
if (limitsState is LimitsLoadedSuccessfully && amount != null) {
248
if (double.parse(amount) < limits.min) {
249
tradeState = TradeIsCreatedFailure(
250
+ title: provider.title,
251
error: S.current.error_text_minimal_limit('${provider.description}',
252
'${limits.min}', currency.toString()));
253
} else if (limits.max != null && double.parse(amount) > limits.max) {
254
tradeState = TradeIsCreatedFailure(
255
+ title: provider.title,
256
error: S.current.error_text_maximum_limit('${provider.description}',
257
'${limits.max}', currency.toString()));
258
} else {
@@ -262,11 +264,14 @@ abstract class ExchangeViewModelBase with Store {
264
await trades.add(trade);
265
tradeState = TradeIsCreatedSuccessfully(trade: trade);
266
} catch (e) {
265
- tradeState = TradeIsCreatedFailure(error: e.toString());
267
+ tradeState = TradeIsCreatedFailure(
268
+ title: provider.title,
269
+ error: e.toString());
270
}
271
}
272
} else {
273
tradeState = TradeIsCreatedFailure(
274
+ title: provider.title,
275
error: S.current
276
.error_text_limits_loading_failed('${provider.description}'));
277
}