Line data Source code
1 : part of apptive_grid_model; 2 : 3 : /// Abstract class for additional options for a [FormComponent] 4 : class FormComponentOptions { 5 : /// Enables const constructors 6 235 : const FormComponentOptions({ 7 : this.description, 8 : this.label, 9 : }); 10 : 11 : /// Deserializes [json] into [TextComponentOptions] 12 6 : FormComponentOptions.fromJson(Map<String, dynamic> json) 13 6 : : description = json['description'], 14 6 : label = json['label']; 15 : 16 : /// Description that describes the Component 17 : final String? description; 18 : 19 : /// Label to be used instead of [FormComponent.property] 20 : final String? label; 21 : 22 : /// Serializes [FormComponentOptions] to json 23 10 : Map<String, dynamic> toJson() => { 24 5 : 'description': description, 25 5 : 'label': label, 26 : }; 27 : 28 4 : @override 29 : String toString() { 30 12 : return '$runtimeType(${toJson()}'; 31 : } 32 : 33 4 : @override 34 : bool operator ==(Object other) { 35 4 : return other is FormComponentOptions && 36 4 : other is! TextComponentOptions && 37 12 : description == other.description && 38 12 : label == other.label; 39 : } 40 : 41 1 : @override 42 2 : int get hashCode => toString().hashCode; 43 : } 44 : 45 : /// [FormComponentOptions] for Text Based Components 46 : class TextComponentOptions extends FormComponentOptions { 47 : /// Creates Options 48 94 : const TextComponentOptions({ 49 : this.multi = false, 50 : this.placeholder, 51 : String? description, 52 : String? label, 53 6 : }) : super( 54 : description: description, 55 : label: label, 56 : ); 57 : 58 : /// Deserializes [json] into [TextComponentOptions] 59 6 : factory TextComponentOptions.fromJson(Map<String, dynamic> json) { 60 6 : final jsonMulti = json['multi'] ?? false; 61 6 : final jsonPlaceholder = json['placeholder']; 62 6 : final jsonDescription = json['description']; 63 6 : final jsonLabel = json['label']; 64 : 65 6 : return TextComponentOptions( 66 : multi: jsonMulti, 67 : placeholder: jsonPlaceholder, 68 : description: jsonDescription, 69 : label: jsonLabel, 70 : ); 71 : } 72 : 73 : /// Determines if the TextField is growable defaults to false 74 : final bool multi; 75 : 76 : /// Placeholder Text 77 : final String? placeholder; 78 : 79 : /// Serializes [TextComponentOptions] to json 80 5 : @override 81 5 : Map<String, dynamic> toJson() => { 82 5 : 'multi': multi, 83 5 : 'placeholder': placeholder, 84 5 : 'description': description, 85 5 : 'label': label 86 : }; 87 : 88 5 : @override 89 : bool operator ==(Object other) { 90 5 : return other is TextComponentOptions && 91 15 : multi == other.multi && 92 15 : placeholder == other.placeholder && 93 15 : description == other.description && 94 15 : label == other.label; 95 : } 96 : 97 1 : @override 98 2 : int get hashCode => toString().hashCode; 99 : }