mirror of
https://github.com/Iconica-Development/flutter_timeline.git
synced 2025-05-19 10:33:44 +02:00
fix: like and dismiss textfield
fixed unlimited liking after creating a post and multiline textfield not being dismissible
This commit is contained in:
parent
ce093f86d4
commit
27d1ef5fac
3 changed files with 179 additions and 165 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
## 2.0.1
|
||||||
|
|
||||||
|
- Fixed multiline textfield not being dismissible.
|
||||||
|
- Fixed liking a new post you created.
|
||||||
|
|
||||||
## 1.0.0 - November 27 2023
|
## 1.0.0 - November 27 2023
|
||||||
|
|
||||||
- Improved TimelineService with support for pagination
|
- Improved TimelineService with support for pagination
|
||||||
|
@ -6,4 +11,4 @@
|
||||||
|
|
||||||
## 0.0.1 - November 22 2023
|
## 0.0.1 - November 22 2023
|
||||||
|
|
||||||
- Initial release
|
- Initial release
|
||||||
|
|
|
@ -106,176 +106,184 @@ class _TimelinePostCreationScreenState
|
||||||
}
|
}
|
||||||
|
|
||||||
var theme = Theme.of(context);
|
var theme = Theme.of(context);
|
||||||
return Padding(
|
return GestureDetector(
|
||||||
padding: widget.options.padding,
|
onTap: () => FocusScope.of(context).unfocus(),
|
||||||
child: SingleChildScrollView(
|
child: Padding(
|
||||||
child: Column(
|
padding: widget.options.padding,
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: SingleChildScrollView(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
children: [
|
mainAxisSize: MainAxisSize.min,
|
||||||
Text(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
widget.options.translations.title,
|
children: [
|
||||||
style: theme.textTheme.displaySmall,
|
Text(
|
||||||
),
|
widget.options.translations.title,
|
||||||
widget.options.textInputBuilder?.call(
|
style: theme.textTheme.displaySmall,
|
||||||
titleController,
|
|
||||||
null,
|
|
||||||
'',
|
|
||||||
) ??
|
|
||||||
TextField(
|
|
||||||
controller: titleController,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
Text(
|
|
||||||
widget.options.translations.content,
|
|
||||||
style: theme.textTheme.displaySmall,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(
|
|
||||||
widget.options.translations.contentDescription,
|
|
||||||
style: theme.textTheme.bodyMedium,
|
|
||||||
),
|
|
||||||
// input field for the content
|
|
||||||
SizedBox(
|
|
||||||
height: 100,
|
|
||||||
child: TextField(
|
|
||||||
controller: contentController,
|
|
||||||
textCapitalization: TextCapitalization.sentences,
|
|
||||||
expands: true,
|
|
||||||
maxLines: null,
|
|
||||||
minLines: null,
|
|
||||||
),
|
),
|
||||||
),
|
widget.options.textInputBuilder?.call(
|
||||||
const SizedBox(
|
titleController,
|
||||||
height: 16,
|
null,
|
||||||
),
|
'',
|
||||||
// input field for the content
|
) ??
|
||||||
Text(
|
TextField(
|
||||||
widget.options.translations.uploadImage,
|
controller: titleController,
|
||||||
style: theme.textTheme.displaySmall,
|
),
|
||||||
),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
widget.options.translations.uploadImageDescription,
|
widget.options.translations.content,
|
||||||
style: theme.textTheme.bodyMedium,
|
style: theme.textTheme.displaySmall,
|
||||||
),
|
),
|
||||||
// image picker field
|
const SizedBox(height: 4),
|
||||||
const SizedBox(
|
Text(
|
||||||
height: 8,
|
widget.options.translations.contentDescription,
|
||||||
),
|
style: theme.textTheme.bodyMedium,
|
||||||
Stack(
|
),
|
||||||
children: [
|
// input field for the content
|
||||||
GestureDetector(
|
SizedBox(
|
||||||
onTap: () async {
|
height: 100,
|
||||||
// open a dialog to choose between camera and gallery
|
child: TextField(
|
||||||
var result = await showModalBottomSheet<Uint8List?>(
|
controller: contentController,
|
||||||
context: context,
|
textCapitalization: TextCapitalization.sentences,
|
||||||
builder: (context) => Container(
|
expands: true,
|
||||||
padding: const EdgeInsets.all(8.0),
|
maxLines: null,
|
||||||
color: theme.colorScheme.background,
|
minLines: null,
|
||||||
child: ImagePicker(
|
),
|
||||||
imagePickerConfig: widget.options.imagePickerConfig,
|
),
|
||||||
imagePickerTheme: widget.options.imagePickerTheme,
|
const SizedBox(
|
||||||
),
|
height: 16,
|
||||||
),
|
),
|
||||||
);
|
// input field for the content
|
||||||
if (result != null) {
|
Text(
|
||||||
setState(() {
|
widget.options.translations.uploadImage,
|
||||||
image = result;
|
style: theme.textTheme.displaySmall,
|
||||||
});
|
),
|
||||||
}
|
Text(
|
||||||
checkIfEditingDone();
|
widget.options.translations.uploadImageDescription,
|
||||||
},
|
style: theme.textTheme.bodyMedium,
|
||||||
child: image != null
|
),
|
||||||
? ClipRRect(
|
// image picker field
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
const SizedBox(
|
||||||
child: Image.memory(
|
height: 8,
|
||||||
image!,
|
),
|
||||||
width: double.infinity,
|
Stack(
|
||||||
height: 150.0,
|
children: [
|
||||||
fit: BoxFit.cover,
|
GestureDetector(
|
||||||
// give it a rounded border
|
onTap: () async {
|
||||||
|
// open a dialog to choose between camera and gallery
|
||||||
|
var result = await showModalBottomSheet<Uint8List?>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
color: theme.colorScheme.background,
|
||||||
|
child: ImagePicker(
|
||||||
|
imagePickerConfig: widget.options.imagePickerConfig,
|
||||||
|
imagePickerTheme: widget.options.imagePickerTheme,
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
: DottedBorder(
|
);
|
||||||
radius: const Radius.circular(8.0),
|
if (result != null) {
|
||||||
color: theme.textTheme.displayMedium?.color ??
|
setState(() {
|
||||||
Colors.white,
|
image = result;
|
||||||
child: const SizedBox(
|
});
|
||||||
width: double.infinity,
|
}
|
||||||
height: 150.0,
|
checkIfEditingDone();
|
||||||
child: Icon(
|
},
|
||||||
Icons.image,
|
child: image != null
|
||||||
size: 32,
|
? ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
child: Image.memory(
|
||||||
|
image!,
|
||||||
|
width: double.infinity,
|
||||||
|
height: 150.0,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
// give it a rounded border
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: DottedBorder(
|
||||||
|
radius: const Radius.circular(8.0),
|
||||||
|
color: theme.textTheme.displayMedium?.color ??
|
||||||
|
Colors.white,
|
||||||
|
child: const SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 150.0,
|
||||||
|
child: Icon(
|
||||||
|
Icons.image,
|
||||||
|
size: 32,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
// if an image is selected, show a delete button
|
|
||||||
if (image != null) ...[
|
|
||||||
Positioned(
|
|
||||||
top: 8,
|
|
||||||
right: 8,
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
image = null;
|
|
||||||
});
|
|
||||||
checkIfEditingDone();
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.black.withOpacity(0.5),
|
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
|
||||||
),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.delete,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
// if an image is selected, show a delete button
|
||||||
],
|
if (image != null) ...[
|
||||||
),
|
Positioned(
|
||||||
|
top: 8,
|
||||||
const SizedBox(height: 16),
|
right: 8,
|
||||||
|
child: GestureDetector(
|
||||||
Text(
|
onTap: () {
|
||||||
widget.options.translations.commentsTitle,
|
setState(() {
|
||||||
style: theme.textTheme.displaySmall,
|
image = null;
|
||||||
),
|
});
|
||||||
Text(
|
checkIfEditingDone();
|
||||||
widget.options.translations.allowCommentsDescription,
|
},
|
||||||
style: theme.textTheme.bodyMedium,
|
child: Container(
|
||||||
),
|
decoration: BoxDecoration(
|
||||||
// radio buttons for yes or no
|
color: Colors.black.withOpacity(0.5),
|
||||||
Switch(
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
value: allowComments,
|
),
|
||||||
onChanged: (newValue) {
|
child: const Icon(
|
||||||
setState(() {
|
Icons.delete,
|
||||||
allowComments = newValue;
|
color: Colors.white,
|
||||||
});
|
),
|
||||||
},
|
),
|
||||||
),
|
|
||||||
// const Spacer(),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.bottomCenter,
|
|
||||||
child: (widget.options.buttonBuilder != null)
|
|
||||||
? widget.options.buttonBuilder!(
|
|
||||||
context,
|
|
||||||
onPostCreated,
|
|
||||||
widget.options.translations.checkPost,
|
|
||||||
enabled: editingDone,
|
|
||||||
)
|
|
||||||
: ElevatedButton(
|
|
||||||
onPressed: editingDone ? onPostCreated : null,
|
|
||||||
child: Text(
|
|
||||||
widget.options.translations.checkPost,
|
|
||||||
style: theme.textTheme.bodyMedium,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
Text(
|
||||||
|
widget.options.translations.commentsTitle,
|
||||||
|
style: theme.textTheme.displaySmall,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
widget.options.translations.allowCommentsDescription,
|
||||||
|
style: theme.textTheme.bodyMedium,
|
||||||
|
),
|
||||||
|
// radio buttons for yes or no
|
||||||
|
Switch(
|
||||||
|
value: allowComments,
|
||||||
|
onChanged: (newValue) {
|
||||||
|
setState(() {
|
||||||
|
allowComments = newValue;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.bottomCenter,
|
||||||
|
child: (widget.options.buttonBuilder != null)
|
||||||
|
? widget.options.buttonBuilder!(
|
||||||
|
context,
|
||||||
|
onPostCreated,
|
||||||
|
widget.options.translations.checkPost,
|
||||||
|
enabled: editingDone,
|
||||||
|
)
|
||||||
|
: ElevatedButton(
|
||||||
|
onPressed: editingDone
|
||||||
|
? () async {
|
||||||
|
await onPostCreated();
|
||||||
|
await widget.service.postService
|
||||||
|
.fetchPosts(null);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
child: Text(
|
||||||
|
widget.options.translations.checkPost,
|
||||||
|
style: theme.textTheme.bodyMedium,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -357,7 +357,8 @@ class _TimelinePostScreenState extends State<_TimelinePostScreen> {
|
||||||
'${post.likes} ${widget.options.translations.likesTitle}',
|
'${post.likes} ${widget.options.translations.likesTitle}',
|
||||||
style: widget
|
style: widget
|
||||||
.options.theme.textStyles.postLikeTitleAndAmount ??
|
.options.theme.textStyles.postLikeTitleAndAmount ??
|
||||||
theme.textTheme.titleSmall,
|
theme.textTheme.titleSmall
|
||||||
|
?.copyWith(color: Colors.black),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text.rich(
|
Text.rich(
|
||||||
|
|
Loading…
Reference in a new issue