Always show rate

This commit is contained in:
Hillel Coren 2020-12-27 22:33:30 +02:00
parent edbb82e791
commit 8e490a7dec
3 changed files with 30 additions and 40 deletions

View File

@ -59,7 +59,7 @@ class DecoratedFormField extends StatelessWidget {
Widget suffixIconButton;
final hasValue =
(initialValue ?? '').isNotEmpty || (controller?.text ?? '').isNotEmpty;
if (hasValue) {
if (hasValue && key == null) {
if (suffixIcon == null && enabled) {
suffixIconButton = IconButton(
icon: Icon(Icons.clear),

View File

@ -533,10 +533,7 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
],
),
SizedBox(
height: (client.isOld &&
client.currencyId != company.currencyId)
? 140
: 100,
height: 125,
child: TabBarView(
controller: _optionTabController,
children: <Widget>[
@ -591,32 +588,25 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
),
Row(
children: [
if (client.isOld &&
client.currencyId != company.currencyId)
Expanded(
child: DecoratedFormField(
key: ValueKey(
'__exchange_rate_${invoice.clientId}__'),
label: localization.exchangeRate,
initialValue: formatNumber(
invoice.exchangeRate, context,
formatNumberType:
FormatNumberType.inputMoney),
onChanged: (value) => viewModel.onChanged(
invoice.rebuild((b) => b
..exchangeRate =
parseDouble(value))),
keyboardType:
TextInputType.numberWithOptions(
decimal: true),
onSavePressed:
widget.entityViewModel.onSavePressed,
),
)
else
Expanded(
child: SizedBox(),
Expanded(
child: DecoratedFormField(
key: ValueKey(
'__exchange_rate_${invoice.clientId}__'),
label: localization.exchangeRate,
initialValue: formatNumber(
invoice.exchangeRate, context,
formatNumberType:
FormatNumberType.inputMoney),
onChanged: (value) => viewModel.onChanged(
invoice.rebuild((b) => b
..exchangeRate = parseDouble(value))),
keyboardType:
TextInputType.numberWithOptions(
decimal: true),
onSavePressed:
widget.entityViewModel.onSavePressed,
),
),
SizedBox(
width: 38,
),
@ -745,6 +735,7 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
),
],
),
SizedBox(height: 16),
],
);
}

View File

@ -373,16 +373,15 @@ class InvoiceEditDetailsState extends State<InvoiceEditDetails> {
onSelected: (value) => viewModel
.onChanged(invoice.rebuild((b) => b..designId = value?.id)),
),
if (client.isOld && client.currencyId != company.currencyId)
DecoratedFormField(
key: ValueKey('__exchange_rate_${invoice.clientId}__'),
label: localization.exchangeRate,
initialValue: formatNumber(invoice.exchangeRate, context,
formatNumberType: FormatNumberType.inputAmount),
onChanged: (value) => viewModel.onChanged(invoice
.rebuild((b) => b..exchangeRate = parseDouble(value))),
keyboardType: TextInputType.numberWithOptions(decimal: true),
),
DecoratedFormField(
key: ValueKey('__exchange_rate_${invoice.clientId}__'),
label: localization.exchangeRate,
initialValue: formatNumber(invoice.exchangeRate, context,
formatNumberType: FormatNumberType.inputAmount),
onChanged: (value) => viewModel.onChanged(
invoice.rebuild((b) => b..exchangeRate = parseDouble(value))),
keyboardType: TextInputType.numberWithOptions(decimal: true),
),
],
),
],