mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 12:47:55 +00:00
connected all apis , create functionality is working
This commit is contained in:
+3
-3
@@ -6,7 +6,7 @@ import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.d
|
||||
class AlertDialogCountdown extends StatefulWidget {
|
||||
const AlertDialogCountdown({super.key, required this.durationValue});
|
||||
|
||||
final String durationValue;
|
||||
final int durationValue;
|
||||
|
||||
@override
|
||||
State<AlertDialogCountdown> createState() => _AlertDialogCountdownState();
|
||||
@@ -16,7 +16,7 @@ class _AlertDialogCountdownState extends State<AlertDialogCountdown> {
|
||||
int durationInSeconds = 0;
|
||||
// Convert seconds to Duration.
|
||||
Duration get duration =>
|
||||
Duration(seconds: int.tryParse(widget.durationValue) ?? 0);
|
||||
Duration(seconds: widget.durationValue) ;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
@@ -32,7 +32,7 @@ class _AlertDialogCountdownState extends State<AlertDialogCountdown> {
|
||||
});
|
||||
context
|
||||
.read<CreateSceneBloc>()
|
||||
.add(SelectedValueEvent(value: newDuration.inSeconds.toString()));
|
||||
.add(SelectedValueEvent(value: newDuration.inSeconds));
|
||||
},
|
||||
),
|
||||
);
|
||||
+3
-3
@@ -21,7 +21,7 @@ class AlertDialogFunctionsOperationsBody extends StatefulWidget {
|
||||
|
||||
class _AlertDialogFunctionsOperationsBodyState
|
||||
extends State<AlertDialogFunctionsOperationsBody> {
|
||||
String? groupValue = "";
|
||||
dynamic groupValue;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
@@ -36,7 +36,7 @@ class _AlertDialogFunctionsOperationsBodyState
|
||||
minLeadingWidth: 15,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
assetPath: operation.icon,
|
||||
titleString: operation.value,
|
||||
titleString: operation.description.toString(),
|
||||
textAlign: TextAlign.start,
|
||||
trailingWidget: Radio(
|
||||
value: operation.value,
|
||||
@@ -58,7 +58,7 @@ class _AlertDialogFunctionsOperationsBodyState
|
||||
});
|
||||
context
|
||||
.read<CreateSceneBloc>()
|
||||
.add(SelectedValueEvent(value: groupValue!));
|
||||
.add(SelectedValueEvent(value: groupValue));
|
||||
},
|
||||
);
|
||||
},
|
||||
+4
-3
@@ -40,7 +40,7 @@ class _AlertDialogTemperatureBodyState
|
||||
});
|
||||
context
|
||||
.read<CreateSceneBloc>()
|
||||
.add(SelectedValueEvent(value: temperature.toString()));
|
||||
.add(SelectedValueEvent(value: temperature * 10));
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.remove,
|
||||
@@ -70,7 +70,8 @@ class _AlertDialogTemperatureBodyState
|
||||
],
|
||||
),
|
||||
subtitle: BodyLarge(
|
||||
text: widget.functions[widget.index].operationalValues[0].value,
|
||||
text: widget.functions[widget.index].operationalValues[0].description
|
||||
.toString(),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
trailing: IconButton(
|
||||
@@ -82,7 +83,7 @@ class _AlertDialogTemperatureBodyState
|
||||
});
|
||||
context
|
||||
.read<CreateSceneBloc>()
|
||||
.add(SelectedValueEvent(value: temperature.toString()));
|
||||
.add(SelectedValueEvent(value: temperature * 10));
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.add,
|
||||
@@ -0,0 +1,106 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/helper/scene_logic_helper.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class CreateSceneSaveButton extends StatefulWidget {
|
||||
const CreateSceneSaveButton({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<CreateSceneSaveButton> createState() => _CreateSceneSaveButtonState();
|
||||
}
|
||||
|
||||
class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton>
|
||||
with SceneLogicHelper {
|
||||
late TextEditingController sceneNameController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sceneNameController = TextEditingController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
sceneNameController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocConsumer<CreateSceneBloc, CreateSceneState>(
|
||||
listener: (context, state) {
|
||||
if (state is CreateSceneWithTasks) {
|
||||
if (state.success == true) {
|
||||
context.showCustomSnackbar(
|
||||
message: 'Scene created successfully',
|
||||
icon: const Icon(
|
||||
Icons.check,
|
||||
color: Colors.green,
|
||||
),
|
||||
);
|
||||
sceneNameController.text = '';
|
||||
}
|
||||
} else if (state is CreateSceneError) {
|
||||
context.showCustomSnackbar(
|
||||
message: state.message,
|
||||
icon: const Icon(
|
||||
Icons.error,
|
||||
color: Colors.red,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return DefaultButton(
|
||||
onPressed: () {
|
||||
context.customAlertDialog(
|
||||
alertBody: Padding(
|
||||
padding: const EdgeInsets.only(left: 8, right: 8, bottom: 8),
|
||||
child: SizedBox(
|
||||
height: 40,
|
||||
child: SearchBar(
|
||||
controller: sceneNameController,
|
||||
elevation: WidgetStateProperty.all(0),
|
||||
textStyle: WidgetStateProperty.all(context.bodyMedium),
|
||||
hintStyle: WidgetStateProperty.all(
|
||||
context.bodyMedium.copyWith(
|
||||
fontSize: 14,
|
||||
color: ColorsManager.secondaryTextColor),
|
||||
),
|
||||
hintText: 'Enter scene name',
|
||||
backgroundColor:
|
||||
WidgetStateProperty.all(ColorsManager.backgroundColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
title: 'Scene Name',
|
||||
onConfirm: () {
|
||||
if (sceneNameController.text.isNotEmpty) {
|
||||
final tasks = context.read<CreateSceneBloc>().tasksList;
|
||||
handleSaveButtonPress(context, sceneNameController, tasks);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
customButtonStyle: ButtonStyle(
|
||||
backgroundColor: WidgetStateProperty.all<Color>(
|
||||
ColorsManager.primaryColorWithOpacity,
|
||||
),
|
||||
),
|
||||
isLoading: state is CreateSceneLoading,
|
||||
child: BodyLarge(
|
||||
text: 'Save',
|
||||
style: context.bodyLarge.copyWith(color: Colors.white),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user