1
0
mirror of https://github.com/stonega/tsacdop synced 2025-01-31 07:45:02 +01:00

82 lines
2.1 KiB
Dart
Raw Normal View History

2020-08-16 01:43:45 +08:00
import 'dart:io';
2020-08-14 20:13:10 +08:00
import 'package:equatable/equatable.dart';
import 'package:audio_service/audio_service.dart';
2020-08-16 01:43:45 +08:00
import 'package:flutter/material.dart';
import '../util/extension_helper.dart';
2020-08-14 20:13:10 +08:00
class EpisodeBrief extends Equatable {
2020-02-09 20:29:09 +08:00
final String title;
final String description;
final int pubDate;
2020-02-09 20:29:09 +08: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;
final String imagePath;
final String mediaId;
2020-04-01 00:36:20 +08:00
final int isNew;
final int skipSeconds;
final int downloadDate;
2020-02-09 20:29:09 +08:00
EpisodeBrief(
this.title,
this.enclosureUrl,
this.enclosureLength,
this.pubDate,
this.feedTitle,
this.primaryColor,
this.duration,
this.explicit,
this.imagePath,
2020-07-24 22:10:08 +08:00
this.isNew,
2020-07-24 02:42:25 +08:00
{this.mediaId,
this.liked,
this.downloaded,
this.skipSeconds,
2020-07-24 02:42:25 +08:00
this.description = '',
this.downloadDate = 0})
: assert(enclosureUrl != null);
MediaItem toMediaItem() {
return MediaItem(
id: mediaId,
title: title,
artist: feedTitle,
album: feedTitle,
duration: Duration.zero,
artUri: 'file://$imagePath',
extras: {'skip': skipSeconds});
}
2020-08-16 01:43:45 +08: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,
skipSeconds: skipSeconds,
description: description,
downloadDate: downloadDate);
2020-06-06 02:33:47 +08:00
@override
2020-08-14 20:13:10 +08:00
List<Object> get props => [enclosureUrl, title];
2020-02-09 20:29:09 +08:00
}