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

63 lines
1.8 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';
import 'package:meta/meta.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,
2020-04-25 09:58:45 +00:00
}) : assert(question != null),
assert(answers.length > 1),
assert(allowNewChoicesCreation != null);
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;
2021-03-13 17:03:20 +00:00
final BytesFile image;
2020-04-25 12:38:15 +00:00
final String url;
2020-04-24 11:35:05 +00:00
final List<int> pdf;
2019-07-05 09:40:43 +00:00
final PostKind kind;
2020-04-25 06:23:52 +00:00
final DateTime timeEnd;
2020-04-25 09:58:45 +00:00
final NewSurvey survey;
2020-04-25 15:16:33 +00:00
final String youtubeId;
2019-07-05 09:40:43 +00:00
2020-04-24 11:35:05 +00:00
const NewPost({
2019-07-05 09:40:43 +00:00
@required this.target,
@required this.targetID,
@required this.visibility,
@required this.content,
@required this.kind,
@required this.image,
2020-04-25 12:38:15 +00:00
@required this.url,
2020-04-24 11:35:05 +00:00
@required this.pdf,
2020-04-25 06:23:52 +00:00
@required this.timeEnd,
2020-04-25 09:58:45 +00:00
@required this.survey,
2020-04-25 15:16:33 +00:00
@required this.youtubeId,
2019-07-05 09:40:43 +00:00
}) : assert(target != null),
assert(targetID != null),
assert(visibility != null),
assert(content != null),
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
}