mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-17 02:25:16 +00:00
push put api
This commit is contained in:
@ -10,7 +10,11 @@ import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
class CreateSceneSaveButton extends StatefulWidget {
|
||||
const CreateSceneSaveButton({
|
||||
super.key,
|
||||
required this.sceneName,
|
||||
required this.sceneId,
|
||||
});
|
||||
final String sceneName;
|
||||
final String sceneId;
|
||||
|
||||
@override
|
||||
State<CreateSceneSaveButton> createState() => _CreateSceneSaveButtonState();
|
||||
@ -22,7 +26,8 @@ class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton>
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sceneNameController = TextEditingController();
|
||||
sceneNameController = TextEditingController(
|
||||
text: widget.sceneName.isNotEmpty ? widget.sceneName : '');
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@ -59,39 +64,58 @@ class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton>
|
||||
},
|
||||
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) {
|
||||
onPressed: widget.sceneName.isNotEmpty
|
||||
? () {
|
||||
final tasks = context.read<CreateSceneBloc>().tasksList;
|
||||
handleSaveButtonPress(context, sceneNameController, tasks);
|
||||
handleSaveButtonPress(
|
||||
context,
|
||||
sceneNameController,
|
||||
tasks,
|
||||
updateScene: true,
|
||||
sceneId: widget.sceneId,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
: () {
|
||||
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,
|
||||
updateScene: false,
|
||||
sceneId: widget.sceneId,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
customButtonStyle: ButtonStyle(
|
||||
backgroundColor: WidgetStateProperty.all<Color>(
|
||||
ColorsManager.primaryColorWithOpacity,
|
||||
ColorsManager.primaryColor,
|
||||
),
|
||||
),
|
||||
isLoading: state is CreateSceneLoading,
|
||||
|
Reference in New Issue
Block a user