Commit bc80c855 authored by Administrator's avatar Administrator

EditAthleteScreen as scoped model from Athlete

parent 042d9d9f
import 'package:flutter/material.dart';
import 'screens/edit_athlete.dart';
void main() => runApp(MyApp());
......@@ -25,28 +26,26 @@ class Dashboard extends StatelessWidget {
Widget build(BuildContext context) {
if (true) {
widget = ListView(padding: EdgeInsets.all(20), children: <Widget>[
Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ListTile(
leading: Icon(Icons.help),
title: Text('Welcome to Encrateia!'),
subtitle: Text('Maybe you want to learn more about Encrateia.'
'We have provided some introductory help for you.')
),
ButtonTheme.bar(
child: ButtonBar(
children: <Widget>[
FlatButton(
child: const Text('HELP'),
onPressed: () {},
)
],
))
],
)),
Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ListTile(
leading: Icon(Icons.help),
title: Text('Welcome to Encrateia!'),
subtitle: Text('Maybe you want to learn more about Encrateia.'
'We have provided some introductory help for you.')),
ButtonTheme.bar(
child: ButtonBar(
children: <Widget>[
FlatButton(
child: const Text('HELP'),
onPressed: () {},
)
],
))
],
)),
Card(
child: Column(
mainAxisSize: MainAxisSize.min,
......@@ -62,7 +61,13 @@ class Dashboard extends StatelessWidget {
children: <Widget>[
FlatButton(
child: const Text('CREATE NEW ATHLETE'),
onPressed: () {},
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => EditAthleteScreen()),
);
},
)
],
))
......
import 'package:jaguar_query/jaguar_query.dart';
import 'package:jaguar_orm/jaguar_orm.dart';
import 'package:scoped_model/scoped_model.dart';
part 'athlete.jorm.dart';
class Athlete {
class Athlete extends Model {
@PrimaryKey()
String id;
String name;
......
import 'package:flutter/material.dart';
import 'package:encrateia/models/athlete.dart';
import 'package:scoped_model/scoped_model.dart';
class EditAthleteScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () {
Navigator.pop(context, true);
},
child: Scaffold(
appBar: AppBar(
title: Text('Create Athlete'),
),
body: ScopedModel<Athlete>(
model: new Athlete(),
child: new ScopedModelDescendant<Athlete>(
builder: (context, child, athlete) =>
new ListView(padding: EdgeInsets.all(20), children: <
Widget>[
TextField(
onChanged: (value) => athlete.name = value,
decoration: InputDecoration(labelText: 'Name')),
// Strava Connection
Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
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: () {},
)
],
))
],
)),
// Cancel and Save
Padding(
padding: EdgeInsets.only(top: 15.0, bottom: 15.0),
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: () {},
),
],
)),
])))));
}
}
......@@ -389,6 +389,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
scoped_model:
dependency: "direct main"
description:
name: scoped_model
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
shelf:
dependency: transitive
description:
......
......@@ -12,6 +12,7 @@ dependencies:
flutter_launcher_icons: ^0.7.2
cupertino_icons: ^0.1.2
jaguar_query_sqflite: ^2.2.10
scoped_model: ^1.0.1
dev_dependencies:
......
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