Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ramin/refactor_accu_barrier_indicator #297

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ class AccumulatorsActiveContract {
/// Initializes [AccumulatorsActiveContract].
const AccumulatorsActiveContract({
required this.profit,
required this.currency,
required this.profitUnit,
required this.fractionalDigits,
});

/// Profit value of the current contract.
final double? profit;

/// The currency of the current contract.
final String? currency;
/// The profit unit label either currency or %, etc that will be shown next to
/// profit value.
final String? profitUnit;

/// The number of decimal places to show the correct formatting of the profit
/// value.
final int fractionalDigits;
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,11 @@ class AccumulatorsClosedIndicatorPainter
if (indicator.activeContract?.profit != null) {
final double profit = indicator.activeContract!.profit!;
final String profitText =
'${profit < 0 ? '' : '+'}${profit.toStringAsFixed(2)}';
'${profit < 0 ? '' : '+'}${profit.toStringAsFixed(
indicator.activeContract!.fractionalDigits,
)}';
final String currencyText =
'${indicator.activeContract?.currency ?? ''}';
'${indicator.activeContract?.profitUnit ?? ''}';
final TextPainter profitPainter = makeTextPainter(
'$profitText $currencyText',
style.textStyle.copyWith(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,14 @@ class AccumulatorIndicatorPainter extends SeriesPainter<AccumulatorIndicator> {
// profit
if (animatedProfit != null && animatedProfit != 0) {
final TextPainter profitPainter = makeTextPainter(
'${animatedProfit < 0 ? '' : '+'}${animatedProfit.toStringAsFixed(2)}',
'${animatedProfit < 0 ? '' : '+'}${animatedProfit.toStringAsFixed(
indicator.activeContract!.fractionalDigits,
)}',
style.textStyle.copyWith(color: color, fontSize: 26),
);

final TextPainter currencyPainter = makeTextPainter(
indicator.activeContract?.currency ?? '',
indicator.activeContract?.profitUnit ?? '',
style.textStyle.copyWith(color: color, fontSize: 14),
);

Expand Down
Loading