Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Upgrade to DCM 1.11.0 #470

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dcm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: CQLabs/setup-dcm@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
version: "1.10.3"
version: "1.11.1"

- uses: ./.github/actions/setup

Expand Down
22 changes: 21 additions & 1 deletion mews_pedantic/lib/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ dart_code_metrics:
- avoid-accessing-collections-by-constant-index
# - avoid-accessing-other-classes-private-members
# - avoid-async-call-in-sync-function
# - avoid-banned-annotations
# - avoid-banned-file-names
# - avoid-banned-types
- avoid-barrel-files
Expand All @@ -253,12 +254,15 @@ dart_code_metrics:
- avoid-cascade-after-if-null
# - avoid-collapsible-if
- avoid-collection-methods-with-unrelated-types
# - avoid-collection-mutating-methods
# - avoid-declaring-call-method
- avoid-double-slash-imports
- avoid-duplicate-cascades
- avoid-duplicate-exports
- avoid-duplicate-mixins
- avoid-duplicate-named-imports
- avoid-duplicate-patterns
- avoid-duplicate-switch-case-conditions
# - avoid-dynamic
- avoid-equal-expressions
- avoid-explicit-pattern-field-name
Expand All @@ -271,6 +275,7 @@ dart_code_metrics:
# - avoid-identical-exception-handling-blocks
# - avoid-ignoring-return-values
# - avoid-importing-entrypoint-exports
# - avoid-inferrable-type-arguments
- avoid-inverted-boolean-checks
- avoid-keywords-in-wildcard-pattern
# - avoid-late-keyword
Expand All @@ -283,6 +288,7 @@ dart_code_metrics:
- avoid-missed-calls
# - avoid-missing-enum-constant-in-map
- avoid-missing-interpolation
# - avoid-missing-test-files
- avoid-misused-wildcard-pattern
- avoid-mixing-named-and-positional-fields
# - avoid-mutating-parameters
Expand Down Expand Up @@ -324,11 +330,12 @@ dart_code_metrics:
- avoid-unnecessary-futures
- avoid-unnecessary-getter
- avoid-unnecessary-if
- avoid-unnecessary-late
- avoid-unnecessary-local-late
- avoid-unnecessary-negations
- avoid-unnecessary-nullable-return-type
- avoid-unnecessary-reassignment
- avoid-unnecessary-return
- avoid-unnecessary-super
- avoid-unnecessary-type-assertions
- avoid-unnecessary-type-casts
- avoid-unrelated-type-assertions
Expand All @@ -350,6 +357,7 @@ dart_code_metrics:
# - map-keys-ordering
# - match-class-name-pattern
- match-getter-setter-field-names
- match-lib-folder-structure
# - match-positional-field-names-on-assignment
# - member-ordering
# - missing-test-assertion
Expand All @@ -368,15 +376,20 @@ dart_code_metrics:
# - no-magic-number
- no-object-declaration
# - parameters-ordering
# - prefer-addition-subtraction-assignments
# - prefer-async-await
- prefer-both-inlining-annotations
# - prefer-bytes-builder
- prefer-commenting-analyzer-ignores
# - prefer-conditional-expressions
# - prefer-correct-callback-field-name
- prefer-correct-error-name
- prefer-correct-for-loop-increment
- prefer-correct-future-return-type
- prefer-correct-handler-name
# - prefer-correct-identifier-length
- prefer-correct-json-casts
- prefer-correct-setter-parameter-name
- prefer-correct-stream-return-type
# - prefer-correct-switch-length
- prefer-correct-test-file-name:
Expand All @@ -386,7 +399,9 @@ dart_code_metrics:
ignore-abstract: false
- prefer-early-return
# - prefer-enums-by-name
- prefer-explicit-function-type
- prefer-explicit-parameter-names
- prefer-explicit-type-arguments
# - prefer-first
# - prefer-getter-over-method
- prefer-immediate-return
Expand All @@ -397,15 +412,20 @@ dart_code_metrics:
- prefer-named-boolean-parameters:
ignore-single: true
# - prefer-named-imports
- prefer-null-aware-spread
- prefer-parentheses-with-if-null
# - prefer-prefixed-global-constants
- prefer-public-exception-classes
- prefer-return-await
- prefer-returning-conditional-expressions
- prefer-simpler-patterns-null-check
- prefer-specific-cases-first
# - prefer-static-class
# - prefer-test-matchers
# - prefer-trailing-comma
- prefer-type-over-var
- prefer-typedefs-for-callbacks
- prefer-unique-test-names
# - prefer-unwrapping-future-or
# - prefer-visible-for-testing-on-members
- prefer-wildcard-pattern
Expand Down
2 changes: 1 addition & 1 deletion optimus/lib/src/banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class OptimusBanner extends StatelessWidget {
top: spacing100,
right: spacing100,
child: OptimusIconButton(
onPressed: () => onDismiss,
onPressed: onDismiss,
icon: const Icon(OptimusIcons.cross_close),
size: OptimusWidgetSize.small,
variant: OptimusButtonVariant.ghost,
Expand Down
88 changes: 45 additions & 43 deletions optimus/lib/src/button/base_dropdown_button.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:optimus/optimus.dart';
import 'package:optimus/src/button/common.dart';
import 'package:optimus/src/common/gesture_wrapper.dart';
import 'package:optimus/src/overlay_controller.dart';
import 'package:optimus/src/typography/presets.dart';

Expand Down Expand Up @@ -64,6 +65,12 @@ class _BaseDropDownButtonState<T> extends State<BaseDropDownButton<T>>

void _onFocusChanged() => setState(() {});

void _handleHoverChanged(bool isHovered) =>
setState(() => _isHovered = isHovered);

void _handlePressedChanged(bool isPressed) =>
setState(() => _isPressed = isPressed);

bool get _isEnabled => widget.onItemSelected != null;

Color get _textColor => widget.variant.toButtonVariant().foregroundColor(
Expand Down Expand Up @@ -106,51 +113,46 @@ class _BaseDropDownButtonState<T> extends State<BaseDropDownButton<T>>
onHidden: _controller.reverse,
child: IgnorePointer(
ignoring: !_isEnabled,
child: MouseRegion(
onEnter: (_) => setState(() => _isHovered = true),
onExit: (_) => setState(() => _isHovered = false),
child: GestureDetector(
onTap: _node.requestFocus,
onTapDown: (_) => setState(() => _isPressed = true),
onTapUp: (_) => setState(() => _isPressed = false),
onTapCancel: () => setState(() => _isPressed = false),
child: Focus(
focusNode: _node,
child: SizedBox(
height: widget.size.value,
child: AnimatedContainer(
padding: const EdgeInsets.symmetric(horizontal: spacing200),
key: _selectFieldKey,
decoration: BoxDecoration(
color: _color,
borderRadius: widget.borderRadius,
border: borderColor != null
? Border.all(color: borderColor, width: 1)
: null,
),
duration: buttonAnimationDuration,
curve: buttonAnimationCurve,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (child != null)
Padding(
padding: const EdgeInsets.only(right: 12),
child: DefaultTextStyle.merge(
style: _labelStyle,
child: child,
),
),
RotationTransition(
turns: _iconTurns,
child: Icon(
OptimusIcons.chevron_down,
size: widget.size.iconSize,
color: _textColor,
child: GestureWrapper(
onHoverChanged: _handleHoverChanged,
onPressedChanged: _handlePressedChanged,
onTap: _node.requestFocus,
child: Focus(
focusNode: _node,
child: SizedBox(
height: widget.size.value,
child: AnimatedContainer(
padding: const EdgeInsets.symmetric(horizontal: spacing200),
key: _selectFieldKey,
decoration: BoxDecoration(
color: _color,
borderRadius: widget.borderRadius,
border: borderColor != null
? Border.all(color: borderColor, width: 1)
: null,
),
duration: buttonAnimationDuration,
curve: buttonAnimationCurve,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (child != null)
Padding(
padding: const EdgeInsets.only(right: 12),
child: DefaultTextStyle.merge(
style: _labelStyle,
child: child,
),
),
],
),
RotationTransition(
turns: _iconTurns,
child: Icon(
OptimusIcons.chevron_down,
size: widget.size.iconSize,
color: _textColor,
),
),
],
),
),
),
Expand Down
63 changes: 31 additions & 32 deletions optimus/lib/src/button/icon.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:optimus/optimus.dart';
import 'package:optimus/src/button/common.dart';
import 'package:optimus/src/common/gesture_wrapper.dart';

/// When you don’t have enough space for regular buttons, or the action is
/// clear enough, you can use an icon button without text.
Expand Down Expand Up @@ -36,9 +37,12 @@ class _OptimusIconButtonState extends State<OptimusIconButton>
bool _isHovered = false;
bool _isPressed = false;

void _onHoverChanged(bool isHovering) =>
void _handleHoverChanged(bool isHovering) =>
setState(() => _isHovered = isHovering);

void _handlePressedChanged(bool isPressed) =>
setState(() => _isPressed = isPressed);

bool get _isEnabled => widget.onPressed != null;

@override
Expand All @@ -53,43 +57,38 @@ class _OptimusIconButtonState extends State<OptimusIconButton>

return IgnorePointer(
ignoring: !isEnabled,
child: MouseRegion(
onEnter: (_) => _onHoverChanged(true),
onExit: (_) => _onHoverChanged(false),
child: GestureDetector(
onTap: widget.onPressed,
onTapDown: (_) => setState(() => _isPressed = true),
onTapUp: (_) => setState(() => _isPressed = false),
onTapCancel: () => setState(() => _isPressed = false),
child: AnimatedContainer(
height: widget.size.containerSize,
width: widget.size.containerSize,
padding: EdgeInsets.zero,
decoration: BoxDecoration(
color: widget.variant.backgroundColor(
child: GestureWrapper(
onHoverChanged: _handleHoverChanged,
onPressedChanged: _handlePressedChanged,
onTap: widget.onPressed,
child: AnimatedContainer(
height: widget.size.containerSize,
width: widget.size.containerSize,
padding: EdgeInsets.zero,
decoration: BoxDecoration(
color: widget.variant.backgroundColor(
tokens,
isEnabled: _isEnabled,
isPressed: _isPressed,
isHovered: _isHovered,
),
border: borderColor != null
? Border.all(color: borderColor, width: 1)
: null,
borderRadius: const BorderRadius.all(borderRadius50),
),
duration: buttonAnimationDuration,
child: IconTheme.merge(
data: IconThemeData(
color: widget.variant.foregroundColor(
tokens,
isEnabled: _isEnabled,
isPressed: _isPressed,
isHovered: _isHovered,
),
border: borderColor != null
? Border.all(color: borderColor, width: 1)
: null,
borderRadius: const BorderRadius.all(borderRadius50),
),
duration: buttonAnimationDuration,
child: IconTheme.merge(
data: IconThemeData(
color: widget.variant.foregroundColor(
tokens,
isEnabled: _isEnabled,
isPressed: _isPressed,
isHovered: _isHovered,
),
size: widget.size.iconSize,
),
child: widget.icon,
size: widget.size.iconSize,
),
child: widget.icon,
),
),
),
Expand Down
4 changes: 2 additions & 2 deletions optimus/lib/src/chat/optimus_chat_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class _OptimusChatInputState extends State<OptimusChatInput> {

void _handleControllerChanged() => setState(() {});

void _onTap() {
void _handleTap() {
widget.onSendPressed(_controller.text);
_controller.clear();
}
Expand All @@ -45,7 +45,7 @@ class _OptimusChatInputState extends State<OptimusChatInput> {
trailing: OptimusEnabled(
isEnabled: _isSendEnabled,
child: GestureDetector(
onTap: _onTap,
onTap: _handleTap,
child: const OptimusIcon(
iconData: OptimusIcons.send_message,
colorOption: OptimusIconColorOption.basic,
Expand Down
6 changes: 3 additions & 3 deletions optimus/lib/src/checkbox/checkbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class OptimusCheckbox extends StatelessWidget {
return false;
}

void _onTap() {
void _handleTap() {
final newValue = isChecked ?? false;
onChanged(!newValue);
}
Expand All @@ -122,7 +122,7 @@ class OptimusCheckbox extends StatelessWidget {
child: GroupWrapper(
error: error,
child: GestureDetector(
onTap: _onTap,
onTap: _handleTap,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
Expand All @@ -134,7 +134,7 @@ class OptimusCheckbox extends StatelessWidget {
isChecked: isChecked,
isEnabled: isEnabled,
onChanged: onChanged,
onTap: _onTap,
onTap: _handleTap,
),
),
Expanded(
Expand Down
4 changes: 2 additions & 2 deletions optimus/lib/src/checkbox/checkbox_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class OptimusCheckboxGroup<T> extends StatelessWidget {
/// Controls whether the whole group is enabled.
final bool isEnabled;

void _onChanged(OptimusGroupItem<T> v, bool checked) {
void _handleChanged(OptimusGroupItem<T> v, bool checked) {
if (checked) {
_values.add(v.value);
} else {
Expand All @@ -69,7 +69,7 @@ class OptimusCheckboxGroup<T> extends StatelessWidget {
size: size,
label: v.label,
isEnabled: isEnabled,
onChanged: (checked) => _onChanged(v, checked),
onChanged: (checked) => _handleChanged(v, checked),
),
)
.toList(),
Expand Down
Loading