73 lines
1.8 KiB
Dart
73 lines
1.8 KiB
Dart
import 'package:dio/dio.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:http/http.dart' as http;
|
|
import 'dart:async';
|
|
import 'dart:convert';
|
|
|
|
class NewWorkoutView extends StatefulWidget{
|
|
String token;
|
|
|
|
NewWorkoutView(this.token);
|
|
|
|
@override
|
|
State<StatefulWidget> createState() {
|
|
return new NewWorkoutViewState();
|
|
}
|
|
}
|
|
|
|
class WorkoutType{
|
|
String id, name, description, type, unit;
|
|
WorkoutType(this.id, this.name, this.description, this.type, this.unit);
|
|
}
|
|
|
|
class NewWorkoutViewState extends State<NewWorkoutView>{
|
|
|
|
String name = "";
|
|
|
|
void speichern() async {
|
|
if(this.name != ''){
|
|
var url = Uri.parse("http://10.16.17.18/api/new_workout.php?token=" + super.widget.token);
|
|
var request = http.MultipartRequest("post", url);
|
|
Map<String, String> test = {"name": name};
|
|
request.fields.addAll(test);
|
|
var response = await request.send();
|
|
Navigator.pop(context);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text("Neues Workout"),
|
|
),
|
|
body: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: <Widget>[
|
|
Padding(
|
|
padding: EdgeInsets.all(8),
|
|
child: TextField(
|
|
autocorrect: true,
|
|
decoration: InputDecoration(
|
|
border: OutlineInputBorder(),
|
|
labelText: "Name des Workouts"
|
|
),
|
|
onChanged: (String s){
|
|
setState(() {
|
|
name = s;
|
|
});
|
|
},
|
|
),
|
|
),
|
|
Padding(
|
|
padding: EdgeInsets.all(8),
|
|
child: RaisedButton(
|
|
onPressed: speichern,
|
|
child: Text("Workout erstellen"),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |