Merge branch 'main' into '8-datenbank-einbinden'
# Conflicts: # lib/widgets/mood_form.dart # lib/widgets/sleep_form.dartmain
commit
33cecb4979
|
@ -11,14 +11,15 @@ class IntervalTimerPage extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _IntervalTimerPageState extends State<IntervalTimerPage> {
|
class _IntervalTimerPageState extends State<IntervalTimerPage> {
|
||||||
final Duration _warmupDuration = const Duration(minutes: 5);
|
final Duration _warmupDuration = const Duration(seconds: 5);
|
||||||
final Duration _cooldownDuration = const Duration(minutes: 5);
|
final Duration _cooldownDuration = const Duration(seconds: 5);
|
||||||
final Duration _highIntensityDuration = const Duration(minutes: 4);
|
final Duration _highIntensityDuration = const Duration(seconds: 4);
|
||||||
final Duration _lowIntensityDuration = const Duration(minutes: 3);
|
final Duration _lowIntensityDuration = const Duration(seconds: 3);
|
||||||
late Duration _totalDuration = const Duration(minutes: 35);
|
late Duration _totalDuration = const Duration(minutes: 35);
|
||||||
AudioPlayer warmUpPlayer = AudioPlayer();
|
AudioPlayer warmUpPlayer = AudioPlayer();
|
||||||
AudioPlayer workoutPlayer = AudioPlayer();
|
AudioPlayer workoutPlayer = AudioPlayer();
|
||||||
AudioPlayer coolDownPlayer = AudioPlayer();
|
AudioPlayer coolDownPlayer = AudioPlayer();
|
||||||
|
final AudioCache _audioCache = AudioCache();
|
||||||
final int _numHighIntensityBlocks = 4;
|
final int _numHighIntensityBlocks = 4;
|
||||||
final int _numLowIntensityBlocks = 3;
|
final int _numLowIntensityBlocks = 3;
|
||||||
|
|
||||||
|
@ -49,7 +50,8 @@ class _IntervalTimerPageState extends State<IntervalTimerPage> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
_isPaused = false;
|
_isPaused = false;
|
||||||
await AudioPlayer().play(UrlSource('assets/go.mp3'));
|
Source source = AssetSource('go.mp3');
|
||||||
|
await AudioPlayer().play(source);
|
||||||
|
|
||||||
_timer = Timer.periodic(const Duration(seconds: 1), (_) => _tick());
|
_timer = Timer.periodic(const Duration(seconds: 1), (_) => _tick());
|
||||||
Future.delayed(const Duration(seconds: 1)).then((value) {
|
Future.delayed(const Duration(seconds: 1)).then((value) {
|
||||||
|
@ -80,20 +82,23 @@ class _IntervalTimerPageState extends State<IntervalTimerPage> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _playWarmUpMusic() async {
|
Future<void> _playWarmUpMusic() async {
|
||||||
|
Source source = AssetSource('warmUp.mp3');
|
||||||
await warmUpPlayer.setReleaseMode(ReleaseMode.loop);
|
await warmUpPlayer.setReleaseMode(ReleaseMode.loop);
|
||||||
await warmUpPlayer.play(UrlSource('assets/warmUp.mp3'));
|
await warmUpPlayer.play(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _playWorkoutMusic() async {
|
Future<void> _playWorkoutMusic() async {
|
||||||
await warmUpPlayer.stop();
|
await warmUpPlayer.stop();
|
||||||
Future.delayed(const Duration(microseconds: 600)).then((value) async {
|
Future.delayed(const Duration(microseconds: 600)).then((value) async {
|
||||||
|
Source source = AssetSource('workout.mp3');
|
||||||
await workoutPlayer.setReleaseMode(ReleaseMode.loop);
|
await workoutPlayer.setReleaseMode(ReleaseMode.loop);
|
||||||
await workoutPlayer.play(UrlSource('assets/workout.mp3'));
|
await workoutPlayer.play(source);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _intervalChange() async {
|
Future<void> _intervalChange() async {
|
||||||
await AudioPlayer().play(UrlSource('assets/beep.mp3'));
|
Source source = AssetSource('beep.mp3');
|
||||||
|
await AudioPlayer().play(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _tick() {
|
void _tick() {
|
||||||
|
@ -123,14 +128,16 @@ class _IntervalTimerPageState extends State<IntervalTimerPage> {
|
||||||
_currentDuration = _cooldownDuration;
|
_currentDuration = _cooldownDuration;
|
||||||
() async {
|
() async {
|
||||||
await workoutPlayer.stop();
|
await workoutPlayer.stop();
|
||||||
|
Source source = AssetSource('cool_down.mp3');
|
||||||
await coolDownPlayer.setReleaseMode(ReleaseMode.loop);
|
await coolDownPlayer.setReleaseMode(ReleaseMode.loop);
|
||||||
await coolDownPlayer.play(UrlSource('assets/cool_down.mp3'));
|
await coolDownPlayer.play(source);
|
||||||
}();
|
}();
|
||||||
} else {
|
} else {
|
||||||
() async {
|
() async {
|
||||||
Future.delayed(const Duration(microseconds: 900))
|
Future.delayed(const Duration(microseconds: 900))
|
||||||
.then((value) async {
|
.then((value) async {
|
||||||
await AudioPlayer().play(UrlSource('assets/finish.mp3'));
|
Source source = AssetSource('finish.mp3');
|
||||||
|
await AudioPlayer().play(source);
|
||||||
});
|
});
|
||||||
}();
|
}();
|
||||||
_resetTimer();
|
_resetTimer();
|
||||||
|
|
|
@ -16,7 +16,7 @@ class MoodForm extends StatefulWidget {
|
||||||
|
|
||||||
class _MoodFormState extends State<MoodForm> {
|
class _MoodFormState extends State<MoodForm> {
|
||||||
final GlobalKey<FormState> _moodFormKey = GlobalKey<FormState>();
|
final GlobalKey<FormState> _moodFormKey = GlobalKey<FormState>();
|
||||||
MySlider slider = const MySlider();
|
MySlider slider = MySlider();
|
||||||
String _textInput = "";
|
String _textInput = "";
|
||||||
|
|
||||||
void submitForm() {
|
void submitForm() {
|
||||||
|
|
|
@ -13,7 +13,7 @@ class TimerStartStopPopup extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class TimerStartStopPopupState extends State<TimerStartStopPopup> {
|
class TimerStartStopPopupState extends State<TimerStartStopPopup> {
|
||||||
final MySlider slider = const MySlider();
|
final MySlider slider = MySlider();
|
||||||
|
|
||||||
void submitForm(BuildContext context) {
|
void submitForm(BuildContext context) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
@ -29,9 +29,9 @@ class TimerStartStopPopupState extends State<TimerStartStopPopup> {
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(top: 8),
|
padding: const EdgeInsets.only(top: 8),
|
||||||
child: MySlider(labelText: 'Motivation'),
|
child: MySlider(),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
MyTextFormField('Beschreibe deinen Motivation', onFormFieldSave),
|
MyTextFormField('Beschreibe deinen Motivation', onFormFieldSave),
|
||||||
|
|
|
@ -16,7 +16,7 @@ class SleepForm extends StatefulWidget {
|
||||||
|
|
||||||
class _SleepFormState extends State<SleepForm> {
|
class _SleepFormState extends State<SleepForm> {
|
||||||
final GlobalKey<FormState> _sleepFormKey = GlobalKey<FormState>();
|
final GlobalKey<FormState> _sleepFormKey = GlobalKey<FormState>();
|
||||||
MySlider slider = const MySlider();
|
MySlider slider = MySlider();
|
||||||
String _textInput = "";
|
String _textInput = "";
|
||||||
TimePicker sleepTimePicker = TimePicker(
|
TimePicker sleepTimePicker = TimePicker(
|
||||||
const TimeOfDay(hour: 22, minute: 00),
|
const TimeOfDay(hour: 22, minute: 00),
|
||||||
|
|
|
@ -1,90 +1,58 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
double _currentSliderValue = 50;
|
// ignore: must_be_immutable
|
||||||
|
|
||||||
class MySlider extends StatefulWidget {
|
class MySlider extends StatefulWidget {
|
||||||
final String _labelText;
|
double _currentSliderValue = 50;
|
||||||
const MySlider({Key? key, String labelText = 'Stimmung'})
|
MySlider({Key? key}) : super(key: key);
|
||||||
: _labelText = labelText,
|
|
||||||
super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => SliderState();
|
State<StatefulWidget> createState() => SliderState();
|
||||||
|
|
||||||
double getSliderValue() {
|
double get sliderValue => _currentSliderValue;
|
||||||
return _currentSliderValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SliderState extends State<MySlider> {
|
class SliderState extends State<MySlider> {
|
||||||
TextEditingController _textFieldController = TextEditingController();
|
|
||||||
String? _errorText;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_textFieldController.text = _currentSliderValue.toStringAsFixed(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
Text('${widget._currentSliderValue.toInt()}',
|
||||||
|
style: const TextStyle(fontSize: 22)),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.remove_outlined),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
widget._currentSliderValue -= 1;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Slider(
|
child: Slider(
|
||||||
value: _currentSliderValue,
|
value: widget._currentSliderValue,
|
||||||
min: 1,
|
min: 0,
|
||||||
max: 100,
|
max: 100,
|
||||||
divisions: 99,
|
divisions: 100,
|
||||||
label: _currentSliderValue.round().toString(),
|
label: widget._currentSliderValue.round().toString(),
|
||||||
onChanged: (double value) {
|
onChanged: (double value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_currentSliderValue = value;
|
widget._currentSliderValue = value;
|
||||||
_textFieldController.text = _currentSliderValue.toStringAsFixed(0);
|
|
||||||
_errorText = null;
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 16),
|
IconButton(
|
||||||
SizedBox(
|
icon: const Icon(Icons.add_outlined),
|
||||||
width: 100,
|
onPressed: () {
|
||||||
child: TextFormField(
|
setState(() {
|
||||||
controller: _textFieldController,
|
widget._currentSliderValue += 1;
|
||||||
keyboardType: TextInputType.number,
|
});
|
||||||
decoration: InputDecoration(
|
},
|
||||||
labelText: widget._labelText,
|
|
||||||
errorText: _errorText,
|
|
||||||
),
|
|
||||||
onChanged: (text) {
|
|
||||||
if (text.isEmpty) {
|
|
||||||
setState(() {
|
|
||||||
_currentSliderValue = 1;
|
|
||||||
_textFieldController.clear();
|
|
||||||
_errorText = null;
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final value = double.tryParse(text);
|
|
||||||
if (value == null || value < 1 || value > 100) {
|
|
||||||
setState(() {
|
|
||||||
_textFieldController.clear();
|
|
||||||
_errorText = 'Please enter a value between 1 and 100.';
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setState(() {
|
|
||||||
_currentSliderValue = value;
|
|
||||||
_errorText = null;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue