318 lines
14 KiB
Dart
318 lines
14 KiB
Dart
import 'package:flutter/material.dart';
|
|
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/database.dart' hide ActivityAction;
|
|
import 'package:sendtrain/extensions/string_extensions.dart';
|
|
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 type;
|
|
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 = (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",
|
|
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(
|
|
id: 1,
|
|
title: 'Campus Board',
|
|
type: 'fundamental',
|
|
categories: ['strength', 'power'],
|
|
description:
|
|
"Campus board session, focusing on explosiveness and contact strength.",
|
|
actions: [
|
|
ActivityAction(
|
|
id: 1,
|
|
title: '1, 3, 5',
|
|
description:
|
|
'Move between the first, third, and fifth rungs, alternating hands. Rest and alternate sides, to start',
|
|
media: [
|
|
Media(
|
|
id: 1,
|
|
reference:
|
|
'https://www.climbing.com/wp-content/uploads/2022/06/campus-board-e1655470701154.jpeg',
|
|
type: 'image',
|
|
description: 'Campus board movement'),
|
|
Media(
|
|
id: 1,
|
|
reference: '7ACyeOP-Hxo',
|
|
type: 'youtube',
|
|
description: 'How to campus board')
|
|
],
|
|
activityActionSet: Set(
|
|
type: 'drop_set',
|
|
total: 3,
|
|
rest: 300000,
|
|
reps: Reps(
|
|
type: 'repititions',
|
|
tempo: [0],
|
|
amounts: [1, 1, 1],
|
|
weights: [0],
|
|
rest: 20000))),
|
|
],
|
|
resources: ['https://www.youtube.com/watch?v=bLz0xp1PEm4']),
|
|
ActivityModel(
|
|
id: 2,
|
|
title: 'Projecting',
|
|
type: 'fundamental',
|
|
categories: ['technique', 'conditioning'],
|
|
description:
|
|
"Session focused on attempting a climb at or beyond your perceived limit.",
|
|
actions: [
|
|
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.',
|
|
media: [
|
|
Media(
|
|
id: 1,
|
|
reference:
|
|
'https://www.climbing.com/wp-content/uploads/2022/07/Fixed-44.jpg',
|
|
type: 'image',
|
|
description: 'Projecting a climb'),
|
|
Media(
|
|
id: 1,
|
|
reference: 'BgheYcxhrsw',
|
|
type: 'youtube',
|
|
description: 'How to project climbs')
|
|
],
|
|
activityActionSet: Set(
|
|
type: 'standard',
|
|
total: 10,
|
|
rest: 300000,
|
|
reps: Reps(
|
|
type: 'repititions',
|
|
tempo: [0],
|
|
amounts: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
|
weights: [0],
|
|
rest: 0))),
|
|
],
|
|
resources: ['https://www.youtube.com/watch?v=dyAvbUvY_PU']),
|
|
ActivityModel(
|
|
id: 3,
|
|
title: 'Long Block Pulls',
|
|
type: 'Hypertrophy',
|
|
categories: ['Strength', 'Power'],
|
|
description:
|
|
"Block pull on a edge of a specific size and time to induce a hypertrophic effect on the formarms.",
|
|
actions: [
|
|
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.',
|
|
media: [
|
|
Media(
|
|
id: 1,
|
|
reference:
|
|
'https://trailandcrag.com/sites/default/files/inline-images/05-min_3.jpg',
|
|
type: 'image',
|
|
description: 'Block pull example'),
|
|
Media(
|
|
id: 1,
|
|
reference: 'sZVAEy9UmoY',
|
|
type: 'youtube',
|
|
description:
|
|
'Principals of Grip gains, and related protocols')
|
|
],
|
|
activityActionSet: Set(
|
|
type: 'alternating',
|
|
total: 5,
|
|
rest: 5000,
|
|
reps: Reps(
|
|
type: 'seconds',
|
|
tempo: [0],
|
|
amounts: [5, 5, 5, 5, 5],
|
|
weights: [80, 80, 80, 80, 80],
|
|
rest: 5000))),
|
|
],
|
|
resources: ['https://www.youtube.com/watch?v=dyAvbUvY_PU']),
|
|
],
|
|
achievements: [
|
|
'got 1 3 5 first time!',
|
|
'no pain in elbow',
|
|
'life is pain',
|
|
'new PR for pullups'
|
|
],
|
|
media: [
|
|
Media(
|
|
id: 1,
|
|
reference: 'TwS8ycTY5cc',
|
|
type: 'youtube',
|
|
description: 'Attempting crux move'),
|
|
Media(
|
|
id: 1,
|
|
reference:
|
|
'https://static.wixstatic.com/media/c83481_1dd473ad49524ae5a95d993ba10e0a50~mv2.jpg/v1/fill/w_640,h_426,al_c,q_80,usm_0.66_1.00_0.01,enc_auto/c83481_1dd473ad49524ae5a95d993ba10e0a50~mv2.jpg',
|
|
type: 'image',
|
|
description: 'Struggling on deadpoints'),
|
|
Media(
|
|
id: 1,
|
|
reference: 'TwS8ycTY5cc',
|
|
type: 'youtube',
|
|
description: 'Attempting crux move')
|
|
]);
|
|
|
|
if (type == 0) {
|
|
return Card(
|
|
color: color,
|
|
margin: const EdgeInsets.fromLTRB(15, 15, 15, 0),
|
|
clipBehavior: Clip.hardEdge,
|
|
child: InkWell(
|
|
splashColor: Colors.deepPurple,
|
|
onTap: () => showGeneralDialog(
|
|
barrierColor: Colors.black.withOpacity(0.5),
|
|
transitionDuration: const Duration(milliseconds: 220),
|
|
transitionBuilder: (BuildContext context,
|
|
Animation<double> animation,
|
|
Animation<double> secondaryAnimation,
|
|
Widget child) {
|
|
Animation<Offset> custom = Tween<Offset>(
|
|
begin: const Offset(0.0, 1.0),
|
|
end: const Offset(0.0, 0.0))
|
|
.animate(animation);
|
|
return SlideTransition(
|
|
position: custom,
|
|
child: Dialog.fullscreen(child: SessionView(data: data, session: session)));
|
|
},
|
|
barrierDismissible: true,
|
|
barrierLabel: '',
|
|
context: context,
|
|
pageBuilder: (context, animation1, animation2) {
|
|
return Container();
|
|
}),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
ListTile(
|
|
leading: Padding(
|
|
padding: const EdgeInsets.fromLTRB(0, 8, 0, 0),
|
|
child: Container(
|
|
width: 60,
|
|
decoration: const BoxDecoration(
|
|
image: DecorationImage(
|
|
fit: BoxFit.cover,
|
|
image:
|
|
AssetImage('assets/images/placeholder.jpg')),
|
|
// color: Colors.blue,
|
|
borderRadius:
|
|
BorderRadius.all(Radius.elliptical(10, 10)),
|
|
),
|
|
)),
|
|
title: Text(maxLines: 1, session.title.toTitleCase()),
|
|
subtitle: Text(maxLines: 1, dateFormat.format(session.date as DateTime)),
|
|
trailing: IconButton(
|
|
visualDensity: VisualDensity.compact,
|
|
icon: Icon(Icons.close_rounded),
|
|
onPressed: () {
|
|
showAdaptiveDialog(
|
|
context: context,
|
|
builder: (BuildContext context) => AlertDialog(
|
|
title: const Text('Session Removal'),
|
|
content: const Text(
|
|
'Would you like to permanently remove this session?'),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context, 'Cancel'),
|
|
child: const Text('Cancel'),
|
|
),
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context, 'OK'),
|
|
child: const Text('OK'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
ListTile(
|
|
contentPadding: const EdgeInsets.fromLTRB(15, 0, 15, 15),
|
|
title: Text(
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(fontWeight: FontWeight.w300),
|
|
session.content),
|
|
),
|
|
],
|
|
)),
|
|
);
|
|
} else {
|
|
return Card(
|
|
color: color,
|
|
child: InkWell(
|
|
// overlayColor: MaterialStateColor(Colors.deepPurple as int),
|
|
splashColor: Colors.deepPurple,
|
|
borderRadius: const BorderRadius.all(Radius.elliptical(10, 10)),
|
|
onTap: () => showGeneralDialog(
|
|
// barrierColor: Colors.black.withOpacity(0.5),
|
|
transitionDuration: const Duration(milliseconds: 220),
|
|
transitionBuilder: (BuildContext context,
|
|
Animation<double> animation,
|
|
Animation<double> secondaryAnimation,
|
|
Widget child) {
|
|
Animation<Offset> custom = Tween<Offset>(
|
|
begin: const Offset(0.0, 1.0),
|
|
end: const Offset(0.0, 0.0))
|
|
.animate(animation);
|
|
return SlideTransition(
|
|
position: custom,
|
|
child:
|
|
Dialog.fullscreen(child: SessionView(data: data, session: session)));
|
|
},
|
|
barrierDismissible: true,
|
|
barrierLabel: '',
|
|
context: context,
|
|
pageBuilder: (context, animation1, animation2) {
|
|
return Container();
|
|
}),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
// color: const Color.fromARGB(47, 0, 0, 0),
|
|
borderRadius: BorderRadius.circular(10),
|
|
image: const DecorationImage(
|
|
colorFilter: ColorFilter.mode(
|
|
Color.fromARGB(220, 41, 39, 39),
|
|
BlendMode.hardLight),
|
|
image: AssetImage('assets/images/placeholder.jpg'),
|
|
fit: BoxFit.cover),
|
|
),
|
|
child: Align(
|
|
alignment: Alignment.center,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
ListTile(
|
|
title: Text(
|
|
maxLines: 3,
|
|
session.title.toTitleCase(),
|
|
textAlign: TextAlign.center),
|
|
subtitle: Text(
|
|
maxLines: 1,
|
|
dateFormat.format(session.date as DateTime),
|
|
textAlign: TextAlign.center),
|
|
),
|
|
])))));
|
|
}
|
|
}
|
|
}
|