Commit 48e4d8c2 authored by Administrator's avatar Administrator

copy data into athlete

parent ea388f44
import 'package:flutter/material.dart';
import 'package:encrateia/models/athlete.dart';
import 'package:scoped_model/scoped_model.dart';
import 'strava/strava_login.dart';
import 'strava/strava_get_user.dart';
class EditAthleteScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
Athlete athlete = Athlete();
return WillPopScope(
onWillPop: () {
Navigator.pop(context, true);
......@@ -15,10 +16,10 @@ class EditAthleteScreen extends StatelessWidget {
title: Text('Create Athlete'),
),
body: ScopedModel<Athlete>(
model: new Athlete(),
child: new ScopedModelDescendant<Athlete>(
model: athlete,
child: ScopedModelDescendant<Athlete>(
builder: (context, child, athlete) =>
new ListView(padding: EdgeInsets.all(20), children: <
ListView(padding: EdgeInsets.all(20), children: <
Widget>[
TextField(
onChanged: (value) => athlete.firstName = value,
......@@ -44,7 +45,7 @@ class EditAthleteScreen extends StatelessWidget {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => StravaLogin()),
builder: (context) => StravaGetUser(athlete)),
);
},
)
......
import 'package:flutter/material.dart';
import 'package:encrateia/secrets/secrets.dart';
import 'package:strava_flutter/strava.dart';
import 'package:strava_flutter/Models/detailedAthlete.dart';
import 'package:strava_flutter/Models/activity.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:encrateia/models/athlete.dart';
class StravaLogin extends StatefulWidget {
class StravaGetUser extends StatefulWidget {
final String title = "Strava Login";
Athlete athlete;
StravaLogin() {}
StravaGetUser(this.athlete) {}
@override
_StravaLoginState createState() => _StravaLoginState();
_StravaGetUserState createState() => _StravaGetUserState();
}
class _StravaLoginState extends State<StravaLogin> {
bool isAuthOk = false;
class _StravaGetUserState extends State<StravaGetUser> {
Strava strava;
DetailedAthlete athlete;
List<SummaryActivity> activities;
@override
void initState() {
......@@ -27,19 +25,17 @@ class _StravaLoginState extends State<StravaLogin> {
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () {
Navigator.pop(context, true);
},
child: Scaffold(
appBar: AppBar(title: Text('Create Athlete')),
body: Container(child:
Text("isAuthOk ${isAuthOk} \n"
"stravaAthlete ${athlete?.firstname} \n"
"activities ${activities?.length}"))
)
);
appBar: AppBar(title: Text('Create Athlete')),
body: ScopedModelDescendant<Athlete>(
builder: (context, child, model) {
widget.athlete = model;
Container(child: Text("Athlete ${widget.athlete.firstName}"));
})));
}
loginToStrava() async {
......@@ -53,16 +49,9 @@ class _StravaLoginState extends State<StravaLogin> {
prompt);
print(auth);
final stravaAthlete = await strava.getLoggedInAthlete();
// final now = DateTime.now().microsecondsSinceEpoch ~/ 1000 ;
// final yesterday = now - 1550;
// final stravaActivities = await strava.getLoggedInAthleteActivities(
// now,
// yesterday
// );
setState(() {
isAuthOk = auth;
athlete = stravaAthlete;
widget.athlete.firstName = stravaAthlete.firstname;
});
}
}
\ No newline at end of file
}
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