refactor and new activity view
This commit is contained in:
parent
780e270c15
commit
b273979ac0
@ -1,4 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sendtrain/classes/activity_action.dart';
|
||||
import 'package:sendtrain/models/activity_model.dart';
|
||||
|
||||
import '../widgets/activities_header.dart';
|
||||
import '../widgets/activity_card.dart';
|
||||
@ -11,9 +13,34 @@ class ActivitiesScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ActivitiesScreenState extends State<ActivitiesScreen> {
|
||||
|
||||
final data = ActivityModel(
|
||||
id: 1,
|
||||
categories: ['power'],
|
||||
description: 'description',
|
||||
title: 'activity',
|
||||
type: 'fundamentals',
|
||||
actions: List.generate(
|
||||
10,
|
||||
(i) => 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))),
|
||||
));
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> activities = List.generate(10, (i) => ActivityCard());
|
||||
List<Widget> activities = List.generate(10, (i) => ActivityCard(activity: data));
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(10, 15, 10, 0),
|
||||
|
@ -1,46 +1,48 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sendtrain/classes/activity_action.dart';
|
||||
import 'package:sendtrain/models/activity_model.dart';
|
||||
import 'package:sendtrain/widgets/activity_view.dart';
|
||||
|
||||
class ActivityCard extends StatelessWidget {
|
||||
ActivityCard({super.key});
|
||||
const ActivityCard({super.key, required this.activity});
|
||||
|
||||
final data = ActivityModel(
|
||||
id: 1,
|
||||
categories: ['power'],
|
||||
description: 'description',
|
||||
title: 'activity',
|
||||
type: 'fundamentals',
|
||||
actions: List.generate(
|
||||
10,
|
||||
(i) => 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
|
||||
)
|
||||
)
|
||||
),));
|
||||
final ActivityModel activity;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
data.title,
|
||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
color: const Color(0xff3A5FB6),
|
||||
child: ListTile(
|
||||
// dense: true,
|
||||
focusColor: const Color(0xff3A5FB6),
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: 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: ActivityView(activity: activity)));
|
||||
},
|
||||
barrierDismissible: true,
|
||||
barrierLabel: '',
|
||||
context: context,
|
||||
pageBuilder: (context, animation1, animation2) {
|
||||
return Container();
|
||||
}),
|
||||
enableFeedback: true,
|
||||
title: Text(maxLines: 1, activity.title),
|
||||
subtitle: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 3),
|
||||
child: Text(maxLines: 2, activity.description)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
34
lib/widgets/activity_view.dart
Normal file
34
lib/widgets/activity_view.dart
Normal file
@ -0,0 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sendtrain/models/activity_model.dart';
|
||||
|
||||
class ActivityView extends StatelessWidget {
|
||||
const ActivityView({super.key, required this.activity});
|
||||
|
||||
final ActivityModel activity;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
AppBar(
|
||||
centerTitle: true,
|
||||
title: Text(activity.title, style: const TextStyle(fontSize: 25)),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 25, bottom: 10, left: 15, right: 15),
|
||||
child: Text(
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(fontSize: 20),
|
||||
activity.description)),
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 25, bottom: 10),
|
||||
child: Text(
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
'Actions:')),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ class SessionCard extends StatelessWidget {
|
||||
|
||||
Color color = (state == 0)
|
||||
? const Color(0xff3A5FB6)
|
||||
: ThemeData.dark(useMaterial3: true).colorScheme.surface;
|
||||
: ThemeData.dark(useMaterial3: true).colorScheme.surfaceBright;
|
||||
|
||||
// place holder until we can retrieve real data
|
||||
final data = SessionModel(
|
||||
@ -35,7 +35,7 @@ class SessionCard extends StatelessWidget {
|
||||
type: 'fundamental',
|
||||
categories: ['strength', 'power'],
|
||||
description:
|
||||
"Campus board session, focussing on explosiveness and contact strength.",
|
||||
"Campus board session, focusing on explosiveness and contact strength.",
|
||||
actions: [
|
||||
ActivityAction(
|
||||
id: 1,
|
||||
|
@ -5,6 +5,7 @@ import 'package:intl/date_symbol_data_local.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/activity_card.dart';
|
||||
import 'package:sendtrain/widgets/media_card.dart';
|
||||
|
||||
class SessionView extends StatelessWidget {
|
||||
@ -18,17 +19,18 @@ class SessionView extends StatelessWidget {
|
||||
final DateFormat dateFormat = DateFormat('yyyy-MM-dd');
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
AppBar(
|
||||
centerTitle: true,
|
||||
title: Text('Session @ ${dateFormat.format(data.date)}',
|
||||
style: const TextStyle(fontSize: 15)),
|
||||
style: const TextStyle(fontSize: 25)),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20, right: 20, bottom: 10),
|
||||
padding:
|
||||
const EdgeInsets.only(left: 20, right: 20, top: 15, bottom: 10),
|
||||
child: Text(
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 1,
|
||||
style:
|
||||
const TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
@ -36,13 +38,19 @@ class SessionView extends StatelessWidget {
|
||||
SessionViewAchievements(achievements: data.achievements),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 15, right: 15),
|
||||
child: Text(textAlign: TextAlign.center, data.content)),
|
||||
child: Text(textAlign: TextAlign.left, data.content)),
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(15, 30, 0, 10),
|
||||
child: Text(
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
'Media:')),
|
||||
SessionViewMedia(media: data.media),
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 25, bottom: 10),
|
||||
padding: EdgeInsets.fromLTRB(15, 30, 0, 10),
|
||||
child: Text(
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
'Activities:')),
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
'Activites:')),
|
||||
SessionViewActivities(activities: data.activities),
|
||||
// TextButton(
|
||||
// onPressed: () {
|
||||
@ -68,52 +76,7 @@ class SessionViewActivities extends StatelessWidget {
|
||||
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
|
||||
itemCount: activities?.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Card(
|
||||
color: const Color(0xff3A5FB6),
|
||||
child: ListTile(
|
||||
// dense: true,
|
||||
focusColor: const Color(0xff3A5FB6),
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: 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: Flex(
|
||||
direction: Axis.vertical,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
AppBar(
|
||||
centerTitle: true,
|
||||
title: const Text('test activity',
|
||||
style: TextStyle(fontSize: 15)),
|
||||
),
|
||||
],
|
||||
)));
|
||||
},
|
||||
barrierDismissible: true,
|
||||
barrierLabel: '',
|
||||
context: context,
|
||||
pageBuilder: (context, animation1, animation2) {
|
||||
return Container();
|
||||
}),
|
||||
enableFeedback: true,
|
||||
title: Text(maxLines: 1, '${activities?[index].title}'),
|
||||
subtitle: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 3),
|
||||
child:
|
||||
Text(maxLines: 2, '${activities?[index].description}')),
|
||||
));
|
||||
return ActivityCard(activity: activities![index]);
|
||||
},
|
||||
));
|
||||
}
|
||||
@ -143,22 +106,8 @@ class SessionViewAchievements extends StatelessWidget {
|
||||
visualDensity: VisualDensity.compact,
|
||||
avatar: const Icon(Icons.check_circle_outline),
|
||||
label: Text(maxLines: 1, '${achievements?[index]}'),
|
||||
onPressed: () {
|
||||
// setState(() {
|
||||
// favorite = !favorite;
|
||||
// });
|
||||
},
|
||||
onPressed: () {},
|
||||
));
|
||||
// return Card(
|
||||
// child: ListTile(
|
||||
// // dense: true,
|
||||
// focusColor: Colors.deepPurple,
|
||||
// shape: const RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.all(Radius.circular(10))),
|
||||
// onTap: () {},
|
||||
// enableFeedback: true,
|
||||
// title: Text(maxLines: 1, '${achievements?[index]}'),
|
||||
// ));
|
||||
},
|
||||
))),
|
||||
],
|
||||
@ -178,16 +127,11 @@ class SessionViewMedia extends StatelessWidget {
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 25),
|
||||
child: Text(
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
'Media:')),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 100,
|
||||
child: GridView.count(
|
||||
padding: const EdgeInsets.fromLTRB(15, 10, 0, 0),
|
||||
padding: const EdgeInsets.fromLTRB(15, 0, 0, 0),
|
||||
scrollDirection: Axis.horizontal,
|
||||
crossAxisSpacing: 5,
|
||||
mainAxisSpacing: 5,
|
||||
@ -197,24 +141,3 @@ class SessionViewMedia extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// SizedBox(
|
||||
// height: 100,
|
||||
// width: double.infinity,
|
||||
// child: ListView.builder(
|
||||
// // scrollDirection: Axis.horizontal,
|
||||
// padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
|
||||
// itemCount: media?.length,
|
||||
// itemBuilder: (BuildContext context, int index) {
|
||||
// return Card(
|
||||
// child: ListTile(
|
||||
// dense: true,
|
||||
// focusColor: Colors.deepPurple,
|
||||
// shape: const RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.all(Radius.circular(10))),
|
||||
// onTap: () {},
|
||||
// enableFeedback: true,
|
||||
// title: const Text(maxLines: 1, 'test'),
|
||||
// ));
|
||||
// }))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user