Skip to content

Commit

Permalink
Merge pull request #698 from MewsSystems/DX-3266
Browse files Browse the repository at this point in the history
feat!: [DX-3266] Upgrade to DCM 1.23
  • Loading branch information
witwash authored Oct 21, 2024
2 parents f3b1561 + bb78480 commit baf4246
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 12 deletions.
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.22.1"
version: "1.23.1"

- uses: ./.github/actions/setup

Expand Down
8 changes: 8 additions & 0 deletions mews_pedantic/lib/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ dart_code_metrics:
- avoid-collection-equality-checks
- avoid-collection-methods-with-unrelated-types
# - avoid-collection-mutating-methods
- avoid-complex-loop-conditions
- avoid-conditions-with-boolean-literals
- avoid-contradictory-expressions
# - avoid-declaring-call-method
Expand Down Expand Up @@ -291,13 +292,15 @@ dart_code_metrics:
- avoid-getter-prefix:
prefix: '^get'
- avoid-global-state
# - avoid-high-cyclomatic-complexity
# - avoid-identical-exception-handling-blocks
# - avoid-ignoring-return-values
- avoid-implicitly-nullable-extension-types
# - avoid-importing-entrypoint-exports
# - avoid-inferrable-type-arguments
- avoid-inverted-boolean-checks
- avoid-keywords-in-wildcard-pattern
- avoid-late-final-reassignment
# - avoid-late-keyword
# - avoid-local-functions
# - avoid-long-functions
Expand Down Expand Up @@ -325,6 +328,7 @@ dart_code_metrics:
# - avoid-nested-switch-expressions
- avoid-nested-switches
# - avoid-non-ascii-symbols
# - avoid-non-empty-constructor-bodies
- avoid-non-final-exception-class-fields
- avoid-non-null-assertion
- avoid-not-encodable-in-to-json
Expand All @@ -343,6 +347,7 @@ dart_code_metrics:
- avoid-redundant-positional-field-name
# - avoid-redundant-pragma-inline
# - avoid-referencing-discarded-variables
- avoid-referencing-subclasses
# - avoid-renaming-representation-getters
- avoid-returning-cascades
- avoid-returning-void
Expand Down Expand Up @@ -484,6 +489,7 @@ dart_code_metrics:
- prefer-public-exception-classes
- prefer-return-await
- prefer-returning-conditional-expressions
- prefer-simpler-boolean-expressions
- prefer-simpler-patterns-null-check
# - prefer-single-declaration-per-file
- prefer-specific-cases-first
Expand All @@ -501,6 +507,7 @@ dart_code_metrics:
- prefer-wildcard-pattern
# - tag-name
# - unnecessary-trailing-comma
- use-existing-variable

# Flutter

Expand Down Expand Up @@ -560,6 +567,7 @@ dart_code_metrics:

- avoid-bloc-public-methods
- avoid-cubits
# - avoid-empty-build-when
- avoid-passing-bloc-to-bloc
# - check-is-not-closed-after-async-gap
- prefer-correct-bloc-provider
Expand Down
2 changes: 2 additions & 0 deletions optimus/lib/src/button/base_button_variant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:optimus/src/theme/optimus_tokens.dart';
enum BaseButtonVariant { primary, secondary, tertiary, ghost, danger, success }

extension ColorScheme on BaseButtonVariant {
// TODO(witwash): split and rework, possibly using WidgetStates
Color? getBackgroundColor(
OptimusTokens tokens, {
required bool isEnabled,
Expand Down Expand Up @@ -105,6 +106,7 @@ extension ColorScheme on BaseButtonVariant {
}
}

// TODO(witwash): split and rewrite, possibly using WidgetState
Color getBadgeTextColor(
OptimusTokens tokens, {
required bool isEnabled,
Expand Down
9 changes: 5 additions & 4 deletions optimus/lib/src/form/date_formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,29 +105,30 @@ class DateFormatter extends TextInputFormatter {
/// empty space will be filled with the placeholder
/// result = '23-05-201Y'
@override
// TODO(witwash): rewrite and split in chunks
TextEditingValue formatEditUpdate(
TextEditingValue oldValue,
TextEditingValue newValue,
) {
final oldSelection = oldValue.selection;
final oldText = oldValue.text;
final newText = newValue.text;
final oldSelectionStart = oldValue.selection.start;
final oldSelectionStart = oldSelection.start;
final newSelectionStart = newValue.selection.start;

String resultText = oldText;
int resultSelection = oldSelectionStart;

if (oldValue.text.isEmpty) {
if (oldText.isEmpty) {
if (newText.clean().isEmpty) return oldValue;

return _pasteStarting(placeholder, 0, placeholder.length, newText);
} else if (oldSelection.end - oldSelection.start >= 1) {
} else if (oldSelection.end - oldSelectionStart >= 1) {
return _pasteStarting(
oldText,
oldSelectionStart,
oldSelection.end,
newText.substring(oldSelection.start, newValue.selection.end),
newText.substring(oldSelectionStart, newValue.selection.end),
);
}

Expand Down
2 changes: 1 addition & 1 deletion optimus/lib/src/form/input_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class _OptimusInputFieldState extends State<OptimusInputField>
caption: widget.caption,
captionIcon: widget.captionIcon,
helperMessage: widget.helperMessage,
error: widget.error,
error: error,
errorVariant: widget.errorVariant,
hasBorders: widget.hasBorders,
isRequired: widget.isRequired,
Expand Down
4 changes: 2 additions & 2 deletions optimus/lib/src/form/input_form_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ class _InputFormFieldState extends FormFieldState<String> {
final oldWidgetController = oldWidget.controller;
final widgetController = widget.controller;

if (oldWidgetController != null && widget.controller == null) {
if (oldWidgetController != null && widgetController == null) {
_controller =
TextEditingController.fromValue(oldWidgetController.value);
}
if (widgetController != null) {
setValue(widgetController.text);
if (oldWidget.controller == null) _controller = null;
if (oldWidgetController == null) _controller = null;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion optimus/lib/src/form/multiselect_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class _OptimusMultiSelectInputFieldState extends State<MultiSelectInputField>
caption: widget.caption,
captionIcon: widget.captionIcon,
helperMessage: widget.helperMessage,
error: widget.error,
error: error,
errorVariant: widget.errorVariant,
isRequired: widget.isRequired,
prefix: prefix,
Expand Down
2 changes: 1 addition & 1 deletion optimus/lib/src/icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class OptimusIcon extends StatelessWidget {
iconData,
color: colorOption?.let((option) => option.toIconColor(tokens)) ??
tokens.textStaticPrimary,
size: _getIconSize(context.tokens),
size: _getIconSize(tokens),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion optimus/lib/src/progress_indicator/progress_indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class _VerticalProgressIndicatorState extends State<_VerticalProgressIndicator>
Widget build(BuildContext context) {
final bool isClosed = !_isExpanded && _animationController.isDismissed;
final items = widget.items;
final headerItem = _isExpanded ? widget.items.first : _currentItem;
final headerItem = _isExpanded ? items.first : _currentItem;

final Widget result = Offstage(
offstage: isClosed,
Expand Down
2 changes: 1 addition & 1 deletion optimus/lib/src/select_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class _Chevron extends StatelessWidget {

return Icon(
OptimusIcons.chevron_down,
size: context.tokens.sizing300,
size: tokens.sizing300,
color: isEnabled ? tokens.textStaticPrimary : tokens.textDisabled,
);
}
Expand Down

0 comments on commit baf4246

Please sign in to comment.