four_scene&6scene

This commit is contained in:
mohammad
2024-11-21 15:34:20 +03:00
parent b4f990e7a9
commit 6c2c866969
27 changed files with 867 additions and 250 deletions
@@ -54,7 +54,14 @@ class _LocationSixScenePageState extends State<LocationSixScenePage> {
builder: (context, state) {
final sensor = BlocProvider.of<SixSceneBloc>(context);
SixSceneModel model = SixSceneModel(
batteryPercentage: 0, waterContactState: 'normal');
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_5: '',
scene_6: '',
scene_id_group_id: '',
switch_backlight: '');
List<SubSpaceModel>? rooms = [];
if (state is LoadingNewSate) {
model = state.sosSensor;
@@ -30,7 +30,14 @@ class QuestionPage extends StatelessWidget {
builder: (context, state) {
final sensor = BlocProvider.of<SixSceneBloc>(context);
SixSceneModel model = SixSceneModel(
batteryPercentage: 0, waterContactState: 'normal');
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_5: '',
scene_6: '',
scene_id_group_id: '',
switch_backlight: '');
if (state is LoadingNewSate) {
model = state.sosSensor;
} else if (state is UpdateState) {
@@ -29,7 +29,14 @@ class ShareSixScenePage extends StatelessWidget {
builder: (context, state) {
final sensor = BlocProvider.of<SixSceneBloc>(context);
SixSceneModel model = SixSceneModel(
batteryPercentage: 0, waterContactState: 'normal');
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_5: '',
scene_6: '',
scene_id_group_id: '',
switch_backlight: '');
if (state is LoadingNewSate) {
model = state.sosSensor;
} else if (state is UpdateState) {
@@ -29,8 +29,15 @@ class SixSceneCreateGroup extends StatelessWidget {
child: BlocBuilder<SixSceneBloc, SixSceneState>(
builder: (context, state) {
final sensor = BlocProvider.of<SixSceneBloc>(context);
SixSceneModel model = SixSceneModel(
batteryPercentage: 0, waterContactState: 'normal');
SixSceneModel model = SixSceneModel(
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_5: '',
scene_6: '',
scene_id_group_id: '',
switch_backlight: '');
if (state is LoadingNewSate) {
model = state.sosSensor;
} else if (state is UpdateState) {
@@ -28,8 +28,15 @@ class SixSceneInfoPage extends StatelessWidget {
child: BlocBuilder<SixSceneBloc, SixSceneState>(
builder: (context, state) {
final sensor = BlocProvider.of<SixSceneBloc>(context);
SixSceneModel model = SixSceneModel(
batteryPercentage: 0, waterContactState: 'normal');
SixSceneModel model = SixSceneModel(
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_5: '',
scene_6: '',
scene_id_group_id: '',
switch_backlight: '');
if (state is LoadingNewSate) {
model = state.sosSensor;
} else if (state is UpdateState) {
@@ -32,8 +32,15 @@ class SixSceneProfilePage extends StatelessWidget {
child: BlocBuilder<SixSceneBloc, SixSceneState>(
builder: (context, state) {
final sensor = BlocProvider.of<SixSceneBloc>(context);
SixSceneModel model = SixSceneModel(
batteryPercentage: 0, waterContactState: 'normal');
SixSceneModel model = SixSceneModel(
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_5: '',
scene_6: '',
scene_id_group_id: '',
switch_backlight: '');
if (state is LoadingNewSate) {
model = state.sosSensor;
} else if (state is UpdateState) {
@@ -38,8 +38,15 @@ class SixSceneSettings extends StatelessWidget {
child: BlocBuilder<SixSceneBloc, SixSceneState>(
builder: (context, state) {
final sensor = BlocProvider.of<SixSceneBloc>(context);
SixSceneModel model = SixSceneModel(
batteryPercentage: 0, waterContactState: 'normal');
SixSceneModel model = SixSceneModel(
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_5: '',
scene_6: '',
scene_id_group_id: '',
switch_backlight: '');
if (state is LoadingNewSate) {
model = state.sosSensor;
} else if (state is UpdateState) {
@@ -74,8 +81,7 @@ class SixSceneSettings extends StatelessWidget {
child: Stack(
children: [
const Column(
crossAxisAlignment:
CrossAxisAlignment.stretch,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(height: 20),
DefaultContainer(
@@ -16,8 +16,10 @@ import 'package:syncrow_app/navigation/navigation_service.dart';
import 'package:syncrow_app/navigation/routing_constants.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class SelectSceneSixPage extends StatelessWidget {
SelectSceneSixPage({super.key});
class SixSelectSceneFourPage extends StatelessWidget {
final String? switchSelected;
final String? deviceId;
SixSelectSceneFourPage({super.key, this.switchSelected, this.deviceId});
final TextEditingController _searchController = TextEditingController();
final int? selectedSwitchIndex = 0;
@@ -26,22 +28,26 @@ class SelectSceneSixPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => SixSceneBloc(sixSceneId: '')
create: (context) => SixSceneBloc(sixSceneId: deviceId!)
..add(LoadScenes(
unit: spaces!.first,
unitId: spaces!.first.id,
showInDevice: false,
)),
))
..add(GetSceneBySwitchName(switchName: switchSelected)),
child: BlocBuilder<SixSceneBloc, SixSceneState>(
builder: (context, state) {
final sensorBloc = BlocProvider.of<SixSceneBloc>(context);
if (state is SaveSelectionSuccessState) {
Navigator.of(context).pop(true);
Navigator.of(context).pop(true);
}
return DefaultScaffold(
title: 'Select Scene',
actions: [_buildSaveButton(context, state, sensorBloc)],
child: state is SixSceneLoadingState
? _buildLoadingIndicator()
: _buildSceneContent(context, sensorBloc),
: _buildSceneContent(context, sensorBloc, state),
);
},
),
@@ -51,14 +57,15 @@ class SelectSceneSixPage extends StatelessWidget {
// Save button builder
Widget _buildSaveButton(
BuildContext context, SixSceneState state, SixSceneBloc sensorBloc) {
final bool canSave =
state is OptionSelectedState && state.hasSelectionChanged;
final bool canSave = state is SceneSelectionUpdatedState;
return GestureDetector(
onTap: canSave
? () {
print('object');
context.read<SixSceneBloc>().add(SaveSelectionEvent());
context.read<SixSceneBloc>().add(AssignDeviceScene(
sceneUuid: sensorBloc.selectedSceneId,
switchName: switchSelected,
unit: spaces!.first));
}
: null,
child: BodyMedium(
@@ -84,13 +91,14 @@ class SelectSceneSixPage extends StatelessWidget {
}
// Main scene content with search bar and grid
Widget _buildSceneContent(BuildContext context, SixSceneBloc sensorBloc) {
Widget _buildSceneContent(
BuildContext context, SixSceneBloc sensorBloc, SixSceneState state) {
return Column(
children: [
_buildSearchBar(sensorBloc),
const SizedBox(height: 20),
Expanded(
child: _buildSceneGrid(sensorBloc),
child: _buildSceneGrid(sensorBloc, state),
),
],
);
@@ -125,7 +133,7 @@ class SelectSceneSixPage extends StatelessWidget {
}
// Scene grid builder
Widget _buildSceneGrid(SixSceneBloc sensorBloc) {
Widget _buildSceneGrid(SixSceneBloc sensorBloc, SixSceneState state) {
final scenes = sensorBloc.filteredScenes;
return GridView.builder(
@@ -152,13 +160,18 @@ class SelectSceneSixPage extends StatelessWidget {
);
} else {
final scene = scenes[index];
bool isSelected = scene.id ==
(state is SceneSelectionUpdatedState
? state.selectedSceneId
: sensorBloc.selectedFormApiSceneId);
return SceneItem(
id: scene.id,
value: sensorBloc.selectedSceneId == scene.id,
value: isSelected,
disablePlayButton: false,
onChanged: (isSelected) {
sensorBloc.selectedSceneId = isSelected ? scene.id : 'null';
sensorBloc.add(SelectOptionEvent(selectedOption: scene.id));
sensorBloc.add(SelectSceneEvent(unitId: scene.id));
},
icon: scene.iconInBytes,
title: scene.name,
@@ -169,8 +182,8 @@ class SelectSceneSixPage extends StatelessWidget {
}
}
class SceneItem extends StatefulWidget {
final String id; // Unique ID for each scene
class SceneItem extends StatelessWidget {
final String id;
final Uint8List icon;
final String title;
final bool disablePlayButton;
@@ -186,11 +199,6 @@ class SceneItem extends StatefulWidget {
required this.onChanged,
});
@override
State<SceneItem> createState() => _SceneItemState();
}
class _SceneItemState extends State<SceneItem> {
@override
Widget build(BuildContext context) {
return Container(
@@ -215,9 +223,9 @@ class _SceneItemState extends State<SceneItem> {
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (!widget.disablePlayButton)
if (!disablePlayButton)
Image.memory(
widget.icon,
icon,
height: 32,
width: 32,
fit: BoxFit.fill,
@@ -228,7 +236,7 @@ class _SceneItemState extends State<SceneItem> {
fit: BoxFit.fill),
),
BodyMedium(
text: widget.title,
text: title,
style: const TextStyle(
fontSize: 17,
fontWeight: FontWeight.w700,
@@ -238,8 +246,8 @@ class _SceneItemState extends State<SceneItem> {
],
),
CircularCheckbox(
value: widget.value,
onChanged: (isSelected) => widget.onChanged(isSelected!),
value: value,
onChanged: (isSelected) => onChanged(isSelected!),
),
],
),
@@ -1,16 +1,18 @@
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/switches_card.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/six_switches_card.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class SelectSwitchDialog extends StatefulWidget {
final Function()? cancelTab;
final Function()? confirmTab;
final Function(String)? confirmTab;
String? switch1Title;
String? switch2Title;
String? switch3Title;
String? switch4Title;
String? switch5Title;
String? switch6Title;
SelectSwitchDialog(
{super.key,
required this.cancelTab,
@@ -18,14 +20,16 @@ class SelectSwitchDialog extends StatefulWidget {
this.switch1Title,
this.switch2Title,
this.switch3Title,
this.switch4Title});
this.switch4Title,
this.switch5Title,
this.switch6Title});
@override
State<SelectSwitchDialog> createState() => _SelectSwitchDialogState();
}
class _SelectSwitchDialogState extends State<SelectSwitchDialog> {
int? selectedSwitchIndex = 0;
String selectedSwitchName = '';
@override
Widget build(BuildContext context) {
@@ -49,34 +53,48 @@ class _SelectSwitchDialogState extends State<SelectSwitchDialog> {
const SizedBox(height: 20),
Row(
children: [
SwitchsCard(
SixSwitchsCardDialog(
switch1Title: widget.switch1Title,
switch2Title: widget.switch2Title,
switch3Title: widget.switch3Title,
switch4Title: widget.switch4Title,
switch1Down: selectedSwitchIndex == -1
switch5Title: widget.switch5Title,
switch6Title: widget.switch6Title,
switch1Down: selectedSwitchName == 'scene_4'
? Assets.removeSceneIcon
: Assets.addSwitchIcon,
switch1Up: selectedSwitchIndex == 1
switch1Up: selectedSwitchName == 'scene_1'
? Assets.removeSceneIcon
: Assets.addSwitchIcon,
switch2Down: selectedSwitchIndex == -2
switch2Down: selectedSwitchName == 'scene_5'
? Assets.removeSceneIcon
: Assets.addSwitchIcon,
switch2Up: selectedSwitchIndex == 2
switch2Up: selectedSwitchName == 'scene_2'
? Assets.removeSceneIcon
: Assets.addSwitchIcon,
switch3Up: selectedSwitchName == 'scene_3'
? Assets.removeSceneIcon
: Assets.addSwitchIcon,
switch3Down: selectedSwitchName == 'scene_6'
? Assets.removeSceneIcon
: Assets.addSwitchIcon,
onSwitch3DownTap: () {
setState(() => selectedSwitchName = 'scene_3');
},
onSwitch3UpTap: () {
setState(() => selectedSwitchName = 'scene_6');
},
onSwitch1UpTap: () {
setState(() => selectedSwitchIndex = 1);
setState(() => selectedSwitchName = 'scene_1');
},
onSwitch1DownTap: () {
setState(() => selectedSwitchIndex = -1);
setState(() => selectedSwitchName = 'scene_4');
},
onSwitch2UpTap: () {
setState(() => selectedSwitchIndex = 2);
setState(() => selectedSwitchName = 'scene_5');
},
onSwitch2DownTap: () {
setState(() => selectedSwitchIndex = -2);
setState(() => selectedSwitchName = 'scene_2');
},
),
],
@@ -125,14 +143,16 @@ class _SelectSwitchDialogState extends State<SelectSwitchDialog> {
top: BorderSide(color: ColorsManager.textGray, width: 1.0),
)),
child: InkWell(
onTap: selectedSwitchIndex == 0 ? () {} : widget.confirmTab,
onTap: selectedSwitchName == ''
? () {}
: () => widget.confirmTab!(selectedSwitchName),
child: Padding(
padding: EdgeInsets.all(15),
child: Center(
child: Text(
'Next',
style: TextStyle(
color: selectedSwitchIndex == 0
color: selectedSwitchName == ''
? ColorsManager.textPrimaryColor
.withOpacity(0.6)
: ColorsManager.primaryColor,
@@ -11,7 +11,7 @@ import 'package:syncrow_app/features/devices/model/six_scene_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_settings.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/select_scene_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/select_switch_dialog.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/switches_card.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/six_switches_card.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
@@ -41,12 +41,22 @@ class SixSceneScreen extends StatelessWidget {
],
child: BlocProvider(
create: (context) => SixSceneBloc(sixSceneId: device?.uuid ?? '')
..add(const SixSceneInitial()),
..add(const SixSceneInitial())
..add(const SixSceneInitialInfo())
..add(const SexSceneSwitchInitial()),
child: BlocBuilder<SixSceneBloc, SixSceneState>(
builder: (context, state) {
final sensor = BlocProvider.of<SixSceneBloc>(context);
final _bloc = BlocProvider.of<SixSceneBloc>(context);
SixSceneModel model = SixSceneModel(
batteryPercentage: 0, waterContactState: 'normal');
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_5: '',
scene_6: '',
scene_id_group_id: '',
switch_backlight: '');
if (state is LoadingNewSate) {
model = state.sosSensor;
} else if (state is UpdateState) {
@@ -61,7 +71,7 @@ class SixSceneScreen extends StatelessWidget {
)
: RefreshIndicator(
onRefresh: () async {
sensor.add(const SixSceneInitial());
_bloc.add(const SixSceneInitial());
},
child: ListView(
children: [
@@ -69,24 +79,43 @@ class SixSceneScreen extends StatelessWidget {
height: MediaQuery.sizeOf(context).height * 0.8,
child: Column(
children: [
SwitchsCard(
// switch1Title: ,
// switch2Title: ,
// switch3Title: ,
// switch4Title: ,
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,
SixSwitchsCardDialog(
switch1Title: model.scene_1,
switch2Title: model.scene_2,
switch3Title: model.scene_3,
switch4Title: model.scene_4,
switch5Title: model.scene_5,
switch6Title: model.scene_6,
switch1Down:
_bloc.deviceStatus.switch_backlight == true
? Assets.switchOn
: Assets.switchOff,
switch1Up:
_bloc.deviceStatus.switch_backlight == true
? Assets.switchOn
: Assets.switchOff,
switch2Down:
_bloc.deviceStatus.switch_backlight == true
? Assets.switchOn
: Assets.switchOff,
switch2Up:
_bloc.deviceStatus.switch_backlight == true
? Assets.switchOn
: Assets.switchOff,
switch3Up:
_bloc.deviceStatus.switch_backlight == true
? Assets.switchOn
: Assets.switchOff,
switch3Down:
_bloc.deviceStatus.switch_backlight == true
? Assets.switchOn
: Assets.switchOff,
onSwitch3DownTap: () {
debugPrint("onSwitch3DownTap");
},
onSwitch3UpTap: () {
debugPrint("onSwitch3UpTap");
},
onSwitch1UpTap: () {
debugPrint("Switch 1 Up tapped");
},
@@ -106,7 +135,7 @@ class SixSceneScreen extends StatelessWidget {
Expanded(
child: DefaultContainer(
onTap: () {
sensor.add(ChangeSwitchStatusEvent());
_bloc.add(ChangeSwitchStatusEvent());
},
child: Column(
crossAxisAlignment:
@@ -140,19 +169,29 @@ class SixSceneScreen extends StatelessWidget {
),
Expanded(
child: DefaultContainer(
onTap: () {
showDialog(
onTap: () async {
var value = await showDialog(
context: context,
builder: (context) {
return SelectSwitchDialog(
switch1Title: model.scene_1,
switch2Title: model.scene_2,
switch3Title: model.scene_3,
switch4Title: model.scene_4,
switch5Title: model.scene_5,
switch6Title: model.scene_6,
cancelTab: () {
Navigator.of(context).pop();
},
confirmTab: () {
confirmTab: (v) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
SelectSceneSixPage()),
SixSelectSceneFourPage(
deviceId:
device!.uuid,
switchSelected: v,
)),
);
},
);
@@ -0,0 +1,193 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class SixSwitchsCardDialog extends StatelessWidget {
final String? switch1Title;
final String? switch2Title;
final String? switch3Title;
final String? switch4Title;
final String? switch5Title;
final String? switch6Title;
final String switch1Up;
final String switch1Down;
final String switch2Up;
final String switch2Down;
final String switch3Down;
final String switch3Up;
final VoidCallback onSwitch1UpTap;
final VoidCallback onSwitch1DownTap;
final VoidCallback onSwitch2UpTap;
final VoidCallback onSwitch2DownTap;
final VoidCallback onSwitch3DownTap;
final VoidCallback onSwitch3UpTap;
SixSwitchsCardDialog(
{required this.switch1Down,
required this.switch1Up,
required this.switch2Down,
required this.switch2Up,
required this.onSwitch1UpTap,
required this.onSwitch1DownTap,
required this.onSwitch2UpTap,
required this.onSwitch2DownTap,
required this.onSwitch3DownTap,
required this.onSwitch3UpTap,
required this.switch3Down,
this.switch1Title,
this.switch2Title,
this.switch3Title,
this.switch4Title,
this.switch5Title,
this.switch6Title,
required this.switch3Up});
@override
Widget build(BuildContext context) {
return Expanded(
flex: 4,
child: InkWell(
overlayColor: MaterialStateProperty.all(Colors.transparent),
onTap: () {},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 10),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 10),
decoration: BoxDecoration(
color: ColorsManager.onPrimaryColor,
boxShadow: [
BoxShadow(
color: Colors.white.withOpacity(0.1),
blurRadius: 24,
offset: const Offset(-2, -2),
blurStyle: BlurStyle.outer,
),
BoxShadow(
color: Colors.black.withOpacity(0.11),
blurRadius: 5,
offset: const Offset(2, 0),
blurStyle: BlurStyle.outer,
),
BoxShadow(
color: Colors.white.withOpacity(0.13),
blurRadius: 10,
offset: const Offset(5, 1),
blurStyle: BlurStyle.inner,
),
],
),
child: SizedBox(
height: 300,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
// Switch 1
_buildSwitchColumn(
switchUp: switch1Up,
switchDown: switch1Down,
onUpTap: onSwitch1UpTap,
onDownTap: onSwitch1DownTap,
titleDown: switch4Title!,
titleUp: switch1Title!),
_buildDivider(),
// Switch 2
_buildSwitchColumn(
switchUp: switch2Up,
switchDown: switch2Down,
onDownTap: onSwitch2UpTap,
onUpTap: onSwitch2DownTap,
titleDown: switch5Title!,
titleUp: switch2Title!),
_buildDivider(),
// Switch 3
_buildSwitchColumn(
switchUp: switch3Up,
switchDown: switch3Down,
onDownTap: onSwitch3UpTap,
onUpTap: onSwitch3DownTap,
titleDown: switch6Title!,
titleUp: switch3Title!),
],
),
),
),
),
),
],
),
),
);
}
Widget _buildSwitchColumn({
String switchUp = '',
String titleUp = '',
String titleDown = '',
String switchDown = '',
VoidCallback? onUpTap,
VoidCallback? onDownTap,
}) {
return Expanded(
child: Padding(
padding: const EdgeInsets.only(top: 30, bottom: 30),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
InkWell(
onTap: onUpTap,
child: Container(
height: 20,
width: 20,
child: SvgPicture.asset(switchUp),
),
),
BodySmall(
text: titleUp,
)
],
),
Column(
children: [
InkWell(
onTap: onDownTap,
child: Container(
height: 20,
width: 20,
child: SvgPicture.asset(switchDown),
),
),
BodySmall(
text: titleDown,
)
],
),
],
),
),
);
}
Widget _buildDivider() {
return Container(
width: 3,
color: ColorsManager.dividerColor,
);
}
}
@@ -150,8 +150,8 @@ class FourSceneScreen extends StatelessWidget {
),
Expanded(
child: DefaultContainer(
onTap: () {
showDialog(
onTap: () async {
var value = await showDialog(
context: context,
builder: (context) {
return FourSelectSwitchDialog(
@@ -162,18 +162,29 @@ class FourSceneScreen extends StatelessWidget {
cancelTab: () {
Navigator.of(context).pop();
},
confirmTab: (switchSelected) {
confirmTab:
(switchSelected) async {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
FourSelectSceneFourPage(
switchSelected: switchSelected,
deviceId:device!.uuid)),
switchSelected:
switchSelected,
deviceId:
device!
.uuid)),
);
},
);
},
);
if (value == true) {
_bloc.add(const FourSceneInitial());
_bloc.add(
const FourSceneInitialInfo());
_bloc.add(
const FourSceneSwitchInitial());
}
},
child: Column(
crossAxisAlignment:
@@ -67,11 +67,22 @@ class FourSceneProfilePage extends StatelessWidget {
backgroundColor: Colors.white,
child: CircleAvatar(
radius: 55,
backgroundColor: Colors.grey,
backgroundColor: ColorsManager.graysColor,
child: ClipOval(
child: SvgPicture.asset(
Assets.sosProfileIcon,
fit: BoxFit.fill,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 10,
),
Center(
child: SvgPicture.asset(
Assets.fourSceneIcon,
fit: BoxFit.contain,
),
),
],
),
),
),
@@ -15,7 +15,6 @@ import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_update_dialog.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_update_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/share_four_scene_page.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
@@ -139,9 +138,24 @@ class FourSceneSettings extends StatelessWidget {
radius: 40,
backgroundColor:
ColorsManager.backgroundColor,
child: SvgPicture.asset(
Assets.sixSceneIcon,
fit: BoxFit.fill,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(
top: 8),
child: SizedBox(
height: 70,
child: SvgPicture.asset(
Assets.fourSceneIcon,
fit: BoxFit.contain,
),
),
),
],
),
),
)),
@@ -38,13 +38,16 @@ class FourSelectSceneFourPage extends StatelessWidget {
child: BlocBuilder<FourSceneBloc, FourSceneState>(
builder: (context, state) {
final sensorBloc = BlocProvider.of<FourSceneBloc>(context);
if (state is SaveSelectionSuccessState) {
Navigator.of(context).pop(true);
Navigator.of(context).pop(true);
}
return DefaultScaffold(
title: 'Select Scene',
actions: [_buildSaveButton(context, state, sensorBloc)],
child: state is FourSceneLoadingState
? _buildLoadingIndicator()
: _buildSceneContent(context, sensorBloc),
: _buildSceneContent(context, sensorBloc, state),
);
},
),
@@ -54,8 +57,7 @@ class FourSelectSceneFourPage extends StatelessWidget {
// Save button builder
Widget _buildSaveButton(
BuildContext context, FourSceneState state, FourSceneBloc sensorBloc) {
final bool canSave =
state is OptionSelectedState && state.hasSelectionChanged;
final bool canSave = state is SceneSelectionUpdatedState;
return GestureDetector(
onTap: canSave
@@ -89,13 +91,14 @@ class FourSelectSceneFourPage extends StatelessWidget {
}
// Main scene content with search bar and grid
Widget _buildSceneContent(BuildContext context, FourSceneBloc sensorBloc) {
Widget _buildSceneContent(
BuildContext context, FourSceneBloc sensorBloc, FourSceneState state) {
return Column(
children: [
_buildSearchBar(sensorBloc),
const SizedBox(height: 20),
Expanded(
child: _buildSceneGrid(sensorBloc),
child: _buildSceneGrid(sensorBloc, state),
),
],
);
@@ -130,8 +133,9 @@ class FourSelectSceneFourPage extends StatelessWidget {
}
// Scene grid builder
Widget _buildSceneGrid(FourSceneBloc sensorBloc) {
Widget _buildSceneGrid(FourSceneBloc sensorBloc, FourSceneState state) {
final scenes = sensorBloc.filteredScenes;
return GridView.builder(
itemCount: scenes.length + 1,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
@@ -141,7 +145,6 @@ class FourSelectSceneFourPage extends StatelessWidget {
mainAxisExtent: 120,
),
itemBuilder: (context, index) {
// sensorBloc.sceneId;
if (index == scenes.length) {
return InkWell(
onTap: () => Navigator.pushNamed(
@@ -157,13 +160,18 @@ class FourSelectSceneFourPage extends StatelessWidget {
);
} else {
final scene = scenes[index];
bool isSelected = scene.id ==
(state is SceneSelectionUpdatedState
? state.selectedSceneId
: sensorBloc.selectedFormApiSceneId);
return SceneItem(
id: scene.id,
value: (sensorBloc.selectedSceneId == scene.id),
value: isSelected,
disablePlayButton: false,
onChanged: (isSelected) {
sensorBloc.selectedSceneId = isSelected ? scene.id : 'null';
sensorBloc.add(SelectOptionEvent(selectedOption: scene.id));
sensorBloc.add(SelectSceneEvent(selectedSceneId: scene.id));
},
icon: scene.iconInBytes,
title: scene.name,
@@ -174,8 +182,8 @@ class FourSelectSceneFourPage extends StatelessWidget {
}
}
class SceneItem extends StatefulWidget {
final String id; // Unique ID for each scene
class SceneItem extends StatelessWidget {
final String id;
final Uint8List icon;
final String title;
final bool disablePlayButton;
@@ -191,11 +199,6 @@ class SceneItem extends StatefulWidget {
required this.onChanged,
});
@override
State<SceneItem> createState() => _SceneItemState();
}
class _SceneItemState extends State<SceneItem> {
@override
Widget build(BuildContext context) {
return Container(
@@ -220,9 +223,9 @@ class _SceneItemState extends State<SceneItem> {
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (!widget.disablePlayButton)
if (!disablePlayButton)
Image.memory(
widget.icon,
icon,
height: 32,
width: 32,
fit: BoxFit.fill,
@@ -233,7 +236,7 @@ class _SceneItemState extends State<SceneItem> {
fit: BoxFit.fill),
),
BodyMedium(
text: widget.title,
text: title,
style: const TextStyle(
fontSize: 17,
fontWeight: FontWeight.w700,
@@ -243,8 +246,8 @@ class _SceneItemState extends State<SceneItem> {
],
),
CircularCheckbox(
value: widget.value,
onChanged: (isSelected) => widget.onChanged(isSelected!),
value: value,
onChanged: (isSelected) => onChanged(isSelected!),
),
],
),
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/switches_card.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_switches_card_dialog.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
@@ -51,7 +51,7 @@ class _FourSelectSwitchDialogState extends State<FourSelectSwitchDialog> {
const SizedBox(height: 20),
Row(
children: [
SwitchsCard(
FourSwitchsCardDialog(
switch1Title: widget.switch1Title,
switch2Title: widget.switch2Title,
switch3Title: widget.switch3Title,
@@ -3,7 +3,7 @@ import 'package:flutter_svg/svg.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class SwitchsCard extends StatelessWidget {
class FourSwitchsCardDialog extends StatelessWidget {
final String? switch1Title;
final String? switch2Title;
final String? switch3Title;
@@ -19,7 +19,7 @@ class SwitchsCard extends StatelessWidget {
final VoidCallback onSwitch2UpTap;
final VoidCallback onSwitch2DownTap;
SwitchsCard({
FourSwitchsCardDialog({
required this.switch1Down,
required this.switch1Up,
required this.switch2Down,
@@ -7,6 +7,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/six_scene_screen.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_view.dart';
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtain_view.dart';
import 'package:syncrow_app/features/devices/view/widgets/door_sensor/door_sensor_screen.dart';
@@ -213,6 +214,13 @@ void showDeviceInterface(DeviceModel device, BuildContext context) {
pageBuilder: (context, animation1, animation2) =>
WaterLeakScreen(device: device)));
case DeviceType.SixScene:
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
SixSceneScreen(device: device)));
case DeviceType.FourScene:
Navigator.push(
context,