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; Widget suffixIconButton;
final hasValue = final hasValue =
(initialValue ?? '').isNotEmpty || (controller?.text ?? '').isNotEmpty; (initialValue ?? '').isNotEmpty || (controller?.text ?? '').isNotEmpty;
if (hasValue) { if (hasValue && key == null) {
if (suffixIcon == null && enabled) { if (suffixIcon == null && enabled) {
suffixIconButton = IconButton( suffixIconButton = IconButton(
icon: Icon(Icons.clear), icon: Icon(Icons.clear),

View File

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