push put api

This commit is contained in:
ashrafzarkanisala
2024-07-01 01:57:13 +03:00
parent cc6b754845
commit c01d9034fd
16 changed files with 883 additions and 176 deletions

View File

@ -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,