forked from firka/student-legacy
added expire date to ads
This commit is contained in:
parent
bbbaea9224
commit
e66fdbaeac
@ -5,6 +5,7 @@ class Ad {
|
||||
Uri? logoUrl;
|
||||
bool overridePremium;
|
||||
DateTime date;
|
||||
DateTime expireDate;
|
||||
Uri launchUrl;
|
||||
|
||||
Ad({
|
||||
@ -14,6 +15,7 @@ class Ad {
|
||||
this.logoUrl,
|
||||
this.overridePremium = false,
|
||||
required this.date,
|
||||
required this.expireDate,
|
||||
required this.launchUrl,
|
||||
});
|
||||
|
||||
@ -27,6 +29,9 @@ class Ad {
|
||||
overridePremium: json['override_premium'] ?? false,
|
||||
date:
|
||||
json['date'] != null ? DateTime.parse(json['date']) : DateTime.now(),
|
||||
expireDate: json['expire_date'] != null
|
||||
? DateTime.parse(json['expire_date'])
|
||||
: DateTime.now(),
|
||||
launchUrl: Uri.parse(json['launch_url'] ?? 'https://refilc.hu'),
|
||||
);
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ List<DateWidget> getWidgets(List<Ad> providerAds) {
|
||||
|
||||
if (providerAds.isNotEmpty) {
|
||||
for (var ad in providerAds) {
|
||||
if (ad.date.isBefore(DateTime.now())) {
|
||||
if (ad.date.isBefore(DateTime.now()) &&
|
||||
ad.expireDate.isAfter(DateTime.now())) {
|
||||
providerAds.sort((a, b) => -a.date.compareTo(b.date));
|
||||
|
||||
items.add(DateWidget(
|
||||
|
Loading…
x
Reference in New Issue
Block a user