mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-24 13:37:55 +00:00
Merged with SP-203
This commit is contained in:
@@ -11,6 +11,7 @@ import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface_temp_
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
||||
|
||||
class AcInterface extends StatelessWidget {
|
||||
const AcInterface({super.key, required this.ac});
|
||||
@@ -22,15 +23,12 @@ class AcInterface extends StatelessWidget {
|
||||
return BlocConsumer<ACsBloc, AcsState>(
|
||||
listener: (context, state) {
|
||||
if (state is AcsFailedState) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(state.error),
|
||||
),
|
||||
);
|
||||
CustomSnackBar.displaySnackBar(state.errorMessage);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
AcStatusModel statusModel = AcStatusModel(
|
||||
uuid: ac.uuid ?? '',
|
||||
acSwitch: true,
|
||||
modeString: 'hot',
|
||||
tempSet: 300,
|
||||
|
||||
@@ -9,14 +9,12 @@ import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
|
||||
class ACModeControlUnit extends StatelessWidget {
|
||||
const ACModeControlUnit({
|
||||
super.key,
|
||||
required this.acStatus,
|
||||
required this.deviceId,
|
||||
});
|
||||
const ACModeControlUnit(
|
||||
{super.key, required this.acStatus, required this.deviceId, this.productId = ''});
|
||||
|
||||
final AcStatusModel acStatus;
|
||||
final String deviceId;
|
||||
final String? productId;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -28,8 +26,10 @@ class ACModeControlUnit extends StatelessWidget {
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (state is! AcChangeLoading && state is! AcsLoadingState) {
|
||||
BlocProvider.of<ACsBloc>(context)
|
||||
.add(ChangeFanSpeed(fanSpeeds: acStatus.acFanSpeed, deviceId: deviceId));
|
||||
BlocProvider.of<ACsBloc>(context).add(ChangeFanSpeed(
|
||||
fanSpeeds: acStatus.acFanSpeed,
|
||||
deviceId: deviceId,
|
||||
productId: productId ?? ''));
|
||||
}
|
||||
// else if (state is AcModifyingState) {
|
||||
// BlocProvider.of<ACsBloc>(context)
|
||||
@@ -54,8 +54,10 @@ class ACModeControlUnit extends StatelessWidget {
|
||||
// .add(ChangeAcMode(tempModes: state.acStatusModel.acMode));
|
||||
// }
|
||||
if (state is! AcChangeLoading && state is! AcsLoadingState) {
|
||||
BlocProvider.of<ACsBloc>(context)
|
||||
.add(ChangeAcMode(tempModes: acStatus.acMode, deviceId: deviceId));
|
||||
BlocProvider.of<ACsBloc>(context).add(ChangeAcMode(
|
||||
tempModes: acStatus.acMode,
|
||||
deviceId: deviceId,
|
||||
productId: productId ?? ''));
|
||||
}
|
||||
},
|
||||
child: DefaultContainer(
|
||||
|
||||
@@ -35,10 +35,10 @@ class ACTempWidget extends StatelessWidget {
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
double tempC = temp / 10;
|
||||
if (tempC > 20) {
|
||||
BlocProvider.of<ACsBloc>(context)
|
||||
.add(DecreaseCoolToTemp(value: tempC, deviceId: deviceModel.uuid ?? ''));
|
||||
}
|
||||
BlocProvider.of<ACsBloc>(context).add(DecreaseCoolToTemp(
|
||||
value: tempC,
|
||||
deviceId: deviceModel.uuid ?? '',
|
||||
productId: deviceModel.productUuid ?? ''));
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
Assets.assetsIconsMinus,
|
||||
@@ -57,10 +57,10 @@ class ACTempWidget extends StatelessWidget {
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
double tempC = temp / 10;
|
||||
if (tempC < 30) {
|
||||
BlocProvider.of<ACsBloc>(context)
|
||||
.add(IncreaseCoolToTemp(value: tempC, deviceId: deviceModel.uuid ?? ''));
|
||||
}
|
||||
BlocProvider.of<ACsBloc>(context).add(IncreaseCoolToTemp(
|
||||
value: tempC,
|
||||
deviceId: deviceModel.uuid ?? '',
|
||||
productId: deviceModel.productUuid ?? ''));
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
Assets.assetsIconsPlus,
|
||||
|
||||
@@ -9,9 +9,9 @@ import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_mode_control_un
|
||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_temp_widget.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/universal_ac_temp.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/universal_switch.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
||||
|
||||
class ACsList extends StatelessWidget {
|
||||
const ACsList({
|
||||
@@ -20,7 +20,12 @@ class ACsList extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<ACsBloc, AcsState>(
|
||||
return BlocConsumer<ACsBloc, AcsState>(
|
||||
listener: (context, state) {
|
||||
if (state is AcsFailedState) {
|
||||
CustomSnackBar.displaySnackBar(state.errorMessage);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
List<AcStatusModel> devicesStatuesList = [];
|
||||
List<DeviceModel> devicesList = [];
|
||||
@@ -35,74 +40,78 @@ class ACsList extends StatelessWidget {
|
||||
temperature = state.temp;
|
||||
}
|
||||
return SingleChildScrollView(
|
||||
child: state is AcChangeLoading || state is AcsLoadingState
|
||||
? const Center(
|
||||
child:
|
||||
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
)
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// universal AC controller
|
||||
const SizedBox(height: 10),
|
||||
const BodySmall(text: "All ACs"),
|
||||
const SizedBox(height: 5),
|
||||
UniversalSwitch(
|
||||
allOn: allOn,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
UniversalACTemp(
|
||||
allTempSame: allTempSame,
|
||||
temp: temperature,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
child:
|
||||
// state is AcChangeLoading || state is AcsLoadingState
|
||||
// ? const Center(
|
||||
// child:
|
||||
// DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
// )
|
||||
// :
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// universal AC controller
|
||||
const SizedBox(height: 10),
|
||||
const BodySmall(text: "All ACs"),
|
||||
const SizedBox(height: 5),
|
||||
UniversalSwitch(
|
||||
allOn: allOn,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
UniversalACTemp(
|
||||
allTempSame: allTempSame,
|
||||
temp: temperature,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
// other ACs controls
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(0),
|
||||
itemCount: devicesList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
BodySmall(text: devicesList[index].name ?? ''),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
switchValue: devicesStatuesList[index].acSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ACsBloc>(context).add(AcSwitch(
|
||||
acSwitch: devicesStatuesList[index].acSwitch,
|
||||
deviceId: devicesList[index].uuid ?? ''));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
ACTempWidget(
|
||||
deviceModel: devicesList[index],
|
||||
temp: devicesStatuesList[index].tempSet,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
ACModeControlUnit(
|
||||
acStatus: devicesStatuesList[index],
|
||||
// other ACs controls
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(0),
|
||||
itemCount: devicesList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
BodySmall(text: devicesList[index].name ?? ''),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
switchValue: devicesStatuesList[index].acSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ACsBloc>(context).add(AcSwitch(
|
||||
acSwitch: devicesStatuesList[index].acSwitch,
|
||||
deviceId: devicesList[index].uuid ?? '',
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
productId: devicesList[index].productUuid ?? ''));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
ACTempWidget(
|
||||
deviceModel: devicesList[index],
|
||||
temp: devicesStatuesList[index].tempSet,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
ACModeControlUnit(
|
||||
acStatus: devicesStatuesList[index],
|
||||
deviceId: devicesList[index].uuid ?? '',
|
||||
productId: devicesList[index].productUuid ?? '',
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -29,9 +29,7 @@ class UniversalACTemp extends StatelessWidget {
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
double temperature = temp / 10;
|
||||
if (temperature < 30) {
|
||||
BlocProvider.of<ACsBloc>(context).add(DecreaseAllTemp(value: temperature));
|
||||
}
|
||||
BlocProvider.of<ACsBloc>(context).add(DecreaseAllTemp(value: temperature));
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
Assets.assetsIconsMinus,
|
||||
@@ -50,9 +48,7 @@ class UniversalACTemp extends StatelessWidget {
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
double temperature = temp / 10;
|
||||
if (temperature > 20) {
|
||||
BlocProvider.of<ACsBloc>(context).add(IncreaseAllTemp(value: temperature));
|
||||
}
|
||||
BlocProvider.of<ACsBloc>(context).add(IncreaseAllTemp(value: temperature));
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
Assets.assetsIconsPlus,
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:syncrow_app/features/devices/bloc/three_gang_bloc/three_gang_blo
|
||||
import 'package:syncrow_app/features/devices/bloc/three_gang_bloc/three_gang_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/three_gang_bloc/three_gang_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/group_three_gang_model.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
|
||||
@@ -18,78 +17,71 @@ class ThreeGangList extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<ThreeGangBloc, ThreeGangState>(
|
||||
builder: (context, state) {
|
||||
return state is LoadingNewSate
|
||||
? const Center(
|
||||
child: DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
)
|
||||
: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
const BodySmall(text: 'All Lights'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
switchValue: allSwitches,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(GroupAllOnEvent());
|
||||
},
|
||||
secondAction: () {
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(GroupAllOffEvent());
|
||||
},
|
||||
),
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(0),
|
||||
itemCount: threeGangList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(text: '${threeGangList[index].deviceName} beside light'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
switchValue: threeGangList[index].firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(
|
||||
ChangeFirstSwitchStatusEvent(
|
||||
value: threeGangList[index].firstSwitch,
|
||||
deviceId: threeGangList[index].deviceId));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(text: '${threeGangList[index].deviceName} ceiling light'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
switchValue: threeGangList[index].secondSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(
|
||||
ChangeSecondSwitchStatusEvent(
|
||||
value: threeGangList[index].secondSwitch,
|
||||
deviceId: threeGangList[index].deviceId));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(text: '${threeGangList[index].deviceName} spotlight'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
switchValue: threeGangList[index].thirdSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(
|
||||
ChangeThirdSwitchStatusEvent(
|
||||
value: threeGangList[index].thirdSwitch,
|
||||
deviceId: threeGangList[index].deviceId));
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
const BodySmall(text: 'All Lights'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
switchValue: allSwitches,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(GroupAllOnEvent());
|
||||
},
|
||||
secondAction: () {
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(GroupAllOffEvent());
|
||||
},
|
||||
),
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(0),
|
||||
itemCount: threeGangList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(text: '${threeGangList[index].deviceName} beside light'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
switchValue: threeGangList[index].firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(ChangeFirstSwitchStatusEvent(
|
||||
value: threeGangList[index].firstSwitch,
|
||||
deviceId: threeGangList[index].deviceId));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(text: '${threeGangList[index].deviceName} ceiling light'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
switchValue: threeGangList[index].secondSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(ChangeSecondSwitchStatusEvent(
|
||||
value: threeGangList[index].secondSwitch,
|
||||
deviceId: threeGangList[index].deviceId));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(text: '${threeGangList[index].deviceName} spotlight'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
switchValue: threeGangList[index].thirdSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(ChangeThirdSwitchStatusEvent(
|
||||
value: threeGangList[index].thirdSwitch,
|
||||
deviceId: threeGangList[index].deviceId));
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user