mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 17:17:56 +00:00
connected all apis , create functionality is working
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
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';
|
||||
|
||||
class AlertDialogCountdown extends StatefulWidget {
|
||||
const AlertDialogCountdown({super.key, required this.durationValue});
|
||||
|
||||
final int durationValue;
|
||||
|
||||
@override
|
||||
State<AlertDialogCountdown> createState() => _AlertDialogCountdownState();
|
||||
}
|
||||
|
||||
class _AlertDialogCountdownState extends State<AlertDialogCountdown> {
|
||||
int durationInSeconds = 0;
|
||||
// Convert seconds to Duration.
|
||||
Duration get duration =>
|
||||
Duration(seconds: widget.durationValue) ;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 120,
|
||||
color: Colors.white,
|
||||
child: CupertinoTimerPicker(
|
||||
itemExtent: 120,
|
||||
mode: CupertinoTimerPickerMode.hm,
|
||||
initialTimerDuration: duration,
|
||||
onTimerDurationChanged: (newDuration) {
|
||||
setState(() {
|
||||
durationInSeconds = newDuration.inSeconds;
|
||||
});
|
||||
context
|
||||
.read<CreateSceneBloc>()
|
||||
.add(SelectedValueEvent(value: newDuration.inSeconds));
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
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/model/scene_static_function.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
|
||||
|
||||
class AlertDialogFunctionsOperationsBody extends StatefulWidget {
|
||||
const AlertDialogFunctionsOperationsBody({
|
||||
super.key,
|
||||
required this.functions,
|
||||
required this.index,
|
||||
});
|
||||
|
||||
final List<SceneStaticFunction> functions;
|
||||
final int index;
|
||||
|
||||
@override
|
||||
State<AlertDialogFunctionsOperationsBody> createState() =>
|
||||
_AlertDialogFunctionsOperationsBodyState();
|
||||
}
|
||||
|
||||
class _AlertDialogFunctionsOperationsBodyState
|
||||
extends State<AlertDialogFunctionsOperationsBody> {
|
||||
dynamic groupValue;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
...widget.functions[widget.index].operationalValues.map(
|
||||
(operation) => BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
return SceneListTile(
|
||||
iconsSize: 25,
|
||||
minLeadingWidth: 15,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
assetPath: operation.icon,
|
||||
titleString: operation.description.toString(),
|
||||
textAlign: TextAlign.start,
|
||||
trailingWidget: Radio(
|
||||
value: operation.value,
|
||||
groupValue: (state is SelectedTaskValueState)
|
||||
? state.value
|
||||
: groupValue,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
groupValue = value;
|
||||
});
|
||||
context
|
||||
.read<CreateSceneBloc>()
|
||||
.add(SelectedValueEvent(value: value!));
|
||||
},
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
groupValue = operation.value;
|
||||
});
|
||||
context
|
||||
.read<CreateSceneBloc>()
|
||||
.add(SelectedValueEvent(value: groupValue));
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class AlertDialogTemperatureBody extends StatefulWidget {
|
||||
const AlertDialogTemperatureBody({
|
||||
super.key,
|
||||
required this.index,
|
||||
required this.functions,
|
||||
});
|
||||
|
||||
final List<SceneStaticFunction> functions;
|
||||
final int index;
|
||||
|
||||
@override
|
||||
State<AlertDialogTemperatureBody> createState() =>
|
||||
_AlertDialogTemperatureBodyState();
|
||||
}
|
||||
|
||||
class _AlertDialogTemperatureBodyState
|
||||
extends State<AlertDialogTemperatureBody> {
|
||||
int temperature = 24;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
leading: IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
if (temperature > 20) {
|
||||
temperature--;
|
||||
}
|
||||
});
|
||||
context
|
||||
.read<CreateSceneBloc>()
|
||||
.add(SelectedValueEvent(value: temperature * 10));
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.remove,
|
||||
size: 32,
|
||||
color: ColorsManager.greyColor,
|
||||
)),
|
||||
title: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
TitleMedium(
|
||||
text: temperature.toString(),
|
||||
style: context.titleMedium.copyWith(
|
||||
color: ColorsManager.primaryColorWithOpacity,
|
||||
fontSize: 30,
|
||||
)),
|
||||
const SizedBox(width: 4),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: SvgPicture.asset(
|
||||
Assets.assetsCelsiusDegrees,
|
||||
alignment: Alignment.topCenter,
|
||||
width: 32,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
subtitle: BodyLarge(
|
||||
text: widget.functions[widget.index].operationalValues[0].description
|
||||
.toString(),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
trailing: IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
if (temperature < 30) {
|
||||
temperature++;
|
||||
}
|
||||
});
|
||||
context
|
||||
.read<CreateSceneBloc>()
|
||||
.add(SelectedValueEvent(value: temperature * 10));
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.add,
|
||||
size: 32,
|
||||
color: ColorsManager.greyColor,
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user