Commit f05c1d85 authored by Administrator's avatar Administrator

import weight csv-data: user interface

parent cc1d4763
......@@ -3,6 +3,7 @@ import 'package:encrateia/model/model.dart';
import 'package:path_provider/path_provider.dart';
import 'package:strava_flutter/Models/detailedAthlete.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/models/weight.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'dart:io';
......@@ -73,6 +74,7 @@ class Athlete extends ChangeNotifier {
}
get activities => Activity.all(athlete: this);
get weights => Weight.all(athlete: this);
delete() async {
var appDocDir = await getApplicationDocumentsDirectory();
......
import 'package:flutter/material.dart';
import 'package:encrateia/model/model.dart';
import 'package:encrateia/models/athlete.dart';
class Weight extends ChangeNotifier {
DbWeight db;
Weight();
Weight.fromDb(this.db);
String toString() => '$db.date $db.value';
delete() async {
await this.db.delete();
}
static Future<List<Weight>> all({@required Athlete athlete}) async {
var dbWeightList =
await athlete.db.getDbWeights().orderByDesc('date').toList();
var weights = dbWeightList
.map((dbWeight) => Weight.fromDb(dbWeight))
.toList();
return weights;
}
}
......@@ -9,7 +9,7 @@ class IntroductionScreen extends StatelessWidget {
child: Card(
margin: EdgeInsets.all(10),
child: Padding(
padding: const EdgeInsets.all(8.0),
padding: EdgeInsets.all(8.0),
child: Text('''
Encrateia is a mobile application that wants to help you analyse your activity tracking data. In particular Encrateia analyzes .fit-Files that are created by many fitness trackers by default.
......
......@@ -8,6 +8,7 @@ import 'package:encrateia/widgets/athlete_widgets/athlete_stride_ratio_widget.da
import 'package:encrateia/widgets/athlete_widgets/athlete_settings_widget.dart';
import 'package:encrateia/widgets/athlete_widgets/athlete_power_per_heart_rate_widget.dart';
import 'package:encrateia/widgets/athlete_widgets/athlete_speed_per_heart_rate_widget.dart';
import 'package:encrateia/widgets/athlete_widgets/athlete_body_weight_widget.dart';
import 'package:encrateia/screens/show_athlete_detail_screen.dart';
import 'package:encrateia/utils/icon_utils.dart';
import 'package:flushbar/flushbar.dart';
......@@ -126,6 +127,14 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
),
),
]),
TableRow(children: [
detailTile(
title: "Body Weight",
icon: MyIcon.weight,
nextWidget: AthleteBodyWeightWidget(athlete: widget.athlete),
),
Text("")
])
]),
);
}
......
......@@ -90,4 +90,5 @@ class MyIcon {
static final verticalOscillation = Icon(Icons.unfold_more);
// W
static final website = Icon(Icons.web);
static final weight = Icon(Icons.restaurant_menu);
}
import 'package:flutter/material.dart';
import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/weight.dart';
import 'package:encrateia/utils/icon_utils.dart';
class AthleteBodyWeightWidget extends StatefulWidget {
final Athlete athlete;
AthleteBodyWeightWidget({this.athlete});
@override
_AthleteBodyWeightWidgetState createState() =>
_AthleteBodyWeightWidgetState();
}
class _AthleteBodyWeightWidgetState extends State<AthleteBodyWeightWidget> {
List<Weight> weights = [];
@override
void initState() {
getData();
super.initState();
}
@override
Widget build(context) {
if (weights != null) {
if (weights.length > 0) {
return Text(weights.length.toString());
} else {
return ListView(
children: <Widget>[
Card(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Center(child: Text('''
No weight data available.
You can import your historic weight data by putting a weights.csv-file in the App's document directory.
It's the one with a file named "put_your_fit_files_here.txt" inside.
Put one date and weight per line in the following format:
2020-04-28,75.3
''')),
),
),
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25)),
child: ListTile(
leading: MyIcon.downloadLocal,
title: Text("Import Weigths"),
onTap: () => importWeights(),
),
),
],
);
}
} else {
return Center(
child: Text("loading"),
);
}
}
getData() async {
Athlete athlete = widget.athlete;
weights = await athlete.weights;
setState(() {});
}
importWeights() async {}
}
......@@ -34,15 +34,7 @@ class _AthleteSettingsWidgetState extends State<AthleteSettingsWidget> {
userDB.firstName + " " + userDB.lastName,
),
),
ListTile(
leading: MyIcon.stravaDownload,
title: Text("Strava ID / Username / Location"),
subtitle: Text(userDB.stravaId.toString() +
" / " +
userDB.stravaUsername +
" / " +
userDB.geoState),
),
stravaTile(userDB: userDB),
ListTile(
leading: MyIcon.activities,
title: Text("Number of activities"),
......@@ -71,7 +63,11 @@ class _AthleteSettingsWidgetState extends State<AthleteSettingsWidget> {
],
),
),
ListTile(
leading: MyIcon.weight,
title: Text("Last known weight"),
subtitle: Text("no data available")
)
],
);
}
......@@ -94,8 +90,23 @@ class _AthleteSettingsWidgetState extends State<AthleteSettingsWidget> {
decreaseDownloadInterval() async {
var userDB = widget.athlete.db;
userDB.downloadInterval = (userDB.downloadInterval ?? 21) - 7;
if(userDB.downloadInterval < 7) userDB.downloadInterval = 7;
if (userDB.downloadInterval < 7) userDB.downloadInterval = 7;
await userDB.save();
setState(() {});
}
stravaTile({userDB}) {
if (userDB.stravaId != null)
return ListTile(
leading: MyIcon.stravaDownload,
title: Text("Strava ID / Username / Location"),
subtitle: Text(
userDB.stravaId.toString() +
" / " +
userDB.stravaUsername +
" / " +
userDB.geoState));
else
return Container(width: 0, height: 0);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment