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

63 lines
1.7 KiB
Dart
Raw Normal View History

2019-07-05 09:40:43 +00:00
import 'dart:io';
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';
/// 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;
final File 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
}