-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(PinCode_Widget): introduce PinCode Trait Widget (#54)
* feat(pin_code_icon): introduce pin_code_icon * feat(pin_code_provider): introduce PinCodeProvider * feat(pin_code): introduce pin code slim widget * feat(pin_code_widget): new pin code widget * feat(pin_code_widget): include pin_code_slim_widget in factory * refactor(pin_code_slim_widget): update icons * feat(pin_code_widget): carve out pin code widget details * feat(pin_code_slim_widget): show bottom sheet on click * fix(pin_code_widget): fix icon size and color * feat(pin_code_slim_widget): add basic list and detail view navigation * feat(pin_code_slim_widget): Detail View implementation to create new pin code * fix(pin_code_detail_view): add async modifier to onPressed callback * test(detail_screen_test.dart): add pinCodeProvider mocks to existing tests * refactor(pin_code_slim_widget): add sub-navigation between sheets * feat(pin_code_widget): save new pin code * feat(pin_code): update styles according to figma design * refactor(pin_code_provider): rename from sendAddPinCode to sendCreatePinCode method name * test(pin_code_provider): more tests for pin_code_provider * refactor(pin_code_provider): rename action to sendCreatePinCode * build(pubspec.yaml): update yonomi_platform_sdk dependency to 5.2.0 * chore(config.yml): pin flutter version to 3.3.2 * test(battery_widget, pin_code_widget): wrap tested Widgets in Scaffold widget to fix errors
- Loading branch information
Showing
24 changed files
with
1,258 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:bootstrap_icons/bootstrap_icons.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:yonomi_device_widgets/ui/widget_style_constants.dart'; | ||
|
||
class PinCodeIcon extends Icon { | ||
static const DEFAULT_ICON = BootstrapIcons.grid_3x3_gap_fill; | ||
|
||
PinCodeIcon( | ||
{size = WidgetStyleConstants.defaultDeviceIconSize, | ||
color = WidgetStyleConstants.deviceIconColor, | ||
Key? key}) | ||
: super(DEFAULT_ICON, key: key, size: size, color: color); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:yonomi_device_widgets/providers/device_provider.dart'; | ||
import 'package:yonomi_platform_sdk/yonomi-sdk.dart'; | ||
|
||
typedef SendCreatePinCodeMethod = Future<void> Function( | ||
Request request, String id, String pinCode, String pinCodeName); | ||
|
||
class PinCodeProvider extends DeviceProvider { | ||
static const _DEFAULT_DISPLAY_NAME = 'PIN_CODE'; | ||
|
||
late String _deviceId; | ||
late Request _request; | ||
|
||
PinCodeProvider(Request request, String deviceId, | ||
{GetDeviceDetailsMethod getDetails = DevicesRepository.getDeviceDetails}) | ||
: super(request, deviceId, getDetails: getDetails) { | ||
this._deviceId = deviceId; | ||
this._request = request; | ||
} | ||
|
||
/// Run the "makeCreatePinCodeActionRequest" mutation on this device | ||
/// | ||
/// @param pinCode the pin code | ||
/// @param pinCodeName the name for the pin code | ||
/// @throws ServerException for any errors returned by the platform | ||
Future<void> sendCreatePinCode(String pinCode, String pinCodeName, | ||
{GetDeviceDetailsMethod getDetails = DevicesRepository.getDeviceDetails, | ||
SendCreatePinCodeMethod sendCreatePinCodeMethod = | ||
PinCodeRepository.sendCreatePinCodeAction}) async { | ||
return performAction<List<PinCodeCredential>>( | ||
[...?getPinCodeCredentials, PinCodeCredential(pinCodeName, pinCode)], | ||
() => getPinCodeCredentials, | ||
() => sendCreatePinCodeMethod( | ||
_request, this._deviceId, pinCode, pinCodeName), | ||
getDetails: getDetails); | ||
} | ||
|
||
PinCodeTrait? getPinCodeTrait() { | ||
return trait<PinCodeTrait>() as PinCodeTrait?; | ||
} | ||
|
||
String get displayName => deviceDetail?.displayName ?? _DEFAULT_DISPLAY_NAME; | ||
|
||
/// Get pinCodeCredentials State | ||
List<PinCodeCredential>? get getPinCodeCredentials => | ||
getPinCodeTrait()?.pinCodes; | ||
|
||
/// Get the Max Number Of Credentials allowed for this device | ||
int? get maxNumberOfCredentials => getPinCodeTrait()?.maxNumberOfCredentials; | ||
|
||
/// Get min and max Credential length allowed for this device | ||
PinCodeLengthRange? get pinCodeLengthRange => | ||
getPinCodeTrait()?.pinCodeLengthRange; | ||
|
||
/// Get min and max pin code Name length allowed for this device | ||
PinCodeNameLengthRange? get nameLengthRange => | ||
getPinCodeTrait()?.nameLengthRange; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:yonomi_device_widgets/assets/traits/pin_code_icon.dart'; | ||
import 'package:yonomi_device_widgets/mixins/toast_notifications.dart'; | ||
import 'package:yonomi_device_widgets/providers/pin_code_provider.dart'; | ||
import 'package:yonomi_device_widgets/ui/widget_style_constants.dart'; | ||
|
||
class PinCodeWidget extends StatelessWidget with ToastNotifications { | ||
final PinCodeProvider _pinCodeProvider; | ||
late final Color _iconColor; | ||
late final Color _textColor; | ||
late final double _iconSize; | ||
|
||
PinCodeWidget(this._pinCodeProvider, | ||
{Color iconColor = WidgetStyleConstants.deviceIconColor, | ||
Color textColor = WidgetStyleConstants.darkTextColor, | ||
double iconSize = 60.0, | ||
Key? key}) | ||
: super(key: key) { | ||
this._iconColor = iconColor; | ||
this._textColor = textColor; | ||
this._iconSize = iconSize; | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
if (_pinCodeProvider.isLoading) { | ||
return Center( | ||
child: | ||
SizedBox(child: CircularProgressIndicator(), height: 30, width: 30), | ||
); | ||
} else if (_pinCodeProvider.isInErrorState) { | ||
showToast(context, _pinCodeProvider.getErrorMessage); | ||
return Icon(Icons.error); | ||
} else { | ||
return Column( | ||
mainAxisAlignment: MainAxisAlignment.start, | ||
children: [ | ||
Row(children: <Widget>[ | ||
Text( | ||
'PIN_CODE', | ||
style: Theme.of(context) | ||
.textTheme | ||
.headline6 | ||
?.copyWith(color: _textColor), | ||
) | ||
]), | ||
Padding( | ||
padding: | ||
const EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0), | ||
child: Container( | ||
child: Center( | ||
child: SizedBox( | ||
width: _iconSize, | ||
height: _iconSize, | ||
child: PinCodeIcon(size: _iconSize, color: _iconColor), | ||
), | ||
), | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.