mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-24 06:57:56 +00:00
one gang wizard &two Gang wizard & wh wizard
This commit is contained in:
@@ -8,7 +8,8 @@ import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart'
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
|
||||
class OneGangList extends StatelessWidget {
|
||||
const OneGangList({super.key, required this.oneGangList, required this.allSwitches});
|
||||
const OneGangList(
|
||||
{super.key, required this.oneGangList, required this.allSwitches});
|
||||
|
||||
final List<GroupOneGangModel> oneGangList;
|
||||
final bool allSwitches;
|
||||
@@ -48,9 +49,10 @@ class OneGangList extends StatelessWidget {
|
||||
DevicesDefaultSwitch(
|
||||
switchValue: oneGangList[index].firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<OneGangBloc>(context).add(ChangeFirstSwitchStatusEvent(
|
||||
value: oneGangList[index].firstSwitch,
|
||||
deviceId: oneGangList[index].deviceId));
|
||||
BlocProvider.of<OneGangBloc>(context).add(
|
||||
ChangeFirstWizardSwitchStatusEvent(
|
||||
value: oneGangList[index].firstSwitch,
|
||||
deviceId: oneGangList[index].deviceId));
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import 'package:flutter/material.dart';
|
||||
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_event.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/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
|
||||
class OneGangWizard extends StatelessWidget {
|
||||
const OneGangWizard({super.key, this.device});
|
||||
|
||||
final DeviceModel? device;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<GroupOneGangModel> groupOneGangModel = [];
|
||||
|
||||
return DefaultScaffold(
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
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) {
|
||||
groupOneGangModel = state.oneGangList;
|
||||
allSwitchesOn = state.allSwitches;
|
||||
}
|
||||
return state is LoadingInitialState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: OneGangList(
|
||||
oneGangList: groupOneGangModel,
|
||||
allSwitches: allSwitchesOn,
|
||||
);
|
||||
},
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -51,13 +51,7 @@ class ThreeGangScreen extends StatelessWidget {
|
||||
? const Center(
|
||||
child:
|
||||
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
)
|
||||
: device == null
|
||||
? ThreeGangList(
|
||||
threeGangList: groupThreeGangModel,
|
||||
allSwitches: allSwitchesOn,
|
||||
)
|
||||
: RefreshIndicator(
|
||||
) : RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
BlocProvider.of<ThreeGangBloc>(context)
|
||||
.add(InitialEvent(groupScreen: device != null ? false : true));
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/three_gang_bloc/three_gang_bloc.dart';
|
||||
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/three_gang_list.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
|
||||
class ThreeGangWizard extends StatelessWidget {
|
||||
const ThreeGangWizard({super.key, this.device});
|
||||
|
||||
final DeviceModel? device;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultScaffold(
|
||||
child: BlocProvider(
|
||||
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) {
|
||||
groupThreeGangModel = state.threeGangList;
|
||||
allSwitchesOn = state.allSwitches;
|
||||
}
|
||||
return state is LoadingInitialState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: ThreeGangList(
|
||||
threeGangList: groupThreeGangModel,
|
||||
allSwitches: allSwitchesOn,
|
||||
);
|
||||
},
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,8 @@ import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart'
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
|
||||
class TwoGangList extends StatelessWidget {
|
||||
const TwoGangList({super.key, required this.twoGangList, required this.allSwitches});
|
||||
const TwoGangList(
|
||||
{super.key, required this.twoGangList, required this.allSwitches});
|
||||
|
||||
final List<GroupTwoGangModel> twoGangList;
|
||||
final bool allSwitches;
|
||||
@@ -48,9 +49,10 @@ class TwoGangList extends StatelessWidget {
|
||||
DevicesDefaultSwitch(
|
||||
switchValue: twoGangList[index].firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<TwoGangBloc>(context).add(ChangeFirstSwitchStatusEvent(
|
||||
value: twoGangList[index].firstSwitch,
|
||||
deviceId: twoGangList[index].deviceId));
|
||||
BlocProvider.of<TwoGangBloc>(context).add(
|
||||
ChangeFirstWizardSwitchStatusEvent(
|
||||
value: twoGangList[index].firstSwitch,
|
||||
deviceId: twoGangList[index].deviceId));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
@@ -59,9 +61,10 @@ class TwoGangList extends StatelessWidget {
|
||||
DevicesDefaultSwitch(
|
||||
switchValue: twoGangList[index].secondSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<TwoGangBloc>(context).add(ChangeSecondSwitchStatusEvent(
|
||||
value: twoGangList[index].secondSwitch,
|
||||
deviceId: twoGangList[index].deviceId));
|
||||
BlocProvider.of<TwoGangBloc>(context).add(
|
||||
ChangeSecondWizardSwitchStatusEvent(
|
||||
value: twoGangList[index].secondSwitch,
|
||||
deviceId: twoGangList[index].deviceId));
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
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_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});
|
||||
|
||||
final DeviceModel? device;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<GroupTwoGangModel> groupTwoGangModel = [];
|
||||
|
||||
return DefaultScaffold(
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
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) {
|
||||
groupTwoGangModel = state.twoGangList;
|
||||
allSwitchesOn = state.allSwitches;
|
||||
}
|
||||
return state is LoadingInitialState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: TwoGangList(
|
||||
twoGangList: groupTwoGangModel,
|
||||
allSwitches: allSwitchesOn,
|
||||
);
|
||||
},
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/water_heater_bloc/water_heater_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/water_heater_bloc/water_heater_event.dart';
|
||||
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/shared_widgets/devices_default_switch.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
|
||||
class WHList extends StatelessWidget {
|
||||
const WHList({super.key, required this.whList, required this.allSwitches});
|
||||
|
||||
final List<GroupWHModel> whList;
|
||||
final bool allSwitches;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<WaterHeaterBloc, WaterHeaterState>(
|
||||
builder: (context, state) {
|
||||
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<WaterHeaterBloc>(context)
|
||||
.add(GroupAllOnEvent());
|
||||
},
|
||||
secondAction: () {
|
||||
BlocProvider.of<WaterHeaterBloc>(context)
|
||||
.add(GroupAllOffEvent());
|
||||
},
|
||||
),
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(0),
|
||||
itemCount: whList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(text: whList[index].deviceName),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
switchValue: whList[index].firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<WaterHeaterBloc>(context).add(
|
||||
ChangeFirstWizardSwitchStatusEvent(
|
||||
value: whList[index].firstSwitch,
|
||||
deviceId: whList[index].deviceId));
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/water_heater_bloc/water_heater_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/water_heater_bloc/water_heater_event.dart';
|
||||
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/one_gang/one_gang_list.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/water_heater/wh_list.dart';
|
||||
import 'package:syncrow_app/features/menu/bloc/manage_unit_bloc/manage_unit_state.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
|
||||
class WHWizard extends StatelessWidget {
|
||||
const WHWizard({super.key, this.device});
|
||||
|
||||
final DeviceModel? device;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<GroupWHModel> groupModel = [];
|
||||
|
||||
return DefaultScaffold(
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
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) {
|
||||
groupModel = state.twoGangList;
|
||||
allSwitchesOn = state.allSwitches;
|
||||
}
|
||||
return state is WHLoadingState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: WHList(
|
||||
whList: groupModel,
|
||||
allSwitches: allSwitchesOn,
|
||||
);
|
||||
},
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,12 @@ import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_view.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/one_gang/one_gang_Interface.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/one_gang/one_gang_wizard.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_interface.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_wizard.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/two_gang/two_gang_Interface.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/two_gang/two_gang_wizard.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/water_heater/wh_wizard.dart';
|
||||
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/utils/context_extension.dart';
|
||||
@@ -32,26 +36,36 @@ class WizardPage extends StatelessWidget {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) => const ACsView()));
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const ACsView()));
|
||||
}
|
||||
if (groupsList[index].name == '3G') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const ThreeGangInterface()));
|
||||
const ThreeGangWizard()));
|
||||
}
|
||||
if (groupsList[index].name == '2G') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) => const TwoGangInterface()));
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const TwoGangWizard()));
|
||||
}
|
||||
if (groupsList[index].name == '1G') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) => const OneGangInterface()));
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const OneGangWizard()));
|
||||
}
|
||||
if (groupsList[index].name == 'WH') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const WHWizard()));
|
||||
}
|
||||
},
|
||||
child: DefaultContainer(
|
||||
|
||||
Reference in New Issue
Block a user