From e66fdbaeacdbc237c0a57166cb11c8b0d6657784 Mon Sep 17 00:00:00 2001 From: Kima Date: Tue, 5 Sep 2023 21:59:53 +0200 Subject: [PATCH] added expire date to ads --- filcnaplo/lib/models/ad.dart | 5 +++++ filcnaplo/lib/ui/filter/widgets/ads.dart | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/filcnaplo/lib/models/ad.dart b/filcnaplo/lib/models/ad.dart index ebb73b5..dcc4b0c 100644 --- a/filcnaplo/lib/models/ad.dart +++ b/filcnaplo/lib/models/ad.dart @@ -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'), ); } diff --git a/filcnaplo/lib/ui/filter/widgets/ads.dart b/filcnaplo/lib/ui/filter/widgets/ads.dart index 2632be3..48c39b1 100644 --- a/filcnaplo/lib/ui/filter/widgets/ads.dart +++ b/filcnaplo/lib/ui/filter/widgets/ads.dart @@ -8,7 +8,8 @@ List getWidgets(List 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(