officially getting data from the dbgit add . -p!
This commit is contained in:
parent
b2e2eb67b0
commit
8fe60e7ae3
@ -46,7 +46,7 @@ class _AppState extends State<App> {
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 50, 0, 0),
|
||||
child: <Widget>[
|
||||
const SessionsScreen(),
|
||||
SessionsScreen(),
|
||||
const ActivitiesScreen(),
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
@ -92,14 +92,44 @@ class _AppState extends State<App> {
|
||||
}
|
||||
|
||||
void main() {
|
||||
final database = AppDatabase();
|
||||
// final database = AppDatabase();
|
||||
|
||||
// database.into(database.sessions).insert(SessionsCompanion.insert(
|
||||
// title: 'test session title',
|
||||
// content: 'test session content description',
|
||||
// status: SessionStatus.started,
|
||||
// date: Value(DateTime.now())));
|
||||
|
||||
// database.into(database.sessions).insert(SessionsCompanion.insert(
|
||||
// title: 'test session title 2',
|
||||
// content: 'test session content description 2',
|
||||
// status: SessionStatus.pending,
|
||||
// date: Value(DateTime.now())));
|
||||
|
||||
// database.into(database.sessions).insert(SessionsCompanion.insert(
|
||||
// title: 'test session title 3',
|
||||
// content: 'test session content description 3',
|
||||
// status: SessionStatus.completed,
|
||||
// date: Value(DateTime.now())));
|
||||
|
||||
// database.into(database.sessions).insert(SessionsCompanion.insert(
|
||||
// title: 'test session title 4',
|
||||
// content: 'test session content description 4',
|
||||
// status: SessionStatus.completed,
|
||||
// date: Value(DateTime.now())));
|
||||
|
||||
// database.into(database.sessions).insert(SessionsCompanion.insert(
|
||||
// title: 'test session title 5',
|
||||
// content: 'test session content description 5',
|
||||
// status: SessionStatus.missed,
|
||||
// date: Value(DateTime.now())));
|
||||
|
||||
// database.into(database.sessions).insert(SessionsCompanion.insert(
|
||||
// title: 'test session title 6',
|
||||
// content: 'test session content description 6',
|
||||
// status: SessionStatus.completed,
|
||||
// date: Value(DateTime.now())));
|
||||
|
||||
// database.into(database.activities).insert(ActivitiesCompanion.insert(
|
||||
// title: "test activity",
|
||||
// type: ActivityType.technical,
|
||||
|
@ -1,52 +1,113 @@
|
||||
import 'package:drift/drift.dart' hide Column;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sendtrain/database.dart';
|
||||
import '../widgets/session_card.dart';
|
||||
|
||||
class SessionsScreen extends StatelessWidget {
|
||||
const SessionsScreen({super.key});
|
||||
final AppDatabase database = AppDatabase();
|
||||
SessionsScreen({super.key});
|
||||
|
||||
Future<List<Session>> getSessions() async {
|
||||
// database.managers.sessions.filter((session) => session.status(SessionStatus.pending));
|
||||
return await database.managers.sessions.get();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> previousSessions =
|
||||
List.generate(10, (i) => const SessionCard(state: 1, type: 1));
|
||||
Widget upcomingSession = const SessionCard(state: 2);
|
||||
Widget currentSession = const SessionCard();
|
||||
return FutureBuilder<List<Session>>(
|
||||
future: getSessions(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
final sessions = snapshot.data!;
|
||||
final pending = sessions.where((session) => session.status == SessionStatus.completed || session.status == SessionStatus.missed);
|
||||
final upcoming = sessions.firstWhere((session) => session.status == SessionStatus.pending);
|
||||
final current = sessions.firstWhere((session) => session.status == SessionStatus.started);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(15, 5, 0, 0),
|
||||
child: Text(
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
'Current:')),
|
||||
currentSession,
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(15, 30, 0, 0),
|
||||
child: Text(
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
'Upcoming:')),
|
||||
upcomingSession,
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(15, 30, 0, 0),
|
||||
child: Text(
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
'Previous:')),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 160,
|
||||
child: GridView.count(
|
||||
padding: const EdgeInsets.fromLTRB(15, 10, 0, 0),
|
||||
scrollDirection: Axis.horizontal,
|
||||
crossAxisSpacing: 5,
|
||||
mainAxisSpacing: 5,
|
||||
crossAxisCount: 1,
|
||||
children: previousSessions))
|
||||
// Flexible(
|
||||
// child: ListView(
|
||||
// scrollDirection: Axis.vertical,
|
||||
// children: previousSessions,
|
||||
// )),
|
||||
],
|
||||
);
|
||||
List<Widget> previousSessions = List.generate(pending.length, (i) => SessionCard(type: 1, session: pending.elementAt(i)));
|
||||
Widget upcomingSession =
|
||||
SessionCard(session: upcoming);
|
||||
Widget currentSession = SessionCard(session: current);
|
||||
|
||||
database.close();
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(15, 5, 0, 0),
|
||||
child: Text(
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
'Current:')),
|
||||
currentSession,
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(15, 30, 0, 0),
|
||||
child: Text(
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
'Upcoming:')),
|
||||
upcomingSession,
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(15, 30, 0, 0),
|
||||
child: Text(
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
'Previous:')),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 160,
|
||||
child: GridView.count(
|
||||
padding: const EdgeInsets.fromLTRB(15, 10, 0, 0),
|
||||
scrollDirection: Axis.horizontal,
|
||||
crossAxisSpacing: 5,
|
||||
mainAxisSpacing: 5,
|
||||
crossAxisCount: 1,
|
||||
children: previousSessions))
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return const CircularProgressIndicator();
|
||||
}
|
||||
});
|
||||
|
||||
// List<Widget> previousSessions = List.generate(
|
||||
// 10, (i) => SessionCard(state: 1, type: 1, session: _sessions.first));
|
||||
// Widget upcomingSession = SessionCard(state: 2, session: _sessions.first);
|
||||
// Widget currentSession = SessionCard(session: _sessions.first);
|
||||
|
||||
// return Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: <Widget>[
|
||||
// const Padding(
|
||||
// padding: EdgeInsets.fromLTRB(15, 5, 0, 0),
|
||||
// child: Text(
|
||||
// style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
// 'Current:')),
|
||||
// currentSession,
|
||||
// const Padding(
|
||||
// padding: EdgeInsets.fromLTRB(15, 30, 0, 0),
|
||||
// child: Text(
|
||||
// style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
// 'Upcoming:')),
|
||||
// upcomingSession,
|
||||
// const Padding(
|
||||
// padding: EdgeInsets.fromLTRB(15, 30, 0, 0),
|
||||
// child: Text(
|
||||
// style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
// 'Previous:')),
|
||||
// SizedBox(
|
||||
// width: double.infinity,
|
||||
// height: 160,
|
||||
// child: GridView.count(
|
||||
// padding: const EdgeInsets.fromLTRB(15, 10, 0, 0),
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// crossAxisSpacing: 5,
|
||||
// mainAxisSpacing: 5,
|
||||
// crossAxisCount: 1,
|
||||
// children: previousSessions))
|
||||
// // Flexible(
|
||||
// // child: ListView(
|
||||
// // scrollDirection: Axis.vertical,
|
||||
// // children: previousSessions,
|
||||
// // )),
|
||||
// ],
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
@ -3,30 +3,31 @@ import 'package:intl/intl.dart';
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
import 'package:sendtrain/classes/activity_action.dart';
|
||||
import 'package:sendtrain/classes/media.dart';
|
||||
import 'package:sendtrain/database.dart' hide ActivityAction;
|
||||
import 'package:sendtrain/models/activity_model.dart';
|
||||
import 'package:sendtrain/models/session_model.dart';
|
||||
import 'package:sendtrain/widgets/session_view.dart';
|
||||
|
||||
class SessionCard extends StatelessWidget {
|
||||
final int state;
|
||||
final int type;
|
||||
const SessionCard({super.key, this.state = 0, this.type = 0});
|
||||
final Session session;
|
||||
const SessionCard({super.key, this.type = 0, required this.session});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
initializeDateFormatting('en');
|
||||
final DateFormat dateFormat = DateFormat('yyyy-MM-dd');
|
||||
|
||||
Color color = (state == 0)
|
||||
Color color = (session.status == SessionStatus.started)
|
||||
? Theme.of(context).colorScheme.primaryContainer
|
||||
: Theme.of(context).colorScheme.surfaceContainerLow;
|
||||
|
||||
// place holder until we can retrieve real data
|
||||
final data = SessionModel(
|
||||
id: 1,
|
||||
title: "Projecting @ Climbers Rock",
|
||||
title: "Projecting @ Climbers Rock - ${session.title}",
|
||||
content:
|
||||
"Beta pully beta beta pinch one arm crimpy. Futuristic pinch, dyno dynamic drop knee climb. Climbing ondra slopey onsight beta ondra power endurance.",
|
||||
"${session.content} - Beta pully beta beta pinch one arm crimpy. Futuristic pinch, dyno dynamic drop knee climb. Climbing ondra slopey onsight beta ondra power endurance.",
|
||||
date: DateTime.now(),
|
||||
activities: [
|
||||
ActivityModel(
|
||||
@ -40,7 +41,8 @@ class SessionCard extends StatelessWidget {
|
||||
ActivityAction(
|
||||
id: 1,
|
||||
title: '1, 3, 5',
|
||||
description: 'Move between the first, third, and fifth rungs, alternating hands. Rest and alternate sides, to start',
|
||||
description:
|
||||
'Move between the first, third, and fifth rungs, alternating hands. Rest and alternate sides, to start',
|
||||
media: [
|
||||
Media(
|
||||
id: 1,
|
||||
@ -77,7 +79,8 @@ class SessionCard extends StatelessWidget {
|
||||
ActivityAction(
|
||||
id: 1,
|
||||
title: 'Attempt Climb',
|
||||
description: 'Attempt your selected climb, if you fall off early in the climb, attempt again. 1 repitition equals roughly doing all the moves, not necessarily in 1 attempt.',
|
||||
description:
|
||||
'Attempt your selected climb, if you fall off early in the climb, attempt again. 1 repitition equals roughly doing all the moves, not necessarily in 1 attempt.',
|
||||
media: [
|
||||
Media(
|
||||
id: 1,
|
||||
@ -114,7 +117,8 @@ class SessionCard extends StatelessWidget {
|
||||
ActivityAction(
|
||||
id: 1,
|
||||
title: 'Long Pulls',
|
||||
description: 'Select your desired weight to pull, add it to the block. You should aim for an effort level of 8-9 when reaching the end of the set time, going to failure will result in significantly extended recovery time.',
|
||||
description:
|
||||
'Select your desired weight to pull, add it to the block. You should aim for an effort level of 8-9 when reaching the end of the set time, going to failure will result in significantly extended recovery time.',
|
||||
media: [
|
||||
Media(
|
||||
id: 1,
|
||||
@ -126,7 +130,8 @@ class SessionCard extends StatelessWidget {
|
||||
id: 1,
|
||||
reference: 'sZVAEy9UmoY',
|
||||
type: 'youtube',
|
||||
description: 'Principals of Grip gains, and related protocols')
|
||||
description:
|
||||
'Principals of Grip gains, and related protocols')
|
||||
],
|
||||
activityActionSet: Set(
|
||||
type: 'alternating',
|
||||
@ -212,8 +217,8 @@ class SessionCard extends StatelessWidget {
|
||||
BorderRadius.all(Radius.elliptical(10, 10)),
|
||||
),
|
||||
)),
|
||||
title: Text(maxLines: 1, data.title),
|
||||
subtitle: Text(maxLines: 1, dateFormat.format(data.date)),
|
||||
title: Text(maxLines: 1, session.title),
|
||||
subtitle: Text(maxLines: 1, dateFormat.format(session.date as DateTime)),
|
||||
trailing: IconButton(
|
||||
visualDensity: VisualDensity.compact,
|
||||
icon: Icon(Icons.close_rounded),
|
||||
@ -222,7 +227,8 @@ class SessionCard extends StatelessWidget {
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Session Removal'),
|
||||
content: const Text('Would you like to permanently remove this session?'),
|
||||
content: const Text(
|
||||
'Would you like to permanently remove this session?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, 'Cancel'),
|
||||
@ -244,7 +250,7 @@ class SessionCard extends StatelessWidget {
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontWeight: FontWeight.w300),
|
||||
data.content),
|
||||
session.content),
|
||||
),
|
||||
],
|
||||
)),
|
||||
@ -297,11 +303,11 @@ class SessionCard extends StatelessWidget {
|
||||
ListTile(
|
||||
title: Text(
|
||||
maxLines: 3,
|
||||
data.title,
|
||||
session.title,
|
||||
textAlign: TextAlign.center),
|
||||
subtitle: Text(
|
||||
maxLines: 1,
|
||||
dateFormat.format(data.date),
|
||||
dateFormat.format(session.date as DateTime),
|
||||
textAlign: TextAlign.center),
|
||||
),
|
||||
])))));
|
||||
|
Loading…
x
Reference in New Issue
Block a user