2020-08-15 19:43:45 +02:00
|
|
|
import 'dart:io';
|
|
|
|
|
2020-08-14 14:13:10 +02:00
|
|
|
import 'package:equatable/equatable.dart';
|
2020-06-27 03:33:01 +02:00
|
|
|
|
2020-03-14 04:14:24 +01:00
|
|
|
import 'package:audio_service/audio_service.dart';
|
2020-08-15 19:43:45 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../util/extension_helper.dart';
|
2020-02-21 16:04:02 +01:00
|
|
|
|
2020-08-14 14:13:10 +02:00
|
|
|
class EpisodeBrief extends Equatable {
|
2020-02-09 13:29:09 +01:00
|
|
|
final String title;
|
2020-06-10 18:36:53 +02:00
|
|
|
final String description;
|
2020-02-21 16:04:02 +01:00
|
|
|
final int pubDate;
|
2020-02-09 13:29:09 +01:00
|
|
|
final int enclosureLength;
|
|
|
|
final String enclosureUrl;
|
|
|
|
final String feedTitle;
|
|
|
|
final String primaryColor;
|
|
|
|
final int liked;
|
|
|
|
final String downloaded;
|
|
|
|
final int duration;
|
|
|
|
final int explicit;
|
2020-02-20 16:44:42 +01:00
|
|
|
final String imagePath;
|
2020-03-14 04:14:24 +01:00
|
|
|
final String mediaId;
|
2020-03-31 18:36:20 +02:00
|
|
|
final int isNew;
|
2020-09-18 17:01:00 +02:00
|
|
|
final int skipSecondsStart;
|
|
|
|
final int skipSecondsEnd;
|
2020-06-10 18:36:53 +02:00
|
|
|
final int downloadDate;
|
2020-02-09 13:29:09 +01:00
|
|
|
EpisodeBrief(
|
|
|
|
this.title,
|
|
|
|
this.enclosureUrl,
|
|
|
|
this.enclosureLength,
|
|
|
|
this.pubDate,
|
|
|
|
this.feedTitle,
|
|
|
|
this.primaryColor,
|
|
|
|
this.duration,
|
2020-02-20 16:44:42 +01:00
|
|
|
this.explicit,
|
2020-03-14 04:14:24 +01:00
|
|
|
this.imagePath,
|
2020-07-24 16:10:08 +02:00
|
|
|
this.isNew,
|
2020-07-23 20:42:25 +02:00
|
|
|
{this.mediaId,
|
|
|
|
this.liked,
|
|
|
|
this.downloaded,
|
2020-09-18 17:01:00 +02:00
|
|
|
this.skipSecondsStart,
|
|
|
|
this.skipSecondsEnd,
|
2020-07-23 20:42:25 +02:00
|
|
|
this.description = '',
|
2020-06-10 18:36:53 +02:00
|
|
|
this.downloadDate = 0})
|
|
|
|
: assert(enclosureUrl != null);
|
2020-02-21 16:04:02 +01:00
|
|
|
|
2020-03-14 04:14:24 +01:00
|
|
|
MediaItem toMediaItem() {
|
|
|
|
return MediaItem(
|
|
|
|
id: mediaId,
|
|
|
|
title: title,
|
|
|
|
artist: feedTitle,
|
|
|
|
album: feedTitle,
|
2020-07-22 11:34:32 +02:00
|
|
|
duration: Duration.zero,
|
2020-04-22 20:10:57 +02:00
|
|
|
artUri: 'file://$imagePath',
|
2020-09-18 17:01:00 +02:00
|
|
|
extras: {
|
|
|
|
'skipSecondsStart': skipSecondsStart,
|
|
|
|
'skipSecondsEnd': skipSecondsEnd
|
|
|
|
});
|
2020-03-14 04:14:24 +01:00
|
|
|
}
|
2020-05-09 17:42:13 +02:00
|
|
|
|
2020-08-15 19:43:45 +02:00
|
|
|
ImageProvider get avatarImage {
|
|
|
|
return File(imagePath).existsSync()
|
|
|
|
? FileImage(File(imagePath))
|
|
|
|
: const AssetImage('assets/avatar_backup.png');
|
|
|
|
}
|
|
|
|
|
|
|
|
Color backgroudColor(BuildContext context) {
|
|
|
|
return context.brightness == Brightness.light
|
|
|
|
? primaryColor.colorizedark()
|
|
|
|
: primaryColor.colorizeLight();
|
|
|
|
}
|
|
|
|
|
|
|
|
EpisodeBrief copyWith({
|
|
|
|
String mediaId,
|
|
|
|
}) =>
|
|
|
|
EpisodeBrief(title, enclosureUrl, enclosureLength, pubDate, feedTitle,
|
|
|
|
primaryColor, duration, explicit, imagePath, isNew,
|
|
|
|
mediaId: mediaId ?? this.mediaId,
|
|
|
|
downloaded: downloaded,
|
2020-09-18 17:01:00 +02:00
|
|
|
skipSecondsStart: skipSecondsStart,
|
|
|
|
skipSecondsEnd: skipSecondsEnd,
|
2020-08-15 19:43:45 +02:00
|
|
|
description: description,
|
|
|
|
downloadDate: downloadDate);
|
|
|
|
|
2020-06-05 20:33:47 +02:00
|
|
|
@override
|
2020-08-14 14:13:10 +02:00
|
|
|
List<Object> get props => [enclosureUrl, title];
|
2020-02-09 13:29:09 +01:00
|
|
|
}
|