Skip to content

Commit 16b008e

Browse files
committed
feat: add SuggestedContentTemplate model
- Defines suggestion block config - Includes type, display, content - Supports title and description
1 parent 1696c63 commit 16b008e

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import 'package:equatable/equatable.dart';
2+
import 'package:ht_shared/src/models/core/content_type.dart';
3+
import 'package:ht_shared/src/models/feed_decorators/suggested_content_display_type.dart';
4+
import 'package:ht_shared/src/models/feed_extras/feed_template_types.dart';
5+
import 'package:json_annotation/json_annotation.dart';
6+
7+
part 'suggested_content_template.g.dart';
8+
9+
/// {@template suggested_content_template}
10+
/// Defines the static content and configuration for a suggestion block.
11+
/// The 'type' of an instance should match a [SuggestionTemplateType] value.
12+
/// {@endtemplate}
13+
@JsonSerializable(explicitToJson: true)
14+
class SuggestedContentTemplate extends Equatable {
15+
/// {@macro suggested_content_template}
16+
const SuggestedContentTemplate({
17+
required this.type,
18+
required this.displayType,
19+
required this.suggestedContentType,
20+
this.title,
21+
this.description,
22+
this.maxItemsToDisplay,
23+
this.fetchCriteria,
24+
});
25+
26+
/// Creates a [SuggestedContentTemplate] from JSON data.
27+
factory SuggestedContentTemplate.fromJson(Map<String, dynamic> json) =>
28+
_$SuggestedContentTemplateFromJson(json);
29+
30+
/// The type of suggestion template, matching a [SuggestionTemplateType] value.
31+
final SuggestionTemplateType type;
32+
33+
/// An optional title for the suggestion block (e.g., "You might like...").
34+
final String? title;
35+
36+
/// An optional description for the suggestion block.
37+
final String? description;
38+
39+
/// The visual presentation or layout style for this suggestion block.
40+
final SuggestedContentDisplayType displayType;
41+
42+
/// Defines what kind of primary content this suggestion block will contain
43+
/// (e.g., if suggesting categories, this would be [ContentType.category]).
44+
final ContentType suggestedContentType;
45+
46+
/// Maximum number of items to display within this suggestion block.
47+
final int? maxItemsToDisplay;
48+
49+
/// Criteria for fetching dynamic items, e.g., "popular", "newest".
50+
/// This is a simple string; the decorator will interpret it.
51+
final String? fetchCriteria;
52+
53+
/// Converts this [SuggestedContentTemplate] instance to JSON data.
54+
Map<String, dynamic> toJson() => _$SuggestedContentTemplateToJson(this);
55+
56+
@override
57+
List<Object?> get props => [
58+
type,
59+
title,
60+
description,
61+
displayType,
62+
suggestedContentType,
63+
maxItemsToDisplay,
64+
fetchCriteria,
65+
];
66+
}

lib/src/models/feed_extras/suggested_content_template.g.dart

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)