Skip to content

Commit

Permalink
v6.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
agordn52 committed Dec 6, 2024
1 parent e5fe093 commit 8de0ca6
Show file tree
Hide file tree
Showing 13 changed files with 532 additions and 59 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [6.8.0] - 2024-12-06

* New `Field.switchBox` added to `NyForm` to create a switch box field
* Localization support for picker and datetime fields
* `currency.toLowerCase()` in Field.currency()
* Update pubspec.yaml

## [6.7.1] - 2024-11-29

* Fix BadgeTab
Expand Down
14 changes: 11 additions & 3 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.1"
http:
dependency: transitive
description:
name: http
sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
url: "https://pub.dev"
source: hosted
version: "1.2.2"
http_parser:
dependency: transitive
description:
Expand Down Expand Up @@ -403,7 +411,7 @@ packages:
path: ".."
relative: true
source: path
version: "6.5.0"
version: "6.7.2"
path:
dependency: transitive
description:
Expand Down Expand Up @@ -653,10 +661,10 @@ packages:
dependency: transitive
description:
name: timezone
sha256: "2236ec079a174ce07434e89fcd3fcda430025eb7692244139a9cf54fdcf1fc7d"
sha256: ffc9d5f4d1193534ef051f9254063fa53d588609418c84299956c3db9383587d
url: "https://pub.dev"
source: hosted
version: "0.9.4"
version: "0.10.0"
typed_data:
dependency: transitive
description:
Expand Down
21 changes: 21 additions & 0 deletions lib/widgets/fields/field_base_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ abstract class FieldBaseState<T extends StatefulWidget> extends State<T> {
return field.cast.metaData![name];
}

/// Get the widget state property for color
WidgetStateProperty<Color>? getWidgetStatePropertyColor(String key,
{Color? defaultValue}) {
Color? colorMetaData = getFieldMeta(key, defaultValue);
if (colorMetaData == null) {
return null;
}
Color? thumbColorMetaData = color(light: colorMetaData, dark: Colors.black);
return WidgetStateProperty.all(thumbColorMetaData);
}

/// Get the widget state property for icon
WidgetStateProperty<Icon>? getWidgetStatePropertyIcon(String key,
{Icon? defaultValue}) {
Icon? iconMetaData = getFieldMeta(key, defaultValue);
if (iconMetaData == null) {
return null;
}
return WidgetStateProperty.all(iconMetaData);
}

/// Get the headerSpacing from the field
double getHeaderSpacing() => getFieldMeta("headerSpacing", 5);

Expand Down
79 changes: 35 additions & 44 deletions lib/widgets/fields/form_checkbox.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:nylo_support/localization/app_localization.dart';
import '/widgets/fields/field_base_state.dart';
import '/widgets/ny_form.dart';
import 'package:recase/recase.dart';
Expand Down Expand Up @@ -115,37 +116,37 @@ class _NyFormCheckboxState extends FieldBaseState<NyFormCheckbox> {

@override
Widget view(BuildContext context) {
Widget? title = getMetaData('title');
Widget? title = getFieldMeta('title', null);

title ??= Text(
widget.field.name.titleCase,
widget.field.name.titleCase.tr(),
style: TextStyle(
color: color(light: Colors.black, dark: Colors.white),
),
);
if (title is Text && (title.data == null || title.data!.isEmpty)) {
title = Text(
widget.field.name.titleCase,
widget.field.name.titleCase.tr(),
style: TextStyle(
color: color(light: Colors.black, dark: Colors.white),
),
);
}

Color? fillColorMetaData = color(
light: getMetaData('fillColor') ?? Colors.transparent,
light: getFieldMeta('fillColor', null) ?? Colors.transparent,
dark: Colors.black);
WidgetStateProperty<Color?>? fillColor =
WidgetStateProperty.all(fillColorMetaData);

Color? overlayColorMetaData = getMetaData('overlayColor');
Color? overlayColorMetaData = getFieldMeta('overlayColor', null);
WidgetStateProperty<Color?>? overlayColor;
if (overlayColorMetaData != null) {
overlayColor = WidgetStateProperty.all(overlayColorMetaData);
}

return CheckboxListTile(
mouseCursor: getMetaData('mouseCursor'),
mouseCursor: getFieldMeta('mouseCursor', null),
title: title,
value: currentValue,
onChanged: (value) {
Expand All @@ -156,52 +157,42 @@ class _NyFormCheckboxState extends FieldBaseState<NyFormCheckbox> {
}
});
},
controlAffinity: ListTileControlAffinity.leading,
controlAffinity:
getFieldMeta("controlAffinity", ListTileControlAffinity.platform),
activeColor: color(
light: getMetaData('activeColor') ?? Colors.black,
light: getFieldMeta('activeColor', null) ?? Colors.black,
dark: Colors.black),
fillColor: fillColor,
checkColor: color(
light: getMetaData('checkColor') ?? Colors.black, dark: Colors.white),
hoverColor: getMetaData('hoverColor'),
light: getFieldMeta('checkColor', null) ?? Colors.black,
dark: Colors.white),
hoverColor: getFieldMeta('hoverColor', null),
overlayColor: overlayColor,
splashRadius: getMetaData('splashRadius'),
materialTapTargetSize: getMetaData('materialTapTargetSize'),
visualDensity: getMetaData('visualDensity'),
focusNode: getMetaData('focusNode'),
autofocus: getMetaData('autofocus'),
shape: getMetaData('shape'),
splashRadius: getFieldMeta('splashRadius', null),
materialTapTargetSize: getFieldMeta('materialTapTargetSize', null),
visualDensity: getFieldMeta('visualDensity', null),
focusNode: getFieldMeta('focusNode', null),
autofocus: getFieldMeta('autofocus', false),
shape: getFieldMeta('shape', null),
side: whenTheme(
light: () => getMetaData('side'),
light: () => getFieldMeta('side', null),
dark: () => BorderSide(
width: 2, color: color(light: Colors.black, dark: Colors.white))),
isError: getMetaData('isError'),
enabled: getMetaData('enabled'),
tileColor: getMetaData('tileColor'),
subtitle: getMetaData('subtitle'),
isThreeLine: getMetaData('isThreeLine'),
dense: getMetaData('dense'),
secondary: getMetaData('secondary'),
selected: getMetaData('selected'),
contentPadding: getMetaData('contentPadding'),
tristate: getMetaData('tristate'),
checkboxShape: getMetaData('checkboxShape'),
selectedTileColor: getMetaData('selectedTileColor'),
onFocusChange: getMetaData('onFocusChange'),
enableFeedback: getMetaData('enableFeedback'),
checkboxSemanticLabel: getMetaData('checkboxSemanticLabel'),
isError: getFieldMeta('isError', false),
enabled: getFieldMeta('enabled', null),
tileColor: getFieldMeta('tileColor', null),
subtitle: getFieldMeta('subtitle', null),
isThreeLine: getFieldMeta('isThreeLine', false),
dense: getFieldMeta('dense', null),
secondary: getFieldMeta('secondary', null),
selected: getFieldMeta('selected', false),
contentPadding: getFieldMeta('contentPadding', null),
tristate: getFieldMeta('tristate', false),
checkboxShape: getFieldMeta('checkboxShape', null),
selectedTileColor: getFieldMeta('selectedTileColor', null),
onFocusChange: getFieldMeta('onFocusChange', null),
enableFeedback: getFieldMeta('enableFeedback', null),
checkboxSemanticLabel: getFieldMeta('checkboxSemanticLabel', null),
);
}

/// Get the metadata from the field
getMetaData(String key) {
dynamic metaData = widget.field.cast.metaData;
if (metaData is! Map) {
return null;
}
if (!metaData.containsKey(key)) {
return null;
}
return widget.field.cast.metaData[key];
}
}
3 changes: 2 additions & 1 deletion lib/widgets/fields/form_chips.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:nylo_support/localization/app_localization.dart';
import '/helpers/extensions.dart';
import '/widgets/fields/field_base_state.dart';
import '/widgets/ny_form.dart';
Expand Down Expand Up @@ -86,7 +87,7 @@ class _NyFormChipState extends FieldBaseState<NyFormChip> {
isSelected ? getSelectedSide() : getUnselectedSide(),
dark: () => BorderSide(color: Colors.transparent)),
shape: getShape(),
label: Text(option,
label: Text(option.tr(),
style: whenTheme(
light: () => isSelected
? getSelectedTextStyle()
Expand Down
3 changes: 2 additions & 1 deletion lib/widgets/fields/form_date_time_picker.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:date_field/date_field.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:nylo_support/localization/app_localization.dart';
import '/widgets/fields/field_base_state.dart';
import '/widgets/ny_form.dart';
import 'package:recase/recase.dart';
Expand Down Expand Up @@ -102,7 +103,7 @@ class _NyFormDateTimePickerState extends FieldBaseState<NyFormDateTimePicker> {
border: InputBorder.none,
filled: true,
suffixIconColor: color(light: Colors.black, dark: Colors.white),
labelText: widget.field.name.titleCase,
labelText: widget.field.name.titleCase.tr(),
labelStyle: TextStyle(
fontSize: 16,
color: color(light: Colors.grey, dark: Colors.white)),
Expand Down
6 changes: 3 additions & 3 deletions lib/widgets/fields/form_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class _NyFormPickerState extends FieldBaseState<NyFormPicker> {
left: 0,
top: 5,
child: Text(
widget.field.name.titleCase,
widget.field.name.titleCase.tr(),
style: TextStyle(
fontSize: 10,
color: color(
Expand All @@ -120,7 +120,7 @@ class _NyFormPickerState extends FieldBaseState<NyFormPicker> {
children: [
Flexible(
child: Text(
"${"Select".tr()} ${widget.field.name}",
"${"Select".tr()} ${widget.field.name.tr()}",
textAlign:
width < 200 ? TextAlign.left : TextAlign.center,
maxLines: 2,
Expand Down Expand Up @@ -181,7 +181,7 @@ class _NyFormPickerState extends FieldBaseState<NyFormPicker> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
widget.field.name,
widget.field.name.tr(),
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold,
Expand Down
Loading

0 comments on commit 8de0ca6

Please sign in to comment.