SendTrain/lib/widgets/session_card.dart
2024-12-05 00:44:13 -05:00

288 lines
12 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/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});
@override
Widget build(BuildContext context) {
initializeDateFormatting('en');
final DateFormat dateFormat = DateFormat('yyyy-MM-dd');
Color color = (state == 0)
? const Color(0xff3A5FB6)
: ThemeData.dark(useMaterial3: true).colorScheme.surfaceBright;
// 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: 'count',
tempo: [2, 3, 5],
amounts: [5, 3, 2],
weights: [50, 70, 80],
rest: 20000))),
],
resources: ['https://www.youtube.com/watch?v=bLz0xp1PEm4']),
ActivityModel(
id: 2,
title: 'Projecting',
type: 'fundamental',
categories: ['technique', 'conditioning'],
description:
"Session focussed 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: 'count',
tempo: [],
amounts: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
weights: [],
rest: 0))),
],
resources: ['https://www.youtube.com/watch?v=dyAvbUvY_PU']),
ActivityModel(
id: 3,
title: 'Weighted Pull Ups',
type: 'fundamental',
categories: ['Strength', 'Power'],
description:
"Weight pullups to increase strength and maximal pulling force.",
actions: [
ActivityAction(
id: 1,
title: 'Pull Ups',
description: 'Select your desired weight to add, and pull up. Be sure to fully drop into extension at start, and make sure chin is above bar for a complete rep. Do not kip during the movement.',
media: [
Media(
id: 1,
reference:
'https://trainingforclimbing.com/wp-content/uploads/2016/03/hypergravity_pull-up-compress3-966x1024.jpg',
type: 'image',
description: 'Weighted Pullups'),
Media(
id: 1,
reference: '7TLG1mHQHgw',
type: 'youtube',
description: 'How to do weighted pullups')
],
activityActionSet: Set(
type: 'drop_set',
total: 5,
rest: 300000,
reps: Reps(
type: 'count',
tempo: [],
amounts: [3, 5, 5, 3, 6],
weights: [80, 80, 80, 80, 80],
rest: 0))),
],
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)));
},
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, data.title),
subtitle: Text(maxLines: 1, dateFormat.format(data.date)),
),
ListTile(
contentPadding: const EdgeInsets.fromLTRB(15, 0, 15, 15),
title: Text(
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontWeight: FontWeight.w300),
data.content),
),
],
)),
);
} else {
return Card(
color: const Color.fromARGB(125, 0, 0, 0),
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)));
},
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,
data.title,
textAlign: TextAlign.center),
subtitle: Text(
maxLines: 1,
dateFormat.format(data.date),
textAlign: TextAlign.center),
),
])))));
}
}
}