This commit is contained in:
Hillel Coren 2020-03-05 16:15:21 +02:00
parent eafc959177
commit 876137a3c2
3 changed files with 51 additions and 35 deletions

View File

@ -136,19 +136,15 @@ abstract class PaymentEntity extends Object
@BuiltValueField(wireName: 'private_notes')
String get privateNotes;
@nullable
@BuiltValueField(wireName: 'custom_value1')
String get customValue1;
@nullable
@BuiltValueField(wireName: 'custom_value2')
String get customValue2;
@nullable
@BuiltValueField(wireName: 'custom_value3')
String get customValue3;
@nullable
@BuiltValueField(wireName: 'custom_value4')
String get customValue4;

View File

@ -149,6 +149,18 @@ class _$PaymentEntitySerializer implements StructuredSerializer<PaymentEntity> {
'private_notes',
serializers.serialize(object.privateNotes,
specifiedType: const FullType(String)),
'custom_value1',
serializers.serialize(object.customValue1,
specifiedType: const FullType(String)),
'custom_value2',
serializers.serialize(object.customValue2,
specifiedType: const FullType(String)),
'custom_value3',
serializers.serialize(object.customValue3,
specifiedType: const FullType(String)),
'custom_value4',
serializers.serialize(object.customValue4,
specifiedType: const FullType(String)),
'is_manual',
serializers.serialize(object.isManual,
specifiedType: const FullType(bool)),
@ -171,30 +183,6 @@ class _$PaymentEntitySerializer implements StructuredSerializer<PaymentEntity> {
specifiedType: const FullType(
BuiltList, const [const FullType(PaymentableEntity)])),
];
if (object.customValue1 != null) {
result
..add('custom_value1')
..add(serializers.serialize(object.customValue1,
specifiedType: const FullType(String)));
}
if (object.customValue2 != null) {
result
..add('custom_value2')
..add(serializers.serialize(object.customValue2,
specifiedType: const FullType(String)));
}
if (object.customValue3 != null) {
result
..add('custom_value3')
..add(serializers.serialize(object.customValue3,
specifiedType: const FullType(String)));
}
if (object.customValue4 != null) {
result
..add('custom_value4')
..add(serializers.serialize(object.customValue4,
specifiedType: const FullType(String)));
}
if (object.exchangeRate != null) {
result
..add('exchange_rate')
@ -824,6 +812,18 @@ class _$PaymentEntity extends PaymentEntity {
if (privateNotes == null) {
throw new BuiltValueNullFieldError('PaymentEntity', 'privateNotes');
}
if (customValue1 == null) {
throw new BuiltValueNullFieldError('PaymentEntity', 'customValue1');
}
if (customValue2 == null) {
throw new BuiltValueNullFieldError('PaymentEntity', 'customValue2');
}
if (customValue3 == null) {
throw new BuiltValueNullFieldError('PaymentEntity', 'customValue3');
}
if (customValue4 == null) {
throw new BuiltValueNullFieldError('PaymentEntity', 'customValue4');
}
if (isManual == null) {
throw new BuiltValueNullFieldError('PaymentEntity', 'isManual');
}

View File

@ -1,8 +1,10 @@
import 'package:built_collection/built_collection.dart';
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/data/models/design_model.dart';
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
import 'package:invoiceninja_flutter/ui/app/edit_scaffold.dart';
import 'package:invoiceninja_flutter/ui/app/form_card.dart';
import 'package:invoiceninja_flutter/ui/app/forms/app_dropdown_button.dart';
@ -109,12 +111,20 @@ class _DesignEditState extends State<DesignEdit>
if (design != widget.viewModel.design) {
widget.viewModel.onChanged(design);
_loadDesign(context, design);
_loadPreview(context, design);
}
});
}
void _loadDesign(BuildContext context, DesignEntity design) {
void _loadDesign(String designId) {
final state = widget.viewModel.state;
final designState = state.designState;
final design = designState.map[designId].design;
_headerController.text = design[kDesignHeader];
}
void _loadPreview(BuildContext context, DesignEntity design) {
print('## _loadDesign');
loadDesign(
@ -178,6 +188,7 @@ class _DesignEditState extends State<DesignEdit>
children: <Widget>[
DesignSettings(
nameController: _nameController,
onLoadDesign: _loadDesign,
),
DesignPreview(),
DesignSection(textController: _headerController),
@ -212,7 +223,10 @@ class _DesignEditState extends State<DesignEdit>
child: TabBarView(
controller: _controller,
children: <Widget>[
DesignSettings(nameController: _nameController),
DesignSettings(
nameController: _nameController,
onLoadDesign: _loadDesign,
),
DesignSection(
textController: _headerController),
DesignSection(textController: _bodyController),
@ -265,13 +279,19 @@ class DesignSection extends StatelessWidget {
}
class DesignSettings extends StatelessWidget {
const DesignSettings({@required this.nameController});
const DesignSettings({
@required this.nameController,
@required this.onLoadDesign,
});
final Function(String) onLoadDesign;
final TextEditingController nameController;
@override
Widget build(BuildContext context) {
final localization = AppLocalization.of(context);
final store = StoreProvider.of<AppState>(context);
final designState = store.state.designState;
return Column(
mainAxisSize: MainAxisSize.min,
@ -284,11 +304,11 @@ class DesignSettings extends StatelessWidget {
),
AppDropdownButton<String>(
value: null,
onChanged: (dynamic value) {},
items: ['']
onChanged: (dynamic value) => onLoadDesign(value),
items: designState.list
.map((value) => DropdownMenuItem(
value: value,
child: Text(value),
child: Text(designState.map[value].displayName),
))
.toList(),
labelText: localization.loadDesign,