tsacdop-podcast-app-android/lib/type/podcastlocal.dart

59 lines
1.6 KiB
Dart
Raw Normal View History

2020-10-28 13:10:43 +01:00
import 'dart:io';
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import '../util/extension_helper.dart';
class PodcastLocal extends Equatable {
final String title;
final String imageUrl;
final String rssUrl;
final String author;
final String primaryColor;
final String id;
final String imagePath;
final String provider;
final String link;
final String description;
2020-12-20 10:35:39 +01:00
final int updateCount;
final int episodeCount;
2020-10-28 13:10:43 +01:00
2020-12-20 10:35:39 +01:00
//set setUpdateCount(i) => updateCount = i;
//set setEpisodeCount(i) => episodeCount = i;
2020-10-28 13:10:43 +01:00
PodcastLocal(this.title, this.imageUrl, this.rssUrl, this.primaryColor,
this.author, this.id, this.imagePath, this.provider, this.link,
2020-12-20 10:35:39 +01:00
{this.description = '', int updateCount, int episodeCount})
2020-10-28 13:10:43 +01:00
: assert(rssUrl != null),
2020-12-20 10:35:39 +01:00
episodeCount = episodeCount ?? 0,
updateCount = updateCount ?? 0;
2020-10-28 13:10:43 +01: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();
}
2020-12-20 10:35:39 +01:00
PodcastLocal copyWith({int updateCount, int episodeCount}) {
return PodcastLocal(title, imageUrl, rssUrl, primaryColor, author, id,
imagePath, provider, link,
description: description,
updateCount: updateCount ?? 0,
episodeCount: episodeCount ?? 0);
}
2020-10-28 13:10:43 +01:00
@override
List<Object> get props => [id, rssUrl];
}