wip refactor timer

main
Julian Gegner 2023-02-26 17:33:32 +01:00
parent 68033a64a5
commit 02ffb9b2f7
3 changed files with 59 additions and 67 deletions

View File

@ -1,8 +1,11 @@
import 'dart:async'; import 'dart:async';
import 'package:audioplayers/audioplayers.dart'; import 'package:audioplayers/audioplayers.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:smoke_cess_app/widgets/popup_for_start_and_stop.dart'; import 'package:smoke_cess_app/widgets/popup_for_start_and_stop.dart';
import '../providers/input_provider.dart';
class IntervalTimerPage extends StatefulWidget { class IntervalTimerPage extends StatefulWidget {
const IntervalTimerPage({Key? key}) : super(key: key); const IntervalTimerPage({Key? key}) : super(key: key);
@ -44,9 +47,11 @@ class _IntervalTimerPageState extends State<IntervalTimerPage> {
await showDialog( await showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return const TimerStartStopPopup( return ChangeNotifierProvider(
create: (context) => InputProvider(),
child: const TimerStartStopPopup(
title: 'Motivation vor dem Training', title: 'Motivation vor dem Training',
); ));
}, },
); );
_isPaused = false; _isPaused = false;
@ -161,8 +166,9 @@ class _IntervalTimerPageState extends State<IntervalTimerPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Center(
body: Center( child: ChangeNotifierProvider(
create: (context) => InputProvider(),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
@ -191,8 +197,9 @@ class _IntervalTimerPageState extends State<IntervalTimerPage> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
IconButton( IconButton(
icon: Icon( icon: Icon(_isPaused
_isPaused ? Icons.play_arrow_rounded : Icons.stop_rounded), ? Icons.play_arrow_rounded
: Icons.stop_rounded),
iconSize: 48.0, iconSize: 48.0,
onPressed: () { onPressed: () {
if (_isPaused) { if (_isPaused) {

View File

@ -1,41 +1,26 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:smoke_cess_app/widgets/slider.dart'; import 'package:smoke_cess_app/widgets/slider.dart';
import 'package:smoke_cess_app/widgets/submit_form_button.dart';
import 'package:smoke_cess_app/widgets/text_formfield.dart'; import 'package:smoke_cess_app/widgets/text_formfield.dart';
class TimerStartStopPopup extends StatefulWidget { class TimerStartStopPopup extends StatelessWidget {
final String title; final String title;
const TimerStartStopPopup({Key? key, required this.title}) : super(key: key); const TimerStartStopPopup({Key? key, required this.title}) : super(key: key);
@override
TimerStartStopPopupState createState() => TimerStartStopPopupState();
}
class TimerStartStopPopupState extends State<TimerStartStopPopup> {
final MySlider slider = MySlider();
void submitForm(BuildContext context) {
Navigator.of(context).pop();
}
void onFormFieldSave(String? newValue) => newValue!;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AlertDialog( return AlertDialog(
title: Text(widget.title), title: Text(title),
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: const [
Padding( Padding(
padding: const EdgeInsets.only(top: 8), padding: const EdgeInsets.only(top: 8),
child: MySlider(), child: MySlider(),
), ),
const SizedBox(height: 16), SizedBox(height: 16),
MyTextFormField('Beschreibe deinen Motivation'), MyTextFormField('Beschreibe deinen Motivation'),
SubmitFormButton(() => submitForm(context)),
], ],
), ),
); );

View File