Commit 6480ce2a authored by Administrator's avatar Administrator

refactoring

parent 3a1432a2
......@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:encrateia/utils/db.dart';
import 'package:encrateia/model/model.dart';
import 'package:strava_flutter/Models/detailedAthlete.dart';
class Athlete extends Model {
int id;
......@@ -13,16 +14,16 @@ class Athlete extends Model {
int stravaId;
Athlete();
String toString() => '$firstName $lastName ($id)';
String toString() => '$firstName $lastName ($stravaId)';
void set({firstName, lastName, state, stravaId, stravaUsername, photoPath}) {
this
..firstName = firstName
..lastName = lastName
..state = state
..stravaId = stravaId
..stravaUsername = stravaUsername
..photoPath = photoPath;
updateFromStravaAthlete(DetailedAthlete athlete) {
firstName = athlete.firstname;
lastName = athlete.lastname;
state = athlete.state;
stravaId = athlete.id;
stravaUsername = athlete.username;
photoPath = athlete.profile;
state = "unsaved";
notifyListeners();
}
......@@ -36,7 +37,7 @@ class Athlete extends Model {
text = "Strava data loaded successfully.";
break;
default:
text = "Unknown State, should have never come here.";
text = "Unknown state, should have never come here.";
}
return text;
}
......
......@@ -41,13 +41,6 @@ class StravaGetUser extends StatelessWidget {
prompt);
final stravaAthlete = await strava.getLoggedInAthlete();
athlete.set(
firstName: stravaAthlete.firstname,
lastName: stravaAthlete.lastname,
stravaId: stravaAthlete.id,
stravaUsername: stravaAthlete.username,
photoPath: stravaAthlete.profile,
state: "unsaved",
);
athlete.updateFromStravaAthlete(stravaAthlete);
}
}
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