Skip to content

Commit

Permalink
Rename tagline* to AppNews
Browse files Browse the repository at this point in the history
  • Loading branch information
g123k committed Jun 15, 2024
1 parent b300955 commit 218fe46
Show file tree
Hide file tree
Showing 18 changed files with 533 additions and 534 deletions.
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ User lists:

Product scan carousel:
- changed-files:
- any-glob-to-any-file: 'packages/smooth_app/lib/widgets/smooth_product_carousel.dart'
- any-glob-to-any-file: 'packages/smooth_app/lib/widgets/scan_carousel.dart'

✏️ Editing - 📦 Packaging input:
- changed-files:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
part of 'tagline_provider.dart';
part of 'newsfeed_provider.dart';

/// Content from the JSON and converted to what's in "tagmodel.dart"
/// Content from the JSON and converted to what's in "newsfeed_model.dart"
class _TagLineJSON {
_TagLineJSON.fromJson(Map<dynamic, dynamic> json)
Expand All @@ -15,34 +15,33 @@ class _TagLineJSON {
final _TagLineJSONNewsList news;
final _TaglineJSONFeed taglineFeed;

TagLine toTagLine(String locale) {
final Map<String, TagLineNewsItem> tagLineNews = news.map(
(String key, _TagLineItemNewsItem value) =>
MapEntry<String, TagLineNewsItem>(
AppNews toTagLine(String locale) {
final Map<String, AppNewsItem> tagLineNews = news.map(
(String key, _TagLineItemNewsItem value) => MapEntry<String, AppNewsItem>(
key,
value.toTagLineItem(locale),
),
);

final _TagLineJSONFeedLocale localizedFeed = taglineFeed.loadNews(locale);
final Iterable<TagLineFeedItem> feed = localizedFeed.news
final Iterable<AppNewsFeedItem> feed = localizedFeed.news
.map((_TagLineJSONFeedLocaleItem item) {
if (news[item.id] == null) {
// The asked ID doesn't exist in the news
return null;
}
return item.overrideNewsItem(news[item.id]!, locale);
})
.where((TagLineFeedItem? item) =>
.where((AppNewsFeedItem? item) =>
item != null &&
(item.startDate == null ||
item.startDate!.isBefore(DateTime.now())) &&
(item.endDate == null || item.endDate!.isAfter(DateTime.now())))
.whereNotNull();

return TagLine(
news: TagLineNewsList(tagLineNews),
feed: TagLineFeed(
return AppNews(
news: AppNewsList(tagLineNews),
feed: AppNewsFeed(
feed.toList(growable: false),
),
);
Expand Down Expand Up @@ -106,10 +105,10 @@ class _TagLineItemNewsItem {
return _translations['default']!.merge(translation);
}

TagLineNewsItem toTagLineItem(String locale) {
AppNewsItem toTagLineItem(String locale) {
final _TagLineItemNewsTranslation translation = loadTranslation(locale);
// We can assume the default translation has a non-null title and message
return TagLineNewsItem(
return AppNewsItem(
id: id,
title: translation.title!,
message: translation.message!,
Expand Down Expand Up @@ -224,8 +223,8 @@ class _TagLineNewsImage {
final double? width;
final String? alt;

TagLineImage toTagLineImage() {
return TagLineImage(
AppNewsImage toTagLineImage() {
return AppNewsImage(
src: url,
width: width,
alt: alt,
Expand Down Expand Up @@ -303,7 +302,7 @@ class _TagLineNewsStyle {
);
}

TagLineStyle toTagLineStyle() => TagLineStyle.fromHexa(
AppNewsStyle toTagLineStyle() => AppNewsStyle.fromHexa(
titleBackground: titleBackground,
titleTextColor: titleTextColor,
titleIndicatorColor: titleIndicatorColor,
Expand Down Expand Up @@ -369,7 +368,7 @@ class _TagLineJSONFeedLocaleItem {
final String id;
final _TagLineJSONFeedNewsItemOverride? overrideContent;

TagLineFeedItem overrideNewsItem(
AppNewsFeedItem overrideNewsItem(
_TagLineItemNewsItem newsItem,
String locale,
) {
Expand All @@ -384,9 +383,9 @@ class _TagLineJSONFeedLocaleItem {
);
}

final TagLineNewsItem tagLineItem = item.toTagLineItem(locale);
final AppNewsItem tagLineItem = item.toTagLineItem(locale);

return TagLineFeedItem(
return AppNewsFeedItem(
news: tagLineItem,
startDate: tagLineItem.startDate,
endDate: tagLineItem.endDate,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import 'dart:ui';

class TagLine {
const TagLine({
class AppNews {
const AppNews({
required this.news,
required this.feed,
});

final TagLineNewsList news;
final TagLineFeed feed;
final AppNewsList news;
final AppNewsFeed feed;

@override
String toString() {
return 'TagLine{news: $news, feed: $feed}';
return 'AppNews{news: $news, feed: $feed}';
}
}

class TagLineNewsList {
const TagLineNewsList(Map<String, TagLineNewsItem> news) : _news = news;
class AppNewsList {
const AppNewsList(Map<String, AppNewsItem> news) : _news = news;

final Map<String, TagLineNewsItem> _news;
final Map<String, AppNewsItem> _news;

TagLineNewsItem? operator [](String key) => _news[key];
AppNewsItem? operator [](String key) => _news[key];

@override
String toString() {
return 'TagLineNewsList{_news: $_news}';
return 'AppNewsList{_news: $_news}';
}
}

class TagLineNewsItem {
const TagLineNewsItem({
class AppNewsItem {
const AppNewsItem({
required this.id,
required this.title,
required this.message,
Expand All @@ -48,17 +48,17 @@ class TagLineNewsItem {
final String? buttonLabel;
final DateTime? startDate;
final DateTime? endDate;
final TagLineImage? image;
final TagLineStyle? style;
final AppNewsImage? image;
final AppNewsStyle? style;

@override
String toString() {
return 'TagLineNewsItem{id: $id, title: $title, message: $message, url: $url, buttonLabel: $buttonLabel, startDate: $startDate, endDate: $endDate, image: $image, style: $style}';
return 'AppNewsItem{id: $id, title: $title, message: $message, url: $url, buttonLabel: $buttonLabel, startDate: $startDate, endDate: $endDate, image: $image, style: $style}';
}
}

class TagLineStyle {
const TagLineStyle({
class AppNewsStyle {
const AppNewsStyle({
this.titleBackground,
this.titleTextColor,
this.titleIndicatorColor,
Expand All @@ -69,7 +69,7 @@ class TagLineStyle {
this.contentBackgroundColor,
});

TagLineStyle.fromHexa({
AppNewsStyle.fromHexa({
String? titleBackground,
String? titleTextColor,
String? titleIndicatorColor,
Expand Down Expand Up @@ -105,12 +105,12 @@ class TagLineStyle {

@override
String toString() {
return 'TagLineStyle{titleBackground: $titleBackground, titleTextColor: $titleTextColor, titleIndicatorColor: $titleIndicatorColor, messageBackground: $messageBackground, messageTextColor: $messageTextColor, buttonBackground: $buttonBackground, buttonTextColor: $buttonTextColor, contentBackgroundColor: $contentBackgroundColor}';
return 'AppNewsStyle{titleBackground: $titleBackground, titleTextColor: $titleTextColor, titleIndicatorColor: $titleIndicatorColor, messageBackground: $messageBackground, messageTextColor: $messageTextColor, buttonBackground: $buttonBackground, buttonTextColor: $buttonTextColor, contentBackgroundColor: $contentBackgroundColor}';
}
}

class TagLineImage {
const TagLineImage({
class AppNewsImage {
const AppNewsImage({
required this.src,
this.width,
this.alt,
Expand All @@ -122,14 +122,14 @@ class TagLineImage {

@override
String toString() {
return 'TagLineImage{src: $src, width: $width, alt: $alt}';
return 'AppNewsImage{src: $src, width: $width, alt: $alt}';
}
}

class TagLineFeed {
const TagLineFeed(this.news);
class AppNewsFeed {
const AppNewsFeed(this.news);

final List<TagLineFeedItem> news;
final List<AppNewsFeedItem> news;

bool get isNotEmpty => news.isNotEmpty;

Expand All @@ -139,15 +139,15 @@ class TagLineFeed {
}
}

class TagLineFeedItem {
const TagLineFeedItem({
class AppNewsFeedItem {
const AppNewsFeedItem({
required this.news,
DateTime? startDate,
DateTime? endDate,
}) : _startDate = startDate,
_endDate = endDate;

final TagLineNewsItem news;
final AppNewsItem news;
final DateTime? _startDate;
final DateTime? _endDate;

Expand All @@ -159,6 +159,6 @@ class TagLineFeedItem {

@override
String toString() {
return 'TagLineFeedItem{news: $news, _startDate: $_startDate, _endDate: $_endDate}';
return 'AppNewsFeedItem{news: $news, _startDate: $_startDate, _endDate: $_endDate}';
}
}
Loading

0 comments on commit 218fe46

Please sign in to comment.