Skip to content

Commit

Permalink
Merge pull request #658 from MewsSystems/DX-2112
Browse files Browse the repository at this point in the history
feat!: Upgrade to DCM 1.21.0
  • Loading branch information
witwash authored Aug 15, 2024
2 parents 0e41778 + 70e9182 commit 800a3a3
Show file tree
Hide file tree
Showing 62 changed files with 336 additions and 308 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.19.1"
version: "1.21.0"

- uses: ./.github/actions/setup

Expand Down
14 changes: 9 additions & 5 deletions kiosk_mode/lib/kiosk_mode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> startKioskMode() => _channel
.invokeMethod<bool>('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.
///
Expand All @@ -42,16 +43,19 @@ Future<bool> 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<bool?> stopKioskMode() => _channel.invokeMethod<bool>('stopKioskMode');

/// Returns the current [KioskMode].
///
/// On Android, it calls `isInLockTaskMode`.
///
/// On iOS, it returns result of `UIAccessibility.isGuidedAccessEnabled`.
Future<KioskMode> getKioskMode() => _channel
.invokeMethod<bool>('isInKioskMode')
.then((value) => value == true ? KioskMode.enabled : KioskMode.disabled);
Future<KioskMode> getKioskMode() =>
_channel.invokeMethod<bool>('isInKioskMode').then(
(isInKioskMode) =>
isInKioskMode == true ? KioskMode.enabled : KioskMode.disabled,
);

/// Returns `true`, if app is in a proper managed kiosk mode.
///
Expand All @@ -64,7 +68,7 @@ Future<KioskMode> getKioskMode() => _channel
/// detection of Apple Business Manager yet.
Future<bool> isManagedKiosk() => _channel
.invokeMethod<bool>('isManagedKiosk')
.then((value) => value == true);
.then((isManagedKiosk) => isManagedKiosk == true);

/// Returns the stream with [KioskMode].
///
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 @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions optimus/lib/src/badge/badge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand All @@ -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
Expand All @@ -35,7 +35,7 @@ class OptimusBadge extends StatelessWidget {

return BaseBadge(
text: text,
outline: outline,
isOutlined: isOutlined,
textColor: variant.getTextColor(tokens),
backgroundColor: variant.getBackgroundColor(tokens),
);
Expand Down
11 changes: 6 additions & 5 deletions optimus/lib/src/badge/base_badge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ 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,
this.outlineColor,
});

final String text;
final bool outline;
final bool isOutlined;
final TextOverflow overflow;
final Color? backgroundColor;
final Color? textColor;
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions optimus/lib/src/button/base_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,15 @@ extension on OptimusWidgetSize {
OptimusWidgetSize.extraLarge =>
tokens.spacing150,
};

double getHorizontalPadding(OptimusTokens tokens) => switch (this) {
OptimusWidgetSize.small => tokens.spacing150,
OptimusWidgetSize.medium => tokens.spacing200,
OptimusWidgetSize.large ||
OptimusWidgetSize.extraLarge =>
tokens.spacing300,
};

double getInsideHorizontalPadding(OptimusTokens tokens) => switch (this) {
OptimusWidgetSize.small => tokens.spacing100,
OptimusWidgetSize.medium ||
Expand Down
12 changes: 6 additions & 6 deletions optimus/lib/src/card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand All @@ -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,
Expand Down Expand Up @@ -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,
});

Expand All @@ -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;
Expand All @@ -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,
Expand Down
34 changes: 17 additions & 17 deletions optimus/lib/src/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,27 @@ class OptimusChat extends StatelessWidget {
final ValueChanged<String> onSendPressed;
final Predicate<OptimusMessage> 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);

Expand All @@ -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 &&
Expand All @@ -78,7 +78,7 @@ class OptimusChat extends StatelessWidget {
1;
}

bool _moreThanOneMinuteDifferenceForward(int index) {
bool _isMoreThanOneMinuteDifferenceForward(int index) {
final nextMessageTime = _nextMessageTime(index);

return nextMessageTime != null &&
Expand All @@ -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);
Expand Down Expand Up @@ -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,
),
],
Expand Down
13 changes: 5 additions & 8 deletions optimus/lib/src/checkbox/checkbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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',
);

Expand All @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions optimus/lib/src/checkbox/checkbox_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class OptimusCheckboxGroup<T> extends StatelessWidget {
/// Controls whether the whole group is enabled.
final bool isEnabled;

void _handleChanged(OptimusGroupItem<T> v, bool checked) {
if (checked) {
void _handleChanged(OptimusGroupItem<T> v, bool isChecked) {
if (isChecked) {
_values.add(v.value);
} else {
_values.remove(v.value);
Expand All @@ -70,7 +70,7 @@ class OptimusCheckboxGroup<T> extends StatelessWidget {
size: size,
label: v.label,
isEnabled: isEnabled,
onChanged: (checked) => _handleChanged(v, checked),
onChanged: (isChecked) => _handleChanged(v, isChecked),
),
)
.toList(),
Expand Down
8 changes: 4 additions & 4 deletions optimus/lib/src/checkbox/checkbox_tick.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class _CheckboxTickState extends State<CheckboxTick> 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(
Expand Down
Loading

0 comments on commit 800a3a3

Please sign in to comment.