Flutter upgrade

This commit is contained in:
Hillel Coren 2021-11-19 12:23:54 +02:00
parent 7a7ba913be
commit 6cfb0bd066
23 changed files with 21 additions and 47 deletions

View File

@ -11,19 +11,20 @@ import 'package:flutter_redux/flutter_redux.dart';
// Project imports:
import 'package:invoiceninja_flutter/.env.dart';
import 'package:invoiceninja_flutter/constants.dart';
import 'package:invoiceninja_flutter/data/models/models.dart';
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
import 'package:invoiceninja_flutter/ui/app/app_border.dart';
import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart';
import 'package:invoiceninja_flutter/ui/app/responsive_padding.dart';
import 'package:invoiceninja_flutter/ui/app/scrollable_listview.dart';
import 'package:invoiceninja_flutter/utils/colors.dart';
import 'package:invoiceninja_flutter/utils/formatting.dart';
import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:invoiceninja_flutter/utils/platforms.dart';
class EntityDropdown extends StatefulWidget {
const EntityDropdown({
@required Key key,
@required this.entityType,
@required this.labelText,
@required this.onSelected,
@ -38,7 +39,7 @@ class EntityDropdown extends StatefulWidget {
this.onFieldSubmitted,
this.overrideSuggestedAmount,
this.overrideSuggestedLabel,
}) : super(key: key);
});
final EntityType entityType;
final List<String> entityList;
@ -81,6 +82,15 @@ class _EntityDropdownState extends State<EntityDropdown> {
}
}
@override
void didUpdateWidget(oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.entityId != oldWidget.entityId) {
_textController.text = _entityMap[widget.entityId]?.listDisplayName ?? '';
}
}
@override
void didChangeDependencies() {
final state = StoreProvider.of<AppState>(context).state;
@ -262,6 +272,8 @@ class _EntityDropdownState extends State<EntityDropdown> {
optionsViewBuilder: (BuildContext context,
AutocompleteOnSelected<SelectableEntity> onSelected,
Iterable<SelectableEntity> options) {
final highlightedIndex = AutocompleteHighlightedOption.of(context);
return Theme(
data: theme,
child: Align(
@ -277,7 +289,12 @@ class _EntityDropdownState extends State<EntityDropdown> {
itemCount: options.length,
itemBuilder: (BuildContext context, int index) {
return Container(
color: Theme.of(context).cardColor,
color: highlightedIndex == index
? convertHexStringToColor(
state.prefState.enableDarkMode
? kDefaultDarkSelectedColor
: kDefaultLightSelectedColor)
: Theme.of(context).cardColor,
child: _EntityListTile(
onTap: (entity) => onSelected(entity),
entity: options.elementAt(index),

View File

@ -37,7 +37,6 @@ class ClientPicker extends StatelessWidget {
final state = store.state;
return EntityDropdown(
key: ValueKey('__client_${clientId}__'),
entityType: EntityType.client,
labelText: localization.client,
entityId: clientId,

View File

@ -65,7 +65,6 @@ class DynamicSelector extends StatelessWidget {
);
} else {
return EntityDropdown(
key: ValueKey('__entity_id_${entityId}__'),
labelText: labelText ?? localization.lookup('$entityType'),
entityType: entityType,
onSelected: (entity) => onChanged(entity?.id),

View File

@ -138,7 +138,6 @@ class ClientEditBillingAddressState extends State<ClientEditBillingAddress> {
onSavePressed: viewModel.onSavePressed,
),
EntityDropdown(
key: ValueKey('__country_${client.countryId}__'),
entityType: EntityType.country,
entityList: memoizedCountryList(viewModel.staticState.countryMap),
labelText: localization.country,

View File

@ -120,7 +120,6 @@ class ClientEditNotesState extends State<ClientEditNotes> {
showBlank: true,
),
EntityDropdown(
key: ValueKey('__industry_${client.industryId}__'),
entityType: EntityType.industry,
entityList: memoizedIndustryList(viewModel.staticState.industryMap),
labelText: localization.industry,

View File

@ -95,7 +95,6 @@ class ClientEditSettingsState extends State<ClientEditSettings> {
: null,
children: <Widget>[
EntityDropdown(
key: ValueKey('__currency_${client.currencyId}__'),
entityType: EntityType.currency,
entityList: memoizedCurrencyList(viewModel.staticState.currencyMap),
labelText: localization.currency,
@ -104,7 +103,6 @@ class ClientEditSettingsState extends State<ClientEditSettings> {
.rebuild((b) => b..settings.currencyId = currency?.id ?? '')),
),
EntityDropdown(
key: ValueKey('__language_${client.languageId}__'),
entityType: EntityType.language,
entityList: memoizedLanguageList(viewModel.staticState.languageMap),
labelText: localization.language,

View File

@ -134,7 +134,6 @@ class ClientEditShippingAddressState extends State<ClientEditShippingAddress> {
onSavePressed: viewModel.onSavePressed,
),
EntityDropdown(
key: ValueKey('__country_${client.shippingCountryId}__'),
entityType: EntityType.country,
entityList: memoizedCountryList(viewModel.staticState.countryMap),
labelText: localization.country,

View File

@ -146,7 +146,6 @@ class _CompanyGatewayEditState extends State<CompanyGatewayEdit>
children: <Widget>[
if (companyGateway.isNew)
EntityDropdown(
key: ValueKey('__gateway_${companyGateway.gatewayId}__'),
entityType: EntityType.gateway,
entityList:
memoizedGatewayList(state.staticState.gatewayMap),

View File

@ -147,7 +147,6 @@ class ExpenseEditDetailsState extends State<ExpenseEditDetails> {
autocorrect: false,
),
EntityDropdown(
key: ValueKey('__vendor_${expense.vendorId}__'),
//autofocus: true,
entityType: EntityType.vendor,
labelText: localization.vendor,
@ -164,7 +163,6 @@ class ExpenseEditDetailsState extends State<ExpenseEditDetails> {
),
if (!expense.isInvoiced) ...[
EntityDropdown(
key: ValueKey('__client_${expense.clientId}__'),
entityType: EntityType.client,
labelText: localization.client,
entityId: expense.clientId,
@ -284,7 +282,6 @@ class ExpenseEditDetailsState extends State<ExpenseEditDetails> {
),
if (expense.usesInclusiveTaxes) amountField,
EntityDropdown(
key: ValueKey('__currency_${expense.currencyId}__'),
entityType: EntityType.currency,
entityList: memoizedCurrencyList(staticState.currencyMap),
labelText: localization.currency,

View File

@ -189,8 +189,6 @@ class ExpenseEditSettingsState extends State<ExpenseEditSettings> {
children: <Widget>[
SizedBox(height: 8),
EntityDropdown(
key: ValueKey(
'__payment_type_${expense.paymentTypeId}__'),
entityType: EntityType.paymentType,
entityList:
memoizedPaymentTypeList(staticState.paymentTypeMap),
@ -242,8 +240,6 @@ class ExpenseEditSettingsState extends State<ExpenseEditSettings> {
children: <Widget>[
SizedBox(height: 8),
EntityDropdown(
key: ValueKey(
'__invoice_currency_${expense.invoiceCurrencyId}__'),
entityType: EntityType.currency,
entityList:
memoizedCurrencyList(staticState.currencyMap),

View File

@ -251,7 +251,7 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
children: <Widget>[
if (invoice.isNew)
ClientPicker(
//autofocus: true,
autofocus: true,
clientId: invoice.clientId,
clientState: state.clientState,
onSelected: (client) {

View File

@ -201,7 +201,6 @@ class _PaymentEditState extends State<PaymentEdit> {
children: <Widget>[
if (payment.isNew) ...[
EntityDropdown(
key: ValueKey('__client_${payment.clientId}__'),
entityType: EntityType.client,
labelText: AppLocalization.of(context).client,
entityId: payment.clientId,
@ -269,7 +268,6 @@ class _PaymentEditState extends State<PaymentEdit> {
),
if (payment.isApplying != true)
EntityDropdown(
key: ValueKey('__type_${payment.typeId}__'),
entityType: EntityType.paymentType,
entityList: memoizedPaymentTypeList(
viewModel.staticState.paymentTypeMap),
@ -369,8 +367,6 @@ class _PaymentEditState extends State<PaymentEdit> {
),
if (_showConvertCurrency) ...[
EntityDropdown(
key: ValueKey(
'__currency_${payment.exchangeCurrencyId}_${_showConvertCurrency}__'),
entityType: EntityType.currency,
entityList:
memoizedCurrencyList(viewModel.staticState.currencyMap),
@ -644,7 +640,6 @@ class _PaymentableEditorState extends State<PaymentableEditor> {
if (widget.entityType == EntityType.invoice)
Expanded(
child: EntityDropdown(
key: ValueKey('__invoice_${paymentable.invoiceId}__'),
allowClearing: false,
entityType: EntityType.invoice,
labelText: AppLocalization.of(context).invoice,
@ -675,7 +670,6 @@ class _PaymentableEditorState extends State<PaymentableEditor> {
if (widget.entityType == EntityType.credit)
Expanded(
child: EntityDropdown(
key: ValueKey('__credit_${paymentable.creditId}__'),
allowClearing: false,
entityType: EntityType.credit,
labelText: AppLocalization.of(context).credit,

View File

@ -319,7 +319,6 @@ class _PaymentableEditorState extends State<PaymentableEditor> {
children: <Widget>[
Expanded(
child: EntityDropdown(
key: ValueKey('__invoice_${paymentable.invoiceId}__'),
allowClearing: false,
entityType: EntityType.invoice,
labelText: AppLocalization.of(context).invoice,

View File

@ -164,7 +164,6 @@ class _ProjectEditState extends State<ProjectEdit> {
),
project.isNew
? EntityDropdown(
key: ValueKey('__client_${project.clientId}__'),
entityType: EntityType.client,
labelText: localization.client,
entityId: project.clientId,

View File

@ -330,7 +330,6 @@ class _CompanyDetailsState extends State<CompanyDetails>
showBlank: true,
),
EntityDropdown(
key: ValueKey('__industry_${company.industryId}__'),
entityType: EntityType.industry,
entityList:
memoizedIndustryList(state.staticState.industryMap),
@ -383,7 +382,6 @@ class _CompanyDetailsState extends State<CompanyDetails>
autofillHints: [AutofillHints.postalCode],
),
EntityDropdown(
key: ValueKey('__country_${settings.countryId}__'),
entityType: EntityType.country,
entityList:
memoizedCountryList(state.staticState.countryMap),
@ -475,8 +473,6 @@ class _CompanyDetailsState extends State<CompanyDetails>
))
.toList()),
EntityDropdown(
key: ValueKey(
'__default_payment_type_${settings.defaultPaymentTypeId}__'),
entityType: EntityType.paymentType,
entityList: memoizedPaymentTypeList(
state.staticState.paymentTypeMap),

View File

@ -277,7 +277,6 @@ class _InvoiceDesignState extends State<InvoiceDesign>
LearnMoreUrl(
url: 'https://fonts.google.com',
child: EntityDropdown(
key: ValueKey('__primary_font_${settings.primaryFont}__'),
entityType: EntityType.font,
labelText: localization.primaryFont,
entityId: settings.primaryFont,
@ -287,8 +286,6 @@ class _InvoiceDesignState extends State<InvoiceDesign>
),
),
EntityDropdown(
key: ValueKey(
'__secondary_fond_${settings.secondaryFont}__'),
entityType: EntityType.font,
labelText: localization.secondaryFont,
entityId: settings.secondaryFont,

View File

@ -142,7 +142,6 @@ class _LocalizationSettingsState extends State<LocalizationSettings>
FormCard(
children: <Widget>[
EntityDropdown(
key: ValueKey('__currency_${settings.currencyId}__'),
entityType: EntityType.currency,
entityList:
memoizedCurrencyList(state.staticState.currencyMap),
@ -171,7 +170,6 @@ class _LocalizationSettingsState extends State<LocalizationSettings>
url: kTransifexURL,
label: localization.helpTranslate,
child: EntityDropdown(
key: ValueKey('__language_${settings.languageId}__'),
entityType: EntityType.language,
entityList:
memoizedLanguageList(state.staticState.languageMap),
@ -183,7 +181,6 @@ class _LocalizationSettingsState extends State<LocalizationSettings>
),
),
EntityDropdown(
key: ValueKey('__timezone_${settings.timezoneId}__'),
entityType: EntityType.timezone,
entityList:
memoizedTimezoneList(state.staticState.timezoneMap),
@ -194,7 +191,6 @@ class _LocalizationSettingsState extends State<LocalizationSettings>
.rebuild((b) => b..timezoneId = timezone?.id)),
),
EntityDropdown(
key: ValueKey('__date_format_${settings.dateFormatId}__'),
entityType: EntityType.dateFormat,
entityList:
memoizedDateFormatList(state.staticState.dateFormatMap),

View File

@ -248,7 +248,6 @@ class _SettingsWizardState extends State<SettingsWizard> {
);
final currency = EntityDropdown(
key: ValueKey('__currency_${_currencyId}__'),
entityType: EntityType.currency,
entityList: memoizedCurrencyList(state.staticState.currencyMap),
labelText: localization.currency,
@ -260,7 +259,6 @@ class _SettingsWizardState extends State<SettingsWizard> {
);
final language = EntityDropdown(
key: ValueKey('__language_${_languageId}__'),
entityType: EntityType.language,
entityList: memoizedLanguageList(state.staticState.languageMap),
labelText: localization.language,

View File

@ -252,7 +252,6 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
isLast: true,
children: <Widget>[
EntityDropdown(
key: ValueKey('__products_${subscription.productIds}__'),
entityType: EntityType.product,
entityList: dropdownProductsSelector(state.productState.map,
state.productState.list, state.userState.map),
@ -291,8 +290,6 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
height: 16,
),
EntityDropdown(
key: ValueKey(
'__recuring_products_${subscription.recurringProductIds}__'),
entityType: EntityType.product,
entityList: dropdownProductsSelector(state.productState.map,
state.productState.list, state.userState.map),

View File

@ -164,7 +164,6 @@ class _TaskEditDesktopState extends State<TaskEditDesktop> {
children: [
if (!task.isInvoiced) ...[
EntityDropdown(
key: ValueKey('__client_${task.clientId}__'),
entityType: EntityType.client,
labelText: localization.client,
entityId: task.clientId,

View File

@ -130,7 +130,6 @@ class _TaskEditDetailsState extends State<TaskEditDetails> {
children: <Widget>[
if (!task.isInvoiced) ...[
EntityDropdown(
key: ValueKey('__client_${task.clientId}__'),
entityType: EntityType.client,
labelText: localization.client,
entityId: task.clientId,

View File

@ -128,7 +128,6 @@ class VendorEditAddressState extends State<VendorEditAddress> {
onSavePressed: viewModel.onSavePressed,
),
EntityDropdown(
key: ValueKey('__country_${vendor.countryId}__'),
entityType: EntityType.country,
entityList:
memoizedCountryList(viewModel.state.staticState.countryMap),

View File

@ -94,7 +94,6 @@ class VendorEditNotesState extends State<VendorEditNotes> {
: null,
children: <Widget>[
EntityDropdown(
key: ValueKey('__currency_${vendor.currencyId}__'),
entityType: EntityType.currency,
entityList: memoizedCurrencyList(staticState.currencyMap),
labelText: localization.currency,