1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-24 22:09:21 +00:00
comunicmobile/lib/models/new_post.dart

56 lines
1.5 KiB
Dart
Raw Normal View History

2019-07-05 09:40:43 +00: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 17:03:20 +00:00
import 'api_request.dart';
2019-07-05 09:40:43 +00:00
/// New post information
///
/// @author Pierre HUBERT
2020-04-25 09:58:45 +00:00
class NewSurvey {
final String question;
final Set<String> answers;
final bool allowNewChoicesCreation;
2020-04-25 09:58:45 +00:00
const NewSurvey({
required this.question,
required this.answers,
required this.allowNewChoicesCreation,
2022-03-11 16:13:54 +00:00
}) : assert(answers.length > 1);
2020-04-25 09:58:45 +00:00
}
2019-07-05 09:40:43 +00: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 09:40:43 +00:00
final PostKind kind;
final DateTime? timeEnd;
final NewSurvey? survey;
final String? youtubeId;
2019-07-05 09:40:43 +00:00
2020-04-24 11:35:05 +00: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,
2022-03-11 16:13:54 +00:00
}) : assert(kind != PostKind.TEXT || content.length > 3),
2020-04-24 11:35:05 +00:00
assert(kind != PostKind.IMAGE || image != null),
2020-04-25 12:38:15 +00:00
assert(kind != PostKind.WEB_LINK || url != null),
2020-04-25 06:23:52 +00:00
assert(kind != PostKind.PDF || pdf != null),
2020-04-25 09:58:45 +00:00
assert(kind != PostKind.COUNTDOWN || timeEnd != null),
2020-04-25 15:16:33 +00:00
assert(kind != PostKind.SURVEY || survey != null),
assert(kind != PostKind.YOUTUBE || youtubeId != null);
2019-07-05 09:40:43 +00:00
}