1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-02-16 21:52:38 +00:00
comunicmobile/lib/models/new_post.dart

62 lines
1.7 KiB
Dart
Raw Normal View History

2019-07-05 11:40:43 +02:00
import 'package:comunic/enums/post_kind.dart';
import 'package:comunic/enums/post_target.dart';
import 'package:comunic/enums/post_visibility_level.dart';
2021-03-13 18:03:20 +01:00
import 'api_request.dart';
2019-07-05 11:40:43 +02:00
/// New post information
///
/// @author Pierre HUBERT
2020-04-25 11:58:45 +02:00
class NewSurvey {
final String question;
final Set<String> answers;
final bool allowNewChoicesCreation;
2020-04-25 11:58:45 +02:00
const NewSurvey({
required this.question,
required this.answers,
required this.allowNewChoicesCreation,
2020-04-25 11:58:45 +02:00
}) : assert(question != null),
assert(answers.length > 1),
assert(allowNewChoicesCreation != null);
2020-04-25 11:58:45 +02:00
}
2019-07-05 11:40:43 +02:00
class NewPost {
final PostTarget target;
final int targetID;
final PostVisibilityLevel visibility;
final String content;
final BytesFile? image;
final String? url;
final List<int>? pdf;
2019-07-05 11:40:43 +02:00
final PostKind kind;
final DateTime? timeEnd;
final NewSurvey? survey;
final String? youtubeId;
2019-07-05 11:40:43 +02:00
2020-04-24 13:35:05 +02:00
const NewPost({
required this.target,
required this.targetID,
required this.visibility,
required this.content,
required this.kind,
required this.image,
required this.url,
required this.pdf,
required this.timeEnd,
required this.survey,
required this.youtubeId,
2019-07-05 11:40:43 +02:00
}) : assert(target != null),
assert(targetID != null),
assert(visibility != null),
assert(content != null),
assert(kind != PostKind.TEXT || content.length > 3),
2020-04-24 13:35:05 +02:00
assert(kind != PostKind.IMAGE || image != null),
2020-04-25 14:38:15 +02:00
assert(kind != PostKind.WEB_LINK || url != null),
2020-04-25 08:23:52 +02:00
assert(kind != PostKind.PDF || pdf != null),
2020-04-25 11:58:45 +02:00
assert(kind != PostKind.COUNTDOWN || timeEnd != null),
2020-04-25 17:16:33 +02:00
assert(kind != PostKind.SURVEY || survey != null),
assert(kind != PostKind.YOUTUBE || youtubeId != null);
2019-07-05 11:40:43 +02:00
}