Compare commits
No commits in common. "9181aaf83010c2723079b57cc67b503ad09ce058" and "b74cb559dcbde3e1e594d6ec7009dd94de5ba8e5" have entirely different histories.
9181aaf830
...
b74cb559dc
@ -1,126 +0,0 @@
|
|||||||
import 'package:dio/dio.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:http/http.dart' as http;
|
|
||||||
import 'dart:async';
|
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
class AddExercise extends StatefulWidget{
|
|
||||||
int workoutId;
|
|
||||||
|
|
||||||
AddExercise(this.workoutId);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<StatefulWidget> createState() {
|
|
||||||
return new AddExerciseState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class WorkoutType{
|
|
||||||
String id, name, description, type, unit;
|
|
||||||
WorkoutType(this.id, this.name, this.description, this.type, this.unit);
|
|
||||||
}
|
|
||||||
|
|
||||||
class AddExerciseState extends State<AddExercise>{
|
|
||||||
|
|
||||||
int anzahl, sets, exerciseID = 0;
|
|
||||||
List data;
|
|
||||||
|
|
||||||
void speichern(String id) async {
|
|
||||||
if(this.anzahl != 0){
|
|
||||||
var url = Uri.parse("http://10.16.17.18/api/add_exercise_to_workout.php?token=satbwertwhbertnwertwertghwertgwertg");
|
|
||||||
var request = http.MultipartRequest("post", url);
|
|
||||||
Map<String, String> test = {
|
|
||||||
"workout": this.widget.workoutId.toString(),
|
|
||||||
"exercise": id,
|
|
||||||
"amount": anzahl.toString(),
|
|
||||||
"sets": sets.toString()
|
|
||||||
};
|
|
||||||
print(test);
|
|
||||||
request.fields.addAll(test);
|
|
||||||
var response = await request.send();
|
|
||||||
var test2 = await response.stream.bytesToString();
|
|
||||||
print(test2);
|
|
||||||
Navigator.pop(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List> getWorkouts() async {
|
|
||||||
var response = await http.get(
|
|
||||||
"http://10.16.17.18/api/exercises.php?token=satbwertwhbertnwertwertghwertgwertg",
|
|
||||||
headers: {
|
|
||||||
"Accept": "application/json"
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
this.setState(() {
|
|
||||||
data = JsonDecoder().convert(response.body);
|
|
||||||
});
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
// TODO: implement initState
|
|
||||||
getWorkouts();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text("Füge eine neue Übung hinzu"),
|
|
||||||
),
|
|
||||||
body: Column(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: <Widget>[
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
child: TextField(
|
|
||||||
autocorrect: true,
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
labelText: "anzahl"
|
|
||||||
),
|
|
||||||
onChanged: (String s){
|
|
||||||
setState(() {
|
|
||||||
anzahl = int.parse(s);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
child: TextField(
|
|
||||||
autocorrect: true,
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
labelText: "sets"
|
|
||||||
),
|
|
||||||
onChanged: (String s){
|
|
||||||
setState(() {
|
|
||||||
sets = int.parse(s);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: ListView.builder(
|
|
||||||
itemCount: data== null? 0 : data.length,
|
|
||||||
itemBuilder: (BuildContext context, int index){
|
|
||||||
return new ListTile(
|
|
||||||
title: Text(data[index]['name']),
|
|
||||||
subtitle: Text(data[index]['description']),
|
|
||||||
onTap: (){
|
|
||||||
speichern(data[index]['id']);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,3 @@
|
|||||||
import 'package:fitnessapp/Views/add_exercise.dart';
|
|
||||||
import 'package:fitnessapp/Views/exercise_details_view.dart';
|
import 'package:fitnessapp/Views/exercise_details_view.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
@ -24,7 +23,7 @@ class ExerciseViewState extends State<ExerciseView>{
|
|||||||
|
|
||||||
Future<List> getWorkouts() async {
|
Future<List> getWorkouts() async {
|
||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
"http://10.16.17.18/api/workout.php?token=satbwertwhbertnwertwertghwertgwertg&workout="+this.widget.id,
|
"http://10.16.17.65/api/workout.php?token=satbwertwhbertnwertwertghwertgwertg&workout="+this.widget.id,
|
||||||
headers: {
|
headers: {
|
||||||
"Accept": "application/json"
|
"Accept": "application/json"
|
||||||
}
|
}
|
||||||
@ -54,14 +53,14 @@ class ExerciseViewState extends State<ExerciseView>{
|
|||||||
),
|
),
|
||||||
title: Text(this.widget.title),
|
title: Text(this.widget.title),
|
||||||
),
|
),
|
||||||
body: RefreshIndicator(
|
body: ListView.builder(
|
||||||
child: ListView.builder(
|
|
||||||
itemCount: data == null ? 0 : data.length,
|
itemCount: data == null ? 0 : data.length,
|
||||||
itemBuilder: (BuildContext context, int index){
|
itemBuilder: (BuildContext context, int index){
|
||||||
return new ListTile(
|
return new ListTile(
|
||||||
leading: Icon(data[index]['type'] == 'duration' ? Icons.access_alarm : (data[index]['type'] == 'count' ? Icons.filter_1 : Icons.transfer_within_a_station)),
|
leading: Icon(data[index]['type'] == 'duration' ? Icons.access_alarm : (data[index]['type'] == 'count' ? Icons.filter_1 : Icons.transfer_within_a_station)),
|
||||||
title: Text((index+1).toString() + ': ' + data[index]['name']),
|
title: Text(data[index]['name']),
|
||||||
subtitle: Text(data[index]['sets'] + ' x ' + data[index]['amount'] + ' ' + data[index]['unit']),
|
subtitle: Text(data[index]['amount'] + ' ' + data[index]['unit']),
|
||||||
|
trailing: Icon(Icons.add_box),
|
||||||
onTap: (){
|
onTap: (){
|
||||||
Navigator.push(context, MaterialPageRoute(
|
Navigator.push(context, MaterialPageRoute(
|
||||||
builder: (context) => ExerciseDetailsView(data[index]['name'], data[index]['description'], data[index]['amount'], data[index]['type'], data[index]['unit'])
|
builder: (context) => ExerciseDetailsView(data[index]['name'], data[index]['description'], data[index]['amount'], data[index]['type'], data[index]['unit'])
|
||||||
@ -70,16 +69,6 @@ class ExerciseViewState extends State<ExerciseView>{
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
onRefresh: getWorkouts,
|
|
||||||
),
|
|
||||||
floatingActionButton: FloatingActionButton(
|
|
||||||
onPressed: (){
|
|
||||||
Navigator.push(context, MaterialPageRoute(
|
|
||||||
builder: (context) => AddExercise(int.parse(this.widget.id))
|
|
||||||
));
|
|
||||||
},
|
|
||||||
child: Icon(Icons.add),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,3 @@
|
|||||||
import 'package:dio/dio.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
@ -17,28 +16,42 @@ class WorkoutType{
|
|||||||
}
|
}
|
||||||
|
|
||||||
class NewWorkoutViewState extends State<NewWorkoutView>{
|
class NewWorkoutViewState extends State<NewWorkoutView>{
|
||||||
|
List<WorkoutType> data;
|
||||||
|
List<WorkoutType> selectedExercises = new List();
|
||||||
|
String selectedExercisesString = "Derzeit ausgewählte übungen: ";
|
||||||
|
|
||||||
String name = "";
|
Future<List> getWorkouts() async {
|
||||||
|
var response = await http.get(
|
||||||
void speichern() async {
|
"http://10.16.17.65/api/exercises.php?token=satbwertwhbertnwertwertghwertgwertg",
|
||||||
if(this.name != ''){
|
headers: {
|
||||||
FormData data = new FormData.fromMap({
|
"Accept": "application/json"
|
||||||
"name": "Hallo Welt"
|
|
||||||
});
|
|
||||||
var url = Uri.parse("http://10.16.17.18/api/new_workout.php?token=satbwertwhbertnwertwertghwertgwertg");
|
|
||||||
var request = http.MultipartRequest("post", url);
|
|
||||||
Map<String, String> test = {"name": name};
|
|
||||||
request.fields.addAll(test);
|
|
||||||
var response = await request.send();
|
|
||||||
Navigator.pop(context);
|
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
List results = JsonDecoder().convert(response.body);
|
||||||
|
List<WorkoutType> templist = [];
|
||||||
|
for(var i = 0; i < results.length; i++){
|
||||||
|
templist.add(new WorkoutType(results[i]['id'], results[i]['name'], results[i]['description'], results[i]['type'], results[i]['unit']));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState(() {
|
||||||
|
data = templist;
|
||||||
|
});
|
||||||
|
print(data);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
// TODO: implement initState
|
||||||
|
getWorkouts();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text("Füge eine Übung hinzu"),
|
title: Text("Erstelle ein neues Workout"),
|
||||||
),
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
@ -46,24 +59,39 @@ class NewWorkoutViewState extends State<NewWorkoutView>{
|
|||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.all(8),
|
padding: EdgeInsets.all(8),
|
||||||
child: TextField(
|
child: TextField(
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
autocorrect: true,
|
autocorrect: true,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
labelText: "Name des Workouts"
|
labelText: "Name des Workouts"
|
||||||
),
|
),
|
||||||
onChanged: (String s){
|
),
|
||||||
|
),
|
||||||
|
Text(selectedExercisesString),
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: data == null ? 0 : data.length,
|
||||||
|
itemBuilder: (BuildContext context, int index){
|
||||||
|
return new ListTile(
|
||||||
|
title: Text(data[index].name),
|
||||||
|
subtitle: Text(data[index].description),
|
||||||
|
onTap: (){
|
||||||
setState(() {
|
setState(() {
|
||||||
name = s;
|
if(selectedExercises == null){
|
||||||
|
selectedExercises = [data[index]];
|
||||||
|
}else{
|
||||||
|
selectedExercises.add(data[index]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
String temp = "Ausgewählte übungen: ";
|
||||||
|
for (var i = 0; i < selectedExercises.length; i++){
|
||||||
|
temp = temp + selectedExercises[i].name + ', ';
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
selectedExercisesString = temp;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
);
|
||||||
),
|
},
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.all(8),
|
|
||||||
child: RaisedButton(
|
|
||||||
onPressed: speichern,
|
|
||||||
child: Text("Workout erstellen"),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
@ -18,7 +18,7 @@ class WorkoutsViewState extends State<WorkoutsView>{
|
|||||||
|
|
||||||
Future<List> getWorkouts() async {
|
Future<List> getWorkouts() async {
|
||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
"http://10.16.17.18/api/index.php?token=satbwertwhbertnwertwertghwertgwertg",
|
"http://10.16.17.65/api/index.php?token=satbwertwhbertnwertwertghwertgwertg",
|
||||||
headers: {
|
headers: {
|
||||||
"Accept": "application/json"
|
"Accept": "application/json"
|
||||||
}
|
}
|
||||||
@ -39,8 +39,7 @@ class WorkoutsViewState extends State<WorkoutsView>{
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// TODO: implement build
|
// TODO: implement build
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: RefreshIndicator(
|
body: ListView.builder(
|
||||||
child: ListView.builder(
|
|
||||||
itemCount: data == null ? 0 : data.length,
|
itemCount: data == null ? 0 : data.length,
|
||||||
itemBuilder: (BuildContext context, int index){
|
itemBuilder: (BuildContext context, int index){
|
||||||
return new ListTile(
|
return new ListTile(
|
||||||
@ -55,8 +54,6 @@ class WorkoutsViewState extends State<WorkoutsView>{
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
onRefresh: getWorkouts,
|
|
||||||
),
|
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
onPressed: (){
|
onPressed: (){
|
||||||
Navigator.push(context, MaterialPageRoute(
|
Navigator.push(context, MaterialPageRoute(
|
||||||
|
@ -64,13 +64,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.3"
|
version: "0.1.3"
|
||||||
dio:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: dio
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "3.0.9"
|
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -213,4 +206,4 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "3.5.0"
|
version: "3.5.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">2.4.0 <3.0.0"
|
dart: ">=2.4.0 <3.0.0"
|
||||||
|
@ -24,7 +24,6 @@ dependencies:
|
|||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^0.1.2
|
cupertino_icons: ^0.1.2
|
||||||
http:
|
http:
|
||||||
dio:
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Loading…
Reference in New Issue
Block a user