Commit 2c94445a authored by Administrator's avatar Administrator

started with power zone admin

parent f474ccf4
import 'package:flutter/material.dart';
import 'screens/dashboard.dart';
import 'package:encrateia/utils/db.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:io';
import 'package:encrateia/setup.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Db.create().connect();
await createHintFile();
await Setup.init();
runApp(MyApp());
}
......@@ -23,17 +19,3 @@ class MyApp extends StatelessWidget {
);
}
}
createHintFile() async {
if (Platform.isAndroid) {
var directories = await getExternalStorageDirectories();
var hintFile = File('${directories[0].path}/put_your_fit_files_here.txt');
await hintFile.writeAsString(
'This is the directory where Encrateia can pickup .fit-files from.');
} else {
var directory = await getApplicationDocumentsDirectory();
var hintFile = File('${directory.path}/put_your_fit_files_here.txt');
await hintFile.writeAsString(
'This is the directory where Encrateia can pickup .fit-files from.');
}
}
import 'package:flutter/material.dart';
import 'package:encrateia/model/model.dart';
import 'package:encrateia/models/power_zone_schema.dart';
class PowerZone extends ChangeNotifier {
DbPowerZone db;
PowerZone(
{PowerZoneSchema powerZoneSchema,
String name,
int lowerPercentage,
int upperPercentage,
int lowerLimit,
int upperLimit}) {
db = DbPowerZone()
..powerZoneSchemataId = powerZoneSchema.db.id
..lowerLimit = lowerLimit ?? 0
..upperLimit = upperLimit ?? 0
..lowerPercentage = lowerPercentage ?? 0
..upperPercentage = upperPercentage ?? 0;
if (lowerPercentage != null)
db.lowerLimit = (lowerPercentage * powerZoneSchema.db.base / 100).round();
if (upperPercentage != null)
db.upperLimit = (upperPercentage * powerZoneSchema.db.base / 100).round();
}
PowerZone.fromDb(this.db);
String toString() => '$db.date $db.name';
delete() async {
await this.db.delete();
}
static Future<List<PowerZone>> all(
{@required PowerZoneSchema powerZoneSchema}) async {
var dbPowerZoneList = await powerZoneSchema.db
.getDbPowerZones()
.orderByDesc('lowerlimit')
.toList();
var powerZones = dbPowerZoneList
.map((dbPowerZone) => PowerZone.fromDb(dbPowerZone))
.toList();
return powerZones;
}
}
import 'package:encrateia/models/power_zone.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/model/model.dart';
import 'package:encrateia/models/athlete.dart';
class PowerZoneSchema extends ChangeNotifier {
DbPowerZoneSchema db;
PowerZoneSchema() {
db = DbPowerZoneSchema();
}
PowerZoneSchema.fromDb(this.db);
PowerZoneSchema.likeStryd({Athlete athlete}) {
db = DbPowerZoneSchema()
..athletesId = athlete.db.id
..name = "like Stryd"
..date = DateTime(1970, 01, 01)
..base = 250;
}
addStrydZones() async {
await PowerZone(
powerZoneSchema: this,
name: "Easy",
lowerPercentage: 65,
upperPercentage: 80,
).db.save();
await PowerZone(
powerZoneSchema: this,
name: "Moderate",
lowerPercentage: 80,
upperPercentage: 90,
).db.save();
await PowerZone(
powerZoneSchema: this,
name: "Threshold",
lowerPercentage: 90,
upperPercentage: 100,
).db.save();
await PowerZone(
powerZoneSchema: this,
name: "Interval",
lowerPercentage: 100,
upperPercentage: 115,
).db.save();
await PowerZone(
powerZoneSchema: this,
name: "Repetition",
lowerPercentage: 115,
upperPercentage: 130,
).db.save();
}
// https://www.velopress.com/jim-vances-running-power-zones/
PowerZoneSchema.likeJimVance({Athlete athlete}) {
db = DbPowerZoneSchema()
..athletesId = athlete.db.id
..name = "like Jim Vance"
..date = DateTime(1970, 01, 01)
..base = 250;
}
addJimVanceZones() async {
await PowerZone(
powerZoneSchema: this,
name: "Walking",
lowerPercentage: 0,
upperPercentage: 81,
).db.save();
await PowerZone(
powerZoneSchema: this,
name: "Endurance",
lowerPercentage: 81,
upperPercentage: 88,
).db.save();
await PowerZone(
powerZoneSchema: this,
name: "Tempo",
lowerPercentage: 88,
upperPercentage: 95,
).db.save();
await PowerZone(
powerZoneSchema: this,
name: "Threshold",
lowerPercentage: 95,
upperPercentage: 105,
).db.save();
await PowerZone(
powerZoneSchema: this,
name: "High Intensity",
lowerPercentage: 105,
upperPercentage: 115,
).db.save();
await PowerZone(
powerZoneSchema: this,
name: "VO2",
lowerPercentage: 115,
upperPercentage: 128,
).db.save();
await PowerZone(
powerZoneSchema: this,
name: "Peak",
lowerPercentage: 128,
upperPercentage: 150,
).db.save();
}
PowerZoneSchema.likeStefanDillinger({Athlete athlete}) {
db = DbPowerZoneSchema()
..athletesId = athlete.db.id
..name = "like Stefan Dillinger"
..date = DateTime(1970, 01, 01)
..base = 250;
}
addStefanDillingerZones() async {
await PowerZone(
powerZoneSchema: this,
name: "GA1",
lowerPercentage: 70,
upperPercentage: 80,
).db.save();
await PowerZone(
powerZoneSchema: this,
name: "GA2",
lowerPercentage: 80,
upperPercentage: 90,
).db.save();
await PowerZone(
powerZoneSchema: this,
name: "SL",
lowerPercentage: 90,
upperPercentage: 100,
).db.save();
await PowerZone(
powerZoneSchema: this,
name: "Int",
lowerPercentage: 100,
upperPercentage: 110,
).db.save();
await PowerZone(
powerZoneSchema: this,
name: "FSB",
lowerPercentage: 110,
upperPercentage: 120,
).db.save();
await PowerZone(
powerZoneSchema: this,
name: "MRT",
lowerPercentage: 85,
upperPercentage: 90,
).db.save();
await PowerZone(
powerZoneSchema: this,
name: "HMRT",
lowerPercentage: 90,
upperPercentage: 98,
).db.save();
}
String toString() => '$db.date $db.name';
delete() async {
await this.db.delete();
}
static Future<List<PowerZoneSchema>> all({@required Athlete athlete}) async {
var dbPowerZoneSchemaList =
await athlete.db.getDbPowerZoneSchemas().orderByDesc('date').toList();
var powerZoneSchemas = dbPowerZoneSchemaList
.map((dbPowerZoneSchema) => PowerZoneSchema.fromDb(dbPowerZoneSchema))
.toList();
return powerZoneSchemas;
}
}
import 'package:flutter/material.dart';
import 'package:encrateia/utils/db.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:io';
class Setup {
static init() async {
WidgetsFlutterBinding.ensureInitialized();
await Db.create().connect();
await createHintFile();
}
static createHintFile() async {
if (Platform.isAndroid) {
var directories = await getExternalStorageDirectories();
var hintFile = File('${directories[0].path}/put_your_fit_files_here.txt');
await hintFile.writeAsString(
'This is the directory where Encrateia can pickup .fit-files from.');
} else {
var directory = await getApplicationDocumentsDirectory();
var hintFile = File('${directory.path}/put_your_fit_files_here.txt');
await hintFile.writeAsString(
'This is the directory where Encrateia can pickup .fit-files from.');
}
}
}
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