diff --git a/.github/workflows/dcm.yml b/.github/workflows/dcm.yml index 2a9c8230..7daffd48 100644 --- a/.github/workflows/dcm.yml +++ b/.github/workflows/dcm.yml @@ -16,7 +16,7 @@ jobs: uses: CQLabs/setup-dcm@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }} - version: "1.19.1" + version: "1.21.0" - uses: ./.github/actions/setup diff --git a/kiosk_mode/lib/kiosk_mode.dart b/kiosk_mode/lib/kiosk_mode.dart index 403b7e82..8dec8a3c 100644 --- a/kiosk_mode/lib/kiosk_mode.dart +++ b/kiosk_mode/lib/kiosk_mode.dart @@ -30,9 +30,10 @@ enum KioskMode { /// /// [1]: https://developer.android.com/reference/android/app/Activity#startLockTask() /// [2]: https://developer.apple.com/documentation/uikit/uiaccessibility/1615186-requestguidedaccesssession/ +// ignore: prefer-boolean-prefixes, a valid name with bool result Future startKioskMode() => _channel .invokeMethod('startKioskMode') - .then((value) => value ?? false); + .then((didStartKioskMode) => didStartKioskMode ?? false); /// On Android, stops the current task from being locked. On iOS, exits the Single App mode. /// @@ -42,6 +43,7 @@ Future startKioskMode() => _channel /// On iOS, the result will be `true` if the request was fulfilled, `false` - otherwise. /// /// [1]: https://developer.android.com/reference/android/app/Activity#stopLockTask() +// ignore: prefer-boolean-prefixes, a valid name with a bool result Future stopKioskMode() => _channel.invokeMethod('stopKioskMode'); /// Returns the current [KioskMode]. @@ -49,9 +51,11 @@ Future stopKioskMode() => _channel.invokeMethod('stopKioskMode'); /// On Android, it calls `isInLockTaskMode`. /// /// On iOS, it returns result of `UIAccessibility.isGuidedAccessEnabled`. -Future getKioskMode() => _channel - .invokeMethod('isInKioskMode') - .then((value) => value == true ? KioskMode.enabled : KioskMode.disabled); +Future getKioskMode() => + _channel.invokeMethod('isInKioskMode').then( + (isInKioskMode) => + isInKioskMode == true ? KioskMode.enabled : KioskMode.disabled, + ); /// Returns `true`, if app is in a proper managed kiosk mode. /// @@ -64,7 +68,7 @@ Future getKioskMode() => _channel /// detection of Apple Business Manager yet. Future isManagedKiosk() => _channel .invokeMethod('isManagedKiosk') - .then((value) => value == true); + .then((isManagedKiosk) => isManagedKiosk == true); /// Returns the stream with [KioskMode]. /// diff --git a/mews_pedantic/lib/analysis_options.yaml b/mews_pedantic/lib/analysis_options.yaml index 8ea36ff2..75430e13 100644 --- a/mews_pedantic/lib/analysis_options.yaml +++ b/mews_pedantic/lib/analysis_options.yaml @@ -250,6 +250,8 @@ dart_code_metrics: # - avoid-async-call-in-sync-function # - avoid-banned-annotations # - avoid-banned-file-names + # - avoid-banned-imports + # - avoid-banned-names # - avoid-banned-types - avoid-barrel-files - avoid-bottom-type-in-patterns @@ -305,6 +307,7 @@ dart_code_metrics: - avoid-missing-interpolation # - avoid-missing-test-files - avoid-misused-test-matchers + - avoid-misused-set-literals - avoid-misused-wildcard-pattern - avoid-mixing-named-and-positional-fields - avoid-multi-assignment @@ -345,6 +348,7 @@ dart_code_metrics: # - avoid-similar-names # - avoid-slow-collection-methods # - avoid-substring + - avoid-suspicious-super-overrides # - avoid-throw-in-catch-block # - avoid-throw-objects-without-tostring # - avoid-top-level-members-in-tests @@ -380,6 +384,7 @@ dart_code_metrics: # - ban-name # - banned-usage # - binary-expression-operand-order + - dispose-class-fields # - double-literal-format # - enum-constants-ordering # - format-comment @@ -400,6 +405,7 @@ dart_code_metrics: - move-variable-closer-to-its-usage - move-variable-outside-iteration # - newline-before-case + - newline-before-method - newline-before-return - no-boolean-literal-compare # - no-empty-block @@ -417,6 +423,8 @@ dart_code_metrics: # - prefer-addition-subtraction-assignments - prefer-any-or-every # - prefer-async-await + - prefer-boolean-prefixes: + prefixes: [is, are, was, were, has, have, had, can, should, will, do, does, did, allow, show, use, hide, only, enable] - prefer-both-inlining-annotations # - prefer-bytes-builder - prefer-commenting-analyzer-ignores diff --git a/optimus/lib/src/badge/badge.dart b/optimus/lib/src/badge/badge.dart index 374d378f..855389f4 100644 --- a/optimus/lib/src/badge/badge.dart +++ b/optimus/lib/src/badge/badge.dart @@ -9,7 +9,7 @@ class OptimusBadge extends StatelessWidget { const OptimusBadge({ super.key, this.text = '', - this.outline = true, + this.isOutlined = true, this.overflow = TextOverflow.ellipsis, this.variant = OptimusBadgeVariant.primary, }); @@ -19,7 +19,7 @@ class OptimusBadge extends StatelessWidget { /// Whether to use the outline. Outlined version could be more accessible, /// depending on the underlying component. - final bool outline; + final bool isOutlined; /// Define how to display the overflowing text. Defaults to /// [TextOverflow.ellipsis]. Due to small height of the badge, the @@ -35,7 +35,7 @@ class OptimusBadge extends StatelessWidget { return BaseBadge( text: text, - outline: outline, + isOutlined: isOutlined, textColor: variant.getTextColor(tokens), backgroundColor: variant.getBackgroundColor(tokens), ); diff --git a/optimus/lib/src/badge/base_badge.dart b/optimus/lib/src/badge/base_badge.dart index ee5453a1..4383165e 100644 --- a/optimus/lib/src/badge/base_badge.dart +++ b/optimus/lib/src/badge/base_badge.dart @@ -5,7 +5,7 @@ class BaseBadge extends StatelessWidget { const BaseBadge({ super.key, required this.text, - required this.outline, + required this.isOutlined, this.overflow = TextOverflow.ellipsis, this.backgroundColor, this.textColor, @@ -13,7 +13,7 @@ class BaseBadge extends StatelessWidget { }); final String text; - final bool outline; + final bool isOutlined; final TextOverflow overflow; final Color? backgroundColor; final Color? textColor; @@ -31,13 +31,14 @@ class BaseBadge extends StatelessWidget { final badgeHeight = tokens.sizing200; final bareHeight = text.isEmpty ? tokens.spacing100 : badgeHeight; final outlinedHeight = bareHeight + outlineSize * 2; - final height = outline ? outlinedHeight : bareHeight; + final height = isOutlined ? outlinedHeight : bareHeight; final decoration = BoxDecoration( borderRadius: const BorderRadius.all(Radius.circular(50)), color: backgroundColor, - border: - outline ? Border.all(width: outlineSize, color: outlineColor) : null, + border: isOutlined + ? Border.all(width: outlineSize, color: outlineColor) + : null, ); final child = hasText diff --git a/optimus/lib/src/button/base_button.dart b/optimus/lib/src/button/base_button.dart index 32b02bdc..6f2b19ad 100644 --- a/optimus/lib/src/button/base_button.dart +++ b/optimus/lib/src/button/base_button.dart @@ -376,6 +376,7 @@ extension on OptimusWidgetSize { OptimusWidgetSize.extraLarge => tokens.spacing150, }; + double getHorizontalPadding(OptimusTokens tokens) => switch (this) { OptimusWidgetSize.small => tokens.spacing150, OptimusWidgetSize.medium => tokens.spacing200, @@ -383,6 +384,7 @@ extension on OptimusWidgetSize { OptimusWidgetSize.extraLarge => tokens.spacing300, }; + double getInsideHorizontalPadding(OptimusTokens tokens) => switch (this) { OptimusWidgetSize.small => tokens.spacing100, OptimusWidgetSize.medium || diff --git a/optimus/lib/src/card.dart b/optimus/lib/src/card.dart index 739f896a..96725207 100644 --- a/optimus/lib/src/card.dart +++ b/optimus/lib/src/card.dart @@ -50,7 +50,7 @@ class OptimusCard extends StatelessWidget { this.padding = OptimusCardSpacing.spacing200, this.attachment = OptimusCardAttachment.none, this.variant = OptimusBasicCardVariant.normal, - this.outline = true, + this.isOutlined = true, this.radius = OptimusCardCornerRadius.medium, }); @@ -71,12 +71,12 @@ class OptimusCard extends StatelessWidget { final OptimusBasicCardVariant variant; /// Whether card should be outlined; - final bool outline; + final bool isOutlined; /// Controls the radius of the card. final OptimusCardCornerRadius radius; - Border? _border(BuildContext context) => outline + Border? _border(BuildContext context) => isOutlined ? Border.all( width: context.tokens.borderWidth150, color: context.tokens.borderStaticPrimary, @@ -124,7 +124,7 @@ class OptimusNestedCard extends StatelessWidget { this.padding = OptimusCardSpacing.spacing200, this.attachment = OptimusCardAttachment.none, this.variant = OptimusNestedCardVariant.normal, - this.outline = false, + this.isOutlined = false, this.radius = OptimusCardCornerRadius.medium, }); @@ -145,7 +145,7 @@ class OptimusNestedCard extends StatelessWidget { final OptimusNestedCardVariant variant; /// Whether card should be outlined. - final bool outline; + final bool isOutlined; /// The radius of the card. final OptimusCardCornerRadius radius; @@ -155,7 +155,7 @@ class OptimusNestedCard extends StatelessWidget { OptimusCardCornerRadius.medium => context.tokens.borderRadius200, }; - Border? _border(BuildContext context) => outline + Border? _border(BuildContext context) => isOutlined ? Border.all( width: context.tokens.borderWidth150, color: context.tokens.borderStaticPrimary, diff --git a/optimus/lib/src/chat/chat.dart b/optimus/lib/src/chat/chat.dart index 23d57efb..33b8a029 100644 --- a/optimus/lib/src/chat/chat.dart +++ b/optimus/lib/src/chat/chat.dart @@ -36,27 +36,27 @@ class OptimusChat extends StatelessWidget { final ValueChanged onSendPressed; final Predicate isFromCurrentUser; - bool _previousMessageIsFromSameUser(int index) => + bool _isPreviousMessageFromSameUser(int index) => index - 1 >= 0 && _messages[index - 1].author.id == _messages[index].author.id; bool _showAvatar(int index) => - _lastMessageOfDay(index) || - _moreThanOneMinuteDifferenceForward(index) || - _latestMessage(index) || - !_previousMessageIsFromSameUser(index); + _isLastMessageOfDay(index) || + _isMoreThanOneMinuteDifferenceForward(index) || + _isLatestMessage(index) || + !_isPreviousMessageFromSameUser(index); bool _showStatus(int index) => - _lastMessageOfDay(index) || - _moreThanOneMinuteDifferenceForward(index) || + _isLastMessageOfDay(index) || + _isMoreThanOneMinuteDifferenceForward(index) || _messages[index].state != MessageState.sent || - _latestMessage(index) || - !_previousMessageIsFromSameUser(index); + _isLatestMessage(index) || + !_isPreviousMessageFromSameUser(index); bool _showUserName(int index) => !isFromCurrentUser(_messages[index]) && - (_moreThanOneMinuteDifferenceBack(index) || - _oldestMessage(index) || + (_isMoreThanOneMinuteDifferenceBack(index) || + _isOldestMessage(index) || _messages[index < _messages.length ? index + 1 : index].author.id != _messages[index].author.id); @@ -67,7 +67,7 @@ class OptimusChat extends StatelessWidget { _currentMessageTime(index).difference(previousMessageTime).inDays >= 1; } - bool _moreThanOneMinuteDifferenceBack(int index) { + bool _isMoreThanOneMinuteDifferenceBack(int index) { final previousMessageTime = _previousMessageTime(index); return previousMessageTime != null && @@ -78,7 +78,7 @@ class OptimusChat extends StatelessWidget { 1; } - bool _moreThanOneMinuteDifferenceForward(int index) { + bool _isMoreThanOneMinuteDifferenceForward(int index) { final nextMessageTime = _nextMessageTime(index); return nextMessageTime != null && @@ -97,16 +97,16 @@ class OptimusChat extends StatelessWidget { DateTime? _nextMessageTime(int index) => index - 1 > 0 ? _messages[index - 1].time : null; - bool _lastMessageOfDay(int index) { + bool _isLastMessageOfDay(int index) { final nextMessageTime = _nextMessageTime(index); return nextMessageTime == null || nextMessageTime.difference(_currentMessageTime(index)).inDays > 1; } - bool _latestMessage(int index) => index == 0; + bool _isLatestMessage(int index) => index == 0; - bool _oldestMessage(int index) => index + 1 == _messages.length; + bool _isOldestMessage(int index) => index + 1 == _messages.length; int _byTime(OptimusMessage m1, OptimusMessage m2) => m2.time.compareTo(m1.time); @@ -157,7 +157,7 @@ class OptimusChat extends StatelessWidget { sending: sending, sent: sent, isFromCurrentUser: isFromCurrentUser(_messages[index]), - isLatestMessage: _latestMessage(index), + isLatestMessage: _isLatestMessage(index), alignment: _messages[index].alignment, ), ], diff --git a/optimus/lib/src/checkbox/checkbox.dart b/optimus/lib/src/checkbox/checkbox.dart index 8a6fd729..5a3c074b 100644 --- a/optimus/lib/src/checkbox/checkbox.dart +++ b/optimus/lib/src/checkbox/checkbox.dart @@ -17,7 +17,7 @@ enum OptimusCheckboxSize { /// A checkbox is a binary form of input and is used to let a user select one /// or more options for a limited number of choices. Each selection is -/// independent (with exceptions). If [tristate] is enabled, checkbox can be in +/// independent (with exceptions). If [isTristate] is enabled, checkbox can be in /// three states: checked, unchecked and indeterminate. class OptimusCheckbox extends StatelessWidget { const OptimusCheckbox({ @@ -27,10 +27,10 @@ class OptimusCheckbox extends StatelessWidget { this.error, this.isEnabled = true, this.size = OptimusCheckboxSize.large, - this.tristate = false, + this.isTristate = false, required this.onChanged, }) : assert( - tristate || isChecked != null, + isTristate || isChecked != null, 'isChecked must be set if tristate is false', ); @@ -49,7 +49,7 @@ class OptimusCheckbox extends StatelessWidget { /// {@template optimus.checkbox.tristate} /// Whether this checkbox has 3 states. /// {@endtemplate} - final bool tristate; + final bool isTristate; /// {@template optimus.checkbox.error} /// Controls error that appears below checkbox. @@ -112,10 +112,7 @@ class OptimusCheckbox extends StatelessWidget { return false; } - void _handleTap() { - final newValue = isChecked ?? false; - onChanged(!newValue); - } + void _handleTap() => onChanged(!(isChecked ?? false)); @override Widget build(BuildContext context) { diff --git a/optimus/lib/src/checkbox/checkbox_group.dart b/optimus/lib/src/checkbox/checkbox_group.dart index 6870cf60..2e7634e7 100644 --- a/optimus/lib/src/checkbox/checkbox_group.dart +++ b/optimus/lib/src/checkbox/checkbox_group.dart @@ -45,8 +45,8 @@ class OptimusCheckboxGroup extends StatelessWidget { /// Controls whether the whole group is enabled. final bool isEnabled; - void _handleChanged(OptimusGroupItem v, bool checked) { - if (checked) { + void _handleChanged(OptimusGroupItem v, bool isChecked) { + if (isChecked) { _values.add(v.value); } else { _values.remove(v.value); @@ -70,7 +70,7 @@ class OptimusCheckboxGroup extends StatelessWidget { size: size, label: v.label, isEnabled: isEnabled, - onChanged: (checked) => _handleChanged(v, checked), + onChanged: (isChecked) => _handleChanged(v, isChecked), ), ) .toList(), diff --git a/optimus/lib/src/checkbox/checkbox_tick.dart b/optimus/lib/src/checkbox/checkbox_tick.dart index c34f950f..98302be8 100644 --- a/optimus/lib/src/checkbox/checkbox_tick.dart +++ b/optimus/lib/src/checkbox/checkbox_tick.dart @@ -38,11 +38,11 @@ class _CheckboxTickState extends State with ThemeGetter { return _InteractionState.basic; } - void _handleHoverChanged(bool hovered) => - setState(() => _isHovering = hovered); + void _handleHoverChanged(bool isHovered) => + setState(() => _isHovering = isHovered); - void _handlePressedChanged(bool pressed) => - setState(() => _isPressed = pressed); + void _handlePressedChanged(bool isPressed) => + setState(() => _isPressed = isPressed); @override Widget build(BuildContext context) => GestureWrapper( diff --git a/optimus/lib/src/checkbox/nested_checkbox.dart b/optimus/lib/src/checkbox/nested_checkbox.dart index fc56bbfa..33346723 100644 --- a/optimus/lib/src/checkbox/nested_checkbox.dart +++ b/optimus/lib/src/checkbox/nested_checkbox.dart @@ -58,13 +58,13 @@ class OptimusNestedCheckboxGroup extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ OptimusCheckbox( - tristate: true, + isTristate: true, isEnabled: isEnabled, isChecked: _isParentChecked, label: parent, - onChanged: (bool value) { + onChanged: (bool isChecked) { for (final child in children) { - child.onChanged(value); + child.onChanged(isChecked); } }, ), @@ -120,7 +120,7 @@ class OptimusNestedCheckbox extends StatelessWidget { return OptimusCheckbox( label: label, size: size, - tristate: false, + isTristate: false, isEnabled: isEnabled, isChecked: isChecked, onChanged: onChanged, diff --git a/optimus/lib/src/common/anchored_overlay.dart b/optimus/lib/src/common/anchored_overlay.dart index 48e2f96a..ab2eba61 100644 --- a/optimus/lib/src/common/anchored_overlay.dart +++ b/optimus/lib/src/common/anchored_overlay.dart @@ -31,13 +31,13 @@ class AnchoredOverlay extends StatefulWidget { required this.anchorKey, required this.child, required this.width, - this.rootOverlay = false, + this.useRootOverlay = false, }); final GlobalKey anchorKey; final double? width; final Widget child; - final bool rootOverlay; + final bool useRootOverlay; static AnchoredOverlayController? of(BuildContext context) => context .dependOnInheritedWidgetOfExactType() @@ -129,7 +129,7 @@ class AnchoredOverlayState extends State } RenderBox? _getOverlay() => - Overlay.of(context, rootOverlay: widget.rootOverlay) + Overlay.of(context, rootOverlay: widget.useRootOverlay) .context .findRenderObject() as RenderBox?; diff --git a/optimus/lib/src/common/field_wrapper.dart b/optimus/lib/src/common/field_wrapper.dart index 5c348614..bd0ab7d4 100644 --- a/optimus/lib/src/common/field_wrapper.dart +++ b/optimus/lib/src/common/field_wrapper.dart @@ -23,8 +23,8 @@ class FieldWrapper extends StatefulWidget { this.children = const [], this.size = OptimusWidgetSize.large, this.inputCounter, - this.inline = false, - this.multiline = false, + this.isInlined = false, + this.hasMultipleLines = false, this.statusBarState, this.placeholder, }); @@ -46,8 +46,8 @@ class FieldWrapper extends StatefulWidget { final Key? fieldBoxKey; final OptimusWidgetSize size; final Widget? inputCounter; - final bool inline; - final bool multiline; + final bool isInlined; + final bool hasMultipleLines; final OptimusStatusBarState? statusBarState; final Widget? placeholder; @@ -95,11 +95,11 @@ class _FieldWrapper extends State with ThemeGetter { bool get _isFocused => widget.isFocused ?? widget.focusNode.hasFocus; bool get _hasHeader => - (widget.label != null || widget.caption != null) && !widget.inline; + (widget.label != null || widget.caption != null) && !widget.isInlined; bool get _hasFooter => widget.isEnabled && - !widget.inline && + !widget.isInlined && (widget.helperMessage != null || widget.inputCounter != null || _normalizedError.isNotEmpty); @@ -108,7 +108,7 @@ class _FieldWrapper extends State with ThemeGetter { bool get _hasFooterError => _normalizedError.isNotEmpty && _isUsingBottomHint; - double get _verticalPadding => widget.multiline + double get _verticalPadding => widget.hasMultipleLines ? widget.size.getVerticalPadding(tokens) : tokens.spacing0; @@ -497,6 +497,7 @@ extension on OptimusWidgetSize { OptimusWidgetSize.extraLarge => EdgeInsets.only(bottom: tokens.spacing100), }; + EdgeInsets getHelperPadding(OptimusTokens tokens) => switch (this) { OptimusWidgetSize.small || OptimusWidgetSize.medium => @@ -505,6 +506,7 @@ extension on OptimusWidgetSize { OptimusWidgetSize.extraLarge => EdgeInsets.only(top: tokens.spacing100), }; + EdgeInsets getErrorPadding(OptimusTokens tokens) => EdgeInsets.only(top: tokens.spacing50); diff --git a/optimus/lib/src/date_time_field.dart b/optimus/lib/src/date_time_field.dart index 70421fc2..0dd56a56 100644 --- a/optimus/lib/src/date_time_field.dart +++ b/optimus/lib/src/date_time_field.dart @@ -87,7 +87,7 @@ class _OptimusDateTimeFieldState extends State @override Widget build(BuildContext context) => OptimusInputField( controller: _controller, - readOnly: true, + isReadOnly: true, onTap: _handleTap, error: widget.error, label: widget.label, diff --git a/optimus/lib/src/dialogs/dialog_wrapper.dart b/optimus/lib/src/dialogs/dialog_wrapper.dart index 1fba861a..49cce728 100644 --- a/optimus/lib/src/dialogs/dialog_wrapper.dart +++ b/optimus/lib/src/dialogs/dialog_wrapper.dart @@ -10,7 +10,7 @@ abstract class DialogController { bool isDismissible = true, List actions = const [], OptimusDialogSize size = OptimusDialogSize.regular, - bool rootOverlay = false, + bool useRootOverlay = false, }); void showInline({ @@ -18,7 +18,7 @@ abstract class DialogController { required Widget content, OptimusDialogSize size = OptimusDialogSize.small, List actions = const [], - bool rootOverlay = false, + bool useRootOverlay = false, }); void hide(); @@ -67,7 +67,7 @@ class _DialogWrapperState extends State bool isDismissible = true, List actions = const [], OptimusDialogSize size = OptimusDialogSize.regular, - bool rootOverlay = false, + bool useRootOverlay = false, }) { hide(); final entry = OverlayEntry( @@ -81,7 +81,7 @@ class _DialogWrapperState extends State ), ); _entry = entry; - Overlay.of(context, rootOverlay: rootOverlay).insert(entry); + Overlay.of(context, rootOverlay: useRootOverlay).insert(entry); } @override @@ -90,7 +90,7 @@ class _DialogWrapperState extends State required Widget content, List actions = const [], OptimusDialogSize size = OptimusDialogSize.small, - bool rootOverlay = false, + bool useRootOverlay = false, }) { hide(); final entry = OverlayEntry( @@ -112,7 +112,7 @@ class _DialogWrapperState extends State ), ); _entry = entry; - Overlay.of(context, rootOverlay: rootOverlay).insert(entry); + Overlay.of(context, rootOverlay: useRootOverlay).insert(entry); } @override diff --git a/optimus/lib/src/dropdown/base_dropdown_tile.dart b/optimus/lib/src/dropdown/base_dropdown_tile.dart index 7cf3b652..9fcd6032 100644 --- a/optimus/lib/src/dropdown/base_dropdown_tile.dart +++ b/optimus/lib/src/dropdown/base_dropdown_tile.dart @@ -54,6 +54,7 @@ class BaseDropdownTile extends StatelessWidget { padding: EdgeInsets.only(right: tokens.spacing200), child: CheckboxTick( isEnabled: true, + // ignore: prefer-boolean-prefixes, DCM bug onChanged: (_) {}, onTap: () {}, isChecked: isSelected, diff --git a/optimus/lib/src/dropdown/dropdown_select.dart b/optimus/lib/src/dropdown/dropdown_select.dart index 3617335a..2cf930e0 100644 --- a/optimus/lib/src/dropdown/dropdown_select.dart +++ b/optimus/lib/src/dropdown/dropdown_select.dart @@ -28,7 +28,7 @@ class DropdownSelect extends StatefulWidget { this.helperMessage, this.error, this.size = OptimusWidgetSize.large, - this.readOnly = false, + this.isReadOnly = false, this.showCursor, this.prefix, this.suffix, @@ -36,14 +36,14 @@ class DropdownSelect extends StatefulWidget { this.shouldCloseOnInputTap = false, this.showLoader = false, this.isClearEnabled = false, - this.rootOverlay = false, + this.useRootOverlay = false, this.emptyResultPlaceholder, this.embeddedSearch, this.onDropdownShow, this.onDropdownHide, this.groupBy, this.groupBuilder, - this.multiselect = false, + this.allowMultipleSelection = false, this.selectedValues, this.builder, }); @@ -72,7 +72,7 @@ class DropdownSelect extends StatefulWidget { final bool isClearEnabled; final FocusNode? focusNode; final bool shouldCloseOnInputTap; - final bool rootOverlay; + final bool useRootOverlay; final OptimusDropdownEmbeddedSearch? embeddedSearch; final Widget? emptyResultPlaceholder; final VoidCallback? onDropdownShow; @@ -84,9 +84,9 @@ class DropdownSelect extends StatefulWidget { final bool? showCursor; /// {@macro flutter.widgets.editableText.readOnly} - final bool readOnly; + final bool isReadOnly; - final bool multiselect; + final bool allowMultipleSelection; final List? selectedValues; final ValueBuilder? builder; @@ -165,7 +165,7 @@ class _DropdownSelectState extends State> { void _showOverlay() { if (_overlayEntry != null) return; _overlayEntry = _createOverlayEntry().also((it) { - Overlay.of(context, rootOverlay: widget.rootOverlay).insert(it); + Overlay.of(context, rootOverlay: widget.useRootOverlay).insert(it); widget.onDropdownShow?.call(); }); setState(() {}); @@ -242,7 +242,7 @@ class _DropdownSelectState extends State> { OverlayEntry _createOverlayEntry() => OverlayEntry( builder: (context) { void handleTapDown(TapDownDetails details) { - bool hitTest(RenderBox box) => box.hitTest( + bool didHit(RenderBox box) => box.hitTest( BoxHitTestResult(), position: box.globalToLocal(details.globalPosition), ); @@ -252,10 +252,10 @@ class _DropdownSelectState extends State> { final RenderObject? dropdownRenderObject = context.findRenderObject(); if (dropdownRenderObject is RenderBox && - hitTest(dropdownRenderObject)) { + didHit(dropdownRenderObject)) { // Touch on dropdown shouldn't close overlay } else if (inputFieldRenderObject is RenderBox && - hitTest(inputFieldRenderObject)) { + didHit(inputFieldRenderObject)) { if (widget.shouldCloseOnInputTap) _removeOverlay(); } else { _removeOverlay(); @@ -267,7 +267,7 @@ class _DropdownSelectState extends State> { behavior: HitTestBehavior.translucent, onTapDown: handleTapDown, child: DropdownTapInterceptor( - onTap: widget.multiselect ? () {} : _handleClose, + onTap: widget.allowMultipleSelection ? () {} : _handleClose, child: OptimusDropdown( items: widget.items, size: widget.size, @@ -308,7 +308,7 @@ class _DropdownSelectState extends State> { return PopScope( canPop: _canPop, onPopInvoked: _handleOnBackPressed, - child: widget.multiselect && _hasValues + child: widget.allowMultipleSelection && _hasValues ? MultiSelectInputField( values: _values ?? [], leading: leading, @@ -347,7 +347,7 @@ class _DropdownSelectState extends State> { helperMessage: widget.helperMessage, error: widget.error, size: widget.size, - readOnly: widget.readOnly, + isReadOnly: widget.isReadOnly, showCursor: widget.showCursor, showLoader: widget.showLoader, ), diff --git a/optimus/lib/src/expansion/expansion_tile.dart b/optimus/lib/src/expansion/expansion_tile.dart index bf0d3647..d7adcdc5 100644 --- a/optimus/lib/src/expansion/expansion_tile.dart +++ b/optimus/lib/src/expansion/expansion_tile.dart @@ -10,7 +10,7 @@ const Duration _kExpand = Duration(milliseconds: 200); class OptimusExpansionTile extends StatefulWidget { /// Creates a single-line [OptimusListTile] with a trailing button that expands or /// collapses the tile to reveal or hide the [children]. The - /// [initiallyExpanded] property must be non-null. + /// [isInitiallyExpanded] property must be non-null. const OptimusExpansionTile({ super.key, this.leading, @@ -20,7 +20,7 @@ class OptimusExpansionTile extends StatefulWidget { this.onExpansionChanged, this.children = const [], this.trailing, - this.initiallyExpanded = false, + this.isInitiallyExpanded = false, this.hasBorders = true, this.actionsWidth = 0, this.slidableActions = const [], @@ -62,7 +62,7 @@ class OptimusExpansionTile extends StatefulWidget { /// Specifies if the list tile is initially expanded (true) /// or collapsed (false, the default). - final bool initiallyExpanded; + final bool isInitiallyExpanded; /// Borders of the inner [OptimusSlidable] widget final bool hasBorders; @@ -104,7 +104,7 @@ class _OptimusExpansionTileState extends State _iconTurns = _controller.drive(_halfTween.chain(_easeInTween)); _isExpanded = (PageStorage.of(context).readState(context) ?? - widget.initiallyExpanded) as bool; + widget.isInitiallyExpanded) as bool; if (_isExpanded) _controller.value = 1.0; } @@ -141,7 +141,7 @@ class _OptimusExpansionTileState extends State @override Widget build(BuildContext context) { - final bool closed = !_isExpanded && _controller.isDismissed; + final bool isClosed = !_isExpanded && _controller.isDismissed; return AnimatedBuilder( animation: _controller.view, @@ -178,7 +178,7 @@ class _OptimusExpansionTileState extends State ], ); }, - child: closed ? null : Column(children: widget.children), + child: isClosed ? null : Column(children: widget.children), ); } } diff --git a/optimus/lib/src/feedback/alert.dart b/optimus/lib/src/feedback/alert.dart index 758caee4..4b91c784 100644 --- a/optimus/lib/src/feedback/alert.dart +++ b/optimus/lib/src/feedback/alert.dart @@ -1,4 +1,5 @@ import 'dart:math'; + import 'package:flutter/widgets.dart'; import 'package:optimus/optimus.dart'; import 'package:optimus/src/feedback/common.dart'; @@ -82,7 +83,7 @@ class OptimusAlert extends StatelessWidget { link?.onPressed(); OptimusAlertOverlay.of(context)?.remove(this); }, - dismissible: isDismissible, + isDismissible: isDismissible, ), if (isDismissible) Positioned( @@ -110,7 +111,7 @@ class _AlertContent extends StatelessWidget { required this.variant, required this.title, required this.description, - required this.dismissible, + required this.isDismissible, this.onLinkPressed, this.linkText, }); @@ -121,11 +122,11 @@ class _AlertContent extends StatelessWidget { final Widget? description; final Widget? linkText; final VoidCallback? onLinkPressed; - final bool dismissible; + final bool isDismissible; bool get _isExpanded => description != null || linkText != null; - EdgeInsets _getContentPadding(OptimusTokens tokens) => dismissible + EdgeInsets _getContentPadding(OptimusTokens tokens) => isDismissible ? EdgeInsets.fromLTRB( tokens.spacing200, tokens.spacing200, diff --git a/optimus/lib/src/feedback/alert_overlay.dart b/optimus/lib/src/feedback/alert_overlay.dart index cca2124a..284b47fa 100644 --- a/optimus/lib/src/feedback/alert_overlay.dart +++ b/optimus/lib/src/feedback/alert_overlay.dart @@ -120,7 +120,7 @@ class _OptimusAlertOverlayState extends State child: AnimatedList( key: _listKey, shrinkWrap: true, - reverse: widget.position.reverse, + reverse: widget.position.isReversed, itemBuilder: (context, index, animation) => _AnimatedAlert( animation: animation, alert: _alerts[index], @@ -141,6 +141,7 @@ abstract class OptimusAlertManager { const OptimusAlertManager(); void show(OptimusAlert alert); + void remove(OptimusAlert alert); } @@ -263,7 +264,7 @@ extension on OptimusAlertPosition { Tween(begin: const Offset(1.0, 0.0), end: Offset.zero), }; - bool get reverse => switch (this) { + bool get isReversed => switch (this) { OptimusAlertPosition.topLeft || OptimusAlertPosition.topRight => false, OptimusAlertPosition.bottomLeft || OptimusAlertPosition.bottomRight => diff --git a/optimus/lib/src/form/checkbox_form_field.dart b/optimus/lib/src/form/checkbox_form_field.dart index 434e5b1d..4a504eb3 100644 --- a/optimus/lib/src/form/checkbox_form_field.dart +++ b/optimus/lib/src/form/checkbox_form_field.dart @@ -15,6 +15,7 @@ class OptimusCheckBoxFormField extends StatelessWidget { final Widget label; final ValueChanged? onSaved; + // ignore: prefer-boolean-prefixes, valid naming final bool initialValue; final bool isEnabled; final OptimusCheckboxSize size; diff --git a/optimus/lib/src/form/input_field.dart b/optimus/lib/src/form/input_field.dart index 49f0ecf4..cac75beb 100644 --- a/optimus/lib/src/form/input_field.dart +++ b/optimus/lib/src/form/input_field.dart @@ -28,8 +28,8 @@ class OptimusInputField extends StatefulWidget { this.error, this.errorVariant = OptimusInputErrorVariant.bottomHint, this.enableInteractiveSelection = true, - this.autofocus = false, - this.autocorrect = true, + this.enableAutoFocus = false, + this.enableAutoCorrect = true, this.hasBorders = true, this.isRequired = false, this.isFocused, @@ -40,7 +40,7 @@ class OptimusInputField extends StatefulWidget { this.trailing, this.inputKey, this.fieldBoxKey, - this.readOnly = false, + this.isReadOnly = false, this.onTap, this.textAlign = TextAlign.start, this.textCapitalization = TextCapitalization.none, @@ -51,8 +51,8 @@ class OptimusInputField extends StatefulWidget { this.keyboardAppearance, this.enableIMEPersonalizedLearning = true, this.enableSuggestions = true, - this.inline = false, - this.autoCollapse = false, + this.isInlined = false, + this.enableAutoCollapse = false, this.statusBarState, }); @@ -98,11 +98,11 @@ class OptimusInputField extends StatefulWidget { final bool enableInteractiveSelection; /// {@macro flutter.widgets.editableText.autofocus} - final bool autofocus; + final bool enableAutoFocus; final bool? isFocused; /// {@macro flutter.widgets.editableText.autocorrect} - final bool autocorrect; + final bool enableAutoCorrect; final bool hasBorders; final bool isRequired; @@ -129,7 +129,7 @@ class OptimusInputField extends StatefulWidget { final Widget? trailing; /// {@macro flutter.widgets.editableText.readOnly} - final bool readOnly; + final bool isReadOnly; /// The callback to be called when the field is tapped. final VoidCallback? onTap; @@ -169,11 +169,11 @@ class OptimusInputField extends StatefulWidget { /// Controls whether the components should be inside the input field or /// outside, wrapping it. The inline variant is more dense and is smaller in /// the vertical direction. - final bool inline; + final bool isInlined; /// Controls whether the input should collapse to one line height if not /// focused. - final bool autoCollapse; + final bool enableAutoCollapse; final OptimusStatusBarState? statusBarState; @@ -220,7 +220,7 @@ class _OptimusInputFieldState extends State @override void didUpdateWidget(OptimusInputField oldWidget) { super.didUpdateWidget(oldWidget); - if (widget.autoCollapse != oldWidget.autoCollapse || + if (widget.enableAutoCollapse != oldWidget.enableAutoCollapse || widget.minLines != oldWidget.minLines || widget.maxLines != oldWidget.maxLines) { _updateLines(); @@ -229,7 +229,7 @@ class _OptimusInputFieldState extends State bool get _shouldShowInlineError => (widget.errorVariant == OptimusInputErrorVariant.inlineTooltip || - widget.inline) && + widget.isInlined) && widget.hasError; void _handleClearAllTap() { @@ -243,7 +243,7 @@ class _OptimusInputFieldState extends State bool get _shouldShowSuffix => widget.suffix != null || widget.trailing != null || - (widget.inline && widget.maxCharacters != null) || + (widget.isInlined && widget.maxCharacters != null) || widget.showLoader || widget.isPasswordField || _shouldShowClearAllButton || @@ -255,10 +255,10 @@ class _OptimusInputFieldState extends State widget.isPasswordField && !widget.showLoader; bool get _shouldCollapse => - widget.autoCollapse && !_effectiveFocusNode.hasFocus; + widget.enableAutoCollapse && !_effectiveFocusNode.hasFocus; void _handleFocusUpdate() => setState(() { - if (!widget.autoCollapse) return; + if (!widget.enableAutoCollapse) return; _updateLines(); }); @@ -313,9 +313,9 @@ class _OptimusInputFieldState extends State errorVariant: widget.errorVariant, hasBorders: widget.hasBorders, isRequired: widget.isRequired, - inline: widget.inline, - multiline: widget.minLines != null, - inputCounter: widget.inline ? null : counter, + isInlined: widget.isInlined, + hasMultipleLines: widget.minLines != null, + inputCounter: widget.isInlined ? null : counter, statusBarState: widget.statusBarState, prefix: _shouldShowPrefix ? Prefix(prefix: widget.prefix, leading: widget.leading) @@ -324,7 +324,7 @@ class _OptimusInputFieldState extends State ? Suffix( suffix: widget.suffix, trailing: widget.trailing, - counter: widget.inline ? counter : null, + counter: widget.isInlined ? counter : null, passwordButton: _isPasswordToggleVisible ? _PasswordButton( onTap: _handlePasswordTap, @@ -356,8 +356,8 @@ class _OptimusInputFieldState extends State enableSuggestions: widget.enableSuggestions, textCapitalization: widget.textCapitalization, cursorColor: theme.tokens.textStaticSecondary, - autocorrect: widget.autocorrect, - autofocus: widget.autofocus, + autocorrect: widget.enableAutoCorrect, + autofocus: widget.enableAutoFocus, enableInteractiveSelection: widget.enableInteractiveSelection, controller: _effectiveController, maxLines: _maxLines, @@ -379,7 +379,7 @@ class _OptimusInputFieldState extends State keyboardType: widget.keyboardType, obscureText: widget.isPasswordField && !_isShowPasswordEnabled, onTap: widget.onTap, - readOnly: widget.readOnly, + readOnly: widget.isReadOnly, showCursor: widget.showCursor, inputFormatters: widget.inputFormatters, keyboardAppearance: widget.keyboardAppearance ?? theme.brightness, diff --git a/optimus/lib/src/form/input_form_field.dart b/optimus/lib/src/form/input_form_field.dart index ab7e7969..fad54e9f 100644 --- a/optimus/lib/src/form/input_form_field.dart +++ b/optimus/lib/src/form/input_form_field.dart @@ -72,8 +72,8 @@ class OptimusInputFormField extends FormField { controller: state._effectiveController, error: field.errorText, enableInteractiveSelection: enableInteractiveSelection, - autofocus: autofocus, - autocorrect: autocorrect, + enableAutoFocus: autofocus, + enableAutoCorrect: autocorrect, hasBorders: hasBorders, isRequired: isRequired, leading: leading, @@ -81,7 +81,7 @@ class OptimusInputFormField extends FormField { suffix: suffix, trailing: trailing, inputKey: inputKey, - readOnly: readOnly, + isReadOnly: readOnly, showCursor: showCursor, onTap: onTap, textAlign: textAlign, diff --git a/optimus/lib/src/form/password_form_field.dart b/optimus/lib/src/form/password_form_field.dart index 8dec9e7e..d8e756d3 100644 --- a/optimus/lib/src/form/password_form_field.dart +++ b/optimus/lib/src/form/password_form_field.dart @@ -23,11 +23,11 @@ class OptimusPasswordFormField extends StatelessWidget { this.minLines, this.maxCharacters, this.enableInteractiveSelection = true, - this.autofocus = false, + this.enableAutoFocus = false, this.hasBorders = true, this.isRequired = false, this.inputKey, - this.readOnly = false, + this.isReadOnly = false, this.showCursor, this.showLoader = false, this.onTap, @@ -90,7 +90,7 @@ class OptimusPasswordFormField extends StatelessWidget { final bool enableInteractiveSelection; /// Whether the form field has to be autofocused. Defaults to false. - final bool autofocus; + final bool enableAutoFocus; /// Whether the form field has borders. Defaults to true. final bool hasBorders; @@ -102,7 +102,7 @@ class OptimusPasswordFormField extends StatelessWidget { final Key? inputKey; /// Whether the form field is read-only. Defaults to false. - final bool readOnly; + final bool isReadOnly; /// Whether the cursor is shown. final bool? showCursor; @@ -157,11 +157,11 @@ class OptimusPasswordFormField extends StatelessWidget { minLines: minLines, maxCharacters: maxCharacters, enableInteractiveSelection: enableInteractiveSelection, - autofocus: autofocus, + autofocus: enableAutoFocus, hasBorders: hasBorders, isRequired: isRequired, inputKey: inputKey, - readOnly: readOnly, + readOnly: isReadOnly, showCursor: showCursor, onTap: onTap, textAlign: textAlign, diff --git a/optimus/lib/src/form/select_input_form_field.dart b/optimus/lib/src/form/select_input_form_field.dart index 6ddd4740..dfaa79c2 100644 --- a/optimus/lib/src/form/select_input_form_field.dart +++ b/optimus/lib/src/form/select_input_form_field.dart @@ -14,7 +14,7 @@ class OptimusSelectInputFormField extends FormField { required ValueBuilder builder, required List> items, ValueChanged? onChanged, - bool multiselect = false, + bool allowMultipleSelection = false, List? values, }) : super( builder: (FormFieldState field) => OptimusSelectInput( @@ -29,8 +29,8 @@ class OptimusSelectInputFormField extends FormField { field.didChange(v); onChanged?.call(v); }, - multiselect: multiselect, - selectedValues: multiselect ? values : null, + allowMultipleSelection: allowMultipleSelection, + selectedValues: allowMultipleSelection ? values : null, ), ); } diff --git a/optimus/lib/src/form/stepper_form_field.dart b/optimus/lib/src/form/stepper_form_field.dart index 481a3d87..11ddbf24 100644 --- a/optimus/lib/src/form/stepper_form_field.dart +++ b/optimus/lib/src/form/stepper_form_field.dart @@ -41,7 +41,7 @@ class OptimusStepperFormField extends FormField { field.didChange(value); onChanged?.call(value); }, - enabled: enabled, + isEnabled: enabled, error: field.errorText, focusNode: focusNode, controller: controller, @@ -57,7 +57,7 @@ class _Stepper extends StatefulWidget { this.min = 0, this.max = 100, this.focusNode, - this.enabled = true, + this.isEnabled = true, this.error, this.controller, this.size = OptimusWidgetSize.large, @@ -68,7 +68,7 @@ class _Stepper extends StatefulWidget { final int min; final int max; final FocusNode? focusNode; - final bool enabled; + final bool isEnabled; final String? error; final TextEditingController? controller; final OptimusWidgetSize size; @@ -169,11 +169,11 @@ class _StepperState extends State<_Stepper> { size: widget.size, textAlign: TextAlign.center, error: widget.error, - isEnabled: widget.enabled, + isEnabled: widget.isEnabled, controller: _effectiveController, leading: _StepperButton( iconData: OptimusIcons.minus_simple, - onPressed: widget.enabled + onPressed: widget.isEnabled ? value == null || value > widget.min ? _handleMinusTap : null @@ -181,7 +181,7 @@ class _StepperState extends State<_Stepper> { ), trailing: _StepperButton( iconData: OptimusIcons.plus_simple, - onPressed: widget.enabled + onPressed: widget.isEnabled ? value == null || value < widget.max ? _handlePlusTap : null diff --git a/optimus/lib/src/form/text_area.dart b/optimus/lib/src/form/text_area.dart index faa51d79..fe2634f1 100644 --- a/optimus/lib/src/form/text_area.dart +++ b/optimus/lib/src/form/text_area.dart @@ -23,13 +23,13 @@ class OptimusTextArea extends StatelessWidget { this.error, this.errorVariant = OptimusInputErrorVariant.bottomHint, this.enableInteractiveSelection = true, - this.autofocus = false, + this.enableAutoFocus = false, this.isFocused, - this.autocorrect = true, + this.enableAutoCorrect = true, this.isRequired = false, this.inputKey, this.fieldBoxKey, - this.readOnly = false, + this.isReadOnly = false, this.onTap, this.textAlign = TextAlign.start, this.textCapitalization = TextCapitalization.none, @@ -39,9 +39,9 @@ class OptimusTextArea extends StatelessWidget { this.keyboardAppearance, this.enableIMEPersonalizedLearning = true, this.enableSuggestions = true, - this.inline = false, - this.autoSize = true, - this.autoCollapse = true, + this.isInlined = false, + this.enableAutoSize = true, + this.enableAutoCollapse = true, }); /// {@macro flutter.widgets.editableText.onChanged} @@ -103,13 +103,13 @@ class OptimusTextArea extends StatelessWidget { final bool enableInteractiveSelection; /// {@macro flutter.widgets.editableText.autofocus} - final bool autofocus; + final bool enableAutoFocus; /// Controls whether the field is focused. Overrides [focusNode] focus. final bool? isFocused; /// {@macro flutter.widgets.editableText.autocorrect} - final bool autocorrect; + final bool enableAutoCorrect; /// Defines whether the field is required. final bool isRequired; @@ -121,7 +121,7 @@ class OptimusTextArea extends StatelessWidget { final Key? fieldBoxKey; /// {@macro flutter.widgets.editableText.readOnly} - final bool readOnly; + final bool isReadOnly; /// The callback that will be called when the field is tapped. final VoidCallback? onTap; @@ -159,15 +159,15 @@ class OptimusTextArea extends StatelessWidget { /// Controls whether the components should be inside the input field or /// outside, wrapping it. The inline variant is more dense and is smaller in /// the vertical direction. - final bool inline; + final bool isInlined; /// Controls whether the text area should automatically adjust its height to /// fit the content. Defaults to true. - final bool autoSize; + final bool enableAutoSize; /// Controls whether the input should collapse to one line height if not /// focused. - final bool autoCollapse; + final bool enableAutoCollapse; @override Widget build(BuildContext context) => OptimusInputField( @@ -185,18 +185,18 @@ class OptimusTextArea extends StatelessWidget { helperMessage: helperMessage, maxLines: rows, maxCharacters: maxCharacters, - minLines: autoSize ? 1 : rows, + minLines: enableAutoSize ? 1 : rows, controller: controller, error: error, errorVariant: errorVariant, enableInteractiveSelection: enableInteractiveSelection, - autofocus: autofocus, + enableAutoFocus: enableAutoFocus, isFocused: isFocused, - autocorrect: autocorrect, + enableAutoCorrect: enableAutoCorrect, isRequired: isRequired, inputKey: inputKey, fieldBoxKey: fieldBoxKey, - readOnly: readOnly, + isReadOnly: isReadOnly, onTap: onTap, textAlign: textAlign, textCapitalization: textCapitalization, @@ -206,7 +206,7 @@ class OptimusTextArea extends StatelessWidget { keyboardAppearance: keyboardAppearance, enableIMEPersonalizedLearning: enableIMEPersonalizedLearning, enableSuggestions: enableSuggestions, - inline: inline, - autoCollapse: autoCollapse, + isInlined: isInlined, + enableAutoCollapse: enableAutoCollapse, ); } diff --git a/optimus/lib/src/link/base_link.dart b/optimus/lib/src/link/base_link.dart index 19b09a0c..7d04fd09 100644 --- a/optimus/lib/src/link/base_link.dart +++ b/optimus/lib/src/link/base_link.dart @@ -13,8 +13,8 @@ class BaseLink extends StatefulWidget { this.icon, this.onPressed, this.overflow, - this.inherit = false, - this.strong = false, + this.shouldInherit = false, + this.useStrong = false, this.variant = OptimusLinkVariant.primary, }); @@ -22,8 +22,8 @@ class BaseLink extends StatefulWidget { final TextStyle? textStyle; final Widget text; final Widget? icon; - final bool strong; - final bool inherit; + final bool useStrong; + final bool shouldInherit; final TextOverflow? overflow; final OptimusLinkVariant variant; @@ -41,7 +41,7 @@ class _BaseLinkState extends State with ThemeGetter { void _handlePressedChange(bool isPressed) => setState(() => _isPressed = isPressed); - Color get _effectiveColor => widget.inherit ? _inheritedColor : _color; + Color get _effectiveColor => widget.shouldInherit ? _inheritedColor : _color; Color get _color { if (!_isEnabled) return widget.variant.getDisabledColor(tokens); @@ -66,7 +66,7 @@ class _BaseLinkState extends State with ThemeGetter { style: _textStyle.copyWith( color: _effectiveColor, overflow: widget.overflow, - fontWeight: widget.strong ? FontWeight.w500 : FontWeight.w400, + fontWeight: widget.useStrong ? FontWeight.w500 : FontWeight.w400, decoration: _isHovering ? null : TextDecoration.underline, ), child: widget.text, @@ -105,13 +105,16 @@ extension on OptimusLinkVariant { OptimusLinkVariant.primary => tokens.textInteractivePrimaryDefault, OptimusLinkVariant.basic => tokens.textStaticPrimary, }; + Color getHoveredColor(OptimusTokens tokens) => switch (this) { OptimusLinkVariant.primary => tokens.textInteractivePrimaryHover, OptimusLinkVariant.basic => tokens.textStaticTertiary, }; + Color getTappedColor(OptimusTokens tokens) => switch (this) { OptimusLinkVariant.primary => tokens.textInteractivePrimaryActive, OptimusLinkVariant.basic => tokens.textStaticPrimary, }; + Color getDisabledColor(OptimusTokens tokens) => tokens.textDisabled; } diff --git a/optimus/lib/src/link/inline_link.dart b/optimus/lib/src/link/inline_link.dart index 53642817..684f4cb0 100644 --- a/optimus/lib/src/link/inline_link.dart +++ b/optimus/lib/src/link/inline_link.dart @@ -16,8 +16,8 @@ class OptimusInlineLink extends StatelessWidget { this.textStyle, this.onPressed, this.overflow, - this.inherit = false, - this.strong = false, + this.shouldInherit = false, + this.useStrong = false, this.variant = OptimusLinkVariant.primary, }); @@ -30,7 +30,7 @@ class OptimusInlineLink extends StatelessWidget { final Widget text; /// Controls if link should inherit parent style. - final bool inherit; + final bool shouldInherit; /// Controls the link's text overflowing. final TextOverflow? overflow; @@ -39,7 +39,7 @@ class OptimusInlineLink extends StatelessWidget { final TextStyle? textStyle; /// Defines the weight of the font. - final bool strong; + final bool useStrong; /// Link color variant. final OptimusLinkVariant variant; @@ -48,10 +48,10 @@ class OptimusInlineLink extends StatelessWidget { Widget build(BuildContext context) => BaseLink( text: text, textStyle: textStyle, - inherit: inherit, + shouldInherit: shouldInherit, onPressed: onPressed, overflow: overflow, variant: variant, - strong: strong, + useStrong: useStrong, ); } diff --git a/optimus/lib/src/link/standalone_link.dart b/optimus/lib/src/link/standalone_link.dart index faa1b446..9d6d568f 100644 --- a/optimus/lib/src/link/standalone_link.dart +++ b/optimus/lib/src/link/standalone_link.dart @@ -26,9 +26,9 @@ class OptimusStandaloneLink extends StatelessWidget { required this.text, this.size, this.overflow, - this.inherit = false, + this.shouldInherit = false, this.isExternal = false, - this.strong = false, + this.useStrong = false, this.variant = OptimusLinkVariant.primary, }); @@ -41,7 +41,7 @@ class OptimusStandaloneLink extends StatelessWidget { final Widget text; /// Controls if link should inherit parent style. - final bool inherit; + final bool shouldInherit; /// Controls if link is external and icon should be displayed. final bool isExternal; @@ -50,20 +50,21 @@ class OptimusStandaloneLink extends StatelessWidget { final TextOverflow? overflow; /// Weight of the font. - final bool strong; + final bool useStrong; /// Link size. final OptimusStandaloneLinkSize? size; // Link color variant. final OptimusLinkVariant variant; + @override Widget build(BuildContext context) => BaseLink( text: text, textStyle: DefaultTextStyle.of(context).style.copyWith( fontSize: size?.getFontSize(context.tokens), ), - inherit: inherit, + shouldInherit: shouldInherit, onPressed: onPressed, overflow: overflow, icon: isExternal @@ -73,7 +74,7 @@ class OptimusStandaloneLink extends StatelessWidget { ) : null, variant: variant, - strong: strong, + useStrong: useStrong, ); } diff --git a/optimus/lib/src/overlay_controller.dart b/optimus/lib/src/overlay_controller.dart index c58bebc2..bccf570b 100644 --- a/optimus/lib/src/overlay_controller.dart +++ b/optimus/lib/src/overlay_controller.dart @@ -17,7 +17,7 @@ class OverlayController extends StatefulWidget { this.width, this.onShown, this.onHidden, - this.rootOverlay = false, + this.useRootOverlay = false, }); final Widget child; @@ -29,7 +29,7 @@ class OverlayController extends StatefulWidget { final GlobalKey anchorKey; final VoidCallback? onShown; final VoidCallback? onHidden; - final bool rootOverlay; + final bool useRootOverlay; final OptimusWidgetSize size; @override @@ -61,7 +61,7 @@ class _OverlayControllerState extends State> { void _showOverlay() { if (_overlayEntry != null) return; _overlayEntry = _createOverlayEntry().also((it) { - Overlay.of(context, rootOverlay: widget.rootOverlay).insert(it); + Overlay.of(context, rootOverlay: widget.useRootOverlay).insert(it); }); widget.onShown?.call(); diff --git a/optimus/lib/src/progress_indicator/progress_indicator.dart b/optimus/lib/src/progress_indicator/progress_indicator.dart index 04ff3f40..37d88698 100644 --- a/optimus/lib/src/progress_indicator/progress_indicator.dart +++ b/optimus/lib/src/progress_indicator/progress_indicator.dart @@ -236,12 +236,12 @@ class _VerticalProgressIndicatorState extends State<_VerticalProgressIndicator> @override Widget build(BuildContext context) { - final bool closed = !_isExpanded && _animationController.isDismissed; + final bool isClosed = !_isExpanded && _animationController.isDismissed; final items = widget.items; final headerItem = _isExpanded ? widget.items.first : _currentItem; final Widget result = Offstage( - offstage: closed, + offstage: isClosed, child: AllowMultipleRawGestureDetector( onTap: _handleTap, child: Column( diff --git a/optimus/lib/src/progress_indicator/progress_indicator_item.dart b/optimus/lib/src/progress_indicator/progress_indicator_item.dart index 18f1ea5f..adad51ae 100644 --- a/optimus/lib/src/progress_indicator/progress_indicator_item.dart +++ b/optimus/lib/src/progress_indicator/progress_indicator_item.dart @@ -82,8 +82,8 @@ class _ProgressIndicatorItemState extends State final itemsCount = widget.itemsCount; return GestureWrapper( - onHoverChanged: (value) => setState(() => _isHovered = value), - onPressedChanged: (value) => setState(() => _isPressed = value), + onHoverChanged: (isHovered) => setState(() => _isHovered = isHovered), + onPressedChanged: (isPressed) => setState(() => _isPressed = isPressed), child: switch (widget.axis) { Axis.horizontal => _HorizontalItem( indicator: indicator, @@ -292,8 +292,8 @@ class ProgressIndicatorSpacer extends StatelessWidget { @override Widget build(BuildContext context) { final tokens = context.tokens; - final enabled = nextItemState.isAccessible; - final color = enabled + final isEnabled = nextItemState.isAccessible; + final color = isEnabled ? tokens.borderInteractivePrimaryDefault : tokens.borderStaticPrimary; diff --git a/optimus/lib/src/search/search_field.dart b/optimus/lib/src/search/search_field.dart index 865ce550..96e63cac 100644 --- a/optimus/lib/src/search/search_field.dart +++ b/optimus/lib/src/search/search_field.dart @@ -24,7 +24,7 @@ class OptimusSearch extends StatelessWidget { this.helperMessage, this.error, this.size = OptimusWidgetSize.large, - this.readOnly = false, + this.isReadOnly = false, this.showCursor, this.prefix, this.suffix, @@ -110,7 +110,7 @@ class OptimusSearch extends StatelessWidget { final bool? showCursor; /// {@macro flutter.widgets.editableText.readOnly} - final bool readOnly; + final bool isReadOnly; /// {@macro optimus.select.groupBy} final Grouper? groupBy; @@ -138,7 +138,7 @@ class OptimusSearch extends StatelessWidget { helperMessage: helperMessage, error: error, size: size, - readOnly: readOnly, + isReadOnly: isReadOnly, showCursor: showCursor, prefix: prefix, suffix: suffix, diff --git a/optimus/lib/src/select_input.dart b/optimus/lib/src/select_input.dart index 6ea37c18..73cde4f4 100644 --- a/optimus/lib/src/select_input.dart +++ b/optimus/lib/src/select_input.dart @@ -33,13 +33,13 @@ class OptimusSelectInput extends StatefulWidget { this.controller, this.onTextChanged, this.focusNode, - this.readOnly, + this.isReadOnly, this.showLoader = false, this.emptyResultPlaceholder, this.embeddedSearch, this.groupBy, this.groupBuilder, - this.multiselect = false, + this.allowMultipleSelection = false, this.selectedValues, }); @@ -68,7 +68,7 @@ class OptimusSelectInput extends StatefulWidget { final ValueSetter onChanged; final TextEditingController? controller; final ValueSetter? onTextChanged; - final bool? readOnly; + final bool? isReadOnly; /// An embedded search field that can be used to filter the list of items. /// Will be displayed as a part of the dropdown menu. If the [controller] or @@ -94,7 +94,7 @@ class OptimusSelectInput extends StatefulWidget { /// If enabled, you can select multiple items at the same time. /// State of the selected items is managed outside this widget and has to be /// set in [selectedValues]. - final bool multiselect; + final bool allowMultipleSelection; /// List of selected values. Would be omitted if the multiselect is disabled. final List? selectedValues; @@ -189,7 +189,7 @@ class _OptimusSelectInput extends State> : tokens.textStaticPrimary : tokens.textDisabled; - T? get _value => widget.multiselect ? null : widget.value; + T? get _value => widget.allowMultipleSelection ? null : widget.value; @override Widget build(BuildContext context) => DropdownSelect( @@ -214,10 +214,11 @@ class _OptimusSelectInput extends State> focusNode: _effectiveFocusNode, placeholderStyle: _textStyle, controller: _effectiveController, - readOnly: widget.readOnly ?? !_isUsingInlineSearch, + isReadOnly: widget.isReadOnly ?? !_isUsingInlineSearch, showCursor: _isUsingInlineSearch, showLoader: widget.showLoader, - shouldCloseOnInputTap: !widget.multiselect || !_isUsingInlineSearch, + shouldCloseOnInputTap: + !widget.allowMultipleSelection || !_isUsingInlineSearch, emptyResultPlaceholder: widget.emptyResultPlaceholder, embeddedSearch: _isUsingEmbeddedSearch ? widget.embeddedSearch : null, onDropdownShow: @@ -226,7 +227,7 @@ class _OptimusSelectInput extends State> _isUsingEmbeddedSearch ? _animationController.reverse : null, groupBy: widget.groupBy, groupBuilder: widget.groupBuilder, - multiselect: widget.multiselect, + allowMultipleSelection: widget.allowMultipleSelection, selectedValues: widget.selectedValues, builder: widget.builder, ); diff --git a/optimus/lib/src/tabs.dart b/optimus/lib/src/tabs.dart index df59c4a4..f9abfe7f 100644 --- a/optimus/lib/src/tabs.dart +++ b/optimus/lib/src/tabs.dart @@ -54,7 +54,7 @@ class OptimusTab extends StatelessWidget { constraints: BoxConstraints(maxWidth: tokens.sizing400), child: BaseBadge( text: badge, - outline: false, + isOutlined: false, textColor: badgeVariant.getTextColor(tokens), backgroundColor: badgeVariant.getBackgroundColor(tokens), ), diff --git a/optimus/lib/src/tag.dart b/optimus/lib/src/tag.dart index 08cf73e3..c10760ce 100644 --- a/optimus/lib/src/tag.dart +++ b/optimus/lib/src/tag.dart @@ -19,7 +19,7 @@ class OptimusTag extends StatelessWidget { this.colorOption = OptimusColorOption.basic, this.leadingIcon, this.trailingIcon, - this.outline = false, + this.isOutlined = false, }); /// The text to display in the tag. @@ -37,7 +37,7 @@ class OptimusTag extends StatelessWidget { final OptimusColorOption colorOption; /// Whether the tag should use the outlined style. - final bool outline; + final bool isOutlined; /// Optional leading icon of the tag. final IconData? leadingIcon; @@ -56,7 +56,7 @@ class OptimusTag extends StatelessWidget { borderColor: colorOption.borderColor(tokens), leadingIcon: leadingIcon, trailingIcon: trailingIcon, - outline: outline, + isOutlined: isOutlined, ); } } @@ -89,7 +89,7 @@ class OptimusCategoricalTag extends StatelessWidget { required this.colorOption, this.leadingIcon, this.trailingIcon, - this.outline = false, + this.isOutlined = false, }); /// Text of the tag. @@ -105,7 +105,7 @@ class OptimusCategoricalTag extends StatelessWidget { final IconData? trailingIcon; /// Whether to use outlined tag style. - final bool outline; + final bool isOutlined; @override Widget build(BuildContext context) { @@ -118,7 +118,7 @@ class OptimusCategoricalTag extends StatelessWidget { borderColor: colorOption.borderColor(tokens), leadingIcon: leadingIcon, trailingIcon: trailingIcon, - outline: outline, + isOutlined: isOutlined, ); } } @@ -131,7 +131,7 @@ class _Tag extends StatelessWidget { required this.borderColor, this.leadingIcon, this.trailingIcon, - this.outline = false, + this.isOutlined = false, }); final String text; @@ -140,7 +140,7 @@ class _Tag extends StatelessWidget { final Color borderColor; final IconData? leadingIcon; final IconData? trailingIcon; - final bool outline; + final bool isOutlined; @override Widget build(BuildContext context) { @@ -148,8 +148,8 @@ class _Tag extends StatelessWidget { return Container( decoration: BoxDecoration( - color: outline ? null : backgroundColor, - border: outline + color: isOutlined ? null : backgroundColor, + border: isOutlined ? Border.all( color: borderColor, width: tokens.borderWidth150, diff --git a/optimus/lib/src/tooltip/tooltip_controller.dart b/optimus/lib/src/tooltip/tooltip_controller.dart index 31cec981..dfa1051b 100644 --- a/optimus/lib/src/tooltip/tooltip_controller.dart +++ b/optimus/lib/src/tooltip/tooltip_controller.dart @@ -63,12 +63,12 @@ class _TooltipControllerState extends State { ), ); - void _handleShow({bool autoHide = true}) { + void _handleShow({bool enableAutoHide = true}) { if (_entry != null) return; _entry = _createEntry().also((it) { Overlay.of(context).insert(it); - if (autoHide) Future.delayed(widget.autoHideDuration, _handleHide); + if (enableAutoHide) Future.delayed(widget.autoHideDuration, _handleHide); }); } @@ -80,7 +80,7 @@ class _TooltipControllerState extends State { @override Widget build(BuildContext context) => MouseRegion( - onEnter: (_) => _handleShow(autoHide: false), + onEnter: (_) => _handleShow(enableAutoHide: false), onExit: (_) => _handleHide(), child: GestureDetector( onTap: _handleShow, diff --git a/optimus/lib/src/tooltip/tooltip_overlay.dart b/optimus/lib/src/tooltip/tooltip_overlay.dart index 49f1eabd..9356df30 100644 --- a/optimus/lib/src/tooltip/tooltip_overlay.dart +++ b/optimus/lib/src/tooltip/tooltip_overlay.dart @@ -26,7 +26,7 @@ class TooltipOverlay extends StatefulWidget { super.key, required this.anchorKey, required this.tooltip, - this.rootOverlay = false, + this.useRootOverlay = false, required this.tooltipKey, this.position, }); @@ -41,7 +41,7 @@ class TooltipOverlay extends StatefulWidget { final OptimusTooltip tooltip; /// Whether the tooltip should use the root overlay. - final bool rootOverlay; + final bool useRootOverlay; /// Position of the tooltip relative to the child widget. If not specified, /// the tooltip will be positioned automatically. Depending on the space @@ -281,7 +281,7 @@ class TooltipOverlayState extends State } RenderBox? _getOverlay() => - Overlay.of(context, rootOverlay: widget.rootOverlay) + Overlay.of(context, rootOverlay: widget.useRootOverlay) .context .findRenderObject() as RenderBox?; diff --git a/remote_logger/lib/src/remote_logger.dart b/remote_logger/lib/src/remote_logger.dart index 3c65c1fd..44053939 100644 --- a/remote_logger/lib/src/remote_logger.dart +++ b/remote_logger/lib/src/remote_logger.dart @@ -62,6 +62,7 @@ class RemoteLogger { final GetHeaders _getHeaders; Duration _currentTimeout = _initialTimeout; + // ignore: dispose-class-fields, we don't want to dispose a user-provided client. final Client? _client; Client? _internalClient; @@ -84,6 +85,7 @@ class RemoteLogger { /// /// `true` means either the record was posted or the error was not retriable, /// in any case we can move to the next record. + // ignore: prefer-boolean-prefixes, a valid name with a bool result Future _processRecord(String record) async { try { final headers = await _getHeaders(_defaultHeaders); diff --git a/storybook/lib/stories/avatar.dart b/storybook/lib/stories/avatar.dart index 6b3a4ff3..f9fc825d 100644 --- a/storybook/lib/stories/avatar.dart +++ b/storybook/lib/stories/avatar.dart @@ -15,7 +15,7 @@ final avatarStory = Story( final hasIndicator = k.boolean(label: 'Has indicator', initial: false); final useImage = k.boolean(label: 'Use image', initial: false); - final errorLoading = k.boolean(label: 'Error loading', initial: false); + final isErrorLoading = k.boolean(label: 'Error loading', initial: false); final title = k.text(label: 'Title', initial: 'User'); final useBadge = k.boolean(label: 'Use badge', initial: false); @@ -23,7 +23,7 @@ final avatarStory = Story( child: OptimusAvatar( title: title, imageUrl: useImage - ? errorLoading + ? isErrorLoading ? _badUrl : _avatarUrl : null, diff --git a/storybook/lib/stories/button/toggle.dart b/storybook/lib/stories/button/toggle.dart index 2af325f6..bf836559 100644 --- a/storybook/lib/stories/button/toggle.dart +++ b/storybook/lib/stories/button/toggle.dart @@ -13,22 +13,23 @@ final toggleButtonStory = Story( initial: OptimusToggleButtonSizeVariant.large, options: OptimusToggleButtonSizeVariant.values.toOptions(), ); - final label = k.boolean(label: 'Label', initial: true); + final hasLabel = k.boolean(label: 'Label', initial: true); return Center( - child: _ToggleExample(label: label, isEnabled: isEnabled, size: size), + child: + _ToggleExample(hasLabel: hasLabel, isEnabled: isEnabled, size: size), ); }, ); class _ToggleExample extends StatefulWidget { const _ToggleExample({ - required this.label, + required this.hasLabel, required this.isEnabled, required this.size, }); - final bool label; + final bool hasLabel; final bool isEnabled; final OptimusToggleButtonSizeVariant size; @@ -43,7 +44,7 @@ class _ToggleExampleState extends State<_ToggleExample> { @override Widget build(BuildContext context) => OptimusToggleButton( - label: widget.label ? Text(_label) : null, + label: widget.hasLabel ? Text(_label) : null, isToggled: _isToggled, isLoading: _isLoading, onPressed: widget.isEnabled diff --git a/storybook/lib/stories/card.dart b/storybook/lib/stories/card.dart index e5da8700..68c09ff7 100644 --- a/storybook/lib/stories/card.dart +++ b/storybook/lib/stories/card.dart @@ -30,7 +30,7 @@ final Story cardStory = Story( initial: OptimusCardCornerRadius.medium, options: OptimusCardCornerRadius.values.toOptions(), ), - outline: k.boolean(label: 'Outline', initial: true), + isOutlined: k.boolean(label: 'Outline', initial: true), child: const _Content(), ); }, @@ -62,7 +62,7 @@ final Story nestedCardStory = Story( initial: OptimusCardCornerRadius.medium, options: OptimusCardCornerRadius.values.toOptions(), ), - outline: k.boolean(label: 'Outline', initial: false), + isOutlined: k.boolean(label: 'Outline', initial: false), child: const _Content(), ); }, diff --git a/storybook/lib/stories/checkbox.dart b/storybook/lib/stories/checkbox.dart index db072a6a..470ba138 100644 --- a/storybook/lib/stories/checkbox.dart +++ b/storybook/lib/stories/checkbox.dart @@ -18,9 +18,9 @@ class _CheckboxStory extends StatefulWidget { } class _CheckboxStoryState extends State<_CheckboxStory> { - bool _checked = false; + bool _isChecked = false; - void _handleChanged(bool isChecked) => setState(() => _checked = isChecked); + void _handleChanged(bool isChecked) => setState(() => _isChecked = isChecked); @override Widget build(BuildContext context) { @@ -38,7 +38,7 @@ class _CheckboxStoryState extends State<_CheckboxStory> { options: OptimusCheckboxSize.values.toOptions(), initial: OptimusCheckboxSize.large, ), - isChecked: _checked, + isChecked: _isChecked, onChanged: _handleChanged, ), ), diff --git a/storybook/lib/stories/checkbox_nested.dart b/storybook/lib/stories/checkbox_nested.dart index 626a611f..197f8279 100644 --- a/storybook/lib/stories/checkbox_nested.dart +++ b/storybook/lib/stories/checkbox_nested.dart @@ -22,19 +22,19 @@ class _CheckboxGroupStory extends StatefulWidget { class _CheckboxGroupStoryState extends State<_CheckboxGroupStory> { // ignore: avoid-duplicate-collection-elements, duplicity is intentional final List _values = [false, true, false, false, false]; - bool _outsideCheckbox = false; + bool _isRootChecked = false; - void _handleChanged(int position, bool value) => - setState(() => _values[position] = value); + void _handleChanged(int position, bool isChecked) => + setState(() => _values[position] = isChecked); - void _handleOutsideChanged(bool value) => - setState(() => _outsideCheckbox = value); + void _handleRootChanged(bool isRootChecked) => + setState(() => _isRootChecked = isRootChecked); @override Widget build(BuildContext context) { final k = widget.knobs; - final enabled = k.boolean(label: 'Enabled', initial: true); + final isEnabled = k.boolean(label: 'Enabled', initial: true); return Center( child: Column( @@ -42,40 +42,40 @@ class _CheckboxGroupStoryState extends State<_CheckboxGroupStory> { children: [ OptimusCheckbox( label: const Text('Outside Checkbox'), - isChecked: _outsideCheckbox, - isEnabled: enabled, - onChanged: _handleOutsideChanged, + isChecked: _isRootChecked, + isEnabled: isEnabled, + onChanged: _handleRootChanged, ), OptimusNestedCheckboxGroup( parent: const Text('Parent'), label: k.text(label: 'Label'), error: k.text(label: 'Error'), - isEnabled: enabled, + isEnabled: isEnabled, children: [ OptimusNestedCheckbox( label: const Text('Checkbox 1'), isChecked: _values.first, - onChanged: (bool value) => _handleChanged(0, value), + onChanged: (bool isChecked) => _handleChanged(0, isChecked), ), OptimusNestedCheckbox( label: const Text('Checkbox 2'), isChecked: _values[1], - onChanged: (bool value) => _handleChanged(1, value), + onChanged: (bool isChecked) => _handleChanged(1, isChecked), ), OptimusNestedCheckbox( isChecked: _values[2], label: const Text('Checkbox 3'), - onChanged: (bool value) => _handleChanged(2, value), + onChanged: (bool isChecked) => _handleChanged(2, isChecked), ), OptimusNestedCheckbox( isChecked: _values[3], label: const Text('Checkbox 4'), - onChanged: (bool value) => _handleChanged(3, value), + onChanged: (bool isChecked) => _handleChanged(3, isChecked), ), OptimusNestedCheckbox( isChecked: _values.last, label: const Text('Checkbox 5'), - onChanged: (bool value) => _handleChanged(4, value), + onChanged: (bool isChecked) => _handleChanged(4, isChecked), ), ], ), diff --git a/storybook/lib/stories/date_input_field.dart b/storybook/lib/stories/date_input_field.dart index db26ecc5..bb07450e 100644 --- a/storybook/lib/stories/date_input_field.dart +++ b/storybook/lib/stories/date_input_field.dart @@ -9,6 +9,7 @@ final Story dateInputStory = Story( class _DateFieldExample extends StatefulWidget { const _DateFieldExample(); + @override State<_DateFieldExample> createState() => _DateFieldExampleState(); } @@ -26,7 +27,7 @@ class _DateFieldExampleState extends State<_DateFieldExample> { Widget build(BuildContext context) { final k = context.knobs; - final enabled = k.boolean(label: 'Enabled', initial: true); + final isEnabled = k.boolean(label: 'Enabled', initial: true); final error = k.text(label: 'Error'); final isClearEnabled = k.boolean(label: 'Clear all', initial: false); final String format = k.options( @@ -41,7 +42,7 @@ class _DateFieldExampleState extends State<_DateFieldExample> { label: 'Date', value: _value, error: error.isNotEmpty ? error : null, - isEnabled: enabled, + isEnabled: isEnabled, format: DateFormat(format), isClearAllEnabled: isClearEnabled, onSubmitted: (value) => setState(() => _value = value), diff --git a/storybook/lib/stories/date_input_form_field.dart b/storybook/lib/stories/date_input_form_field.dart index b1bf7b6b..791dbb54 100644 --- a/storybook/lib/stories/date_input_form_field.dart +++ b/storybook/lib/stories/date_input_form_field.dart @@ -7,7 +7,7 @@ final Story dateInputFormFieldStory = Story( builder: (context) { final k = context.knobs; - final enabled = k.boolean(label: 'Enabled', initial: true); + final isEnabled = k.boolean(label: 'Enabled', initial: true); final isClearEnabled = k.boolean(label: 'Clear all', initial: false); final String format = k.options( label: 'Format', @@ -20,7 +20,7 @@ final Story dateInputFormFieldStory = Story( child: OptimusDateInputFormField( label: 'Date', value: DateTime.now(), - isEnabled: enabled, + isEnabled: isEnabled, format: DateFormat(format), isClearAllEnabled: isClearEnabled, ), diff --git a/storybook/lib/stories/feedback/alert.dart b/storybook/lib/stories/feedback/alert.dart index e5bb0c9d..58aa59d1 100644 --- a/storybook/lib/stories/feedback/alert.dart +++ b/storybook/lib/stories/feedback/alert.dart @@ -20,7 +20,7 @@ class AlertStory extends StatelessWidget { final title = knobsBuilder.text(label: 'Title', initial: 'Title'); final description = knobsBuilder.text(label: 'Description', initial: ''); final link = knobsBuilder.text(label: 'Link text', initial: ''); - final dismissible = knobsBuilder.boolean(label: 'Is Dismissible'); + final isDismissible = knobsBuilder.boolean(label: 'Is Dismissible'); final position = knobsBuilder.options( label: 'Position', initial: OptimusAlertPosition.topRight, @@ -33,7 +33,7 @@ class AlertStory extends StatelessWidget { title: title, description: description, link: link, - dismissible: dismissible, + isDismissible: isDismissible, ), ); } @@ -44,13 +44,13 @@ class _AlertStoryContent extends StatelessWidget { required this.title, required this.description, required this.link, - required this.dismissible, + required this.isDismissible, }); final String title; final String description; final String link; - final bool dismissible; + final bool isDismissible; OptimusFeedbackLink? get _link => link.isNotEmpty ? OptimusFeedbackLink( @@ -72,7 +72,7 @@ class _AlertStoryContent extends StatelessWidget { description.isNotEmpty ? Text(description) : null, variant: variant, link: _link, - isDismissible: dismissible, + isDismissible: isDismissible, ), ), OptimusButton( @@ -83,7 +83,7 @@ class _AlertStoryContent extends StatelessWidget { description: description.isNotEmpty ? Text(description) : null, link: _link, - isDismissible: dismissible, + isDismissible: isDismissible, ), ); }, diff --git a/storybook/lib/stories/feedback/badge.dart b/storybook/lib/stories/feedback/badge.dart index fdbdb6f3..f84bb0b4 100644 --- a/storybook/lib/stories/feedback/badge.dart +++ b/storybook/lib/stories/feedback/badge.dart @@ -7,9 +7,9 @@ final Story badgeStory = Story( name: 'Feedback/Badge', builder: (context) { final knobs = context.knobs; - final grayBackground = + final useGrayBackground = knobs.boolean(label: 'Grey background', initial: true); - final outline = knobs.boolean(label: 'Outline', initial: true); + final isOutlined = knobs.boolean(label: 'Outline', initial: true); final variant = knobs.options( label: 'Variant', initial: OptimusBadgeVariant.values.first, @@ -19,12 +19,12 @@ final Story badgeStory = Story( return Container( width: 600, height: 400, - color: grayBackground ? Colors.grey : null, + color: useGrayBackground ? Colors.grey : null, child: Center( child: OptimusBadge( text: knobs.text(label: 'Content', initial: 'Info Text'), variant: variant, - outline: outline, + isOutlined: isOutlined, ), ), ); diff --git a/storybook/lib/stories/feedback/chip.dart b/storybook/lib/stories/feedback/chip.dart index eec901a1..0e0bd671 100644 --- a/storybook/lib/stories/feedback/chip.dart +++ b/storybook/lib/stories/feedback/chip.dart @@ -9,12 +9,12 @@ final chipStory = Story( final isEnabled = k.boolean(label: 'Enabled', initial: true); final text = k.text(label: 'Chip text', initial: 'Chip'); - final error = k.boolean(label: 'Error', initial: false); + final hasError = k.boolean(label: 'Error', initial: false); return OptimusChip( isEnabled: isEnabled, onRemoved: () {}, - hasError: error, + hasError: hasError, child: Text(text), ); }, diff --git a/storybook/lib/stories/feedback/tags.dart b/storybook/lib/stories/feedback/tags.dart index cfc0c703..38bf5276 100644 --- a/storybook/lib/stories/feedback/tags.dart +++ b/storybook/lib/stories/feedback/tags.dart @@ -8,7 +8,7 @@ final Story tagStory = Story( builder: (context) { final k = context.knobs; - final outline = k.boolean(label: 'Outlined', initial: false); + final isOutlined = k.boolean(label: 'Outlined', initial: false); final leadingIcon = k.options( label: 'Leading icon', initial: null, @@ -35,7 +35,7 @@ final Story tagStory = Story( leadingIcon: leadingIcon, trailingIcon: trailingIcon, colorOption: c, - outline: outline, + isOutlined: isOutlined, ), ), ) @@ -53,7 +53,7 @@ final Story tagStory = Story( leadingIcon: leadingIcon, trailingIcon: trailingIcon, colorOption: c, - outline: outline, + isOutlined: isOutlined, ), ), ) diff --git a/storybook/lib/stories/form/form_story.dart b/storybook/lib/stories/form/form_story.dart index c5c57e06..03f583e2 100644 --- a/storybook/lib/stories/form/form_story.dart +++ b/storybook/lib/stories/form/form_story.dart @@ -37,7 +37,8 @@ class _ContentState extends State<_Content> { ), ], ); - final multiselect = k.boolean(label: 'Multiselect', initial: false); + final allowMultipleSelection = + k.boolean(label: 'Multiselect', initial: false); return Form( key: _formKey, @@ -60,7 +61,8 @@ class _ContentState extends State<_Content> { (e) => ListDropdownTile( value: e, title: Text(e), - isSelected: multiselect ? _values.contains(e) : null, + isSelected: + allowMultipleSelection ? _values.contains(e) : null, ), ) .toList(), @@ -75,7 +77,7 @@ class _ContentState extends State<_Content> { }, validator: (String? v) => v?.isNotEmpty != true ? error : null, autovalidateMode: autovalidateMode, - multiselect: multiselect, + allowMultipleSelection: allowMultipleSelection, values: _values, ), OptimusButton( diff --git a/storybook/lib/stories/form/text_area.dart b/storybook/lib/stories/form/text_area.dart index d8117835..4385d2c7 100644 --- a/storybook/lib/stories/form/text_area.dart +++ b/storybook/lib/stories/form/text_area.dart @@ -13,8 +13,8 @@ final textAreaStory = Story( final isEnabled = k.boolean(label: 'Enabled', initial: true); final isRequired = k.boolean(label: 'Required', initial: false); final rows = k.sliderInt(label: 'Rows', initial: 1, min: 1, max: 10); - final autoCollapse = k.boolean(label: 'Auto collapse', initial: true); - final autoSize = k.boolean(label: 'Auto size', initial: true); + final enableAutoCollapse = k.boolean(label: 'Auto collapse', initial: true); + final enableAutoSize = k.boolean(label: 'Auto size', initial: true); final maxCharacters = k.sliderInt(label: 'Max characters', initial: 100, min: 0, max: 100); @@ -26,8 +26,8 @@ final textAreaStory = Story( isEnabled: isEnabled, isRequired: isRequired, rows: rows, - autoCollapse: autoCollapse, - autoSize: autoSize, + enableAutoCollapse: enableAutoCollapse, + enableAutoSize: enableAutoSize, error: error.isNotEmpty ? error : null, maxCharacters: maxCharacters == 0 ? null : maxCharacters, ), diff --git a/storybook/lib/stories/inline_dialog.dart b/storybook/lib/stories/inline_dialog.dart index deb610d9..559ca274 100644 --- a/storybook/lib/stories/inline_dialog.dart +++ b/storybook/lib/stories/inline_dialog.dart @@ -37,19 +37,16 @@ class _InlineDialogStoryState extends State { alignment: position, child: OptimusButton( key: _anchor, - onPressed: () => { - DialogWrapper.of(context)?.showInline( - anchorKey: _anchor, - size: OptimusDialogSize.regular, - content: const Padding( - padding: EdgeInsets.all(8.0), - child: _InlineContentExample(), - ), - actions: hasActions - ? [const OptimusDialogAction(title: Text('OK'))] - : [], + onPressed: () => DialogWrapper.of(context)?.showInline( + anchorKey: _anchor, + size: OptimusDialogSize.regular, + content: const Padding( + padding: EdgeInsets.all(8.0), + child: _InlineContentExample(), ), - }, + actions: + hasActions ? [const OptimusDialogAction(title: Text('OK'))] : [], + ), child: const Text('show'), ), ); diff --git a/storybook/lib/stories/input.dart b/storybook/lib/stories/input.dart index 5cb925e3..eac331d6 100644 --- a/storybook/lib/stories/input.dart +++ b/storybook/lib/stories/input.dart @@ -34,12 +34,12 @@ final Story inputStory = Story( initial: OptimusInputErrorVariant.bottomHint, options: OptimusInputErrorVariant.values.toOptions(), ); - final limitChars = k.boolean( + final hasCharsLimit = k.boolean( label: 'Limit characters', initial: true, ); int? maxChars; - if (limitChars) { + if (hasCharsLimit) { maxChars = k.sliderInt(label: 'Max Characters', max: 100, min: 1, initial: 30); } @@ -50,8 +50,8 @@ final Story inputStory = Story( initial: null, options: KeyboardType.values.toOptions().withEmpty(), ); - final inline = k.boolean(label: 'Inline', initial: false); - final autoCollapse = k.boolean(label: 'Auto Collapse', initial: true); + final isInlined = k.boolean(label: 'Inline', initial: false); + final enableAutoCollapse = k.boolean(label: 'Auto Collapse', initial: true); final statusBar = k.options( label: 'Status Bar', @@ -84,8 +84,8 @@ final Story inputStory = Story( initial: OptimusWidgetSize.large, options: sizeOptions, ), - inline: inline, - autoCollapse: autoCollapse, + isInlined: isInlined, + enableAutoCollapse: enableAutoCollapse, label: k.text(label: 'Label', initial: 'Optimus input field'), placeholder: k.text(label: 'Placeholder', initial: 'Put some hint here...'), diff --git a/storybook/lib/stories/link/inline_link.dart b/storybook/lib/stories/link/inline_link.dart index 688d54ef..8d4a2168 100644 --- a/storybook/lib/stories/link/inline_link.dart +++ b/storybook/lib/stories/link/inline_link.dart @@ -10,7 +10,7 @@ final Story inlineLink = Story( final k = context.knobs; final size = k.sliderInt(label: 'Text size', initial: 16, min: 12, max: 20); - final inherit = k.boolean(label: 'Inherit', initial: false); + final allowInherit = k.boolean(label: 'Inherit', initial: false); final color = k.options(label: 'Colors', initial: null, options: _colors); final onPressed = k.boolean(label: 'Enabled', initial: true) ? () {} : null; @@ -26,10 +26,10 @@ final Story inlineLink = Story( Text('Some text before inline link. Inline ', style: style), OptimusInlineLink( text: const Text('Link'), - inherit: inherit, + shouldInherit: allowInherit, onPressed: onPressed, - strong: k.boolean(label: 'Strong', initial: false), - textStyle: inherit ? style : null, + useStrong: k.boolean(label: 'Strong', initial: false), + textStyle: allowInherit ? style : null, variant: k.options( label: 'Variant', initial: OptimusLinkVariant.primary, diff --git a/storybook/lib/stories/link/standalone_link.dart b/storybook/lib/stories/link/standalone_link.dart index 3628dc65..3e03ecd9 100644 --- a/storybook/lib/stories/link/standalone_link.dart +++ b/storybook/lib/stories/link/standalone_link.dart @@ -22,7 +22,7 @@ final Story standaloneLink = Story( text: Text(k.text(label: 'Text', initial: 'Link')), size: size, isExternal: k.boolean(label: 'External', initial: false), - strong: k.boolean(label: 'Strong', initial: false), + useStrong: k.boolean(label: 'Strong', initial: false), variant: k.options( label: 'Variant', initial: OptimusLinkVariant.primary, diff --git a/storybook/lib/stories/list/expanded_list.dart b/storybook/lib/stories/list/expanded_list.dart index 885afb09..c1b9f20d 100644 --- a/storybook/lib/stories/list/expanded_list.dart +++ b/storybook/lib/stories/list/expanded_list.dart @@ -10,7 +10,7 @@ final Story expandedListTileStory = Story( final k = context.knobs; final title = k.text(label: 'Title', initial: 'Title'); final subtitle = k.text(label: 'Subtitle', initial: 'Subtitle'); - final longSubtitle = k.boolean(label: 'Long subtitle', initial: false); + final useLongSubtitle = k.boolean(label: 'Long subtitle', initial: false); final trailing = k.options( label: 'Trailing', initial: null, @@ -29,7 +29,7 @@ final Story expandedListTileStory = Story( (i) => OptimusExpansionTile( title: Text(title), subtitle: subtitle.isNotEmpty - ? Text(longSubtitle ? longText : subtitle) + ? Text(useLongSubtitle ? longText : subtitle) : null, trailing: trailing != null ? Icon(trailing) : null, leading: leading != null ? Icon(leading) : null, diff --git a/storybook/lib/stories/list/list_tile.dart b/storybook/lib/stories/list/list_tile.dart index 63c33e89..7c9f3469 100644 --- a/storybook/lib/stories/list/list_tile.dart +++ b/storybook/lib/stories/list/list_tile.dart @@ -10,7 +10,7 @@ final Story listTileStory = Story( final k = context.knobs; final title = k.text(label: 'Title', initial: 'Title'); final subtitle = k.text(label: 'Subtitle', initial: 'Subtitle'); - final longSubtitle = k.boolean(label: 'Long subtitle', initial: false); + final useLongSubtitle = k.boolean(label: 'Long subtitle', initial: false); final prefix = k.options( label: 'Prefix', initial: null, @@ -40,7 +40,7 @@ final Story listTileStory = Story( (i) => OptimusListTile( title: Text(title), subtitle: subtitle.isNotEmpty - ? Text(longSubtitle ? longText : subtitle) + ? Text(useLongSubtitle ? longText : subtitle) : null, info: info.isNotEmpty ? Text(info) : null, fontVariant: fontVariant, diff --git a/storybook/lib/stories/nonmodal_wrapper.dart b/storybook/lib/stories/nonmodal_wrapper.dart index dedb5694..e9f5a946 100644 --- a/storybook/lib/stories/nonmodal_wrapper.dart +++ b/storybook/lib/stories/nonmodal_wrapper.dart @@ -22,16 +22,14 @@ class NonModalDialogStory extends StatelessWidget { final title = k.text(label: 'Title', initial: 'Dialog title'); return OptimusButton( - onPressed: () => { - DialogWrapper.of(context)?.show( - title: Text(title), - content: const Text('Content'), - isDismissible: isDismissible, - actions: - hasActions ? [const OptimusDialogAction(title: Text('OK'))] : [], - size: OptimusDialogSize.small, - ), - }, + onPressed: () => DialogWrapper.of(context)?.show( + title: Text(title), + content: const Text('Content'), + isDismissible: isDismissible, + actions: + hasActions ? [const OptimusDialogAction(title: Text('OK'))] : [], + size: OptimusDialogSize.small, + ), child: const Text('show'), ); } diff --git a/storybook/lib/stories/select_input.dart b/storybook/lib/stories/select_input.dart index 4ff83f57..e73542d4 100644 --- a/storybook/lib/stories/select_input.dart +++ b/storybook/lib/stories/select_input.dart @@ -45,9 +45,11 @@ class _SelectInputStoryState extends State { final trailing = k.options(label: 'Trailing Icon', options: exampleIcons, initial: null); final showLoader = k.boolean(label: 'Show loader', initial: false); - final embeddedSearch = k.boolean(label: 'Embedded search', initial: false); + final isSearchEmbedded = + k.boolean(label: 'Embedded search', initial: false); final enableGrouping = k.boolean(label: 'Grouped', initial: true); - final multiselect = k.boolean(label: 'Multiselect', initial: true); + final allowMultipleSelection = + k.boolean(label: 'Multiselect', initial: true); return Align( alignment: k.options( @@ -70,7 +72,7 @@ class _SelectInputStoryState extends State { suffix: suffix.isNotEmpty ? Text(suffix) : null, trailing: trailing != null ? Icon(trailing) : null, showLoader: showLoader, - onChanged: (value) => _handleChanged(multiselect, value), + onChanged: (value) => _handleChanged(allowMultipleSelection, value), size: k.options( label: 'Size', initial: OptimusWidgetSize.large, @@ -89,7 +91,9 @@ class _SelectInputStoryState extends State { value: e, title: Text(e), subtitle: Text(e.toUpperCase()), - isSelected: multiselect ? _selectedValues.contains(e) : null, + isSelected: allowMultipleSelection + ? _selectedValues.contains(e) + : null, ), ) .toList(), @@ -98,9 +102,9 @@ class _SelectInputStoryState extends State { padding: EdgeInsets.all(8), child: OptimusLabel(child: Text('No results found')), ), - multiselect: multiselect, - selectedValues: multiselect ? _selectedValues : null, - embeddedSearch: embeddedSearch + allowMultipleSelection: allowMultipleSelection, + selectedValues: allowMultipleSelection ? _selectedValues : null, + embeddedSearch: isSearchEmbedded ? OptimusDropdownEmbeddedSearch( initialValue: _searchToken, onTextChanged: _handleTextChanged,