feat: add methods in timeline service interface

This commit is contained in:
Freek van de Ven 2023-11-20 07:52:47 +01:00
parent fb8ca56a87
commit d24731412f
5 changed files with 36 additions and 4 deletions

View file

@ -14,6 +14,11 @@ environment:
dependencies:
flutter:
sdk: flutter
cloud_firestore: ^4.13.1
firebase_core: ^2.22.0
firebase_storage: ^11.5.1
uuid: ^4.2.1
flutter_timeline_interface:
git:
url: https://github.com/Iconica-Development/flutter_timeline.git

View file

@ -11,8 +11,9 @@ class TimelinePostReaction {
required this.id,
required this.postId,
required this.creatorId,
required this.reaction,
required this.createdAt,
this.reaction,
this.imageUrl,
this.creator,
});
@ -28,8 +29,11 @@ class TimelinePostReaction {
/// The creator of the post. If null it isn't loaded yet.
final TimelinePosterUserModel? creator;
/// The reactiontext
final String reaction;
/// The reaction text if the creator sent one
final String? reaction;
/// The url of the image if the creator sent one
final String? imageUrl;
/// Reaction creation date.
final DateTime createdAt;

View file

@ -0,0 +1,17 @@
import 'dart:typed_data';
import 'package:flutter_timeline_interface/src/model/timeline_post.dart';
import 'package:flutter_timeline_interface/src/model/timeline_reaction.dart';
abstract class TimelineService {
Future<void> deletePost(TimelinePost post);
Future<void> createPost(TimelinePost post);
Future<List<TimelinePost>> fetchPosts(String? category);
Future<TimelinePost> fetchPostDetails(TimelinePost post);
Future<void> reactToPost(
TimelinePost post,
TimelinePostReaction reaction, {
Uint8List image,
});
Future<void> likePost(TimelinePost post);
}

View file

@ -0,0 +1,5 @@
import 'package:flutter_timeline_interface/src/model/timeline_poster.dart';
mixin TimelineUserService {
Future<TimelinePosterUserModel?> getUser(String userId);
}

View file

@ -155,9 +155,10 @@ class TimelinePostScreen extends StatelessWidget {
),
],
const SizedBox(width: 10),
// TODO(anyone): show image if the user send one
Expanded(
child: Text(
reaction.reaction,
reaction.reaction ?? '',
style: theme.textTheme.bodyMedium,
// text should go to new line
softWrap: true,