genericizing add card, activity ui tweaks
This commit is contained in:
parent
8ec531c0ea
commit
0b0ca884bc
@ -1,8 +1,10 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:sendtrain/daos/activities_dao.dart';
|
||||
import 'package:sendtrain/database/database.dart';
|
||||
// import 'package:sendtrain/widgets/activities/activity_card.dart';
|
||||
import 'package:sendtrain/helpers/widget_helpers.dart';
|
||||
import 'package:sendtrain/widgets/generic/elements/form_search_input.dart';
|
||||
|
||||
class ActivityFinderService {
|
||||
@ -27,10 +29,10 @@ class ActivityFinderService {
|
||||
}
|
||||
|
||||
Widget resultWidget(Activity activity, Function? callback) {
|
||||
// return ActivityCard(activity: activity, callback: callback);
|
||||
return ListTile(
|
||||
title: Text(activity.title),
|
||||
subtitle: Text(activity.description ?? ""),
|
||||
subtitle: Text(jsonToDescription(json.decode(activity.description ?? "")),
|
||||
maxLines: 2, softWrap: true, overflow: TextOverflow.ellipsis),
|
||||
onTap: () {
|
||||
if (callback != null) {
|
||||
callback();
|
||||
|
@ -11,6 +11,7 @@ import 'package:sendtrain/models/activity_timer_model.dart';
|
||||
import 'package:sendtrain/widgets/activities/activity_action_view.dart';
|
||||
import 'package:sendtrain/widgets/activities/activity_view_categories.dart';
|
||||
import 'package:sendtrain/widgets/activities/activity_view_media.dart';
|
||||
import 'package:sendtrain/widgets/generic/elements/add_card_generic.dart';
|
||||
|
||||
class ActivityView extends StatefulWidget {
|
||||
const ActivityView({super.key, required this.activity});
|
||||
@ -87,7 +88,15 @@ class _ActivityViewState extends State<ActivityView> {
|
||||
ActivityActionView(actions: actions)
|
||||
];
|
||||
} else {
|
||||
return [Text('add an action')];
|
||||
return [
|
||||
AddCardGeneric(
|
||||
title: 'Add an Action!',
|
||||
description:
|
||||
'Click here to create an exercise template (sets and reps, etc) for your activity!',
|
||||
action: () {
|
||||
print('teset');
|
||||
})
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,8 +187,8 @@ class _ActivityViewState extends State<ActivityView> {
|
||||
: []),
|
||||
ActivityViewCategories<List<ActivityType>>(
|
||||
icon: Icon(Icons.type_specimen_rounded),
|
||||
text: 'Activity Equipments',
|
||||
object: activity.equipment != null
|
||||
text: 'Activity Type',
|
||||
object: activity.type != null
|
||||
? [activity.type!]
|
||||
: []),
|
||||
])),
|
||||
@ -188,11 +197,12 @@ class _ActivityViewState extends State<ActivityView> {
|
||||
top: 0, bottom: 0, left: 15, right: 15),
|
||||
child: Text(
|
||||
maxLines: 4,
|
||||
overflow: TextOverflow. ellipsis,
|
||||
softWrap: true,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
// softWrap: true,
|
||||
textAlign: TextAlign.left,
|
||||
style: const TextStyle(fontSize: 15),
|
||||
jsonToDescription(json.decode(activity.description ?? "")))),
|
||||
jsonToDescription([json
|
||||
.decode(activity.description ?? "")[0]]))),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 15),
|
||||
child: Align(
|
||||
@ -215,12 +225,18 @@ class _ActivityViewState extends State<ActivityView> {
|
||||
context,
|
||||
Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Text(jsonToDescription(
|
||||
json.decode(activity.description ??
|
||||
"")))));
|
||||
child: Text(
|
||||
style:
|
||||
TextStyle(fontSize: 18),
|
||||
jsonToDescription(json.decode(
|
||||
activity.description ??
|
||||
"")))));
|
||||
},
|
||||
child: Text("read more",
|
||||
textAlign: TextAlign.right, style: TextStyle(fontSize: 12),),
|
||||
child: Text(
|
||||
"read more",
|
||||
textAlign: TextAlign.right,
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
))),
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(15, 10, 0, 10),
|
||||
|
37
lib/widgets/generic/elements/add_card_generic.dart
Normal file
37
lib/widgets/generic/elements/add_card_generic.dart
Normal file
@ -0,0 +1,37 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AddCardGeneric extends StatelessWidget {
|
||||
const AddCardGeneric(
|
||||
{super.key, required this.title, required this.description, this.action});
|
||||
|
||||
final String title;
|
||||
final String description;
|
||||
final Function? action;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
|
||||
children: [
|
||||
Card.outlined(
|
||||
child: InkWell(
|
||||
customBorder: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
onTap: () {
|
||||
if (action != null) {
|
||||
action!();
|
||||
}
|
||||
},
|
||||
child: ListTile(
|
||||
contentPadding:
|
||||
EdgeInsets.only(top: 5, left: 15, right: 5, bottom: 5),
|
||||
autofocus: true,
|
||||
leading: Icon(Icons.add_box_rounded),
|
||||
title: Text(title),
|
||||
subtitle: Text(description),
|
||||
)))
|
||||
]));
|
||||
}
|
||||
}
|
@ -11,9 +11,11 @@ import 'package:sendtrain/widgets/builders/dialogs.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
|
||||
class MediaCard extends StatelessWidget {
|
||||
const MediaCard({super.key, required this.media, this.callback});
|
||||
const MediaCard(
|
||||
{super.key, required this.media, this.callback, this.canDelete});
|
||||
|
||||
final MediaItem media;
|
||||
final bool? canDelete;
|
||||
final Function? callback;
|
||||
|
||||
@override
|
||||
@ -44,7 +46,9 @@ class MediaCard extends StatelessWidget {
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
shadowColor: const Color.fromARGB(0, 255, 255, 255),
|
||||
child: TextButton(
|
||||
onLongPress: () => showRemovalDialog(
|
||||
onLongPress: () {
|
||||
if (canDelete == true) {
|
||||
showRemovalDialog(
|
||||
'Media Removal',
|
||||
'Would you like to permanently remove this media from the current session?',
|
||||
context, () {
|
||||
@ -55,7 +59,9 @@ class MediaCard extends StatelessWidget {
|
||||
if (callback != null) {
|
||||
callback!();
|
||||
}
|
||||
}),
|
||||
});
|
||||
}
|
||||
},
|
||||
onPressed: () => showMediaDetailWidget(context, media),
|
||||
child: const ListTile(
|
||||
title: Text(''),
|
||||
|
@ -83,7 +83,7 @@ class _SessionViewState extends State<SessionView> {
|
||||
),
|
||||
children: [
|
||||
FloatingActionButton.extended(
|
||||
icon: const Icon(Icons.edit_outlined),
|
||||
icon: const Icon(Icons.military_tech_rounded),
|
||||
label: Text('Add Achievement'),
|
||||
onPressed: () {
|
||||
showEditorSheet(
|
||||
@ -93,7 +93,7 @@ class _SessionViewState extends State<SessionView> {
|
||||
},
|
||||
),
|
||||
FloatingActionButton.extended(
|
||||
icon: const Icon(Icons.edit_outlined),
|
||||
icon: const Icon(Icons.sports_gymnastics_rounded),
|
||||
label: Text('Add Activity'),
|
||||
onPressed: () {
|
||||
showEditorSheet(
|
||||
@ -104,7 +104,7 @@ class _SessionViewState extends State<SessionView> {
|
||||
),
|
||||
FloatingActionButton.extended(
|
||||
icon: const Icon(Icons.edit_outlined),
|
||||
label: Text('Edit'),
|
||||
label: Text('Edit Session'),
|
||||
onPressed: () {
|
||||
showEditorSheet(
|
||||
context,
|
||||
@ -114,7 +114,7 @@ class _SessionViewState extends State<SessionView> {
|
||||
),
|
||||
FloatingActionButton.extended(
|
||||
icon: const Icon(Icons.history_outlined),
|
||||
label: Text('Restart'),
|
||||
label: Text('Restart Session'),
|
||||
onPressed: () {
|
||||
Session newSession =
|
||||
session.copyWith(status: SessionStatus.pending);
|
||||
@ -131,7 +131,7 @@ class _SessionViewState extends State<SessionView> {
|
||||
),
|
||||
FloatingActionButton.extended(
|
||||
icon: const Icon(Icons.done_all_outlined),
|
||||
label: Text('Done'),
|
||||
label: Text('Finish Session'),
|
||||
onPressed: () {
|
||||
Session newSession =
|
||||
session.copyWith(status: SessionStatus.completed);
|
||||
|
@ -4,6 +4,7 @@ import 'package:sendtrain/daos/activities_dao.dart';
|
||||
import 'package:sendtrain/database/database.dart';
|
||||
import 'package:sendtrain/helpers/widget_helpers.dart';
|
||||
import 'package:sendtrain/widgets/activities/activity_card.dart';
|
||||
import 'package:sendtrain/widgets/generic/elements/add_card_generic.dart';
|
||||
import 'package:sendtrain/widgets/generic/elements/generic_progress_indicator.dart';
|
||||
import 'package:sendtrain/widgets/sessions/session_activities_editor.dart';
|
||||
|
||||
@ -32,36 +33,21 @@ class _SessionViewActivitiesState extends State<SessionViewActivities> {
|
||||
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
|
||||
itemCount: activities.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return ActivityCard(activity: activities[index], session: widget.session);
|
||||
return ActivityCard(
|
||||
activity: activities[index], session: widget.session);
|
||||
},
|
||||
));
|
||||
} else {
|
||||
return Expanded(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
|
||||
children: [
|
||||
Card.outlined(
|
||||
child: InkWell(
|
||||
customBorder: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
onTap: () {
|
||||
showEditorSheet(
|
||||
context,
|
||||
SessionActivitiesEditor(
|
||||
session: widget.session,
|
||||
callback: () {}));
|
||||
},
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.only(
|
||||
top: 5, left: 15, right: 5, bottom: 5),
|
||||
autofocus: true,
|
||||
leading: Icon(Icons.add_box_rounded),
|
||||
title: Text('Add an Activity!'),
|
||||
subtitle: Text(
|
||||
'Here you can associate one or more activities that you can follow along with during your session.'),
|
||||
)))
|
||||
]));
|
||||
return AddCardGeneric(
|
||||
title: 'Add an Activity!',
|
||||
description:
|
||||
'Here you can associate one or more activities that you can follow along with during your session.',
|
||||
action: () {
|
||||
showEditorSheet(
|
||||
context,
|
||||
SessionActivitiesEditor(
|
||||
session: widget.session, callback: () {}));
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return GenericProgressIndicator();
|
||||
|
@ -32,7 +32,7 @@ class _SessionViewMediaState extends State<SessionViewMedia> {
|
||||
List<Widget> content;
|
||||
if (mediaItems.isNotEmpty) {
|
||||
List<Widget> mediaCards = List.generate(mediaItems.length,
|
||||
(i) => MediaCard(media: mediaItems[i], callback: resetState));
|
||||
(i) => MediaCard(media: mediaItems[i], callback: resetState, canDelete: true));
|
||||
content = mediaCards;
|
||||
} else {
|
||||
content = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user