mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 22:07:55 +00:00
Bug fixes
This commit is contained in:
@@ -3,9 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/one_gang_bloc/one_gang_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/one_gang_bloc/one_gang_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/group_one_gang_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/one_gang_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/one_gang/one_gang_list.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/one_gang/one_gang_timer_screen.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/three_gang/gang_switch.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
@@ -22,9 +20,8 @@ class OneGangScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) =>
|
||||
OneGangBloc(switchCode: 'switch_1', oneGangId: device?.uuid ?? '')
|
||||
..add(const InitialEvent(groupScreen: false)),
|
||||
create: (context) => OneGangBloc(switchCode: 'switch_1', oneGangId: device?.uuid ?? '')
|
||||
..add(const InitialEvent(groupScreen: false)),
|
||||
child: BlocBuilder<OneGangBloc, OneGangState>(
|
||||
builder: (context, state) {
|
||||
OneGangModel oneGangModel = OneGangModel(
|
||||
@@ -32,164 +29,135 @@ class OneGangScreen extends StatelessWidget {
|
||||
firstCountDown: 0,
|
||||
);
|
||||
|
||||
List<GroupOneGangModel> groupOneGangModel = [];
|
||||
bool allSwitchesOn = false;
|
||||
|
||||
if (state is LoadingNewSate) {
|
||||
oneGangModel = state.oneGangModel;
|
||||
} else if (state is UpdateState) {
|
||||
oneGangModel = state.oneGangModel;
|
||||
} else if (state is UpdateGroupState) {
|
||||
groupOneGangModel = state.oneGangList;
|
||||
allSwitchesOn = state.allSwitches;
|
||||
}
|
||||
return state is LoadingInitialState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
child:
|
||||
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
)
|
||||
: device == null
|
||||
? OneGangList(
|
||||
oneGangList: groupOneGangModel,
|
||||
allSwitches: allSwitchesOn)
|
||||
: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
BlocProvider.of<OneGangBloc>(context).add(InitialEvent(
|
||||
groupScreen: device != null ? false : true));
|
||||
},
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const Expanded(child: SizedBox.shrink()),
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
BlocProvider.of<OneGangBloc>(context)
|
||||
.add(InitialEvent(groupScreen: device != null ? false : true));
|
||||
},
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const Expanded(child: SizedBox.shrink()),
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
GangSwitch(
|
||||
threeGangSwitch: device!,
|
||||
value: oneGangModel.firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<OneGangBloc>(
|
||||
context)
|
||||
.add(
|
||||
ChangeFirstSwitchStatusEvent(
|
||||
value: oneGangModel
|
||||
.firstSwitch));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const SizedBox(
|
||||
width: 70,
|
||||
child: BodySmall(
|
||||
text: " Entrance Light",
|
||||
fontColor: ColorsManager
|
||||
.textPrimaryColor,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
GangSwitch(
|
||||
threeGangSwitch: device!,
|
||||
value: oneGangModel.firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<OneGangBloc>(context).add(
|
||||
ChangeFirstSwitchStatusEvent(
|
||||
value: oneGangModel.firstSwitch));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const SizedBox(
|
||||
width: 70,
|
||||
child: BodySmall(
|
||||
text: " Entrance Light",
|
||||
fontColor: ColorsManager.textPrimaryColor,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
children: [
|
||||
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) =>
|
||||
TimerScheduleScreen(
|
||||
switchCode:
|
||||
'switch_1',
|
||||
device: device!,
|
||||
deviceCode:
|
||||
'countdown_1',
|
||||
)));
|
||||
},
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(
|
||||
text: "Timer",
|
||||
style: context.bodyMedium.copyWith(
|
||||
color: ColorsManager
|
||||
.textPrimaryColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(child: SizedBox())
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
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) =>
|
||||
TimerScheduleScreen(
|
||||
switchCode: 'switch_1',
|
||||
device: device!,
|
||||
deviceCode: 'countdown_1',
|
||||
)));
|
||||
},
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(
|
||||
text: "Timer",
|
||||
style: context.bodyMedium.copyWith(
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(child: SizedBox())
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:syncrow_app/features/devices/bloc/one_gang_bloc/one_gang_event.d
|
||||
import 'package:syncrow_app/features/devices/bloc/one_gang_bloc/one_gang_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/group_one_gang_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/one_gang_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/one_gang/one_gang_list.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
@@ -22,30 +21,19 @@ class OneGangWizard extends StatelessWidget {
|
||||
return DefaultScaffold(
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
OneGangBloc(switchCode: '', oneGangId: device?.uuid ?? '')
|
||||
..add(InitialWizardEvent()),
|
||||
OneGangBloc(switchCode: '', oneGangId: device?.uuid ?? '')..add(InitialWizardEvent()),
|
||||
child: BlocBuilder<OneGangBloc, OneGangState>(
|
||||
builder: (context, state) {
|
||||
OneGangModel oneGangModel = OneGangModel(
|
||||
firstSwitch: false,
|
||||
firstCountDown: 0,
|
||||
);
|
||||
bool allSwitchesOn = false;
|
||||
|
||||
if (state is LoadingNewSate) {
|
||||
oneGangModel = state.oneGangModel;
|
||||
} else if (state is UpdateState) {
|
||||
oneGangModel = state.oneGangModel;
|
||||
} else if (state is UpdateGroupState) {
|
||||
if (state is UpdateGroupState) {
|
||||
groupOneGangModel = state.oneGangList;
|
||||
allSwitchesOn = state.allSwitches;
|
||||
}
|
||||
return state is LoadingInitialState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
child:
|
||||
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
)
|
||||
: OneGangList(
|
||||
oneGangList: groupOneGangModel,
|
||||
|
||||
@@ -4,11 +4,9 @@ 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/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/group_three_gang_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/three_gang_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/three_gang/gang_switch.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/three_gang/schedule_screen.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_list.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
@@ -22,9 +20,7 @@ class ThreeGangScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => ThreeGangBloc(
|
||||
switchCode: '',
|
||||
threeGangId: device?.uuid ?? '')
|
||||
create: (context) => ThreeGangBloc(switchCode: '', threeGangId: device?.uuid ?? '')
|
||||
..add(InitialEvent(groupScreen: device != null ? false : true)),
|
||||
child: BlocBuilder<ThreeGangBloc, ThreeGangState>(
|
||||
builder: (context, state) {
|
||||
@@ -36,360 +32,354 @@ class ThreeGangScreen extends StatelessWidget {
|
||||
secondCountDown: 0,
|
||||
thirdCountDown: 0);
|
||||
|
||||
List<GroupThreeGangModel> groupThreeGangModel = [];
|
||||
bool allSwitchesOn = false;
|
||||
|
||||
if (state is LoadingNewSate) {
|
||||
threeGangModel = state.threeGangModel;
|
||||
} else if (state is UpdateState) {
|
||||
threeGangModel = state.threeGangModel;
|
||||
} else if (state is UpdateGroupState) {
|
||||
groupThreeGangModel = state.threeGangList;
|
||||
allSwitchesOn = state.allSwitches;
|
||||
}
|
||||
return state is LoadingInitialState
|
||||
? const Center(
|
||||
child:
|
||||
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
) : RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
BlocProvider.of<ThreeGangBloc>(context)
|
||||
.add(InitialEvent(groupScreen: device != null ? false : true));
|
||||
},
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const Expanded(child: SizedBox.shrink()),
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
BlocProvider.of<ThreeGangBloc>(context)
|
||||
.add(InitialEvent(groupScreen: device != null ? false : true));
|
||||
},
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const Expanded(child: SizedBox.shrink()),
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
GangSwitch(
|
||||
threeGangSwitch: device!,
|
||||
value: threeGangModel.firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(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,
|
||||
),
|
||||
),
|
||||
],
|
||||
GangSwitch(
|
||||
threeGangSwitch: device!,
|
||||
value: threeGangModel.firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(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,
|
||||
// ),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
GangSwitch(
|
||||
threeGangSwitch: device!,
|
||||
value: threeGangModel.secondSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(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<ThreeGangBloc>(context).add(
|
||||
ChangeThirdSwitchStatusEvent(
|
||||
value: threeGangModel.thirdSwitch));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const SizedBox(
|
||||
width: 70,
|
||||
child: BodySmall(
|
||||
text: "Spotlight",
|
||||
fontColor: ColorsManager.textPrimaryColor,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 20),
|
||||
const SizedBox(
|
||||
width: 70,
|
||||
child: BodySmall(
|
||||
text: "Bedside Light",
|
||||
fontColor: ColorsManager.textPrimaryColor,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
Column(
|
||||
children: [
|
||||
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: 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<ThreeGangBloc>(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),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(
|
||||
text: "All On",
|
||||
style: context.bodyMedium.copyWith(
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
GangSwitch(
|
||||
threeGangSwitch: device!,
|
||||
value: threeGangModel.secondSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(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: 20,
|
||||
width: 70,
|
||||
child: BodySmall(
|
||||
text: "Ceiling Light",
|
||||
fontColor: ColorsManager.textPrimaryColor,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
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,
|
||||
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,
|
||||
],
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
GangSwitch(
|
||||
threeGangSwitch: device!,
|
||||
value: threeGangModel.thirdSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(
|
||||
ChangeThirdSwitchStatusEvent(
|
||||
value: threeGangModel.thirdSwitch));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const SizedBox(
|
||||
width: 70,
|
||||
child: BodySmall(
|
||||
text: "Spotlight",
|
||||
fontColor: ColorsManager.textPrimaryColor,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
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: 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<ThreeGangBloc>(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,
|
||||
size: 25,
|
||||
),
|
||||
),
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
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<ThreeGangBloc>(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),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(
|
||||
text: "All Off",
|
||||
style: context.bodyMedium.copyWith(
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(
|
||||
text: "All On",
|
||||
style: context.bodyMedium.copyWith(
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(child: SizedBox())
|
||||
],
|
||||
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,
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
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<ThreeGangBloc>(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),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(
|
||||
text: "All Off",
|
||||
style: context.bodyMedium.copyWith(
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
Expanded(child: SizedBox())
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:syncrow_app/features/devices/bloc/three_gang_bloc/three_gang_eve
|
||||
import 'package:syncrow_app/features/devices/bloc/three_gang_bloc/three_gang_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/group_three_gang_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/three_gang_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_list.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
@@ -19,36 +18,21 @@ class ThreeGangWizard extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultScaffold(
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
ThreeGangBloc(switchCode: '', threeGangId: device?.uuid ?? '')
|
||||
..add(InitialEvent(groupScreen: device != null ? false : true)),
|
||||
create: (context) => ThreeGangBloc(switchCode: '', threeGangId: device?.uuid ?? '')
|
||||
..add(InitialEvent(groupScreen: device != null ? false : true)),
|
||||
child: BlocBuilder<ThreeGangBloc, ThreeGangState>(
|
||||
builder: (context, state) {
|
||||
ThreeGangModel threeGangModel = ThreeGangModel(
|
||||
firstSwitch: false,
|
||||
secondSwitch: false,
|
||||
thirdSwitch: false,
|
||||
firstCountDown: 0,
|
||||
secondCountDown: 0,
|
||||
thirdCountDown: 0);
|
||||
|
||||
List<GroupThreeGangModel> groupThreeGangModel = [];
|
||||
bool allSwitchesOn = false;
|
||||
|
||||
if (state is LoadingNewSate) {
|
||||
threeGangModel = state.threeGangModel;
|
||||
} else if (state is UpdateState) {
|
||||
threeGangModel = state.threeGangModel;
|
||||
} else if (state is UpdateGroupState) {
|
||||
if (state is UpdateGroupState) {
|
||||
groupThreeGangModel = state.threeGangList;
|
||||
allSwitchesOn = state.allSwitches;
|
||||
}
|
||||
return state is LoadingInitialState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
child:
|
||||
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
)
|
||||
: ThreeGangList(
|
||||
threeGangList: groupThreeGangModel,
|
||||
|
||||
@@ -4,10 +4,8 @@ import 'package:syncrow_app/features/devices/bloc/two_gang_bloc/two_gang_bloc.da
|
||||
import 'package:syncrow_app/features/devices/bloc/two_gang_bloc/two_gang_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/two_gang_bloc/two_gang_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/group_two_gang_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/two_gang_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/three_gang/gang_switch.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/two_gang/two_gang_list.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/two_gang/two_schedule_screen.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
@@ -23,7 +21,7 @@ class TwoGangScreen extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => TwoGangBloc(switchCode: switchCode ?? '', twoGangId: device?.uuid ?? '')
|
||||
..add(InitialEvent(groupScreen: device != null ? false : true)),
|
||||
..add(const InitialEvent()),
|
||||
child: BlocBuilder<TwoGangBloc, TwoGangState>(
|
||||
builder: (context, state) {
|
||||
TwoGangModel twoGangModel = TwoGangModel(
|
||||
@@ -33,304 +31,292 @@ class TwoGangScreen extends StatelessWidget {
|
||||
secondCountDown: 0,
|
||||
);
|
||||
|
||||
List<GroupTwoGangModel> groupTwoGangModel = [];
|
||||
bool allSwitchesOn = false;
|
||||
if (state is LoadingNewSate) {
|
||||
twoGangModel = state.twoGangModel;
|
||||
} else if (state is UpdateState) {
|
||||
twoGangModel = state.twoGangModel;
|
||||
} else if (state is UpdateGroupState) {
|
||||
groupTwoGangModel = state.twoGangList;
|
||||
allSwitchesOn = state.allSwitches;
|
||||
}
|
||||
|
||||
return state is LoadingInitialState
|
||||
? const Center(
|
||||
child:
|
||||
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
)
|
||||
: device == null
|
||||
? TwoGangList(
|
||||
twoGangList: groupTwoGangModel,
|
||||
allSwitches: allSwitchesOn,
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
BlocProvider.of<TwoGangBloc>(context)
|
||||
.add(InitialEvent(groupScreen: device != null ? false : true));
|
||||
},
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const Expanded(child: SizedBox.shrink()),
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
BlocProvider.of<TwoGangBloc>(context).add(const InitialEvent());
|
||||
},
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const Expanded(child: SizedBox.shrink()),
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
GangSwitch(
|
||||
threeGangSwitch: device!,
|
||||
value: twoGangModel.firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<TwoGangBloc>(context).add(
|
||||
ChangeFirstSwitchStatusEvent(
|
||||
value: twoGangModel.firstSwitch));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const SizedBox(
|
||||
width: 77,
|
||||
child: BodySmall(
|
||||
text: "Cove Light",
|
||||
fontColor: ColorsManager.textPrimaryColor,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
GangSwitch(
|
||||
threeGangSwitch: device!,
|
||||
value: twoGangModel.firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<TwoGangBloc>(context).add(
|
||||
ChangeFirstSwitchStatusEvent(
|
||||
value: twoGangModel.firstSwitch));
|
||||
},
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
GangSwitch(
|
||||
threeGangSwitch: device!,
|
||||
value: twoGangModel.secondSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<TwoGangBloc>(context).add(
|
||||
ChangeSecondSwitchStatusEvent(
|
||||
value: twoGangModel.secondSwitch));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const SizedBox(
|
||||
width: 77,
|
||||
child: BodySmall(
|
||||
text: "Chandelier",
|
||||
fontColor: ColorsManager.textPrimaryColor,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 20),
|
||||
const SizedBox(
|
||||
width: 77,
|
||||
child: BodySmall(
|
||||
text: "Cove Light",
|
||||
fontColor: ColorsManager.textPrimaryColor,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
Column(
|
||||
children: [
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Card(
|
||||
elevation: 3,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
BlocProvider.of<TwoGangBloc>(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),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(
|
||||
text: "All On",
|
||||
style: context.bodyMedium.copyWith(
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
GangSwitch(
|
||||
threeGangSwitch: device!,
|
||||
value: twoGangModel.secondSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<TwoGangBloc>(context).add(
|
||||
ChangeSecondSwitchStatusEvent(
|
||||
value: twoGangModel.secondSwitch));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
width: 77,
|
||||
child: BodySmall(
|
||||
text: "Chandelier",
|
||||
fontColor: ColorsManager.textPrimaryColor,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
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) =>
|
||||
TwoGangScheduleScreen(
|
||||
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,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Card(
|
||||
elevation: 3,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
BlocProvider.of<TwoGangBloc>(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,
|
||||
size: 25,
|
||||
),
|
||||
),
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
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<TwoGangBloc>(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),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(
|
||||
text: "All Off",
|
||||
style: context.bodyMedium.copyWith(
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(
|
||||
text: "All On",
|
||||
style: context.bodyMedium.copyWith(
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(child: SizedBox())
|
||||
],
|
||||
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) =>
|
||||
TwoGangScheduleScreen(
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
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<TwoGangBloc>(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),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(
|
||||
text: "All Off",
|
||||
style: context.bodyMedium.copyWith(
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
Expanded(child: SizedBox())
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/two_gang_bloc/two_gang_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/two_gang_bloc/two_gang_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/two_gang_bloc/two_gang_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/group_two_gang_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/two_gang_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/two_gang/two_gang_list.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
|
||||
import '../../../bloc/two_gang_bloc/two_gang_event.dart';
|
||||
|
||||
class TwoGangWizard extends StatelessWidget {
|
||||
const TwoGangWizard({super.key, this.device});
|
||||
|
||||
@@ -23,32 +21,19 @@ class TwoGangWizard extends StatelessWidget {
|
||||
return DefaultScaffold(
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
TwoGangBloc(switchCode: '', twoGangId: device?.uuid ?? '')
|
||||
..add(InitialWizardEvent()),
|
||||
TwoGangBloc(switchCode: '', twoGangId: device?.uuid ?? '')..add(InitialWizardEvent()),
|
||||
child: BlocBuilder<TwoGangBloc, TwoGangState>(
|
||||
builder: (context, state) {
|
||||
TwoGangModel twoGangModel = TwoGangModel(
|
||||
firstSwitch: false,
|
||||
secondSwitch: false,
|
||||
firstCountDown: 0,
|
||||
secondCountDown: 0,
|
||||
);
|
||||
bool allSwitchesOn = false;
|
||||
|
||||
if (state is LoadingNewSate) {
|
||||
twoGangModel = state.twoGangModel;
|
||||
} else if (state is UpdateState) {
|
||||
twoGangModel = state.twoGangModel;
|
||||
} else if (state is UpdateGroupState) {
|
||||
if (state is UpdateGroupState) {
|
||||
groupTwoGangModel = state.twoGangList;
|
||||
allSwitchesOn = state.allSwitches;
|
||||
}
|
||||
return state is LoadingInitialState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
child:
|
||||
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
)
|
||||
: TwoGangList(
|
||||
twoGangList: groupTwoGangModel,
|
||||
|
||||
@@ -25,10 +25,7 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
final String deviceCode;
|
||||
final String switchCode;
|
||||
const WHTimerScheduleScreen(
|
||||
{required this.device,
|
||||
required this.deviceCode,
|
||||
required this.switchCode,
|
||||
super.key});
|
||||
{required this.device, required this.deviceCode, required this.switchCode, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -38,10 +35,9 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
),
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
WaterHeaterBloc(switchCode: switchCode, whId: device.uuid ?? '')
|
||||
..add(GetCounterEvent(deviceCode: deviceCode))
|
||||
..add(GetScheduleEvent()),
|
||||
create: (context) => WaterHeaterBloc(switchCode: switchCode, whId: device.uuid ?? '')
|
||||
..add(GetCounterEvent(deviceCode: deviceCode))
|
||||
..add(GetScheduleEvent()),
|
||||
child: BlocBuilder<WaterHeaterBloc, WaterHeaterState>(
|
||||
builder: (context, state) {
|
||||
final waterHeaterBloc = BlocProvider.of<WaterHeaterBloc>(context);
|
||||
@@ -87,9 +83,8 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
// waterHeaterBloc.toggleCreateSchedule();
|
||||
waterHeaterBloc.add(
|
||||
const ToggleCreateScheduleEvent(
|
||||
index: 1));
|
||||
waterHeaterBloc
|
||||
.add(const ToggleCreateScheduleEvent(index: 1));
|
||||
},
|
||||
icon: const Icon(Icons.add),
|
||||
)
|
||||
@@ -104,7 +99,7 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
: waterHeaterBloc.selectedTabIndex == 2
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
waterHeaterBloc.toggleCreateCirculate();
|
||||
waterHeaterBloc.add(ToggleCreateCirculate());
|
||||
},
|
||||
icon: const Icon(Icons.add),
|
||||
)
|
||||
@@ -120,8 +115,7 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
decoration: const ShapeDecoration(
|
||||
color: ColorsManager.onPrimaryColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(30)),
|
||||
borderRadius: BorderRadius.all(Radius.circular(30)),
|
||||
),
|
||||
),
|
||||
child: TabBar(
|
||||
@@ -130,49 +124,34 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
labelPadding: EdgeInsets.zero,
|
||||
onTap: (value) {
|
||||
if (value == 0) {
|
||||
if (waterHeaterBloc.createSchedule ==
|
||||
true) {
|
||||
if (waterHeaterBloc.createSchedule == true) {
|
||||
// waterHeaterBloc
|
||||
// .toggleCreateSchedule();
|
||||
waterHeaterBloc.add(
|
||||
const ToggleCreateScheduleEvent(
|
||||
index: 1));
|
||||
waterHeaterBloc
|
||||
.add(const ToggleCreateScheduleEvent(index: 1));
|
||||
}
|
||||
waterHeaterBloc.add(
|
||||
ToggleSelectedEvent(
|
||||
index: value));
|
||||
waterHeaterBloc.add(ToggleSelectedEvent(index: value));
|
||||
// waterHeaterBloc
|
||||
// .toggleSelectedIndex(value);
|
||||
} else if (value == 2) {
|
||||
if (waterHeaterBloc.createCirculate ==
|
||||
true) {
|
||||
waterHeaterBloc.add(
|
||||
ToggleCreateCirculateEvent(
|
||||
index: value));
|
||||
if (waterHeaterBloc.createCirculate == true) {
|
||||
waterHeaterBloc
|
||||
.add(ToggleCreateCirculateEvent(index: value));
|
||||
// waterHeaterBloc
|
||||
// .toggleCreateCirculate();
|
||||
}
|
||||
waterHeaterBloc.add(
|
||||
ToggleSelectedEvent(
|
||||
index: value));
|
||||
waterHeaterBloc.add(ToggleSelectedEvent(index: value));
|
||||
// waterHeaterBloc
|
||||
// .toggleSelectedIndex(value);
|
||||
} else {
|
||||
if (waterHeaterBloc.createSchedule ==
|
||||
true) {
|
||||
waterHeaterBloc.add(
|
||||
ToggleSelectedEvent(
|
||||
index: value));
|
||||
if (waterHeaterBloc.createSchedule == true) {
|
||||
waterHeaterBloc.add(ToggleSelectedEvent(index: value));
|
||||
// waterHeaterBloc
|
||||
// .toggleCreateSchedule();
|
||||
}
|
||||
waterHeaterBloc.createCirculate =
|
||||
false;
|
||||
waterHeaterBloc.createSchedule =
|
||||
false;
|
||||
waterHeaterBloc.add(
|
||||
ToggleSelectedEvent(
|
||||
index: value));
|
||||
waterHeaterBloc.createCirculate = false;
|
||||
waterHeaterBloc.createSchedule = false;
|
||||
waterHeaterBloc.add(ToggleSelectedEvent(index: value));
|
||||
// waterHeaterBloc
|
||||
// .toggleSelectedIndex(value);
|
||||
}
|
||||
@@ -183,39 +162,31 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
indicator: const ShapeDecoration(
|
||||
color: ColorsManager.slidingBlueColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(20)),
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
),
|
||||
),
|
||||
isScrollable: false,
|
||||
labelColor: Colors
|
||||
.white, // Text color when selected
|
||||
unselectedLabelColor: ColorsManager
|
||||
.blackColor, // Text color when not selected
|
||||
labelColor: Colors.white, // Text color when selected
|
||||
unselectedLabelColor:
|
||||
ColorsManager.blackColor, // Text color when not selected
|
||||
tabs: [
|
||||
Tab(
|
||||
icon: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 10.0),
|
||||
padding: const EdgeInsets.only(top: 10.0),
|
||||
child: SvgPicture.asset(
|
||||
Assets.scheduleTimeIcon,
|
||||
color: waterHeaterBloc
|
||||
.selectedTabIndex ==
|
||||
0
|
||||
color: waterHeaterBloc.selectedTabIndex == 0
|
||||
? Colors.white
|
||||
: ColorsManager
|
||||
.blackColor, // Change icon color based on selectedIndex
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 5),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
child: BodySmall(
|
||||
text: 'Countdown',
|
||||
style: context.bodySmall.copyWith(
|
||||
color: waterHeaterBloc
|
||||
.selectedTabIndex ==
|
||||
0
|
||||
color: waterHeaterBloc.selectedTabIndex == 0
|
||||
? Colors.white
|
||||
: ColorsManager
|
||||
.blackColor, // Text color based on selectedTabIndex
|
||||
@@ -227,26 +198,20 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
),
|
||||
Tab(
|
||||
icon: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 10),
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: SvgPicture.asset(
|
||||
Assets.scheduleCelenderIcon,
|
||||
color: waterHeaterBloc
|
||||
.selectedTabIndex ==
|
||||
1
|
||||
color: waterHeaterBloc.selectedTabIndex == 1
|
||||
? Colors.white
|
||||
: ColorsManager.blackColor,
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 5),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
child: Text(
|
||||
'Schedule',
|
||||
style: context.bodySmall.copyWith(
|
||||
color: waterHeaterBloc
|
||||
.selectedTabIndex ==
|
||||
1
|
||||
color: waterHeaterBloc.selectedTabIndex == 1
|
||||
? Colors.white
|
||||
: ColorsManager.blackColor,
|
||||
fontSize: 12,
|
||||
@@ -257,26 +222,20 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
),
|
||||
Tab(
|
||||
icon: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 10),
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: SvgPicture.asset(
|
||||
Assets.scheduleCirculateIcon,
|
||||
color: waterHeaterBloc
|
||||
.selectedTabIndex ==
|
||||
2
|
||||
color: waterHeaterBloc.selectedTabIndex == 2
|
||||
? Colors.white
|
||||
: ColorsManager.blackColor,
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 5),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
child: Text(
|
||||
'Circulate',
|
||||
style: context.bodySmall.copyWith(
|
||||
color: waterHeaterBloc
|
||||
.selectedTabIndex ==
|
||||
2
|
||||
color: waterHeaterBloc.selectedTabIndex == 2
|
||||
? Colors.white
|
||||
: ColorsManager.blackColor,
|
||||
fontSize: 12,
|
||||
@@ -287,26 +246,20 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
),
|
||||
Tab(
|
||||
icon: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 10),
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: SvgPicture.asset(
|
||||
Assets.scheduleInchingIcon,
|
||||
color: waterHeaterBloc
|
||||
.selectedTabIndex ==
|
||||
3
|
||||
color: waterHeaterBloc.selectedTabIndex == 3
|
||||
? Colors.white
|
||||
: ColorsManager.blackColor,
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 5),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
child: Text(
|
||||
'Inching',
|
||||
style: context.bodySmall.copyWith(
|
||||
color: waterHeaterBloc
|
||||
.selectedTabIndex ==
|
||||
3
|
||||
color: waterHeaterBloc.selectedTabIndex == 3
|
||||
? Colors.white
|
||||
: ColorsManager.blackColor,
|
||||
fontSize: 12,
|
||||
@@ -325,106 +278,75 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
Center(
|
||||
child: Container(
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
countNum > 0
|
||||
? BodyLarge(
|
||||
text: _formatDuration(
|
||||
countNum),
|
||||
fontColor: ColorsManager
|
||||
.slidingBlueColor,
|
||||
text: _formatDuration(countNum),
|
||||
fontColor: ColorsManager.slidingBlueColor,
|
||||
fontSize: 40,
|
||||
)
|
||||
: CupertinoTimerPicker(
|
||||
mode:
|
||||
CupertinoTimerPickerMode
|
||||
.hm,
|
||||
mode: CupertinoTimerPickerMode.hm,
|
||||
onTimerDurationChanged:
|
||||
(Duration
|
||||
newDuration) {
|
||||
(Duration newDuration) {
|
||||
duration = newDuration;
|
||||
},
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
if (state
|
||||
is LoadingNewSate) {
|
||||
if (state is LoadingNewSate) {
|
||||
return;
|
||||
}
|
||||
if (countNum > 0) {
|
||||
waterHeaterBloc.add(
|
||||
SetCounterValue(
|
||||
deviceCode:
|
||||
deviceCode,
|
||||
duration: Duration
|
||||
.zero));
|
||||
} else if (duration !=
|
||||
Duration.zero) {
|
||||
waterHeaterBloc.add(
|
||||
SetCounterValue(
|
||||
deviceCode:
|
||||
deviceCode,
|
||||
duration:
|
||||
duration));
|
||||
waterHeaterBloc.add(SetCounterValue(
|
||||
deviceCode: deviceCode,
|
||||
duration: Duration.zero));
|
||||
} else if (duration != Duration.zero) {
|
||||
waterHeaterBloc.add(SetCounterValue(
|
||||
deviceCode: deviceCode,
|
||||
duration: duration));
|
||||
}
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
countNum > 0
|
||||
? Assets.pauseIcon
|
||||
: Assets.playIcon)),
|
||||
child: SvgPicture.asset(countNum > 0
|
||||
? Assets.pauseIcon
|
||||
: Assets.playIcon)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
child: waterHeaterBloc.createSchedule ==
|
||||
true
|
||||
child: waterHeaterBloc.createSchedule == true
|
||||
? CreateSchedule(
|
||||
onToggleChanged: (bool isOn) {
|
||||
waterHeaterBloc
|
||||
.toggleSchedule = isOn;
|
||||
waterHeaterBloc.toggleSchedule = isOn;
|
||||
},
|
||||
onDateTimeChanged:
|
||||
(DateTime dateTime) {
|
||||
waterHeaterBloc.selectedTime =
|
||||
dateTime;
|
||||
onDateTimeChanged: (DateTime dateTime) {
|
||||
waterHeaterBloc.selectedTime = dateTime;
|
||||
},
|
||||
days: waterHeaterBloc.days,
|
||||
selectDays: (List<String>
|
||||
selectedDays) {
|
||||
waterHeaterBloc.selectedDays =
|
||||
selectedDays;
|
||||
selectDays: (List<String> selectedDays) {
|
||||
waterHeaterBloc.selectedDays = selectedDays;
|
||||
},
|
||||
)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 10),
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ScheduleListView(
|
||||
listSchedule:
|
||||
waterHeaterBloc
|
||||
.listSchedule, // Pass the schedule list here
|
||||
onDismissed:
|
||||
(scheduleId) {
|
||||
waterHeaterBloc
|
||||
.listSchedule
|
||||
.removeWhere(
|
||||
(schedule) =>
|
||||
schedule
|
||||
.scheduleId ==
|
||||
scheduleId);
|
||||
listSchedule: waterHeaterBloc
|
||||
.listSchedule, // Pass the schedule list here
|
||||
onDismissed: (scheduleId) {
|
||||
waterHeaterBloc.listSchedule.removeWhere(
|
||||
(schedule) =>
|
||||
schedule.scheduleId ==
|
||||
scheduleId);
|
||||
waterHeaterBloc.add(
|
||||
DeleteScheduleEvent(
|
||||
id: scheduleId));
|
||||
DeleteScheduleEvent(id: scheduleId));
|
||||
},
|
||||
onToggleSchedule:
|
||||
(scheduleId,
|
||||
isEnabled) {
|
||||
waterHeaterBloc.add(
|
||||
ToggleScheduleEvent(
|
||||
onToggleSchedule: (scheduleId, isEnabled) {
|
||||
waterHeaterBloc.add(ToggleScheduleEvent(
|
||||
id: scheduleId,
|
||||
toggle: isEnabled,
|
||||
));
|
||||
@@ -437,56 +359,39 @@ class WHTimerScheduleScreen extends StatelessWidget {
|
||||
),
|
||||
Center(
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
waterHeaterBloc.createCirculate ==
|
||||
true
|
||||
waterHeaterBloc.createCirculate == true
|
||||
? CirculateWidget(
|
||||
endDuration: () {
|
||||
waterHeaterBloc.add(
|
||||
SelectTimeEvent(
|
||||
context: context,
|
||||
isEffective:
|
||||
false));
|
||||
waterHeaterBloc.add(SelectTimeEvent(
|
||||
context: context, isEffective: false));
|
||||
},
|
||||
startDuration: () {
|
||||
waterHeaterBloc.add(
|
||||
SelectTimeEvent(
|
||||
context: context,
|
||||
isEffective:
|
||||
false));
|
||||
waterHeaterBloc.add(SelectTimeEvent(
|
||||
context: context, isEffective: false));
|
||||
},
|
||||
isStartEndTime: true,
|
||||
startTime: DateTime.now(),
|
||||
endTime: DateTime.now(),
|
||||
days: waterHeaterBloc.days,
|
||||
selectedDays: [],
|
||||
onToggleStartEndTime:
|
||||
(c) {},
|
||||
onToggleStartEndTime: (c) {},
|
||||
onTimeChanged: (x, f) {},
|
||||
onDaySelected: (p0) {},
|
||||
)
|
||||
: CirculateListView(
|
||||
listSchedule: [], // Pass the schedule list here
|
||||
onDismissed: (scheduleId) {
|
||||
waterHeaterBloc.listSchedule.removeWhere(
|
||||
(schedule) =>
|
||||
schedule.scheduleId == scheduleId);
|
||||
waterHeaterBloc
|
||||
.listSchedule
|
||||
.removeWhere((schedule) =>
|
||||
schedule
|
||||
.scheduleId ==
|
||||
scheduleId);
|
||||
waterHeaterBloc.add(
|
||||
DeleteScheduleEvent(
|
||||
id: scheduleId));
|
||||
.add(DeleteScheduleEvent(id: scheduleId));
|
||||
},
|
||||
onToggleSchedule:
|
||||
(scheduleId,
|
||||
isEnabled) {
|
||||
waterHeaterBloc.add(
|
||||
ToggleScheduleEvent(
|
||||
onToggleSchedule: (scheduleId, isEnabled) {
|
||||
waterHeaterBloc.add(ToggleScheduleEvent(
|
||||
id: scheduleId,
|
||||
toggle: isEnabled,
|
||||
));
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:syncrow_app/features/devices/bloc/water_heater_bloc/water_heater
|
||||
import 'package:syncrow_app/features/devices/bloc/water_heater_bloc/water_heater_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/GroupWHModel.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/water_heater.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/water_heater/wh_list.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
@@ -22,30 +21,19 @@ class WHWizard extends StatelessWidget {
|
||||
return DefaultScaffold(
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
WaterHeaterBloc(switchCode: '', whId: device?.uuid ?? '')
|
||||
..add(InitialWizardEvent()),
|
||||
WaterHeaterBloc(switchCode: '', whId: device?.uuid ?? '')..add(InitialWizardEvent()),
|
||||
child: BlocBuilder<WaterHeaterBloc, WaterHeaterState>(
|
||||
builder: (context, state) {
|
||||
WHModel whModel = WHModel(
|
||||
firstSwitch: false,
|
||||
firstCountDown: 0,
|
||||
);
|
||||
bool allSwitchesOn = false;
|
||||
|
||||
if (state is LoadingNewSate) {
|
||||
whModel = state.whModel;
|
||||
} else if (state is UpdateState) {
|
||||
whModel = state.whModel;
|
||||
} else if (state is UpdateGroupState) {
|
||||
if (state is UpdateGroupState) {
|
||||
groupModel = state.twoGangList;
|
||||
allSwitchesOn = state.allSwitches;
|
||||
}
|
||||
return state is WHLoadingState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
child:
|
||||
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
)
|
||||
: WHList(
|
||||
whList: groupModel,
|
||||
|
||||
Reference in New Issue
Block a user