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,8 +588,6 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
), ),
Row( Row(
children: [ children: [
if (client.isOld &&
client.currencyId != company.currencyId)
Expanded( Expanded(
child: DecoratedFormField( child: DecoratedFormField(
key: ValueKey( key: ValueKey(
@ -604,18 +599,13 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
FormatNumberType.inputMoney), FormatNumberType.inputMoney),
onChanged: (value) => viewModel.onChanged( onChanged: (value) => viewModel.onChanged(
invoice.rebuild((b) => b invoice.rebuild((b) => b
..exchangeRate = ..exchangeRate = parseDouble(value))),
parseDouble(value))),
keyboardType: keyboardType:
TextInputType.numberWithOptions( TextInputType.numberWithOptions(
decimal: true), decimal: true),
onSavePressed: onSavePressed:
widget.entityViewModel.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,14 +373,13 @@ 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(invoice onChanged: (value) => viewModel.onChanged(
.rebuild((b) => b..exchangeRate = parseDouble(value))), invoice.rebuild((b) => b..exchangeRate = parseDouble(value))),
keyboardType: TextInputType.numberWithOptions(decimal: true), keyboardType: TextInputType.numberWithOptions(decimal: true),
), ),
], ],