Skip to content

Commit 95203d1

Browse files
committed
Merge branch 'master' into DX-1203
2 parents f4cea96 + 800a3a3 commit 95203d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+336
-308
lines changed

.github/workflows/dcm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: CQLabs/setup-dcm@v1
1717
with:
1818
github_token: ${{ secrets.GITHUB_TOKEN }}
19-
version: "1.19.1"
19+
version: "1.21.0"
2020

2121
- uses: ./.github/actions/setup
2222

kiosk_mode/lib/kiosk_mode.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ enum KioskMode {
3030
///
3131
/// [1]: https://developer.android.com/reference/android/app/Activity#startLockTask()
3232
/// [2]: https://developer.apple.com/documentation/uikit/uiaccessibility/1615186-requestguidedaccesssession/
33+
// ignore: prefer-boolean-prefixes, a valid name with bool result
3334
Future<bool> startKioskMode() => _channel
3435
.invokeMethod<bool>('startKioskMode')
35-
.then((value) => value ?? false);
36+
.then((didStartKioskMode) => didStartKioskMode ?? false);
3637

3738
/// On Android, stops the current task from being locked. On iOS, exits the Single App mode.
3839
///
@@ -42,16 +43,19 @@ Future<bool> startKioskMode() => _channel
4243
/// On iOS, the result will be `true` if the request was fulfilled, `false` - otherwise.
4344
///
4445
/// [1]: https://developer.android.com/reference/android/app/Activity#stopLockTask()
46+
// ignore: prefer-boolean-prefixes, a valid name with a bool result
4547
Future<bool?> stopKioskMode() => _channel.invokeMethod<bool>('stopKioskMode');
4648

4749
/// Returns the current [KioskMode].
4850
///
4951
/// On Android, it calls `isInLockTaskMode`.
5052
///
5153
/// On iOS, it returns result of `UIAccessibility.isGuidedAccessEnabled`.
52-
Future<KioskMode> getKioskMode() => _channel
53-
.invokeMethod<bool>('isInKioskMode')
54-
.then((value) => value == true ? KioskMode.enabled : KioskMode.disabled);
54+
Future<KioskMode> getKioskMode() =>
55+
_channel.invokeMethod<bool>('isInKioskMode').then(
56+
(isInKioskMode) =>
57+
isInKioskMode == true ? KioskMode.enabled : KioskMode.disabled,
58+
);
5559

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

6973
/// Returns the stream with [KioskMode].
7074
///

mews_pedantic/lib/analysis_options.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ dart_code_metrics:
250250
# - avoid-async-call-in-sync-function
251251
# - avoid-banned-annotations
252252
# - avoid-banned-file-names
253+
# - avoid-banned-imports
254+
# - avoid-banned-names
253255
# - avoid-banned-types
254256
- avoid-barrel-files
255257
- avoid-bottom-type-in-patterns
@@ -305,6 +307,7 @@ dart_code_metrics:
305307
- avoid-missing-interpolation
306308
# - avoid-missing-test-files
307309
- avoid-misused-test-matchers
310+
- avoid-misused-set-literals
308311
- avoid-misused-wildcard-pattern
309312
- avoid-mixing-named-and-positional-fields
310313
- avoid-multi-assignment
@@ -345,6 +348,7 @@ dart_code_metrics:
345348
# - avoid-similar-names
346349
# - avoid-slow-collection-methods
347350
# - avoid-substring
351+
- avoid-suspicious-super-overrides
348352
# - avoid-throw-in-catch-block
349353
# - avoid-throw-objects-without-tostring
350354
# - avoid-top-level-members-in-tests
@@ -380,6 +384,7 @@ dart_code_metrics:
380384
# - ban-name
381385
# - banned-usage
382386
# - binary-expression-operand-order
387+
- dispose-class-fields
383388
# - double-literal-format
384389
# - enum-constants-ordering
385390
# - format-comment
@@ -400,6 +405,7 @@ dart_code_metrics:
400405
- move-variable-closer-to-its-usage
401406
- move-variable-outside-iteration
402407
# - newline-before-case
408+
- newline-before-method
403409
- newline-before-return
404410
- no-boolean-literal-compare
405411
# - no-empty-block
@@ -417,6 +423,8 @@ dart_code_metrics:
417423
# - prefer-addition-subtraction-assignments
418424
- prefer-any-or-every
419425
# - prefer-async-await
426+
- prefer-boolean-prefixes:
427+
prefixes: [is, are, was, were, has, have, had, can, should, will, do, does, did, allow, show, use, hide, only, enable]
420428
- prefer-both-inlining-annotations
421429
# - prefer-bytes-builder
422430
- prefer-commenting-analyzer-ignores

optimus/lib/src/badge/badge.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class OptimusBadge extends StatelessWidget {
99
const OptimusBadge({
1010
super.key,
1111
this.text = '',
12-
this.outline = true,
12+
this.isOutlined = true,
1313
this.overflow = TextOverflow.ellipsis,
1414
this.variant = OptimusBadgeVariant.primary,
1515
});
@@ -19,7 +19,7 @@ class OptimusBadge extends StatelessWidget {
1919

2020
/// Whether to use the outline. Outlined version could be more accessible,
2121
/// depending on the underlying component.
22-
final bool outline;
22+
final bool isOutlined;
2323

2424
/// Define how to display the overflowing text. Defaults to
2525
/// [TextOverflow.ellipsis]. Due to small height of the badge, the
@@ -35,7 +35,7 @@ class OptimusBadge extends StatelessWidget {
3535

3636
return BaseBadge(
3737
text: text,
38-
outline: outline,
38+
isOutlined: isOutlined,
3939
textColor: variant.getTextColor(tokens),
4040
backgroundColor: variant.getBackgroundColor(tokens),
4141
);

optimus/lib/src/badge/base_badge.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ class BaseBadge extends StatelessWidget {
55
const BaseBadge({
66
super.key,
77
required this.text,
8-
required this.outline,
8+
required this.isOutlined,
99
this.overflow = TextOverflow.ellipsis,
1010
this.backgroundColor,
1111
this.textColor,
1212
this.outlineColor,
1313
});
1414

1515
final String text;
16-
final bool outline;
16+
final bool isOutlined;
1717
final TextOverflow overflow;
1818
final Color? backgroundColor;
1919
final Color? textColor;
@@ -31,13 +31,14 @@ class BaseBadge extends StatelessWidget {
3131
final badgeHeight = tokens.sizing200;
3232
final bareHeight = text.isEmpty ? tokens.spacing100 : badgeHeight;
3333
final outlinedHeight = bareHeight + outlineSize * 2;
34-
final height = outline ? outlinedHeight : bareHeight;
34+
final height = isOutlined ? outlinedHeight : bareHeight;
3535

3636
final decoration = BoxDecoration(
3737
borderRadius: const BorderRadius.all(Radius.circular(50)),
3838
color: backgroundColor,
39-
border:
40-
outline ? Border.all(width: outlineSize, color: outlineColor) : null,
39+
border: isOutlined
40+
? Border.all(width: outlineSize, color: outlineColor)
41+
: null,
4142
);
4243

4344
final child = hasText

optimus/lib/src/button/base_button.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,15 @@ extension on OptimusWidgetSize {
376376
OptimusWidgetSize.extraLarge =>
377377
tokens.spacing150,
378378
};
379+
379380
double getHorizontalPadding(OptimusTokens tokens) => switch (this) {
380381
OptimusWidgetSize.small => tokens.spacing150,
381382
OptimusWidgetSize.medium => tokens.spacing200,
382383
OptimusWidgetSize.large ||
383384
OptimusWidgetSize.extraLarge =>
384385
tokens.spacing300,
385386
};
387+
386388
double getInsideHorizontalPadding(OptimusTokens tokens) => switch (this) {
387389
OptimusWidgetSize.small => tokens.spacing100,
388390
OptimusWidgetSize.medium ||

optimus/lib/src/card.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class OptimusCard extends StatelessWidget {
5050
this.padding = OptimusCardSpacing.spacing200,
5151
this.attachment = OptimusCardAttachment.none,
5252
this.variant = OptimusBasicCardVariant.normal,
53-
this.outline = true,
53+
this.isOutlined = true,
5454
this.radius = OptimusCardCornerRadius.medium,
5555
});
5656

@@ -71,12 +71,12 @@ class OptimusCard extends StatelessWidget {
7171
final OptimusBasicCardVariant variant;
7272

7373
/// Whether card should be outlined;
74-
final bool outline;
74+
final bool isOutlined;
7575

7676
/// Controls the radius of the card.
7777
final OptimusCardCornerRadius radius;
7878

79-
Border? _border(BuildContext context) => outline
79+
Border? _border(BuildContext context) => isOutlined
8080
? Border.all(
8181
width: context.tokens.borderWidth150,
8282
color: context.tokens.borderStaticPrimary,
@@ -124,7 +124,7 @@ class OptimusNestedCard extends StatelessWidget {
124124
this.padding = OptimusCardSpacing.spacing200,
125125
this.attachment = OptimusCardAttachment.none,
126126
this.variant = OptimusNestedCardVariant.normal,
127-
this.outline = false,
127+
this.isOutlined = false,
128128
this.radius = OptimusCardCornerRadius.medium,
129129
});
130130

@@ -145,7 +145,7 @@ class OptimusNestedCard extends StatelessWidget {
145145
final OptimusNestedCardVariant variant;
146146

147147
/// Whether card should be outlined.
148-
final bool outline;
148+
final bool isOutlined;
149149

150150
/// The radius of the card.
151151
final OptimusCardCornerRadius radius;
@@ -155,7 +155,7 @@ class OptimusNestedCard extends StatelessWidget {
155155
OptimusCardCornerRadius.medium => context.tokens.borderRadius200,
156156
};
157157

158-
Border? _border(BuildContext context) => outline
158+
Border? _border(BuildContext context) => isOutlined
159159
? Border.all(
160160
width: context.tokens.borderWidth150,
161161
color: context.tokens.borderStaticPrimary,

optimus/lib/src/chat/chat.dart

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,27 @@ class OptimusChat extends StatelessWidget {
3636
final ValueChanged<String> onSendPressed;
3737
final Predicate<OptimusMessage> isFromCurrentUser;
3838

39-
bool _previousMessageIsFromSameUser(int index) =>
39+
bool _isPreviousMessageFromSameUser(int index) =>
4040
index - 1 >= 0 &&
4141
_messages[index - 1].author.id == _messages[index].author.id;
4242

4343
bool _showAvatar(int index) =>
44-
_lastMessageOfDay(index) ||
45-
_moreThanOneMinuteDifferenceForward(index) ||
46-
_latestMessage(index) ||
47-
!_previousMessageIsFromSameUser(index);
44+
_isLastMessageOfDay(index) ||
45+
_isMoreThanOneMinuteDifferenceForward(index) ||
46+
_isLatestMessage(index) ||
47+
!_isPreviousMessageFromSameUser(index);
4848

4949
bool _showStatus(int index) =>
50-
_lastMessageOfDay(index) ||
51-
_moreThanOneMinuteDifferenceForward(index) ||
50+
_isLastMessageOfDay(index) ||
51+
_isMoreThanOneMinuteDifferenceForward(index) ||
5252
_messages[index].state != MessageState.sent ||
53-
_latestMessage(index) ||
54-
!_previousMessageIsFromSameUser(index);
53+
_isLatestMessage(index) ||
54+
!_isPreviousMessageFromSameUser(index);
5555

5656
bool _showUserName(int index) =>
5757
!isFromCurrentUser(_messages[index]) &&
58-
(_moreThanOneMinuteDifferenceBack(index) ||
59-
_oldestMessage(index) ||
58+
(_isMoreThanOneMinuteDifferenceBack(index) ||
59+
_isOldestMessage(index) ||
6060
_messages[index < _messages.length ? index + 1 : index].author.id !=
6161
_messages[index].author.id);
6262

@@ -67,7 +67,7 @@ class OptimusChat extends StatelessWidget {
6767
_currentMessageTime(index).difference(previousMessageTime).inDays >= 1;
6868
}
6969

70-
bool _moreThanOneMinuteDifferenceBack(int index) {
70+
bool _isMoreThanOneMinuteDifferenceBack(int index) {
7171
final previousMessageTime = _previousMessageTime(index);
7272

7373
return previousMessageTime != null &&
@@ -78,7 +78,7 @@ class OptimusChat extends StatelessWidget {
7878
1;
7979
}
8080

81-
bool _moreThanOneMinuteDifferenceForward(int index) {
81+
bool _isMoreThanOneMinuteDifferenceForward(int index) {
8282
final nextMessageTime = _nextMessageTime(index);
8383

8484
return nextMessageTime != null &&
@@ -97,16 +97,16 @@ class OptimusChat extends StatelessWidget {
9797
DateTime? _nextMessageTime(int index) =>
9898
index - 1 > 0 ? _messages[index - 1].time : null;
9999

100-
bool _lastMessageOfDay(int index) {
100+
bool _isLastMessageOfDay(int index) {
101101
final nextMessageTime = _nextMessageTime(index);
102102

103103
return nextMessageTime == null ||
104104
nextMessageTime.difference(_currentMessageTime(index)).inDays > 1;
105105
}
106106

107-
bool _latestMessage(int index) => index == 0;
107+
bool _isLatestMessage(int index) => index == 0;
108108

109-
bool _oldestMessage(int index) => index + 1 == _messages.length;
109+
bool _isOldestMessage(int index) => index + 1 == _messages.length;
110110

111111
int _byTime(OptimusMessage m1, OptimusMessage m2) =>
112112
m2.time.compareTo(m1.time);
@@ -157,7 +157,7 @@ class OptimusChat extends StatelessWidget {
157157
sending: sending,
158158
sent: sent,
159159
isFromCurrentUser: isFromCurrentUser(_messages[index]),
160-
isLatestMessage: _latestMessage(index),
160+
isLatestMessage: _isLatestMessage(index),
161161
alignment: _messages[index].alignment,
162162
),
163163
],

optimus/lib/src/checkbox/checkbox.dart

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ enum OptimusCheckboxSize {
1717

1818
/// A checkbox is a binary form of input and is used to let a user select one
1919
/// or more options for a limited number of choices. Each selection is
20-
/// independent (with exceptions). If [tristate] is enabled, checkbox can be in
20+
/// independent (with exceptions). If [isTristate] is enabled, checkbox can be in
2121
/// three states: checked, unchecked and indeterminate.
2222
class OptimusCheckbox extends StatelessWidget {
2323
const OptimusCheckbox({
@@ -27,10 +27,10 @@ class OptimusCheckbox extends StatelessWidget {
2727
this.error,
2828
this.isEnabled = true,
2929
this.size = OptimusCheckboxSize.large,
30-
this.tristate = false,
30+
this.isTristate = false,
3131
required this.onChanged,
3232
}) : assert(
33-
tristate || isChecked != null,
33+
isTristate || isChecked != null,
3434
'isChecked must be set if tristate is false',
3535
);
3636

@@ -49,7 +49,7 @@ class OptimusCheckbox extends StatelessWidget {
4949
/// {@template optimus.checkbox.tristate}
5050
/// Whether this checkbox has 3 states.
5151
/// {@endtemplate}
52-
final bool tristate;
52+
final bool isTristate;
5353

5454
/// {@template optimus.checkbox.error}
5555
/// Controls error that appears below checkbox.
@@ -112,10 +112,7 @@ class OptimusCheckbox extends StatelessWidget {
112112
return false;
113113
}
114114

115-
void _handleTap() {
116-
final newValue = isChecked ?? false;
117-
onChanged(!newValue);
118-
}
115+
void _handleTap() => onChanged(!(isChecked ?? false));
119116

120117
@override
121118
Widget build(BuildContext context) {

optimus/lib/src/checkbox/checkbox_group.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class OptimusCheckboxGroup<T> extends StatelessWidget {
4545
/// Controls whether the whole group is enabled.
4646
final bool isEnabled;
4747

48-
void _handleChanged(OptimusGroupItem<T> v, bool checked) {
49-
if (checked) {
48+
void _handleChanged(OptimusGroupItem<T> v, bool isChecked) {
49+
if (isChecked) {
5050
_values.add(v.value);
5151
} else {
5252
_values.remove(v.value);
@@ -70,7 +70,7 @@ class OptimusCheckboxGroup<T> extends StatelessWidget {
7070
size: size,
7171
label: v.label,
7272
isEnabled: isEnabled,
73-
onChanged: (checked) => _handleChanged(v, checked),
73+
onChanged: (isChecked) => _handleChanged(v, isChecked),
7474
),
7575
)
7676
.toList(),

0 commit comments

Comments
 (0)