Commit 5048ceaf authored by Administrator's avatar Administrator

templates for zone schemas available, when a zone exists; Dillinger heart rate zone schema

parent 810ceefd
......@@ -25,6 +25,14 @@ class HeartRateZoneSchema extends ChangeNotifier {
..base = 180;
}
HeartRateZoneSchema.likeStefanDillinger({Athlete athlete}) {
db = DbHeartRateZoneSchema()
..athletesId = athlete.db.id
..name = "like Stefan Dillinger"
..date = DateTime(1970, 01, 01)
..base = 165;
}
addGarminZones() async {
await HeartRateZone(
heartRateZoneSchema: this,
......@@ -63,6 +71,45 @@ class HeartRateZoneSchema extends ChangeNotifier {
).db.save();
}
addStefanDillingerZones() async {
await HeartRateZone(
heartRateZoneSchema: this,
name: "Z1",
lowerPercentage: 70,
upperPercentage: 80,
color: Colors.grey.value,
).db.save();
await HeartRateZone(
heartRateZoneSchema: this,
name: "Z2",
lowerPercentage: 80,
upperPercentage: 88,
color: Colors.blue.value,
).db.save();
await HeartRateZone(
heartRateZoneSchema: this,
name: "Z3",
lowerPercentage: 88,
upperPercentage: 95,
color: Colors.green.value,
).db.save();
await HeartRateZone(
heartRateZoneSchema: this,
name: "Z4",
lowerPercentage: 95,
upperPercentage: 100,
color: Colors.orange.value,
).db.save();
await HeartRateZone(
heartRateZoneSchema: this,
name: "Z5/6",
lowerPercentage: 100,
upperPercentage: 115,
color: Colors.red.value,
).db.save();
}
String toString() => '$db.date $db.name';
delete() async {
......
......@@ -32,13 +32,14 @@ class _AthleteHeartRateZoneSchemaWidgetState
Widget build(context) {
if (heartRateZoneSchemas != null) {
if (heartRateZoneSchemas.length > 0) {
rows = (heartRateZoneSchemas.length < 8) ? heartRateZoneSchemas.length : 8;
rows =
(heartRateZoneSchemas.length < 8) ? heartRateZoneSchemas.length : 8;
return ListView(
children: <Widget>[
Center(
child: Text(
"\nHeart Rate Zone Schemas ${offset + 1} - ${offset + rows} "
"of ${heartRateZoneSchemas.length}",
"of ${heartRateZoneSchemas.length}",
style: Theme.of(context).textTheme.title,
),
),
......@@ -95,7 +96,7 @@ class _AthleteHeartRateZoneSchemaWidgetState
MaterialPageRoute(
builder: (context) => AddHeartRateZoneSchemaScreen(
heartRateZoneSchema:
HeartRateZoneSchema(athlete: widget.athlete),
HeartRateZoneSchema(athlete: widget.athlete),
),
),
);
......@@ -107,8 +108,8 @@ class _AthleteHeartRateZoneSchemaWidgetState
onPressed: (offset == 0)
? null
: () => setState(() {
offset > 8 ? offset = offset - rows : offset = 0;
}),
offset > 8 ? offset = offset - rows : offset = 0;
}),
),
Spacer(),
MyButton.navigate(
......@@ -116,14 +117,15 @@ class _AthleteHeartRateZoneSchemaWidgetState
onPressed: (offset + rows == heartRateZoneSchemas.length)
? null
: () => setState(() {
offset + rows < heartRateZoneSchemas.length - rows
? offset = offset + rows
: offset = heartRateZoneSchemas.length - rows;
}),
offset + rows < heartRateZoneSchemas.length - rows
? offset = offset + rows
: offset = heartRateZoneSchemas.length - rows;
}),
),
Spacer(),
],
),
templateButtons(),
],
);
} else {
......@@ -149,19 +151,14 @@ You could also create a schema from scratch.
MaterialPageRoute(
builder: (context) => AddHeartRateZoneSchemaScreen(
heartRateZoneSchema:
HeartRateZoneSchema(athlete: widget.athlete),
HeartRateZoneSchema(athlete: widget.athlete),
),
),
);
getData();
},
),
RaisedButton(
// MyIcon.downloadLocal,
color: Colors.orange,
child: Text("Zone schema like Garmin"),
onPressed: () => likeGarmin(),
),
templateButtons(),
],
),
);
......@@ -184,4 +181,32 @@ You could also create a schema from scratch.
await heartRateZoneSchema.addGarminZones();
await getData();
}
likeStefanDillinger() async {
Athlete athlete = widget.athlete;
var heartRateZoneSchema =
HeartRateZoneSchema.likeStefanDillinger(athlete: athlete);
await heartRateZoneSchema.db.save();
await heartRateZoneSchema.addStefanDillingerZones();
await getData();
}
templateButtons() {
return Column(children: [
Divider(),
Text("Add heart rate zone schema from template:"),
RaisedButton(
// MyIcon.downloadLocal,
color: Colors.orange,
child: Text("like Garmin"),
onPressed: () => likeGarmin(),
),
RaisedButton(
// MyIcon.downloadLocal,
color: Colors.orange,
child: Text("like Stefan Dillinger"),
onPressed: () => likeStefanDillinger(),
),
]);
}
}
......@@ -124,6 +124,10 @@ class _AthletePowerZoneSchemaWidgetState
Spacer(),
],
),
Padding(
padding: EdgeInsets.all(25.0),
child: templateButtons(),
)
],
);
} else {
......@@ -156,24 +160,7 @@ You could also create a schema from scratch.
getData();
},
),
RaisedButton(
// MyIcon.downloadLocal,
color: Colors.orange,
child: Text("Zone schema like Stryd"),
onPressed: () => likeStryd(),
),
RaisedButton(
// MyIcon.downloadLocal,
color: Colors.orange,
child: Text("Zone schema like Jim Vance"),
onPressed: () => likeJimVance(),
),
RaisedButton(
// MyIcon.downloadLocal,
color: Colors.orange,
child: Text("Zone schema like Stefan Dillinger"),
onPressed: () => likeStefanDillinger(),
),
templateButtons(),
],
),
);
......@@ -212,4 +199,29 @@ You could also create a schema from scratch.
await powerZoneSchema.addStefanDillingerZones();
await getData();
}
templateButtons() {
return Column(children: [
Divider(),
Text("Add power zone schema from template:"),
RaisedButton(
// MyIcon.downloadLocal,
color: Colors.orange,
child: Text("like Stryd"),
onPressed: () => likeStryd(),
),
RaisedButton(
// MyIcon.downloadLocal,
color: Colors.orange,
child: Text("like Jim Vance"),
onPressed: () => likeJimVance(),
),
RaisedButton(
// MyIcon.downloadLocal,
color: Colors.orange,
child: Text("like Stefan Dillinger"),
onPressed: () => likeStefanDillinger(),
),
]);
}
}
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