mirror of
https://github.com/Iconica-Development/flutter_timeline.git
synced 2025-05-19 10:33:44 +02:00
feat(timeline-post-creation): add options to enforce image and content length
This commit is contained in:
parent
c5c394348e
commit
d6d12ab312
2 changed files with 39 additions and 0 deletions
|
@ -43,6 +43,11 @@ class TimelineOptions {
|
|||
this.postPadding = const EdgeInsets.all(12.0),
|
||||
this.filterOptions = const FilterOptions(),
|
||||
this.categoriesOptions = const CategoriesOptions(),
|
||||
this.requireImageForPost = false,
|
||||
this.minTitleLength,
|
||||
this.maxTitleLength,
|
||||
this.minContentLength,
|
||||
this.maxContentLength,
|
||||
});
|
||||
|
||||
/// Theming options for the timeline
|
||||
|
@ -121,6 +126,21 @@ class TimelineOptions {
|
|||
|
||||
/// Options for using the category selector.
|
||||
final CategoriesOptions categoriesOptions;
|
||||
|
||||
/// Require image for post
|
||||
final bool requireImageForPost;
|
||||
|
||||
/// Minimum length of the title
|
||||
final int? minTitleLength;
|
||||
|
||||
/// Maximum length of the title
|
||||
final int? maxTitleLength;
|
||||
|
||||
/// Minimum length of the post content
|
||||
final int? minContentLength;
|
||||
|
||||
/// Maximum length of the post content
|
||||
final int? maxContentLength;
|
||||
}
|
||||
|
||||
class CategoriesOptions {
|
||||
|
|
|
@ -64,6 +64,25 @@ class _TimelinePostCreationScreenState
|
|||
setState(() {
|
||||
editingDone =
|
||||
titleController.text.isNotEmpty && contentController.text.isNotEmpty;
|
||||
if (widget.options.requireImageForPost) {
|
||||
editingDone = editingDone && image != null;
|
||||
}
|
||||
if (widget.options.minTitleLength != null) {
|
||||
editingDone = editingDone &&
|
||||
titleController.text.length >= widget.options.minTitleLength!;
|
||||
}
|
||||
if (widget.options.maxTitleLength != null) {
|
||||
editingDone = editingDone &&
|
||||
titleController.text.length <= widget.options.maxTitleLength!;
|
||||
}
|
||||
if (widget.options.minContentLength != null) {
|
||||
editingDone = editingDone &&
|
||||
contentController.text.length >= widget.options.minContentLength!;
|
||||
}
|
||||
if (widget.options.maxContentLength != null) {
|
||||
editingDone = editingDone &&
|
||||
contentController.text.length <= widget.options.maxContentLength!;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue