From 92333d7b2d772e05bfaa3a4408a9e9669ec634db Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Wed, 15 Feb 2023 14:30:40 +0100 Subject: [PATCH] added reusable slider, used it in mood page --- lib/pages/mood_page.dart | 3 ++- lib/widgets/slider.dart | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 lib/widgets/slider.dart diff --git a/lib/pages/mood_page.dart b/lib/pages/mood_page.dart index a8c4a4e..0e76795 100644 --- a/lib/pages/mood_page.dart +++ b/lib/pages/mood_page.dart @@ -1,10 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:smoke_cess_app/widgets/slider.dart'; class MoodPage extends StatelessWidget { const MoodPage({super.key}); @override Widget build(BuildContext context) { - return const Center(child: Text('Hier Fragen wir die Stimmung ab')); + return Column(children: const [MySlider(), Text('Freitext')]); } } diff --git a/lib/widgets/slider.dart b/lib/widgets/slider.dart new file mode 100644 index 0000000..2d800e2 --- /dev/null +++ b/lib/widgets/slider.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; + +class MySlider extends StatefulWidget { + const MySlider({super.key}); + + @override + State createState() => SliderState(); +} + +class SliderState extends State { + double _currentSliderValue = 50; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Slider( + value: _currentSliderValue, + max: 100, + label: _currentSliderValue.round().toString(), + onChanged: (double value) => + {setState((() => _currentSliderValue = value))}), + Text(_currentSliderValue.round().toString()) + ], + ); + } +}