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
@@ -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,
@@ -0,0 +1,171 @@
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 FourSwitchsCardDialog extends StatelessWidget {
final String? switch1Title;
final String? switch2Title;
final String? switch3Title;
final String? switch4Title;
final String switch1Up;
final String switch1Down;
final String switch2Up;
final String switch2Down;
final VoidCallback onSwitch1UpTap;
final VoidCallback onSwitch1DownTap;
final VoidCallback onSwitch2UpTap;
final VoidCallback onSwitch2DownTap;
FourSwitchsCardDialog({
required this.switch1Down,
required this.switch1Up,
required this.switch2Down,
required this.switch2Up,
required this.onSwitch1UpTap,
required this.onSwitch1DownTap,
required this.onSwitch2UpTap,
required this.onSwitch2DownTap,
this.switch1Title,
this.switch2Title,
this.switch3Title,
this.switch4Title,
});
@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: switch3Title!,
titleUp: switch1Title!),
_buildDivider(),
// Switch 2
_buildSwitchColumn(
switchUp: switch2Up,
switchDown: switch2Down,
onDownTap: onSwitch2UpTap,
onUpTap: onSwitch2DownTap,
titleDown: switch4Title!,
titleUp: switch2Title!),
],
),
),
),
),
),
],
),
),
);
}
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,
);
}
}