Fix for user details

This commit is contained in:
Hillel Coren 2020-02-26 10:13:08 +02:00
parent 9624c96f3e
commit c3efe087f6
5 changed files with 23 additions and 27 deletions

View File

@ -243,24 +243,18 @@ abstract class FeesAndLimitsSettings
@BuiltValueField(wireName: 'fee_tax_rate1')
double get taxRate1;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'fee_tax_name1')
String get taxName1;
@BuiltValueField(wireName: 'fee_tax_rate2')
double get taxRate2;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'fee_tax_name2')
String get taxName2;
@BuiltValueField(wireName: 'fee_tax_rate3')
double get taxRate3;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'fee_tax_name3')
String get taxName3;

View File

@ -346,34 +346,26 @@ class _$FeesAndLimitsSettingsSerializer
'fee_tax_rate1',
serializers.serialize(object.taxRate1,
specifiedType: const FullType(double)),
'fee_tax_name1',
serializers.serialize(object.taxName1,
specifiedType: const FullType(String)),
'fee_tax_rate2',
serializers.serialize(object.taxRate2,
specifiedType: const FullType(double)),
'fee_tax_name2',
serializers.serialize(object.taxName2,
specifiedType: const FullType(String)),
'fee_tax_rate3',
serializers.serialize(object.taxRate3,
specifiedType: const FullType(double)),
'fee_tax_name3',
serializers.serialize(object.taxName3,
specifiedType: const FullType(String)),
'adjust_fee_percent',
serializers.serialize(object.adjustFeePercent,
specifiedType: const FullType(bool)),
];
if (object.taxName1 != null) {
result
..add('fee_tax_name1')
..add(serializers.serialize(object.taxName1,
specifiedType: const FullType(String)));
}
if (object.taxName2 != null) {
result
..add('fee_tax_name2')
..add(serializers.serialize(object.taxName2,
specifiedType: const FullType(String)));
}
if (object.taxName3 != null) {
result
..add('fee_tax_name3')
..add(serializers.serialize(object.taxName3,
specifiedType: const FullType(String)));
}
return result;
}
@ -1115,12 +1107,21 @@ class _$FeesAndLimitsSettings extends FeesAndLimitsSettings {
if (taxRate1 == null) {
throw new BuiltValueNullFieldError('FeesAndLimitsSettings', 'taxRate1');
}
if (taxName1 == null) {
throw new BuiltValueNullFieldError('FeesAndLimitsSettings', 'taxName1');
}
if (taxRate2 == null) {
throw new BuiltValueNullFieldError('FeesAndLimitsSettings', 'taxRate2');
}
if (taxName2 == null) {
throw new BuiltValueNullFieldError('FeesAndLimitsSettings', 'taxName2');
}
if (taxRate3 == null) {
throw new BuiltValueNullFieldError('FeesAndLimitsSettings', 'taxRate3');
}
if (taxName3 == null) {
throw new BuiltValueNullFieldError('FeesAndLimitsSettings', 'taxName3');
}
if (adjustFeePercent == null) {
throw new BuiltValueNullFieldError(
'FeesAndLimitsSettings', 'adjustFeePercent');

View File

@ -465,7 +465,8 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
//return 'History: $historyList';
//return 'Use inclusive: ${invoiceUIState.editing.usesInclusiveTaxes}';
//return 'Invitations: ${invoiceUIState.editing.invitations}';
return 'Token: ${userCompanyStates.map((state) => state.token.token).toList().join(', ')}';
//return 'Token: ${userCompanyStates.map((state) => state.token.token).toList().join(', ')}';
return 'Settings: ${userCompany.settings}';
return 'Layout: ${prefState.appLayout}, Route: ${uiState.currentRoute} Prev: ${uiState.previousRoute}';
}
}

View File

@ -92,7 +92,7 @@ UserCompanyEntity loadCompanySuccessReducer(
var userCompany = action.userCompany;
// Check user has a blank user settings object
if (userCompany?.settings?.accentColor == null) {
if (userCompany.settings == null) {
userCompany =
userCompany.rebuild((b) => b..settings.replace(UserSettingsEntity()));
}

View File

@ -135,7 +135,7 @@ class _UserDetailsState extends State<UserDetails> {
children: <Widget>[
FormColorPicker(
labelText: localization.accentColor,
initialValue: user.userCompany.settings.accentColor,
initialValue: viewModel.state.userCompany.settings.accentColor,
onSelected: (value) {
widget.viewModel.onChanged(user.rebuild(
(b) => b..userCompany.settings.accentColor = value));