Show system currency symbol for setting money inputs
This commit is contained in:
parent
9ef0ac7623
commit
dba5988dd4
|
|
@ -1,6 +1,10 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/constants.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/utils/platforms.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
|
||||
class DecoratedFormField extends StatelessWidget {
|
||||
const DecoratedFormField({
|
||||
|
|
@ -28,6 +32,8 @@ class DecoratedFormField extends StatelessWidget {
|
|||
this.textAlign = TextAlign.start,
|
||||
this.decoration,
|
||||
this.focusNode,
|
||||
this.isMoney = false,
|
||||
this.isPercent = false,
|
||||
}) : super(key: key);
|
||||
|
||||
final TextEditingController controller;
|
||||
|
|
@ -53,6 +59,8 @@ class DecoratedFormField extends StatelessWidget {
|
|||
final TextAlign textAlign;
|
||||
final InputDecoration decoration;
|
||||
final FocusNode focusNode;
|
||||
final bool isMoney;
|
||||
final bool isPercent;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
@ -75,10 +83,25 @@ class DecoratedFormField extends StatelessWidget {
|
|||
} else if (label == null) {
|
||||
inputDecoration = null;
|
||||
} else {
|
||||
var icon = suffixIcon ?? suffixIconButton;
|
||||
if (icon == null) {
|
||||
if (isMoney) {
|
||||
final state = StoreProvider.of<AppState>(context).state;
|
||||
icon = Icon(state.company.currencyId == kCurrencyEuro
|
||||
? Icons.euro
|
||||
: Icons.attach_money);
|
||||
} else if (isPercent) {
|
||||
icon = Icon(
|
||||
MdiIcons.percent,
|
||||
size: 16,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
inputDecoration = InputDecoration(
|
||||
labelText: label,
|
||||
hintText: hint,
|
||||
suffixIcon: suffixIcon ?? suffixIconButton,
|
||||
suffixIcon: icon,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -89,14 +112,16 @@ class DecoratedFormField extends StatelessWidget {
|
|||
autofocus: autofocus,
|
||||
decoration: inputDecoration,
|
||||
validator: validator,
|
||||
keyboardType: keyboardType ?? TextInputType.text,
|
||||
keyboardType: isMoney || isPercent
|
||||
? TextInputType.numberWithOptions(decimal: true, signed: true)
|
||||
: keyboardType ?? TextInputType.text,
|
||||
maxLines: expands ? null : maxLines ?? 1,
|
||||
minLines: expands ? null : minLines,
|
||||
expands: expands,
|
||||
autovalidateMode: autovalidate
|
||||
? AutovalidateMode.onUserInteraction
|
||||
: AutovalidateMode.disabled,
|
||||
autocorrect: autocorrect,
|
||||
autocorrect: isMoney || isPercent ? false : autocorrect,
|
||||
obscureText: obscureText,
|
||||
initialValue: initialValue,
|
||||
textInputAction: textInputAction ??
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ class ClientEditSettingsState extends State<ClientEditSettings> {
|
|||
),
|
||||
DecoratedFormField(
|
||||
controller: _taskRateController,
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
isMoney: true,
|
||||
label: localization.taskRate,
|
||||
onSavePressed: viewModel.onSavePressed,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -626,7 +626,9 @@ class _LimitEditorState extends State<LimitEditor> {
|
|||
label: localization.minLimit,
|
||||
enabled: _enableMin,
|
||||
controller: _minController,
|
||||
keyboardType: TextInputType.numberWithOptions(),
|
||||
keyboardType: TextInputType.numberWithOptions(
|
||||
decimal: true, signed: true),
|
||||
autocorrect: false,
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
CheckboxListTile(
|
||||
|
|
@ -656,7 +658,9 @@ class _LimitEditorState extends State<LimitEditor> {
|
|||
label: localization.maxLimit,
|
||||
enabled: _enableMax,
|
||||
controller: _maxController,
|
||||
keyboardType: TextInputType.numberWithOptions(),
|
||||
keyboardType: TextInputType.numberWithOptions(
|
||||
decimal: true, signed: true),
|
||||
autocorrect: false,
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
CheckboxListTile(
|
||||
|
|
@ -778,23 +782,20 @@ class _FeesEditorState extends State<FeesEditor> {
|
|||
|
||||
return FormCard(
|
||||
children: <Widget>[
|
||||
DecoratedFormField(
|
||||
label: localization.feeAmount,
|
||||
controller: _amountController,
|
||||
autocorrect: false,
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
),
|
||||
DecoratedFormField(
|
||||
label: localization.feePercent,
|
||||
controller: _percentController,
|
||||
autocorrect: false,
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
isPercent: true,
|
||||
),
|
||||
DecoratedFormField(
|
||||
label: localization.feeAmount,
|
||||
controller: _amountController,
|
||||
isMoney: true,
|
||||
),
|
||||
DecoratedFormField(
|
||||
label: localization.feeCap,
|
||||
controller: _capController,
|
||||
autocorrect: false,
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
isMoney: true,
|
||||
),
|
||||
if (company.enableFirstItemTaxRate)
|
||||
TaxRateDropdown(
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ class _OnlinePaymentsState extends State<OnlinePayments> {
|
|||
child: DecoratedFormField(
|
||||
label: localization.minimumUnderPaymentAmount,
|
||||
controller: _minimumAmountController,
|
||||
isMoney: true,
|
||||
),
|
||||
),
|
||||
]),
|
||||
|
|
|
|||
|
|
@ -91,9 +91,9 @@ class _TaskSettingsState extends State<TaskSettings> {
|
|||
children: <Widget>[
|
||||
DecoratedFormField(
|
||||
controller: _taskRateController,
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
label: localization.defaultTaskRate,
|
||||
onSavePressed: viewModel.onSavePressed,
|
||||
isMoney: true,
|
||||
),
|
||||
if (!viewModel.state.settingsUIState.isFiltered) ...[
|
||||
SizedBox(height: 32),
|
||||
|
|
|
|||
|
|
@ -530,12 +530,12 @@ class _ReminderSettingsState extends State<ReminderSettings> {
|
|||
DecoratedFormField(
|
||||
label: localization.lateFeeAmount,
|
||||
controller: _feeAmountController,
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
isMoney: true,
|
||||
),
|
||||
DecoratedFormField(
|
||||
label: localization.lateFeePercent,
|
||||
controller: _feePercentController,
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
isPercent: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -216,13 +216,15 @@ class _TaskEditDesktopState extends State<TaskEditDesktop> {
|
|||
DecoratedFormField(
|
||||
controller: _numberController,
|
||||
label: localization.taskNumber,
|
||||
autocorrect: false,
|
||||
isMoney: false,
|
||||
),
|
||||
DecoratedFormField(
|
||||
key: ValueKey('__rate__'),
|
||||
controller: _rateController,
|
||||
label: rateLabel,
|
||||
keyboardType: TextInputType.number,
|
||||
keyboardType: TextInputType.numberWithOptions(
|
||||
decimal: true, signed: true),
|
||||
autocorrect: false,
|
||||
),
|
||||
DynamicSelector(
|
||||
key: ValueKey('__task_status_${task.statusId}__'),
|
||||
|
|
|
|||
|
|
@ -173,7 +173,9 @@ class _TaskEditDetailsState extends State<TaskEditDetails> {
|
|||
key: ValueKey('__rate__'),
|
||||
controller: _rateController,
|
||||
label: rateLabel,
|
||||
keyboardType: TextInputType.number,
|
||||
keyboardType:
|
||||
TextInputType.numberWithOptions(decimal: true, signed: true),
|
||||
autocorrect: false,
|
||||
),
|
||||
DynamicSelector(
|
||||
key: ValueKey('__task_status_${task.statusId}__'),
|
||||
|
|
|
|||
|
|
@ -104,11 +104,7 @@ class _TaxRateEditState extends State<TaxRateEdit> {
|
|||
DecoratedFormField(
|
||||
label: localization.rate,
|
||||
controller: _rateController,
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
suffixIcon: Icon(
|
||||
MdiIcons.percent,
|
||||
size: 16,
|
||||
),
|
||||
isPercent: true,
|
||||
),
|
||||
],
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue