Skip to content

Commit

Permalink
feat(DX-353): display IsJammed State if device supports it (#37)
Browse files Browse the repository at this point in the history
* refactor(device_provider):  move String literal to file containing strings

* test(lock-related): change LockTrait instantiation signatures

* refactor(lock_slim_widget.dart): small refactor

* feat(DX-353): display isJammed State if device supports it

* test(lock_widget_testing): add missing stub

* feat(lock_widget): use warning text color if jammed state is True

* fix(lock_widget): use warning text color for whole row if Jammed State

* test(test/providers/lock_provider_test.dart): Improve test coverage

* fix(lock_widget): follow Figma style guide

* test(lock_widget): update tests

* refactor(lock_widget): remove unused method

* refactor(lock_widget): extract notification to new widget

* test(lock_widget_test): add more tests

* fix(lock_widget_test): fix onTap behavior test

Co-authored-by: CircleCI <developer@yonomi.co>
Co-authored-by: Rigoberto L. Perez <rigoberto.perez@allegion.com>
  • Loading branch information
3 people committed Feb 17, 2022
1 parent f254bd9 commit e82f8d4
Show file tree
Hide file tree
Showing 35 changed files with 1,070 additions and 19 deletions.
2 changes: 1 addition & 1 deletion doc/api/index.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions doc/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ open coverage/html/index.html



##### [notification_bar](ui_notification_bar/ui_notification_bar-library.md)



##### [power_item_icon](assets_traits_power_item_icon/assets_traits_power_item_icon-library.md)


Expand All @@ -144,6 +148,10 @@ open coverage/html/index.html



##### [string_constants](ui_string_constants/ui_string_constants-library.md)



##### [thermostat](devices_thermostat/devices_thermostat-library.md)


Expand Down
9 changes: 9 additions & 0 deletions doc/api/providers_lock_provider/LockProvider-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ _read-only, inherited_



##### [getIsJammedState](../providers_lock_provider/LockProvider/getIsJammedState.md) &#8594; [bool](https://api.flutter.dev/flutter/dart-core/bool-class.html)




_read-only_



##### [getIsLockedState](../providers_lock_provider/LockProvider/getIsLockedState.md) &#8594; [bool](https://api.flutter.dev/flutter/dart-core/bool-class.html)


Expand Down
36 changes: 36 additions & 0 deletions doc/api/providers_lock_provider/LockProvider/getIsJammedState.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@



# getIsJammedState property




*[<Null safety>](https://dart.dev/null-safety)*




[bool](https://api.flutter.dev/flutter/dart-core/bool-class.html) getIsJammedState








## Implementation

```dart
bool get getIsJammedState =>
getLockTrait()?.stateWhereType<IsJammed>().value ?? false;
```








11 changes: 10 additions & 1 deletion doc/api/traits_lock_widget/LockWidget-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

## Constructors

[LockWidget](../traits_lock_widget/LockWidget/LockWidget.md) ([LockProvider](../providers_lock_provider/LockProvider-class.md) _lockProvider, {[Color](https://api.flutter.dev/flutter/dart-ui/Color-class.html) iconColor = WidgetStyleConstants.deviceDetailIconColorActive, [Color](https://api.flutter.dev/flutter/dart-ui/Color-class.html) textColor = WidgetStyleConstants.darkTextColor, [double](https://api.flutter.dev/flutter/dart-core/double-class.html) iconSize = 100, [Key](https://api.flutter.dev/flutter/foundation/Key-class.html)? key})
[LockWidget](../traits_lock_widget/LockWidget/LockWidget.md) ([LockProvider](../providers_lock_provider/LockProvider-class.md) _lockProvider, {[Color](https://api.flutter.dev/flutter/dart-ui/Color-class.html) iconColor = WidgetStyleConstants.deviceDetailIconColorActive, [Color](https://api.flutter.dev/flutter/dart-ui/Color-class.html) textColor = WidgetStyleConstants.darkTextColor, [Color](https://api.flutter.dev/flutter/dart-ui/Color-class.html) warningTextColor = WidgetStyleConstants.globalWarningColor, [double](https://api.flutter.dev/flutter/dart-core/double-class.html) iconSize = 100, [Key](https://api.flutter.dev/flutter/foundation/Key-class.html)? key})



Expand Down Expand Up @@ -112,6 +112,15 @@ _inherited_



##### [shouldDisplayJammedState](../traits_lock_widget/LockWidget/shouldDisplayJammedState.md)() [bool](https://api.flutter.dev/flutter/dart-core/bool-class.html)








##### [toDiagnosticsNode](https://api.flutter.dev/flutter/foundation/DiagnosticableTree/toDiagnosticsNode.html)({[String](https://api.flutter.dev/flutter/dart-core/String-class.html)? name, [DiagnosticsTreeStyle](https://api.flutter.dev/flutter/foundation/DiagnosticsTreeStyle.html)? style}) [DiagnosticsNode](https://api.flutter.dev/flutter/foundation/DiagnosticsNode-class.html)


Expand Down
4 changes: 3 additions & 1 deletion doc/api/traits_lock_widget/LockWidget/LockWidget.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@



LockWidget([LockProvider](../../providers_lock_provider/LockProvider-class.md) _lockProvider, {[Color](https://api.flutter.dev/flutter/dart-ui/Color-class.html) iconColor = WidgetStyleConstants.deviceDetailIconColorActive, [Color](https://api.flutter.dev/flutter/dart-ui/Color-class.html) textColor = WidgetStyleConstants.darkTextColor, [double](https://api.flutter.dev/flutter/dart-core/double-class.html) iconSize = 100, [Key](https://api.flutter.dev/flutter/foundation/Key-class.html)? key})
LockWidget([LockProvider](../../providers_lock_provider/LockProvider-class.md) _lockProvider, {[Color](https://api.flutter.dev/flutter/dart-ui/Color-class.html) iconColor = WidgetStyleConstants.deviceDetailIconColorActive, [Color](https://api.flutter.dev/flutter/dart-ui/Color-class.html) textColor = WidgetStyleConstants.darkTextColor, [Color](https://api.flutter.dev/flutter/dart-ui/Color-class.html) warningTextColor = WidgetStyleConstants.globalWarningColor, [double](https://api.flutter.dev/flutter/dart-core/double-class.html) iconSize = 100, [Key](https://api.flutter.dev/flutter/foundation/Key-class.html)? key})



Expand All @@ -22,11 +22,13 @@ LockWidget([LockProvider](../../providers_lock_provider/LockProvider-class.md) _
LockWidget(this._lockProvider,
{Color iconColor = WidgetStyleConstants.deviceDetailIconColorActive,
Color textColor = WidgetStyleConstants.darkTextColor,
Color warningTextColor = WidgetStyleConstants.globalWarningColor,
double iconSize = 100,
Key? key})
: super(key: key) {
this._iconColor = iconColor;
this._textColor = textColor;
this._warningTextColor = warningTextColor;
this._iconSize = iconSize;
}
```
Expand Down
16 changes: 10 additions & 6 deletions doc/api/traits_lock_widget/LockWidget/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ Widget build(BuildContext context) {
),
],
),
SizedBox(
height: 10,
),
SizedBox(height: 10),
Container(
child: Center(
child: SizedBox(
Expand All @@ -93,15 +91,21 @@ Widget build(BuildContext context) {
size: _iconSize, color: _iconColor)),
),
),
SizedBox(
height: 10,
),
SizedBox(height: 10),
CupertinoSwitch(
onChanged: (bool value) {
_lockTap(_lockProvider);
},
value: _lockProvider.getIsLockedState,
),
if (shouldDisplayJammedState()) ...[
SizedBox(height: 20),
NotificationBar(
messageText: StringConstants.DEVICE_IS_JAMMED,
backgroundColor: _warningTextColor,
),
SizedBox(height: 10),
],
],
);
}
Expand Down
66 changes: 66 additions & 0 deletions doc/api/traits_lock_widget/LockWidget/buildIsJammedRow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@



# buildIsJammedRow method




*[<Null safety>](https://dart.dev/null-safety)*




[Widget](https://api.flutter.dev/flutter/widgets/Widget-class.html) buildIsJammedRow
([BuildContext](https://api.flutter.dev/flutter/widgets/BuildContext-class.html) context)








## Implementation

```dart
Widget buildIsJammedRow(BuildContext context) {
return Container(
height: 48,
margin: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Card(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
SizedBox(width: 16),
Icon(BootstrapIcons.exclamation_diamond_fill),
SizedBox(width: 8),
Text(StringConstants.DEVICE_IS_JAMMED),
],
),
Container(
width: 50,
alignment: Alignment.center,
decoration: BoxDecoration(
border: Border(
left: BorderSide(width: 1.0, color: Colors.white))),
child: Icon(BootstrapIcons.x),
),
],
),
color: _warningTextColor,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
elevation: 2,
),
);
}
```







39 changes: 39 additions & 0 deletions doc/api/traits_lock_widget/LockWidget/shouldDisplayJammedState.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@



# shouldDisplayJammedState method




*[<Null safety>](https://dart.dev/null-safety)*




[bool](https://api.flutter.dev/flutter/dart-core/bool-class.html) shouldDisplayJammedState
()








## Implementation

```dart
bool shouldDisplayJammedState() {
final bool supportsIsJammed =
_lockProvider.getLockTrait()?.supportsIsJammed ?? false;
return supportsIsJammed && _lockProvider.getIsJammedState;
}
```







Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ LockSlimWidget(LockProvider lockProvider, {Color? backgroundColor, Key? key})
},
value: lockProvider.getIsLockedState,
),
headerText: Text(lockProvider.deviceDetail?.displayName ?? 'LOCK',
headerText: Text(lockProvider.displayName,
style: TextStyle(
fontSize: 20, color: WidgetStyleConstants.darkTextColor)),
backgroundColor: backgroundColor,
Expand Down
Loading

0 comments on commit e82f8d4

Please sign in to comment.