From 038ed680dddf8108eea107c8ca0ba43333b7952c Mon Sep 17 00:00:00 2001 From: mohammad Date: Wed, 3 Jul 2024 16:48:46 +0300 Subject: [PATCH] pull to refresh --- .../devices/view/widgets/ACs/acs_view.dart | 29 +- .../ceiling_sensor_interface.dart | 589 +++++++++--------- .../view/widgets/gateway/gateway_view.dart | 153 ++--- .../widgets/smart_door/door_interface.dart | 11 +- .../widgets/three_gang/three_gang_screen.dart | 587 ++++++++--------- .../wall_sensor/wall_sensor_interface.dart | 29 +- 6 files changed, 734 insertions(+), 664 deletions(-) diff --git a/lib/features/devices/view/widgets/ACs/acs_view.dart b/lib/features/devices/view/widgets/ACs/acs_view.dart index 23bedd9..991e83d 100644 --- a/lib/features/devices/view/widgets/ACs/acs_view.dart +++ b/lib/features/devices/view/widgets/ACs/acs_view.dart @@ -63,20 +63,25 @@ class ACsView extends StatelessWidget { opacity: 0.4, ), ), - child: state is AcsLoadingState - ? const Center( - child: DefaultContainer( - width: 50, height: 50, child: CircularProgressIndicator()), - ) - : Container( - padding: const EdgeInsets.only(top: 40), - alignment: AlignmentDirectional.center, - child: - deviceModel != null ? AcInterface(ac: deviceModel!) : const ACsList(), - ), + child: state is AcsLoadingState + ? const Center( + child: DefaultContainer( + width: 50, height: 50, child: CircularProgressIndicator()),) + : RefreshIndicator( + onRefresh: () async { + BlocProvider.of(context).add(AcsInitial(allAcs: deviceModel != null ? false : true)); + }, + child:ListView( + children: [ + Container( + padding: const EdgeInsets.only(top: 40), + alignment: AlignmentDirectional.center, + child: deviceModel != null ? AcInterface(ac: deviceModel!) : const ACsList(), ), + ], + ),), ), - ); + )); }, ), ); diff --git a/lib/features/devices/view/widgets/ceiling_sensor/ceiling_sensor_interface.dart b/lib/features/devices/view/widgets/ceiling_sensor/ceiling_sensor_interface.dart index 3a186c1..c40777c 100644 --- a/lib/features/devices/view/widgets/ceiling_sensor/ceiling_sensor_interface.dart +++ b/lib/features/devices/view/widgets/ceiling_sensor/ceiling_sensor_interface.dart @@ -29,297 +29,314 @@ class CeilingSensorInterface extends StatelessWidget { // .firstWhere((element) => element.code == "presence_state") // .value // .toString(); - return BlocProvider( - create: (context) => - CeilingSensorBloc(deviceId: ceilingSensor.uuid ?? '')..add(InitialEvent()), - child: BlocBuilder(builder: (context, state) { - CeilingSensorModel ceilingSensorModel = - CeilingSensorModel(presenceState: 'none', sensitivity: 1, checkingResult: ''); - if (state is UpdateState) { - ceilingSensorModel = state.ceilingSensorModel; - } else if (state is LoadingNewSate) { - ceilingSensorModel = state.ceilingSensorModel; - } - return AnnotatedRegion( - value: SystemUiOverlayStyle( - statusBarColor: ColorsManager.primaryColor.withOpacity(0.5), - statusBarIconBrightness: Brightness.light, - ), - child: Scaffold( - backgroundColor: ColorsManager.backgroundColor, - extendBodyBehindAppBar: true, - extendBody: true, - appBar: DeviceAppbar( - deviceName: ceilingSensor.name!, - deviceUuid: ceilingSensor.uuid!, - ), - body: Container( - width: MediaQuery.sizeOf(context).width, - height: MediaQuery.sizeOf(context).height, - padding: const EdgeInsets.all(Constants.defaultPadding), - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage( - Assets.assetsImagesBackground, - ), - fit: BoxFit.cover, - opacity: 0.4, - ), - ), - child: state is LoadingInitialState - ? const Center( - child: RefreshProgressIndicator(), - ) - : SafeArea( - child: Column( - children: [ - Expanded( - flex: 1, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - // InkWell( - // onTap: () { - // if ((ceilingSensor.isOnline ?? false) == false) { - // ScaffoldMessenger.of(context).showSnackBar( - // const SnackBar( - // content: Text( - // 'Device is offline', - // ), - // backgroundColor: Colors.red, - // ), - // ); - // return; - // } - // String controlCode = 'sensitivity'; - // showDialog( - // context: context, - // builder: (context) => ParameterControlDialog( - // title: 'Sensitivity', - // sensor: ceilingSensor, - // controlCode: controlCode, - // value: ceilingSensor.status - // .firstWhere((element) => element.code == controlCode) - // .value as int, - // min: ceilingSensor.functions - // .firstWhere((element) => element.code == controlCode) - // .values - // ?.min ?? - // 0, - // max: ceilingSensor.functions - // .firstWhere((element) => element.code == controlCode) - // .values - // ?.max ?? - // 0, - // ), - // ); - // }, - // child: - // ), - SvgPicture.asset( - ceilingSensorModel.presenceState.toLowerCase() == 'motion' - ? Assets.assetsIconsPresenceSensorAssetsPresenceSensorMotion - : Assets.assetsIconsPresenceSensorAssetsPresence, - width: 100, - height: 100, - // colorFilter: ColorFilter.mode( - // (ceilingSensor.isOnline ?? false) - // ? ColorsManager.primaryColor - // : Colors.grey.withOpacity(0.9), - // BlendMode.srcIn, - // ), - ), - const SizedBox( - height: 10, - ), - BodyMedium( - text: - StringHelpers.toTitleCase(ceilingSensorModel.presenceState), - // (ceilingSensor.isOnline ?? false) - // ? StringHelpers.toTitleCase(ceilingSensor.status - // .firstWhere((element) => - // element.code == 'presence_state') - // .value - // .toString()) - // : "Offline", - style: context.bodyMedium.copyWith( - fontWeight: FontsManager.bold, - ), - ), - ], - ), - ), - Expanded( - flex: 2, - child: ListView( - children: [ - DefaultContainer( - padding: const EdgeInsets.symmetric( - vertical: 20, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Flexible( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const BodySmall(text: 'Sports Para'), - BodyLarge( - text: '0', - style: context.bodyLarge.copyWith( - fontWeight: FontsManager.bold, - ), - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), - child: Container( - width: 1, - height: 45, - color: ColorsManager.greyColor, - ), - ), - Flexible( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const BodySmall( - text: 'Detection Range', - textOverflow: TextOverflow.ellipsis, - ), - BodyLarge( - text: '0.0M', - textOverflow: TextOverflow.ellipsis, - style: context.bodyLarge.copyWith( - fontWeight: FontsManager.bold, - ), - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), - child: Container( - width: 1, - height: 45, - color: ColorsManager.greyColor, - ), - ), - Flexible( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const BodySmall( - text: 'Movement', - textOverflow: TextOverflow.ellipsis, - ), - BodyLarge( - text: 'none', - textOverflow: TextOverflow.ellipsis, - style: context.bodyLarge.copyWith( - fontWeight: FontsManager.bold, - ), - ), - ], - ), - ), - ], - )), - const SizedBox( - height: 15, - ), - ...List.generate( - ceilingSensorButtons().length, - (index) => DefaultContainer( - margin: const EdgeInsets.only(bottom: 5), - padding: - const EdgeInsets.symmetric(vertical: 12, horizontal: 20), - onTap: () async { - if (ceilingSensorButtons()[index]['title'] == 'Sensitivity') { - final result = await showDialog( - context: context, - builder: (context) { - return ParameterControlDialog( - title: ceilingSensorButtons()[index]['title'] - .toString(), - sensor: ceilingSensor, - value: ceilingSensorModel.sensitivity, - min: 0, - max: 10, - ); - }, - ); - if (result != null) { - BlocProvider.of(context).add( - ChangeValueEvent( - value: result, code: 'sensitivity')); - } - } - // if (ceilingSensorButtons[index]['page'] != null) { - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (context) => - // ceilingSensorButtons[index]['page'] as Widget, - // ), - // ); - // } - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - SvgPicture.asset( - ceilingSensorButtons()[index]['icon'] as String, - // width: 30, - // height: 50, - ), - const SizedBox( - width: 25, - ), - BodyMedium( - text: ceilingSensorButtons()[index]['title'] - as String, - style: context.bodyMedium.copyWith( - fontWeight: FontsManager.bold, - ), - ), - ], - ), - if (ceilingSensorButtons()[index]['withArrow'] == true) - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Text(ceilingSensorButtons( - sensitivity_val: ceilingSensorModel - .sensitivity - .toString())[index]['val'] - .toString()), - const Icon( - Icons.arrow_forward_ios, - color: ColorsManager.greyColor, - size: 15, - ), - ], + return BlocProvider( + create: (context) => + CeilingSensorBloc(deviceId: ceilingSensor.uuid ?? '')..add(InitialEvent()), + child: BlocBuilder(builder: (context, state) { + CeilingSensorModel ceilingSensorModel = + CeilingSensorModel(presenceState: 'none', sensitivity: 1, checkingResult: ''); + if (state is UpdateState) { + ceilingSensorModel = state.ceilingSensorModel; + } else if (state is LoadingNewSate) { + ceilingSensorModel = state.ceilingSensorModel; + } + return AnnotatedRegion( + value: SystemUiOverlayStyle( + statusBarColor: ColorsManager.primaryColor.withOpacity(0.5), + statusBarIconBrightness: Brightness.light, + ), + child: Scaffold( + backgroundColor: ColorsManager.backgroundColor, + extendBodyBehindAppBar: true, + extendBody: true, + appBar: DeviceAppbar( + deviceName: ceilingSensor.name!, + deviceUuid: ceilingSensor.uuid!, + ), + body: Container( + width: MediaQuery.sizeOf(context).width, + height: MediaQuery.sizeOf(context).height, + padding: const EdgeInsets.all(Constants.defaultPadding), + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage( + Assets.assetsImagesBackground, + ), + fit: BoxFit.cover, + opacity: 0.4, + ), + ), + child: state is LoadingInitialState + ? const Center( + child: RefreshProgressIndicator(), + ) : SafeArea( + child: + RefreshIndicator( + onRefresh: () async { + BlocProvider.of(context).add(InitialEvent()); + }, + child:Container( + child: ListView( + shrinkWrap: true, + children: [ + Container( + height: MediaQuery.of(context).size.height, + + child: Column( + children: [ + Expanded( + child: Column( + children: [ + // InkWell( + // onTap: () { + // if ((ceilingSensor.isOnline ?? false) == false) { + // ScaffoldMessenger.of(context).showSnackBar( + // const SnackBar( + // content: Text( + // 'Device is offline', + // ), + // backgroundColor: Colors.red, + // ), + // ); + // return; + // } + // String controlCode = 'sensitivity'; + // showDialog( + // context: context, + // builder: (context) => ParameterControlDialog( + // title: 'Sensitivity', + // sensor: ceilingSensor, + // controlCode: controlCode, + // value: ceilingSensor.status + // .firstWhere((element) => element.code == controlCode) + // .value as int, + // min: ceilingSensor.functions + // .firstWhere((element) => element.code == controlCode) + // .values + // ?.min ?? + // 0, + // max: ceilingSensor.functions + // .firstWhere((element) => element.code == controlCode) + // .values + // ?.max ?? + // 0, + // ), + // ); + // }, + // child: + // ), + + SvgPicture.asset( + ceilingSensorModel.presenceState.toLowerCase() == 'motion' + ? Assets.assetsIconsPresenceSensorAssetsPresenceSensorMotion + : Assets.assetsIconsPresenceSensorAssetsPresence, + width: 100, + height: 100, + // colorFilter: ColorFilter.mode( + // (ceilingSensor.isOnline ?? false) + // ? ColorsManager.primaryColor + // : Colors.grey.withOpacity(0.9), + // BlendMode.srcIn, + // ), ), - ], + const SizedBox( + height: 10, + ), + BodyMedium( + text: + StringHelpers.toTitleCase(ceilingSensorModel.presenceState), + // (ceilingSensor.isOnline ?? false) + // ? StringHelpers.toTitleCase(ceilingSensor.status + // .firstWhere((element) => + // element.code == 'presence_state') + // .value + // .toString()) + // : "Offline", + style: context.bodyMedium.copyWith( + fontWeight: FontsManager.bold, + ), + ), + ], + ), ), - ), + Expanded( + flex: 3, + child: Column( + children: [ + DefaultContainer( + padding: const EdgeInsets.symmetric( + vertical: 20, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Flexible( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const BodySmall(text: 'Sports Para'), + BodyLarge( + text: '0', + style: context.bodyLarge.copyWith( + fontWeight: FontsManager.bold, + ), + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 10), + child: Container( + width: 1, + height: 45, + color: ColorsManager.greyColor, + ), + ), + Flexible( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const BodySmall( + text: 'Detection Range', + textOverflow: TextOverflow.ellipsis, + ), + BodyLarge( + text: '0.0M', + textOverflow: TextOverflow.ellipsis, + style: context.bodyLarge.copyWith( + fontWeight: FontsManager.bold, + ), + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 10), + child: Container( + width: 1, + height: 45, + color: ColorsManager.greyColor, + ), + ), + Flexible( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const BodySmall( + text: 'Movement', + textOverflow: TextOverflow.ellipsis, + ), + BodyLarge( + text: 'none', + textOverflow: TextOverflow.ellipsis, + style: context.bodyLarge.copyWith( + fontWeight: FontsManager.bold, + ), + ), + ], + ), + ), + ], + )), + const SizedBox( + height: 15, + ), + ...List.generate( + ceilingSensorButtons().length, + (index) => DefaultContainer( + margin: const EdgeInsets.only(bottom: 5), + padding: + const EdgeInsets.symmetric(vertical: 12, horizontal: 20), + onTap: () async { + if (ceilingSensorButtons()[index]['title'] == 'Sensitivity') { + final result = await showDialog( + context: context, + builder: (context) { + return ParameterControlDialog( + title: ceilingSensorButtons()[index]['title'] + .toString(), + sensor: ceilingSensor, + value: ceilingSensorModel.sensitivity, + min: 0, + max: 10, + ); + }, + ); + if (result != null) { + BlocProvider.of(context).add( + ChangeValueEvent( + value: result, code: 'sensitivity')); + } + } + + // if (ceilingSensorButtons[index]['page'] != null) { + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (context) => + // ceilingSensorButtons[index]['page'] as Widget, + // ), + // ); + // } + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + SvgPicture.asset( + ceilingSensorButtons()[index]['icon'] as String, + // width: 30, + // height: 50, + ), + const SizedBox( + width: 25, + ), + BodyMedium( + text: ceilingSensorButtons()[index]['title'] + as String, + style: context.bodyMedium.copyWith( + fontWeight: FontsManager.bold, + ), + ), + ], + ), + if (ceilingSensorButtons()[index]['withArrow'] == true) + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Text(ceilingSensorButtons( + sensitivity_val: ceilingSensorModel + .sensitivity + .toString())[index]['val'] + .toString()), + const Icon( + Icons.arrow_forward_ios, + color: ColorsManager.greyColor, + size: 15, + ), + ], + ), + ], + ), + ), + ), + ], + ), + ), + ], ), - ], - ), + ), + ], ), - ], - ), - )), - ), - ); - }), + ) , + ) + + )), + ), + ); + }), ); } diff --git a/lib/features/devices/view/widgets/gateway/gateway_view.dart b/lib/features/devices/view/widgets/gateway/gateway_view.dart index 0ae479e..62ce1ed 100644 --- a/lib/features/devices/view/widgets/gateway/gateway_view.dart +++ b/lib/features/devices/view/widgets/gateway/gateway_view.dart @@ -39,9 +39,8 @@ class GateWayView extends StatelessWidget { extendBodyBehindAppBar: true, extendBody: true, appBar:DeviceAppbar( - deviceName: 'Gateway', - deviceUuid: gatewayObj.uuid!, - ), + deviceName: 'Gateway', + deviceUuid: gatewayObj.uuid!,), body: Container( width: MediaQuery.sizeOf(context).width, height: MediaQuery.sizeOf(context).height, @@ -55,81 +54,95 @@ class GateWayView extends StatelessWidget { opacity: 0.4, ), ), - child: SafeArea( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + child: RefreshIndicator( + onRefresh:()async { + BlocProvider.of(context).add(GatewayInitial(gatewayId: gatewayObj.uuid ?? '')); + }, + child: ListView( + children: [ Container( - height: MediaQuery.sizeOf(context).height * 0.3, - width: MediaQuery.sizeOf(context).width, - alignment: AlignmentDirectional.center, - child: Stack(children: [ - SvgPicture.asset( - Assets.gatewayIcon, - width: 125, - height: 125, - ), - Positioned( - right: 30, - top: 15, - child: Container( - width: 12, - height: 12, - decoration: const BoxDecoration( - color: ColorsManager.lightGreen, - shape: BoxShape.circle, + height: MediaQuery.of(context).size.height, + child: SafeArea( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + height: MediaQuery.sizeOf(context).height * 0.3, + width: MediaQuery.sizeOf(context).width, + alignment: AlignmentDirectional.center, + child: Stack(children: [ + SvgPicture.asset( + Assets.gatewayIcon, + width: 125, + height: 125, + ), + Positioned( + right: 30, + top: 15, + child: Container( + width: 12, + height: 12, + decoration: const BoxDecoration( + color: ColorsManager.lightGreen, + shape: BoxShape.circle, + ), + ), + ), + ]), ), - ), - ), - ]), - ), - if (devicesList.isEmpty && state is UpdateGatewayState) - Container( - width: MediaQuery.sizeOf(context).width, - alignment: AlignmentDirectional.center, - child: const BodyMedium( - text: 'No devices found', - fontSize: 15, - fontWeight: FontWeight.w700, - ), - ), - if (devicesList.isNotEmpty) - const BodyMedium( - text: 'Zigbee Devices', - fontSize: 15, - fontWeight: FontWeight.w700, - ), - const SizedBox( - height: 10, - ), - state is GatewayLoadingState - ? Center( - child: Container( - margin: const EdgeInsets.only(top: 20), - height: 50, - width: 50, - child: const RefreshProgressIndicator()), - ) - : Expanded( - child: GridView.builder( - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 10, - mainAxisSpacing: 10, - childAspectRatio: 1.5, + if (devicesList.isEmpty && state is UpdateGatewayState) + Container( + width: MediaQuery.sizeOf(context).width, + alignment: AlignmentDirectional.center, + child: const BodyMedium( + text: 'No devices found', + fontSize: 15, + fontWeight: FontWeight.w700, + ), ), - padding: const EdgeInsets.only(top: 10), - shrinkWrap: true, - itemCount: devicesList.length, - itemBuilder: (context, index) { - return RoomPageSwitch(device: devicesList[index]); - }, + if (devicesList.isNotEmpty) + const BodyMedium( + text: 'Zigbee Devices', + fontSize: 15, + fontWeight: FontWeight.w700, + ), + const SizedBox( + height: 10, ), - ) + state is GatewayLoadingState + ? Center( + child: Container( + margin: const EdgeInsets.only(top: 20), + height: 50, + width: 50, + child: const RefreshProgressIndicator()), + ) + : Expanded( + child: GridView.builder( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + crossAxisSpacing: 10, + mainAxisSpacing: 10, + childAspectRatio: 1.5, + ), + padding: const EdgeInsets.only(top: 10), + shrinkWrap: true, + itemCount: devicesList.length, + itemBuilder: (context, index) { + return RoomPageSwitch(device: devicesList[index]); + }, + ), + ) + ], + ), + ), + ), ], ), ), - ))); + ) + )); })); } } diff --git a/lib/features/devices/view/widgets/smart_door/door_interface.dart b/lib/features/devices/view/widgets/smart_door/door_interface.dart index b78378f..d3c2643 100644 --- a/lib/features/devices/view/widgets/smart_door/door_interface.dart +++ b/lib/features/devices/view/widgets/smart_door/door_interface.dart @@ -98,7 +98,14 @@ class DoorInterface extends StatelessWidget { ? const Center( child: RefreshProgressIndicator(), ) - : Column( + : + + RefreshIndicator( + onRefresh: () async { + BlocProvider.of(context).add(InitialEvent()); + }, + child: + ListView( children: [ DoorLockStatusBar( smartDoorModel: smartDoorModel, @@ -120,7 +127,7 @@ class DoorInterface extends StatelessWidget { ), ), ), - ); + )); }), ); } diff --git a/lib/features/devices/view/widgets/three_gang/three_gang_screen.dart b/lib/features/devices/view/widgets/three_gang/three_gang_screen.dart index f0df734..0e18ffd 100644 --- a/lib/features/devices/view/widgets/three_gang/three_gang_screen.dart +++ b/lib/features/devices/view/widgets/three_gang/three_gang_screen.dart @@ -55,326 +55,341 @@ class ThreeGangScreen extends StatelessWidget { threeGangList: groupThreeGangModel, allSwitches: allSwitchesOn, ) - : Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.stretch, + : RefreshIndicator( + onRefresh:()async { + BlocProvider.of(context).add(InitialEvent(groupScreen: device != null ? false : true)); + }, + child: ListView( children: [ - const Expanded(child: SizedBox.shrink()), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Column( - children: [ - GangSwitch( - threeGangSwitch: device!, - value: threeGangModel.firstSwitch, - action: () { - BlocProvider.of(context).add( - ChangeFirstSwitchStatusEvent( - value: threeGangModel.firstSwitch)); - }, - // control: DeviceControlModel( - // deviceId: device.uuid, - // // code: 'switch_1', - // code: device.status[0].code, - // // value: true, - // value: device.status[0].value, - // ), - ), - const SizedBox(height: 20), - const SizedBox( - width: 70, - child: BodySmall( - text: "Bedside Light", - fontColor: ColorsManager.textPrimaryColor, - textAlign: TextAlign.center, - ), - ), - ], - ), - Column( - children: [ - GangSwitch( - threeGangSwitch: device!, - value: threeGangModel.secondSwitch, - action: () { - BlocProvider.of(context).add( - ChangeSecondSwitchStatusEvent( - value: threeGangModel.secondSwitch)); - }, - // control: DeviceControlModel( - // // deviceId: 'bfe10693d4fd263206ocq9', - // // code: 'switch_2', - // // value: true, - // deviceId: device.uuid, - // code: device.status[1].code, - // value: device.status[1].value, - // ), - ), - const SizedBox(height: 20), - const SizedBox( - width: 70, - child: BodySmall( - text: "Ceiling Light", - fontColor: ColorsManager.textPrimaryColor, - textAlign: TextAlign.center, - ), - ), - ], - ), - Column( - children: [ - GangSwitch( - threeGangSwitch: device!, - value: threeGangModel.thirdSwitch, - action: () { - BlocProvider.of(context).add( - ChangeThirdSwitchStatusEvent( - value: threeGangModel.thirdSwitch)); - }, - ), - const SizedBox(height: 20), - const SizedBox( - width: 70, - child: BodySmall( - text: "Spotlight", - fontColor: ColorsManager.textPrimaryColor, - textAlign: TextAlign.center, - ), - ), - ], - ), - ], - ), - Expanded( - child: Center( - child: Row( + SizedBox( + height: MediaQuery.of(context).size.height, + child: Column( mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Column( - mainAxisSize: MainAxisSize.min, - children: [ - Card( - elevation: 3, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(100), + const Expanded(child: SizedBox.shrink()), + Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Column( + children: [ + GangSwitch( + threeGangSwitch: device!, + value: threeGangModel.firstSwitch, + action: () { + BlocProvider.of(context).add( + ChangeFirstSwitchStatusEvent( + value: threeGangModel.firstSwitch)); + }, + // control: DeviceControlModel( + // deviceId: device.uuid, + // // code: 'switch_1', + // code: device.status[0].code, + // // value: true, + // value: device.status[0].value, + // ), + ), + const SizedBox(height: 20), + const SizedBox( + width: 70, + child: BodySmall( + text: "Bedside Light", + fontColor: ColorsManager.textPrimaryColor, + textAlign: TextAlign.center, + ), + ), + ], ), - child: GestureDetector( - onTap: () { - // DevicesCubit.getInstance().deviceControl( - // DeviceControlModel( - // deviceId: device.uuid, - // code: 'switch_1', - // value: true, - // ), - // device.uuid!, - // ); - // DevicesCubit.getInstance().deviceControl( - // DeviceControlModel( - // deviceId: device.uuid, - // code: 'switch_2', - // value: true, - // ), - // device.uuid!, - // ); - // DevicesCubit.getInstance().deviceControl( - // DeviceControlModel( - // deviceId: device.uuid, - // code: 'switch_3', - // value: true, - // ), - // device.uuid!, - // ); - BlocProvider.of(context).add(AllOnEvent()); - }, - child: Stack( - alignment: Alignment.center, + Column( + children: [ + GangSwitch( + threeGangSwitch: device!, + value: threeGangModel.secondSwitch, + action: () { + BlocProvider.of(context).add( + ChangeSecondSwitchStatusEvent( + value: threeGangModel.secondSwitch)); + }, + // control: DeviceControlModel( + // // deviceId: 'bfe10693d4fd263206ocq9', + // // code: 'switch_2', + // // value: true, + // deviceId: device.uuid, + // code: device.status[1].code, + // value: device.status[1].value, + // ), + ), + const SizedBox(height: 20), + const SizedBox( + width: 70, + child: BodySmall( + text: "Ceiling Light", + fontColor: ColorsManager.textPrimaryColor, + textAlign: TextAlign.center, + ), + ), + ], + ), + Column( + children: [ + GangSwitch( + threeGangSwitch: device!, + value: threeGangModel.thirdSwitch, + action: () { + BlocProvider.of(context).add( + ChangeThirdSwitchStatusEvent( + value: threeGangModel.thirdSwitch)); + }, + ), + const SizedBox(height: 20), + const SizedBox( + width: 70, + child: BodySmall( + text: "Spotlight", + fontColor: ColorsManager.textPrimaryColor, + textAlign: TextAlign.center, + ), + ), + ], + ), + ], + ), + ), + Expanded( + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Column( + mainAxisSize: MainAxisSize.min, children: [ - Container( - width: 60, - height: 60, - decoration: BoxDecoration( - color: Colors.grey[300], + Card( + elevation: 3, + shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(100), ), + child: GestureDetector( + onTap: () { + // DevicesCubit.getInstance().deviceControl( + // DeviceControlModel( + // deviceId: device.uuid, + // code: 'switch_1', + // value: true, + // ), + // device.uuid!, + // ); + // DevicesCubit.getInstance().deviceControl( + // DeviceControlModel( + // deviceId: device.uuid, + // code: 'switch_2', + // value: true, + // ), + // device.uuid!, + // ); + // DevicesCubit.getInstance().deviceControl( + // DeviceControlModel( + // deviceId: device.uuid, + // code: 'switch_3', + // value: true, + // ), + // device.uuid!, + // ); + BlocProvider.of(context).add(AllOnEvent()); + }, + child: Stack( + alignment: Alignment.center, + children: [ + Container( + width: 60, + height: 60, + decoration: BoxDecoration( + color: Colors.grey[300], + borderRadius: BorderRadius.circular(100), + ), + ), + Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(100), + ), + child: Center( + child: BodySmall( + text: "On", + style: context.bodyMedium.copyWith( + color: ColorsManager.primaryColorWithOpacity, + fontWeight: FontWeight.bold), + ), + ), + ), + ], + ), + ), ), - Container( - width: 40, - height: 40, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(100), - ), - child: Center( - child: BodySmall( - text: "On", - style: context.bodyMedium.copyWith( - color: ColorsManager.primaryColorWithOpacity, - fontWeight: FontWeight.bold), - ), + const SizedBox(height: 10), + BodySmall( + text: "All On", + style: context.bodyMedium.copyWith( + color: ColorsManager.textPrimaryColor, ), ), ], ), - ), - ), - const SizedBox(height: 10), - BodySmall( - text: "All On", - style: context.bodyMedium.copyWith( - color: ColorsManager.textPrimaryColor, - ), - ), - ], - ), - const SizedBox( - width: 20, - ), - Column( - mainAxisSize: MainAxisSize.min, - children: [ - Card( - elevation: 3, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(100), - ), - child: GestureDetector( - onTap: () { - Navigator.push( - context, - PageRouteBuilder( - pageBuilder: (context, animation1, animation2) => - ScheduleScreen( - device: device!, - ))); - }, - child: Stack( - alignment: Alignment.center, + const SizedBox( + width: 20, + ), + Column( + mainAxisSize: MainAxisSize.min, children: [ - Container( - width: 60, - height: 60, - decoration: BoxDecoration( - color: Colors.grey[300], + Card( + elevation: 3, + shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(100), ), + child: GestureDetector( + onTap: () { + Navigator.push( + context, + PageRouteBuilder( + pageBuilder: (context, animation1, animation2) => + ScheduleScreen( + device: device!, + ))); + }, + child: Stack( + alignment: Alignment.center, + children: [ + Container( + width: 60, + height: 60, + decoration: BoxDecoration( + color: Colors.grey[300], + borderRadius: BorderRadius.circular(100), + ), + ), + Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(100), + ), + child: Center( + child: Icon( + Icons.access_time, + color: ColorsManager.primaryColorWithOpacity, + size: 25, + ), + ), + ), + ], + ), + ), ), - Container( - width: 40, - height: 40, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(100), - ), - child: Center( - child: Icon( - Icons.access_time, - color: ColorsManager.primaryColorWithOpacity, - size: 25, - ), + const SizedBox(height: 10), + BodySmall( + text: "Timer", + style: context.bodyMedium.copyWith( + color: ColorsManager.textPrimaryColor, ), ), ], ), - ), - ), - const SizedBox(height: 10), - BodySmall( - text: "Timer", - style: context.bodyMedium.copyWith( - color: ColorsManager.textPrimaryColor, - ), - ), - ], - ), - const SizedBox( - width: 20, - ), - Column( - mainAxisSize: MainAxisSize.min, - children: [ - Card( - elevation: 3, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(100), - ), - child: GestureDetector( - onTap: () { - // DevicesCubit.getInstance().deviceControl( - // DeviceControlModel( - // deviceId: device.uuid, - // code: 'switch_1', - // value: false, - // ), - // device.uuid!, - // ); - // DevicesCubit.getInstance().deviceControl( - // DeviceControlModel( - // deviceId: device.uuid, - // code: 'switch_2', - // value: false, - // ), - // device.uuid!, - // ); - // DevicesCubit.getInstance().deviceControl( - // DeviceControlModel( - // deviceId: device.uuid, - // code: 'switch_3', - // value: false, - // ), - // device.uuid!, - // ); - BlocProvider.of(context) - .add(AllOffEvent()); - }, - child: Stack( - alignment: Alignment.center, + const SizedBox( + width: 20, + ), + Column( + mainAxisSize: MainAxisSize.min, children: [ - Container( - width: 60, - height: 60, - decoration: BoxDecoration( - color: Colors.grey[300], + Card( + elevation: 3, + shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(100), ), + child: GestureDetector( + onTap: () { + // DevicesCubit.getInstance().deviceControl( + // DeviceControlModel( + // deviceId: device.uuid, + // code: 'switch_1', + // value: false, + // ), + // device.uuid!, + // ); + // DevicesCubit.getInstance().deviceControl( + // DeviceControlModel( + // deviceId: device.uuid, + // code: 'switch_2', + // value: false, + // ), + // device.uuid!, + // ); + // DevicesCubit.getInstance().deviceControl( + // DeviceControlModel( + // deviceId: device.uuid, + // code: 'switch_3', + // value: false, + // ), + // device.uuid!, + // ); + BlocProvider.of(context) + .add(AllOffEvent()); + }, + child: Stack( + alignment: Alignment.center, + children: [ + Container( + width: 60, + height: 60, + decoration: BoxDecoration( + color: Colors.grey[300], + borderRadius: BorderRadius.circular(100), + ), + ), + Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(100), + ), + child: Center( + child: BodySmall( + text: "Off", + style: context.bodyMedium.copyWith( + color: ColorsManager.primaryColorWithOpacity, + fontWeight: FontWeight.bold), + ), + ), + ), + ], + ), + ), ), - Container( - width: 40, - height: 40, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(100), - ), - child: Center( - child: BodySmall( - text: "Off", - style: context.bodyMedium.copyWith( - color: ColorsManager.primaryColorWithOpacity, - fontWeight: FontWeight.bold), - ), + const SizedBox(height: 10), + BodySmall( + text: "All Off", + style: context.bodyMedium.copyWith( + color: ColorsManager.textPrimaryColor, ), ), ], ), - ), + ], ), - const SizedBox(height: 10), - BodySmall( - text: "All Off", - style: context.bodyMedium.copyWith( - color: ColorsManager.textPrimaryColor, - ), - ), - ], + ), ), + Expanded(child: SizedBox()) ], ), - ), ), ], - ); + ), + ); }, ), ); diff --git a/lib/features/devices/view/widgets/wall_sensor/wall_sensor_interface.dart b/lib/features/devices/view/widgets/wall_sensor/wall_sensor_interface.dart index bae19e2..2d760d5 100644 --- a/lib/features/devices/view/widgets/wall_sensor/wall_sensor_interface.dart +++ b/lib/features/devices/view/widgets/wall_sensor/wall_sensor_interface.dart @@ -79,21 +79,34 @@ class WallMountedInterface extends StatelessWidget { child: RefreshProgressIndicator(), ) : SafeArea( - child: Column( + child: RefreshIndicator( + onRefresh: () async { + BlocProvider.of(context).add(InitialEvent()); + }, + child: + ListView( children: [ - PresenceIndicator( - state: wallSensorModel.presenceState, - ), - ParametersList( - wallSensor: deviceModel, - presenceSensorsModel: wallSensorModel, + Container( + height: MediaQuery.of(context).size.height, + child: Column( + + children: [ + PresenceIndicator( + state: wallSensorModel.presenceState, + ), + ParametersList( + wallSensor: deviceModel, + presenceSensorsModel: wallSensorModel, + ), + ], + ), ), ], ), ), ), ), - ); + )); }), ); }