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