mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-27 03:17:55 +00:00
push integer step dialog design
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
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/shared_widgets/text_widgets/body_large.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_small.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class AlertDialogSliderSteps extends StatefulWidget {
|
||||
const AlertDialogSliderSteps({
|
||||
super.key,
|
||||
this.functionValue,
|
||||
required this.taskItem,
|
||||
});
|
||||
|
||||
final dynamic functionValue;
|
||||
final SceneStaticFunction taskItem;
|
||||
|
||||
@override
|
||||
State<AlertDialogSliderSteps> createState() => _AlertDialogSliderStepsState();
|
||||
}
|
||||
|
||||
class _AlertDialogSliderStepsState extends State<AlertDialogSliderSteps> {
|
||||
double? groupValue;
|
||||
int selectedToggleIndex = 0;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
final tempTaskList = context.read<CreateSceneBloc>().tempTasksList;
|
||||
if (tempTaskList.isNotEmpty) {
|
||||
for (var element in tempTaskList) {
|
||||
if (element.code == widget.taskItem.code) {
|
||||
groupValue = element.functionValue;
|
||||
} else {
|
||||
context
|
||||
.read<CreateSceneBloc>()
|
||||
.add(RemoveFromSelectedValueById(code: widget.taskItem.code));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (widget.functionValue != null) {
|
||||
setState(() {
|
||||
groupValue = widget.functionValue;
|
||||
});
|
||||
} else {
|
||||
groupValue = widget.taskItem.operationalValues[0].minValue;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ToggleButtons(
|
||||
isSelected: [
|
||||
selectedToggleIndex == 0,
|
||||
selectedToggleIndex == 1,
|
||||
selectedToggleIndex == 2
|
||||
],
|
||||
onPressed: (index) {
|
||||
setState(() {
|
||||
selectedToggleIndex = index;
|
||||
});
|
||||
},
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
selectedColor: Colors.white,
|
||||
color: ColorsManager.blackColor,
|
||||
fillColor: ColorsManager.primaryColorWithOpacity,
|
||||
constraints: const BoxConstraints(minHeight: 30, minWidth: 30),
|
||||
children: const [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 30.0),
|
||||
child: Text("<"),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 30.0),
|
||||
child: Text("="),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 30.0),
|
||||
child: Text(">"),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
...widget.taskItem.operationalValues.map(
|
||||
(operation) => BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
return Column(
|
||||
children: [
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
TitleMedium(
|
||||
text: groupValue?.toStringAsFixed(1) ?? "0",
|
||||
style: context.titleMedium.copyWith(
|
||||
color: ColorsManager.primaryColorWithOpacity,
|
||||
fontSize: 30,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
TitleMedium(
|
||||
text: operation.description.toString(),
|
||||
style: context.titleMedium.copyWith(
|
||||
color: ColorsManager.primaryColorWithOpacity,
|
||||
fontSize: 30,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Slider(
|
||||
value: groupValue ?? 0,
|
||||
min: operation.minValue?.toDouble() ?? 0,
|
||||
max: operation.maxValue?.toDouble() ?? 0,
|
||||
inactiveColor: ColorsManager.primaryColorWithOpacity,
|
||||
divisions: operation.stepValue != null
|
||||
? ((operation.maxValue!.toDouble() -
|
||||
operation.minValue!.toDouble()) /
|
||||
operation.stepValue!.toDouble())
|
||||
.round()
|
||||
: null,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
groupValue = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user