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(
|
body: Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(0, 50, 0, 0),
|
padding: const EdgeInsets.fromLTRB(0, 50, 0, 0),
|
||||||
child: <Widget>[
|
child: <Widget>[
|
||||||
const SessionsScreen(),
|
SessionsScreen(),
|
||||||
const ActivitiesScreen(),
|
const ActivitiesScreen(),
|
||||||
Container(
|
Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
@ -92,14 +92,44 @@ class _AppState extends State<App> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
final database = AppDatabase();
|
// final database = AppDatabase();
|
||||||
|
|
||||||
// database.into(database.sessions).insert(SessionsCompanion.insert(
|
// database.into(database.sessions).insert(SessionsCompanion.insert(
|
||||||
// title: 'test session title',
|
// title: 'test session title',
|
||||||
// content: 'test session content description',
|
// 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,
|
// status: SessionStatus.pending,
|
||||||
// date: Value(DateTime.now())));
|
// 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(
|
// database.into(database.activities).insert(ActivitiesCompanion.insert(
|
||||||
// title: "test activity",
|
// title: "test activity",
|
||||||
// type: ActivityType.technical,
|
// type: ActivityType.technical,
|
||||||
|
@ -1,15 +1,34 @@
|
|||||||
|
import 'package:drift/drift.dart' hide Column;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:sendtrain/database.dart';
|
||||||
import '../widgets/session_card.dart';
|
import '../widgets/session_card.dart';
|
||||||
|
|
||||||
class SessionsScreen extends StatelessWidget {
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
List<Widget> previousSessions =
|
return FutureBuilder<List<Session>>(
|
||||||
List.generate(10, (i) => const SessionCard(state: 1, type: 1));
|
future: getSessions(),
|
||||||
Widget upcomingSession = const SessionCard(state: 2);
|
builder: (context, snapshot) {
|
||||||
Widget currentSession = const SessionCard();
|
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);
|
||||||
|
|
||||||
|
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(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -41,12 +60,54 @@ class SessionsScreen extends StatelessWidget {
|
|||||||
mainAxisSpacing: 5,
|
mainAxisSpacing: 5,
|
||||||
crossAxisCount: 1,
|
crossAxisCount: 1,
|
||||||
children: previousSessions))
|
children: previousSessions))
|
||||||
// Flexible(
|
|
||||||
// child: ListView(
|
|
||||||
// scrollDirection: Axis.vertical,
|
|
||||||
// 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:intl/date_symbol_data_local.dart';
|
||||||
import 'package:sendtrain/classes/activity_action.dart';
|
import 'package:sendtrain/classes/activity_action.dart';
|
||||||
import 'package:sendtrain/classes/media.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/activity_model.dart';
|
||||||
import 'package:sendtrain/models/session_model.dart';
|
import 'package:sendtrain/models/session_model.dart';
|
||||||
import 'package:sendtrain/widgets/session_view.dart';
|
import 'package:sendtrain/widgets/session_view.dart';
|
||||||
|
|
||||||
class SessionCard extends StatelessWidget {
|
class SessionCard extends StatelessWidget {
|
||||||
final int state;
|
|
||||||
final int type;
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
initializeDateFormatting('en');
|
initializeDateFormatting('en');
|
||||||
final DateFormat dateFormat = DateFormat('yyyy-MM-dd');
|
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.primaryContainer
|
||||||
: Theme.of(context).colorScheme.surfaceContainerLow;
|
: Theme.of(context).colorScheme.surfaceContainerLow;
|
||||||
|
|
||||||
// place holder until we can retrieve real data
|
// place holder until we can retrieve real data
|
||||||
final data = SessionModel(
|
final data = SessionModel(
|
||||||
id: 1,
|
id: 1,
|
||||||
title: "Projecting @ Climbers Rock",
|
title: "Projecting @ Climbers Rock - ${session.title}",
|
||||||
content:
|
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(),
|
date: DateTime.now(),
|
||||||
activities: [
|
activities: [
|
||||||
ActivityModel(
|
ActivityModel(
|
||||||
@ -40,7 +41,8 @@ class SessionCard extends StatelessWidget {
|
|||||||
ActivityAction(
|
ActivityAction(
|
||||||
id: 1,
|
id: 1,
|
||||||
title: '1, 3, 5',
|
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: [
|
||||||
Media(
|
Media(
|
||||||
id: 1,
|
id: 1,
|
||||||
@ -77,7 +79,8 @@ class SessionCard extends StatelessWidget {
|
|||||||
ActivityAction(
|
ActivityAction(
|
||||||
id: 1,
|
id: 1,
|
||||||
title: 'Attempt Climb',
|
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: [
|
||||||
Media(
|
Media(
|
||||||
id: 1,
|
id: 1,
|
||||||
@ -114,7 +117,8 @@ class SessionCard extends StatelessWidget {
|
|||||||
ActivityAction(
|
ActivityAction(
|
||||||
id: 1,
|
id: 1,
|
||||||
title: 'Long Pulls',
|
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: [
|
||||||
Media(
|
Media(
|
||||||
id: 1,
|
id: 1,
|
||||||
@ -126,7 +130,8 @@ class SessionCard extends StatelessWidget {
|
|||||||
id: 1,
|
id: 1,
|
||||||
reference: 'sZVAEy9UmoY',
|
reference: 'sZVAEy9UmoY',
|
||||||
type: 'youtube',
|
type: 'youtube',
|
||||||
description: 'Principals of Grip gains, and related protocols')
|
description:
|
||||||
|
'Principals of Grip gains, and related protocols')
|
||||||
],
|
],
|
||||||
activityActionSet: Set(
|
activityActionSet: Set(
|
||||||
type: 'alternating',
|
type: 'alternating',
|
||||||
@ -212,8 +217,8 @@ class SessionCard extends StatelessWidget {
|
|||||||
BorderRadius.all(Radius.elliptical(10, 10)),
|
BorderRadius.all(Radius.elliptical(10, 10)),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
title: Text(maxLines: 1, data.title),
|
title: Text(maxLines: 1, session.title),
|
||||||
subtitle: Text(maxLines: 1, dateFormat.format(data.date)),
|
subtitle: Text(maxLines: 1, dateFormat.format(session.date as DateTime)),
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
visualDensity: VisualDensity.compact,
|
visualDensity: VisualDensity.compact,
|
||||||
icon: Icon(Icons.close_rounded),
|
icon: Icon(Icons.close_rounded),
|
||||||
@ -222,7 +227,8 @@ class SessionCard extends StatelessWidget {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) => AlertDialog(
|
builder: (BuildContext context) => AlertDialog(
|
||||||
title: const Text('Session Removal'),
|
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>[
|
actions: <Widget>[
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.pop(context, 'Cancel'),
|
onPressed: () => Navigator.pop(context, 'Cancel'),
|
||||||
@ -244,7 +250,7 @@ class SessionCard extends StatelessWidget {
|
|||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: const TextStyle(fontWeight: FontWeight.w300),
|
style: const TextStyle(fontWeight: FontWeight.w300),
|
||||||
data.content),
|
session.content),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
@ -297,11 +303,11 @@ class SessionCard extends StatelessWidget {
|
|||||||
ListTile(
|
ListTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
maxLines: 3,
|
maxLines: 3,
|
||||||
data.title,
|
session.title,
|
||||||
textAlign: TextAlign.center),
|
textAlign: TextAlign.center),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
dateFormat.format(data.date),
|
dateFormat.format(session.date as DateTime),
|
||||||
textAlign: TextAlign.center),
|
textAlign: TextAlign.center),
|
||||||
),
|
),
|
||||||
])))));
|
])))));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user