Skip to content

Commit

Permalink
fix: sdk dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Suraj Adhikari committed Dec 7, 2021
1 parent 250493e commit 5df8963
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 38 deletions.
5 changes: 2 additions & 3 deletions lib/traits/detail_screen.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:bootstrap_icons/bootstrap_icons.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:yonomi_device_widgets/assets/traits/unknown_item_icon.dart';
import 'package:yonomi_device_widgets/providers/lock_provider.dart';
import 'package:yonomi_device_widgets/providers/trait_based_device_notifier.dart';
import 'package:yonomi_device_widgets/traits/lock.dart';
Expand All @@ -20,7 +19,7 @@ class DetailScreen extends StatelessWidget {
return Consumer<LockProvider>(builder: (_, lockProvider, child) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: LockWidget(),
child: LockWidget(lockProvider),
);
});
default:
Expand All @@ -34,7 +33,7 @@ class DetailScreen extends StatelessWidget {
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text('Unknown trait', style: TextStyle(fontSize: 20)),
child: Text(name, style: TextStyle(fontSize: 20)),
),
],
),
Expand Down
59 changes: 25 additions & 34 deletions lib/traits/lock.dart
Original file line number Diff line number Diff line change
@@ -1,71 +1,62 @@
import 'package:bootstrap_icons/bootstrap_icons.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:yonomi_device_widgets/assets/traits/device_item_icon.dart';
import 'package:yonomi_device_widgets/providers/lock_provider.dart';
import 'package:yonomi_device_widgets/ui/widget_style_constants.dart';

class LockWidget extends StatelessWidget {
late final LockProvider _lockProvider;

LockWidget(this._lockProvider);

@override
Widget build(BuildContext context) {
final lockProvider = Provider.of<LockProvider>(context, listen: true);

return lockProvider.loadingDetail
return _lockProvider.loadingDetail
? Center(child: CircularProgressIndicator())
: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
children: <Widget>[
Text(
lockProvider.deviceDetail.displayName,
_lockProvider.getLockTrait().name,
style: Theme.of(context).textTheme.headline6,
),
],
),
SizedBox(
height: 10,
),
Center(
child: SizedBox(
width: 100,
height: 100,
child: lockProvider.loadingDetail
? CircularProgressIndicator()
: lockProvider.isLocked
? Icon(
BootstrapIcons.lock,
size: 100,
)
: Icon(
BootstrapIcons.unlock,
size: 100,
)),
Container(
child: Center(
child: SizedBox(
width: 100,
height: 100,
child: _lockProvider.loadingAction
? CircularProgressIndicator()
: _lockProvider.isLocked
? Icon(
BootstrapIcons.lock,
size: 100,
)
: Icon(
BootstrapIcons.unlock,
size: 100,
)),
),
),
SizedBox(
height: 10,
),
CupertinoSwitch(
onChanged: (bool value) {
_lockTap(lockProvider);
_lockTap(_lockProvider);
},
value: lockProvider.isLocked,
value: _lockProvider.isLocked,
),
],
);
}

Widget getLockStateIcon(LockProvider lockProvider) {
return (lockProvider.loadingDetail || lockProvider.loadingAction)
? Center(child: CircularProgressIndicator())
: (lockProvider.isLocked)
? DeviceItemIcon.buildLockIcon(
175, WidgetStyleConstants.deviceDetailIconColorActive)
: DeviceItemIcon.buildUnlockIcon(
175, WidgetStyleConstants.deviceDetailIconColorInactive);
}

void _lockTap(LockProvider provider) {
bool setLock = !provider.isLocked;
provider.setLockUnlockAction(provider.deviceDetail.id, setLock);
Expand Down
5 changes: 4 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ dependencies:
flutter:
sdk: flutter
bootstrap_icons: ^1.5.0
yonomi_platform_sdk: ^2.0.0
yonomi_platform_sdk:
git:
url: git@github.com:Yonomi/yonomi-sdk-dart.git
ref: fix/unknown_trait_name

dev_dependencies:
mockito: ^5.0.15
Expand Down

0 comments on commit 5df8963

Please sign in to comment.