add mark button to card
This commit is contained in:
parent
9ef214be69
commit
bebdd280fd
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:didvan/config/theme_data.dart';
|
||||
import 'package:didvan/constants/app_icons.dart';
|
||||
import 'package:didvan/models/home_page_content/content.dart';
|
||||
import 'package:didvan/models/requests/studio.dart';
|
||||
|
|
@ -11,24 +12,40 @@ import 'package:didvan/views/widgets/skeleton_image.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:persian_number_utility/persian_number_utility.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:didvan/providers/user.dart';
|
||||
|
||||
class MainPagePodcastItem extends StatelessWidget {
|
||||
class MainPagePodcastItem extends StatefulWidget {
|
||||
final MainPageContentType content;
|
||||
final String type = "podcast";
|
||||
const MainPagePodcastItem({super.key, required this.content});
|
||||
|
||||
@override
|
||||
State<MainPagePodcastItem> createState() => _MainPagePodcastItemState();
|
||||
}
|
||||
|
||||
class _MainPagePodcastItemState extends State<MainPagePodcastItem> {
|
||||
void _onMarkChange() {
|
||||
UserProvider.changeItemMark(
|
||||
widget.type,
|
||||
widget.content.id,
|
||||
!widget.content.marked,
|
||||
);
|
||||
setState(() => widget.content.marked = !widget.content.marked);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
final state = context.read<StudioDetailsState>();
|
||||
await state.getStudioDetails(
|
||||
content.id,
|
||||
widget.content.id,
|
||||
args: const StudioRequestArgs(page: 0, type: 'podcast'),
|
||||
);
|
||||
MediaService.currentPodcast = state.studio;
|
||||
MediaService.handleAudioPlayback(
|
||||
audioSource: content.link,
|
||||
id: content.id,
|
||||
audioSource: widget.content.link,
|
||||
id: widget.content.id,
|
||||
isNetworkAudio: true,
|
||||
isVoiceMessage: false,
|
||||
);
|
||||
|
|
@ -45,69 +62,101 @@ class MainPagePodcastItem extends StatelessWidget {
|
|||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
width: MediaQuery.of(context).size.width / 3 - 15,
|
||||
),
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 2 / 3 - 90,
|
||||
width: MediaQuery.of(context).size.width * 2 / 3 - 60,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(
|
||||
width:
|
||||
MediaQuery.of(context).size.width * 2 / 3 - 90,
|
||||
MediaQuery.of(context).size.width * 2 / 3 - 60,
|
||||
child: AudioWidget(
|
||||
id: content.id,
|
||||
audioUrl: content.link,
|
||||
id: widget.content.id,
|
||||
audioUrl: widget.content.link,
|
||||
audioMetaData: StudioDetailsData(
|
||||
id: content.id,
|
||||
duration: content.duration!,
|
||||
title: content.title,
|
||||
id: widget.content.id,
|
||||
duration: widget.content.duration!,
|
||||
title: widget.content.title,
|
||||
description: '',
|
||||
image: content.image,
|
||||
link: content.link,
|
||||
image: widget.content.image,
|
||||
link: widget.content.link,
|
||||
iframe: null,
|
||||
createdAt: '',
|
||||
order: 1,
|
||||
marked: content.marked,
|
||||
marked: widget.content.marked,
|
||||
comments: 0,
|
||||
tags: [],
|
||||
type: 'podcast',
|
||||
),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
DidvanText(
|
||||
content.title,
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
DidvanText(
|
||||
widget.content.title,
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyLarge,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Icon(
|
||||
DidvanIcons.calendar_day_light,
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
DidvanText(
|
||||
DateTime.parse(
|
||||
widget.content.subtitles[0])
|
||||
.toPersianDateStr(),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Icon(
|
||||
DidvanIcons.calendar_day_light,
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
DidvanText(
|
||||
DateTime.parse(content.subtitles[0])
|
||||
.toPersianDateStr(),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style:
|
||||
Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
GestureDetector(
|
||||
onTap: _onMarkChange,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 12, right: 12, bottom: 8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Icon(
|
||||
widget.content.marked
|
||||
? DidvanIcons.bookmark_solid
|
||||
: DidvanIcons.bookmark_regular,
|
||||
color: widget.content.marked
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.secondary
|
||||
: Theme.of(context)
|
||||
.colorScheme
|
||||
.caption),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
@ -117,9 +166,9 @@ class MainPagePodcastItem extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
SkeletonImage(
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
width: MediaQuery.of(context).size.width / 3 - 15,
|
||||
height: 180,
|
||||
imageUrl: content.image,
|
||||
imageUrl: widget.content.image,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in New Issue