Commit 49f873a7 authored by Administrator's avatar Administrator

persisting athlete, todo: create database and table

parent 6e6b0f5e
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/home/stefan/flutter/flutter"
export "FLUTTER_APPLICATION_PATH=/home/stefan/flutter/encrateia"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "FLUTTER_FRAMEWORK_DIR=/home/stefan/flutter/flutter/bin/cache/artifacts/engine/ios"
export "FLUTTER_BUILD_NAME=0.0.1"
export "FLUTTER_BUILD_NUMBER=0.0.1"
import 'package:jaguar_query/jaguar_query.dart';
import 'package:flutter/material.dart';
import 'package:jaguar_orm/jaguar_orm.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:encrateia/utils/database.dart';
part 'athlete.jorm.dart';
......@@ -12,24 +14,22 @@ class Athlete extends Model {
String state = "";
String stravaUsername;
String photoPath;
int stravaId;
Athlete();
Athlete.make(this.id, this.firstName, this.stravaId);
static const String tableName = '_athlete';
String toString() => '$firstName ($id)';
String toString() => '$firstName $lastName ($id)';
void set({firstName, lastName, state, stravaId, stravaUsername, photoPath}) {
this.firstName = firstName;
this.lastName = lastName;
this.state = state;
this.stravaId = stravaId;
this.stravaUsername = stravaUsername;
this.photoPath = photoPath;
this
..firstName = firstName
..lastName = lastName
..state = state
..stravaId = stravaId
..stravaUsername = stravaUsername
..photoPath = photoPath;
notifyListeners();
}
......@@ -47,6 +47,13 @@ class Athlete extends Model {
}
return text;
}
persist() async{
var connection = await Database.connection();
AthleteBean(connection).insert(this);
}
static Athlete of(BuildContext context) => ScopedModel.of<Athlete>(context);
}
@GenBean()
......@@ -54,4 +61,4 @@ class AthleteBean extends Bean<Athlete> with _AthleteBean {
AthleteBean(Adapter _adapter) : super(_adapter);
final String tableName = 'athletes';
}
\ No newline at end of file
}
import 'package:flutter/material.dart';
import 'package:encrateia/models/athlete.dart';
import 'strava/strava_get_user.dart';
import 'package:scoped_model/scoped_model.dart';
class EditAthleteScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
Athlete athlete = Athlete();
return Scaffold(
appBar: AppBar(
title: Text('Create Athlete'),
),
body: ListView(
padding: EdgeInsets.all(20),
children: <Widget>[
ListTile(
title: Text("First Name"),
subtitle: Text(athlete?.firstName ?? "")),
ListTile(
leading: Text("First Name"),
title: Text(athlete?.firstName ?? "")),
ListTile(
title: Text("First Name"),
trailing: Text(athlete?.firstName ?? "")),
// Strava Connection Card
Card(
child: Column(
mainAxisSize: MainAxisSize.min,
appBar: AppBar(
title: Text('Create Athlete'),
),
body: ScopedModel<Athlete>(
model: Athlete(),
child: ScopedModelDescendant<Athlete>(
builder: (context, _, athlete) => ListView(
padding: EdgeInsets.all(20),
children: <Widget>[
ListTile(
leading: Icon(Icons.link_off),
title: Text('Strava Connection'),
subtitle: Text('This athlete is not connected to a '
'Strava User yet'),
leading: Text("First Name"),
title: Text(athlete?.firstName ?? ""),
),
ListTile(
leading: Text("Last Name"),
title: Text(athlete?.lastName ?? ""),
),
ListTile(
leading: Text("Strava ID"),
title: Text(athlete?.stravaId.toString() ?? ""),
),
ButtonTheme.bar(
child: ButtonBar(
ListTile(
leading: Text("Strava Username"),
title: Text(athlete?.stravaUsername ?? ""),
),
// Strava Connection Card
Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
FlatButton(
child: const Text('CONNECT TO STRAVA'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
StravaGetUser(athlete: athlete),
),
);
},
ListTile(
leading: Icon(Icons.link_off),
title: Text('Strava Connection'),
subtitle: Text('This athlete is not connected to a '
'Strava User yet'),
),
ButtonTheme.bar(
child: ButtonBar(
children: <Widget>[
FlatButton(
child: const Text('CONNECT TO STRAVA'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
StravaGetUser(athlete: athlete),
),
);
},
)
],
),
)
],
),
)
],
),
),
// Cancel and Save Card
Padding(
padding: EdgeInsets.all(15),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
RaisedButton(
color: Theme.of(context).primaryColorDark,
textColor: Theme.of(context).primaryColorLight,
child: Text('Cancel', textScaleFactor: 1.5),
onPressed: () {},
),
Container(width: 20.0),
RaisedButton(
color: Theme.of(context).primaryColorDark,
textColor: Theme.of(context).primaryColorLight,
child: Text('Save', textScaleFactor: 1.5),
onPressed: () {},
// Cancel and Save Card
Padding(
padding: EdgeInsets.all(15),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
RaisedButton(
color: Theme.of(context).primaryColorDark,
textColor: Theme.of(context).primaryColorLight,
child: Text('Cancel', textScaleFactor: 1.5),
onPressed: null,
),
Container(width: 20.0),
RaisedButton(
color: Theme.of(context).primaryColorDark,
textColor: Theme.of(context).primaryColorLight,
child: Text('Save', textScaleFactor: 1.5),
onPressed: athlete.persist,
),
],
),
),
],
),
),
],
),
);
));
}
}
......@@ -34,7 +34,7 @@ class StravaGetUser extends StatelessWidget {
Strava strava = Strava(true, secret);
final prompt = 'auto';
final auth = await strava.oauth(
await strava.oauth(
clientId,
'activity:write,activity:read_all,profile:read_all,profile:write',
secret,
......
import 'package:sqflite/sqflite.dart';
import 'package:jaguar_query_sqflite/jaguar_query_sqflite.dart';
class Database {
static connection() async {
SqfliteAdapter adapter = new SqfliteAdapter(await getDatabasesPath());
await adapter.connect();
return adapter;
}
}
# Generated by pub
# See https://www.dartlang.org/tools/pub/glossary#lockfile
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
analyzer:
dependency: transitive
......@@ -28,14 +28,14 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.3.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.0.5"
build:
dependency: transitive
description:
......@@ -311,7 +311,7 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.1.7"
mime:
dependency: transitive
description:
......@@ -339,7 +339,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
version: "1.6.4"
path_provider:
dependency: transitive
description:
......@@ -353,7 +353,7 @@ packages:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
version: "1.8.0+1"
petitparser:
dependency: transitive
description:
......@@ -395,7 +395,7 @@ packages:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.0.5"
scoped_model:
dependency: "direct main"
description:
......@@ -463,7 +463,7 @@ packages:
name: strava_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.11+30"
version: "1.0.11+32"
stream_channel:
dependency: transitive
description:
......@@ -484,7 +484,7 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.0.5"
synchronized:
dependency: transitive
description:
......@@ -505,7 +505,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.4"
version: "0.2.5"
timing:
dependency: transitive
description:
......@@ -563,5 +563,5 @@ packages:
source: hosted
version: "2.1.16"
sdks:
dart: ">=2.2.0 <3.0.0"
dart: ">=2.2.2 <3.0.0"
flutter: ">=1.5.0 <2.0.0"
......@@ -13,7 +13,7 @@ dependencies:
cupertino_icons: ^0.1.2
jaguar_query_sqflite: ^2.2.10
scoped_model: ^1.0.1
strava_flutter: ^1.0.11+30
strava_flutter: ^1.0.11+32
dev_dependencies:
flutter_test:
......
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