From d7bd755c57e1ab9314e24c69ee982d6f7dffce56 Mon Sep 17 00:00:00 2001 From: Joshua Burman Date: Fri, 29 Nov 2024 12:24:11 -0500 Subject: [PATCH] Activity media --- lib/classes/activity_action.dart | 4 + lib/widgets/activity_action_view.dart | 54 +++++------ lib/widgets/activity_view.dart | 38 ++++++++ lib/widgets/session_card.dart | 126 ++++++++++++++++---------- 4 files changed, 142 insertions(+), 80 deletions(-) diff --git a/lib/classes/activity_action.dart b/lib/classes/activity_action.dart index 29befd5..8c1ece1 100644 --- a/lib/classes/activity_action.dart +++ b/lib/classes/activity_action.dart @@ -1,14 +1,18 @@ +import 'package:sendtrain/classes/media.dart'; + class ActivityAction { int id; String title; String description; Set activityActionSet; + List? media; ActivityAction({ required this.id, required this.title, required this.description, required this.activityActionSet, + this.media, }); } diff --git a/lib/widgets/activity_action_view.dart b/lib/widgets/activity_action_view.dart index f4d7841..f2da55a 100644 --- a/lib/widgets/activity_action_view.dart +++ b/lib/widgets/activity_action_view.dart @@ -13,40 +13,30 @@ class ActivityActionView extends StatefulWidget { class _ActivityActionViewState extends State { @override Widget build(BuildContext context) { - return Column( - children: [ - Expanded( - child: ListView( - children: [ - Text( - textAlign: TextAlign.left, - style: const TextStyle(fontSize: 15), - widget.action.description) - ], - ), - ), - ], - ); + return Expanded( + child: ListView.builder( + // shrinkWrap: true, + padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), + itemCount: widget.action.activityActionSet.total, + itemBuilder: (BuildContext context, int index) { + return Text( + widget.action.description + ); + }, + )); // return Column( - // children: [Expanded( - // child: Column( - // children: [ - // Text( - // textAlign: TextAlign.left, - // style: const TextStyle(fontSize: 15), - // widget.action.description), - // ] + // children: [ + // Expanded( + // child: ListView( + // children: [ + // Text( + // textAlign: TextAlign.left, + // style: const TextStyle(fontSize: 15), + // widget.action.description) + // ], + // ), // ), - // ), - // // this will be you container - // const Column(children: [ - // Text( - // textAlign: TextAlign.left, - // style: TextStyle(fontSize: 15), - // 'bottom') - // ],) // ], // ); } - -} \ No newline at end of file +} diff --git a/lib/widgets/activity_view.dart b/lib/widgets/activity_view.dart index 9770a38..dffecb4 100644 --- a/lib/widgets/activity_view.dart +++ b/lib/widgets/activity_view.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; import 'package:sendtrain/classes/activity_action.dart'; +import 'package:sendtrain/classes/media.dart'; import 'package:sendtrain/models/activity_model.dart'; import 'package:sendtrain/widgets/activity_action_view.dart'; +import 'package:sendtrain/widgets/media_card.dart'; class ActivityView extends StatelessWidget { const ActivityView({super.key, required this.activity}); @@ -32,6 +34,7 @@ class ActivityView extends StatelessWidget { textAlign: TextAlign.left, style: const TextStyle(fontSize: 15), activity.description)), + ActivityViewMedia(activity: activity), const Padding( padding: EdgeInsets.fromLTRB(15, 30, 0, 10), child: Text( @@ -84,3 +87,38 @@ class ActivityViewCategories extends StatelessWidget { ); } } + +class ActivityViewMedia extends StatelessWidget { + const ActivityViewMedia({super.key, this.activity}); + + final ActivityModel? activity; + + @override + Widget build(BuildContext context) { + List media = []; + + for (ActivityAction action in activity!.actions) { + if (action.media!.isNotEmpty) { + media.addAll(action.media as Iterable); + } + } + + List mediaCards = List.generate(media.length, + (i) => MediaCard(media: media[i])); + + return Column( + children: [ + SizedBox( + width: double.infinity, + height: 100, + child: GridView.count( + padding: const EdgeInsets.fromLTRB(15, 0, 0, 0), + scrollDirection: Axis.horizontal, + crossAxisSpacing: 5, + mainAxisSpacing: 5, + crossAxisCount: 1, + children: mediaCards)) + ], + ); + } +} diff --git a/lib/widgets/session_card.dart b/lib/widgets/session_card.dart index f358334..927eb9f 100644 --- a/lib/widgets/session_card.dart +++ b/lib/widgets/session_card.dart @@ -38,22 +38,32 @@ class SessionCard extends StatelessWidget { "Campus board session, focusing on explosiveness and contact strength.", actions: [ ActivityAction( - id: 1, - title: 'test action', - description:'test description', - activityActionSet: Set( - type: 'drop_set', - total: 3, - rest: 3000, - reps: Reps( - type: 'count', - tempo: [2,3,5], - amounts: [5,3,2], - weights: [50,70,80], - rest: 200 - ) - ) - ), + id: 1, + title: 'test action', + description: 'test description', + 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: 3000, + reps: Reps( + type: 'count', + tempo: [2, 3, 5], + amounts: [5, 3, 2], + weights: [50, 70, 80], + rest: 200))), ], resources: ['https://www.youtube.com/watch?v=bLz0xp1PEm4']), ActivityModel( @@ -65,22 +75,32 @@ class SessionCard extends StatelessWidget { "Session focussed on attempting a climb at or beyond your perceived limit.", actions: [ ActivityAction( - id: 1, - title: 'test action', - description:'test description', - activityActionSet: Set( - type: 'drop_set', - total: 3, - rest: 3000, - reps: Reps( - type: 'count', - tempo: [2,3,5], - amounts: [5,3,2], - weights: [50,70,80], - rest: 200 - ) - ) - ), + id: 1, + title: 'test action', + description: 'test description', + 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: 'drop_set', + total: 3, + rest: 3000, + reps: Reps( + type: 'count', + tempo: [2, 3, 5], + amounts: [5, 3, 2], + weights: [50, 70, 80], + rest: 200))), ], resources: ['https://www.youtube.com/watch?v=dyAvbUvY_PU']), ActivityModel( @@ -92,22 +112,32 @@ class SessionCard extends StatelessWidget { "Weight pullups to increase strength and maximal pulling force.", actions: [ ActivityAction( - id: 1, - title: 'test action', - description:'test description', - activityActionSet: Set( - type: 'drop_set', - total: 3, - rest: 3000, - reps: Reps( - type: 'count', - tempo: [2,3,5], - amounts: [5,3,2], - weights: [50,70,80], - rest: 200 - ) - ) - ), + id: 1, + title: 'test action', + description: 'test description', + 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: 3, + rest: 3000, + reps: Reps( + type: 'count', + tempo: [2, 3, 5], + amounts: [5, 3, 2], + weights: [50, 70, 80], + rest: 200))), ], resources: ['https://www.youtube.com/watch?v=dyAvbUvY_PU']), ],