mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-23 20:47:57 +00:00
4scene
This commit is contained in:
@@ -42,11 +42,12 @@ class FourSceneScreen extends StatelessWidget {
|
||||
child: BlocProvider(
|
||||
create: (context) => FourSceneBloc(fourSceneId: device?.uuid ?? '')
|
||||
..add(const FourSceneInitial())
|
||||
..add(FourSceneInitialInfo()),
|
||||
..add(const FourSceneInitialInfo())
|
||||
..add(const FourSceneSwitchInitial()),
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<FourSceneBloc>(context);
|
||||
FourSceneModel model = FourSceneModel(
|
||||
final _bloc = BlocProvider.of<FourSceneBloc>(context);
|
||||
FourSceneModelState model = FourSceneModelState(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
@@ -54,9 +55,9 @@ class FourSceneScreen extends StatelessWidget {
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.sosSensor;
|
||||
model = state.device;
|
||||
} else if (state is UpdateState) {
|
||||
model = state.sensor;
|
||||
model = state.device;
|
||||
}
|
||||
return state is FourSceneLoadingState
|
||||
? const Center(
|
||||
@@ -67,7 +68,7 @@ class FourSceneScreen extends StatelessWidget {
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
sensor.add(const FourSceneInitial());
|
||||
_bloc.add(const FourSceneInitial());
|
||||
},
|
||||
child: ListView(
|
||||
children: [
|
||||
@@ -76,29 +77,45 @@ class FourSceneScreen extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
FourSwitchsCard(
|
||||
switch1Down: sensor.switchStatus == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch1Up: sensor.switchStatus == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch2Down: sensor.switchStatus == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch2Up: sensor.switchStatus == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
title1: _bloc.fourScene.isNotEmpty
|
||||
? _bloc.fourScene[0].switchName
|
||||
: 'title1',
|
||||
title2: _bloc.fourScene.length > 1
|
||||
? _bloc.fourScene[1].switchName
|
||||
: 'title2',
|
||||
title3: _bloc.fourScene.length > 2
|
||||
? _bloc.fourScene[2].switchName
|
||||
: 'title3',
|
||||
title4: _bloc.fourScene.length > 3
|
||||
? _bloc.fourScene[3].switchName
|
||||
: 'title4',
|
||||
switch1:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch2:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch3:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch4:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
onSwitch1UpTap: () {
|
||||
debugPrint("Switch 1 Up tapped");
|
||||
},
|
||||
onSwitch1DownTap: () {
|
||||
debugPrint("Switch 1 Down tapped");
|
||||
},
|
||||
onSwitch2UpTap: () {
|
||||
debugPrint("Switch 2 Up tapped");
|
||||
},
|
||||
onSwitch2DownTap: () {
|
||||
debugPrint("Switch 2 Down tapped");
|
||||
onSwitch3DownTap: () {
|
||||
debugPrint("onSwitch3DownTap");
|
||||
},
|
||||
onSwitch4DownTap: () {
|
||||
debugPrint("onSwitch4DownTap");
|
||||
},
|
||||
),
|
||||
Flexible(
|
||||
@@ -107,7 +124,7 @@ class FourSceneScreen extends StatelessWidget {
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
sensor.add(ChangeSwitchStatusEvent());
|
||||
_bloc.add(ChangeSwitchStatusEvent());
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
|
||||
+3
-3
@@ -29,7 +29,7 @@ class FourSceneCreateGroup extends StatelessWidget {
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<FourSceneBloc>(context);
|
||||
FourSceneModel model = FourSceneModel(
|
||||
FourSceneModelState model = FourSceneModelState(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
@@ -37,9 +37,9 @@ class FourSceneCreateGroup extends StatelessWidget {
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.sosSensor;
|
||||
model = state.device;
|
||||
} else if (state is UpdateState) {
|
||||
model = state.sensor;
|
||||
model = state.device;
|
||||
}
|
||||
return state is LoadingNewSate
|
||||
? const Center(
|
||||
|
||||
+3
-3
@@ -29,7 +29,7 @@ class FourSceneInfoPage extends StatelessWidget {
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
builder: (context, state) {
|
||||
final _bloc = BlocProvider.of<FourSceneBloc>(context);
|
||||
FourSceneModel model = FourSceneModel(
|
||||
FourSceneModelState model = FourSceneModelState(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
@@ -37,9 +37,9 @@ class FourSceneInfoPage extends StatelessWidget {
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.sosSensor;
|
||||
model = state.device;
|
||||
} else if (state is UpdateState) {
|
||||
model = state.sensor;
|
||||
model = state.device;
|
||||
}
|
||||
return state is FourSceneLoadingState
|
||||
? const Center(
|
||||
|
||||
+4
-4
@@ -33,11 +33,11 @@ class FourSceneProfilePage extends StatelessWidget {
|
||||
child: BlocProvider(
|
||||
create: (context) => FourSceneBloc(fourSceneId: device?.uuid ?? '')
|
||||
..add(const FourSceneInitial())
|
||||
..add(FourSceneInitialInfo()),
|
||||
..add(const FourSceneInitialInfo()),
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
builder: (context, state) {
|
||||
final _bloc = BlocProvider.of<FourSceneBloc>(context);
|
||||
FourSceneModel model = FourSceneModel(
|
||||
FourSceneModelState model = FourSceneModelState(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
@@ -45,9 +45,9 @@ class FourSceneProfilePage extends StatelessWidget {
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.sosSensor;
|
||||
model = state.device;
|
||||
} else if (state is UpdateState) {
|
||||
model = state.sensor;
|
||||
model = state.device;
|
||||
}
|
||||
return state is FourSceneLoadingState
|
||||
? const Center(
|
||||
|
||||
+3
-3
@@ -39,7 +39,7 @@ class FourSceneSettings extends StatelessWidget {
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
builder: (context, state) {
|
||||
final _bloc = BlocProvider.of<FourSceneBloc>(context);
|
||||
FourSceneModel model = FourSceneModel(
|
||||
FourSceneModelState model = FourSceneModelState(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
@@ -47,9 +47,9 @@ class FourSceneSettings extends StatelessWidget {
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.sosSensor;
|
||||
model = state.device;
|
||||
} else if (state is UpdateState) {
|
||||
model = state.sensor;
|
||||
model = state.device;
|
||||
}
|
||||
return state is FourSceneLoadingState
|
||||
? const Center(
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ class LocationFourScenePage extends StatelessWidget {
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
builder: (context, state) {
|
||||
final _bloc = BlocProvider.of<FourSceneBloc>(context);
|
||||
FourSceneModel model = FourSceneModel(
|
||||
FourSceneModelState model = FourSceneModelState(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
|
||||
+3
-3
@@ -29,7 +29,7 @@ class QuestionPageFourScene extends StatelessWidget {
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<FourSceneBloc>(context);
|
||||
FourSceneModel model = FourSceneModel(
|
||||
FourSceneModelState model = FourSceneModelState(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
@@ -37,9 +37,9 @@ class QuestionPageFourScene extends StatelessWidget {
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.sosSensor;
|
||||
model = state.device;
|
||||
} else if (state is UpdateState) {
|
||||
model = state.sensor;
|
||||
model = state.device;
|
||||
}
|
||||
return state is FourSceneLoadingState
|
||||
? const Center(
|
||||
|
||||
+3
-3
@@ -25,7 +25,7 @@ class ShareFourScenePage extends StatelessWidget {
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<FourSceneBloc>(context);
|
||||
FourSceneModel model = FourSceneModel(
|
||||
FourSceneModelState model = FourSceneModelState(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
scene_3: '',
|
||||
@@ -33,9 +33,9 @@ class ShareFourScenePage extends StatelessWidget {
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.sosSensor;
|
||||
model = state.device;
|
||||
} else if (state is UpdateState) {
|
||||
model = state.sensor;
|
||||
model = state.device;
|
||||
}
|
||||
return state is LoadingNewSate
|
||||
? const Center(
|
||||
|
||||
@@ -68,6 +68,7 @@ class _FourSelectSwitchDialogState extends State<FourSelectSwitchDialog> {
|
||||
},
|
||||
onSwitch2DownTap: () {
|
||||
setState(() => selectedSwitchIndex = -2);
|
||||
|
||||
},
|
||||
|
||||
),
|
||||
|
||||
@@ -3,25 +3,35 @@ import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class FourSwitchsCard extends StatelessWidget {
|
||||
final String switch1Up;
|
||||
final String switch1Down;
|
||||
final String switch2Up;
|
||||
final String switch2Down;
|
||||
final String switch1;
|
||||
final String title1;
|
||||
final String switch3;
|
||||
final String title3;
|
||||
|
||||
final String switch2;
|
||||
final String title2;
|
||||
|
||||
final String switch4;
|
||||
final String title4;
|
||||
|
||||
final VoidCallback onSwitch1UpTap;
|
||||
final VoidCallback onSwitch1DownTap;
|
||||
final VoidCallback onSwitch4DownTap;
|
||||
final VoidCallback onSwitch2UpTap;
|
||||
final VoidCallback onSwitch2DownTap;
|
||||
final VoidCallback onSwitch3DownTap;
|
||||
|
||||
FourSwitchsCard({
|
||||
required this.switch1Down,
|
||||
required this.switch1Up,
|
||||
required this.switch2Down,
|
||||
required this.switch2Up,
|
||||
required this.title1,
|
||||
required this.title2,
|
||||
required this.title3,
|
||||
required this.title4,
|
||||
required this.switch3,
|
||||
required this.switch1,
|
||||
required this.switch4,
|
||||
required this.switch2,
|
||||
required this.onSwitch1UpTap,
|
||||
required this.onSwitch1DownTap,
|
||||
required this.onSwitch3DownTap,
|
||||
required this.onSwitch2UpTap,
|
||||
required this.onSwitch2DownTap,
|
||||
required this.onSwitch4DownTap,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -73,9 +83,21 @@ class FourSwitchsCard extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildSwitchColumn(switch1Up, switch1Down, onSwitch1UpTap, onSwitch1DownTap),
|
||||
_buildSwitchColumn(
|
||||
switchUp: switch1,
|
||||
switchDown: switch3,
|
||||
onUpTap: onSwitch1UpTap,
|
||||
onDownTap: onSwitch3DownTap,
|
||||
titleDown: title3,
|
||||
titleUp: title1),
|
||||
_buildDivider(),
|
||||
_buildSwitchColumn(switch2Up, switch2Down, onSwitch2UpTap, onSwitch2DownTap),
|
||||
_buildSwitchColumn(
|
||||
titleDown: title4,
|
||||
titleUp: title2,
|
||||
switchUp: switch2,
|
||||
switchDown: switch4,
|
||||
onUpTap: onSwitch2UpTap,
|
||||
onDownTap: onSwitch4DownTap),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -88,33 +110,45 @@ class FourSwitchsCard extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSwitchColumn(
|
||||
String switchUp,
|
||||
String switchDown,
|
||||
VoidCallback onUpTap,
|
||||
VoidCallback onDownTap,
|
||||
) {
|
||||
Widget _buildSwitchColumn({
|
||||
String switchUp = '',
|
||||
String switchDown = '',
|
||||
String titleUp = '',
|
||||
String titleDown = '',
|
||||
VoidCallback? onUpTap,
|
||||
VoidCallback? onDownTap,
|
||||
}) {
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 30, bottom: 30),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: onUpTap,
|
||||
child: Container(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: SvgPicture.asset(switchUp),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: onUpTap,
|
||||
child: Container(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: SvgPicture.asset(switchUp),
|
||||
),
|
||||
),
|
||||
Text(titleUp)
|
||||
],
|
||||
),
|
||||
InkWell(
|
||||
onTap: onDownTap,
|
||||
child: Container(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: SvgPicture.asset(switchDown),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: onDownTap,
|
||||
child: Container(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: SvgPicture.asset(switchDown),
|
||||
),
|
||||
),
|
||||
Text(titleDown)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user