Commit 7fdec90f authored by Administrator's avatar Administrator

model classes

parent 9c70202d
......@@ -15,7 +15,7 @@ class HeartRateZone extends ChangeNotifier {
int color}) {
db = DbHeartRateZone()
..heartRateZoneSchemataId = heartRateZoneSchema.db.id
..name = name ?? "my Zone"
..name = name ?? "My Zone"
..lowerLimit = lowerLimit ?? 70
..upperLimit = upperLimit ?? 100
..lowerPercentage = lowerPercentage ?? 0
......
......@@ -10,7 +10,7 @@ class HeartRateZoneSchema extends ChangeNotifier {
db = DbHeartRateZoneSchema()
..athletesId = athlete.db.id
..base = 180
..name = "MySchema"
..name = "My Schema"
..date = DateTime.now();
}
HeartRateZoneSchema.fromDb(this.db);
......
......@@ -15,7 +15,7 @@ class PowerZone extends ChangeNotifier {
int color}) {
db = DbPowerZone()
..powerZoneSchemataId = powerZoneSchema.db.id
..name = name ?? "my Zone"
..name = name ?? "My Zone"
..lowerLimit = lowerLimit ?? 70
..upperLimit = upperLimit ?? 100
..lowerPercentage = lowerPercentage ?? 0
......
......@@ -10,7 +10,7 @@ class PowerZoneSchema extends ChangeNotifier {
db = DbPowerZoneSchema()
..athletesId = athlete.db.id
..base = 250
..name = "MySchema"
..name = "My Schema"
..date = DateTime.now();
}
PowerZoneSchema.fromDb(this.db);
......
import 'package:flutter/material.dart';
import 'package:encrateia/model/model.dart';
import 'package:encrateia/models/tag_group.dart';
class Tag extends ChangeNotifier {
DbTag db;
Tag({
@required TagGroup tagGroup,
String name,
int color,
}) {
db = DbTag()
..tagGroupsId = tagGroup.db.id
..name = name ?? "my Tag"
..color = color ?? 0xFFFFc107;
}
Tag.fromDb(this.db);
String toString() => '$db.date $db.name';
delete() async {
await this.db.delete();
}
static Future<List<Tag>> all({@required TagGroup tagGroup}) async {
var dbTagList = await tagGroup.db.getDbTags().orderBy('name').toList();
var tags = dbTagList.map((dbTag) => Tag.fromDb(dbTag)).toList();
return tags;
}
}
import 'package:encrateia/models/tag.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/model/model.dart';
import 'package:encrateia/models/athlete.dart';
class TagGroup extends ChangeNotifier {
DbTagGroup db;
TagGroup({@required Athlete athlete}) {
db = DbTagGroup()
..athletesId = athlete.db.id
..name = "My Tag Group";
}
TagGroup.fromDb(this.db);
get powerZones => Tag.all(tagGroup: this);
TagGroup.likeStryd({Athlete athlete}) {
db = DbTagGroup()
..athletesId = athlete.db.id
..name = "CP based";
}
addStrydZones() async {
await Tag(
tagGroup: this,
name: "Easy",
color: Colors.lightGreen.value,
).db.save();
await Tag(
tagGroup: this,
name: "Moderate",
color: Colors.lightBlue.value,
).db.save();
await Tag(
tagGroup: this,
name: "Threshold",
color: Colors.yellow.value,
).db.save();
await Tag(
tagGroup: this,
name: "Interval",
color: Colors.orange.value,
).db.save();
await Tag(
tagGroup: this,
name: "Repetition",
color: Colors.red.value,
).db.save();
}
String toString() => '$db.name';
delete() async {
await this.db.delete();
}
static Future<List<TagGroup>> all({@required Athlete athlete}) async {
var dbTagGroupList =
await athlete.db.getDbTagGroups().orderByDesc('date').toList();
var tagGroups = dbTagGroupList
.map((dbTagGroup) => TagGroup.fromDb(dbTagGroup))
.toList();
return tagGroups;
}
static getBy({
int athletesId,
}) async {
var dbTagGroups = await DbTagGroup()
.select()
.athletesId
.equals(athletesId)
.top(1)
.toList();
if (dbTagGroups.length != 0)
return TagGroup.fromDb(dbTagGroups.first);
}
}
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