mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-25 22:39:22 +00:00
Put post create form into a card
This commit is contained in:
parent
bc3972082c
commit
922fce541f
@ -8,6 +8,7 @@ import 'package:comunic/models/new_post.dart';
|
||||
import 'package:comunic/ui/dialogs/input_url_dialog.dart';
|
||||
import 'package:comunic/ui/dialogs/input_youtube_link_dialog.dart';
|
||||
import 'package:comunic/ui/dialogs/new_survey_dialog.dart';
|
||||
import 'package:comunic/ui/widgets/post_container_widget.dart';
|
||||
import 'package:comunic/utils/files_utils.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:comunic/utils/post_utils.dart';
|
||||
@ -99,108 +100,113 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
// Post text content
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
child: TextField(
|
||||
controller: _postTextController,
|
||||
minLines: 3,
|
||||
maxLines: 10,
|
||||
decoration: InputDecoration(hintText: tr("Create a new post...")),
|
||||
onChanged: (s) => setState(() {}),
|
||||
),
|
||||
),
|
||||
|
||||
// Post options
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 16.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
// Text post button
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
_PostOptionWidget(
|
||||
icon: Icons.text_format,
|
||||
selected: postKind == PostKind.TEXT,
|
||||
onTap: _resetPostSelection),
|
||||
|
||||
// Include image button
|
||||
_PostOptionWidget(
|
||||
icon: Icons.image,
|
||||
selected: postKind == PostKind.IMAGE,
|
||||
onTap: _pickImageForPost,
|
||||
),
|
||||
|
||||
// Web link
|
||||
_PostOptionWidget(
|
||||
icon: Icons.link,
|
||||
selected: postKind == PostKind.WEB_LINK,
|
||||
onTap: _pickURLForPost,
|
||||
),
|
||||
|
||||
// Include PDF button
|
||||
_PostOptionWidget(
|
||||
icon: Icons.picture_as_pdf,
|
||||
selected: postKind == PostKind.PDF,
|
||||
onTap: _pickPDFForPost,
|
||||
),
|
||||
|
||||
// Add countdown timer
|
||||
_PostOptionWidget(
|
||||
icon: Icons.timer,
|
||||
selected: postKind == PostKind.COUNTDOWN,
|
||||
onTap: _pickCountdownTime,
|
||||
),
|
||||
|
||||
// Add survey
|
||||
_PostOptionWidget(
|
||||
icon: Icons.insert_chart,
|
||||
selected: postKind == PostKind.SURVEY,
|
||||
onTap: _pickSurvey,
|
||||
),
|
||||
|
||||
// Specify YouTube video ID
|
||||
_PostOptionWidget(
|
||||
icon: Icons.ondemand_video,
|
||||
selected: postKind == PostKind.YOUTUBE,
|
||||
onTap: _pickYouTubeVideo,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
return PostContainer(
|
||||
child: Card(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
// Post text content
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
child: TextField(
|
||||
controller: _postTextController,
|
||||
minLines: 3,
|
||||
maxLines: 10,
|
||||
decoration:
|
||||
InputDecoration(hintText: tr("Create a new post...")),
|
||||
onChanged: (s) => setState(() {}),
|
||||
),
|
||||
),
|
||||
|
||||
Container(width: 20),
|
||||
// Post options
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 16.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
// Text post button
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
_PostOptionWidget(
|
||||
icon: Icons.text_format,
|
||||
selected: postKind == PostKind.TEXT,
|
||||
onTap: _resetPostSelection),
|
||||
|
||||
// Post visibility level
|
||||
_PostOptionWidget(
|
||||
icon: PostVisibilityLevelsMapIcons[_postVisibilityLevel],
|
||||
selected: false,
|
||||
customColor: Colors.black,
|
||||
onTap: _changeVisibilityLevel,
|
||||
),
|
||||
// Include image button
|
||||
_PostOptionWidget(
|
||||
icon: Icons.image,
|
||||
selected: postKind == PostKind.IMAGE,
|
||||
onTap: _pickImageForPost,
|
||||
),
|
||||
|
||||
// Submit post button
|
||||
_isCreating
|
||||
? Container()
|
||||
: FlatButton(
|
||||
child: Text(tr("Send").toUpperCase()),
|
||||
onPressed: canSubmitForm ? _submitForm : null,
|
||||
color: _ActiveButtonsColor,
|
||||
textColor: _ActiveButtonsTextColor,
|
||||
disabledColor: _InactiveButtonsColor,
|
||||
disabledTextColor: _InactiveButtonsTextColor,
|
||||
// Web link
|
||||
_PostOptionWidget(
|
||||
icon: Icons.link,
|
||||
selected: postKind == PostKind.WEB_LINK,
|
||||
onTap: _pickURLForPost,
|
||||
),
|
||||
|
||||
// Include PDF button
|
||||
_PostOptionWidget(
|
||||
icon: Icons.picture_as_pdf,
|
||||
selected: postKind == PostKind.PDF,
|
||||
onTap: _pickPDFForPost,
|
||||
),
|
||||
|
||||
// Add countdown timer
|
||||
_PostOptionWidget(
|
||||
icon: Icons.timer,
|
||||
selected: postKind == PostKind.COUNTDOWN,
|
||||
onTap: _pickCountdownTime,
|
||||
),
|
||||
|
||||
// Add survey
|
||||
_PostOptionWidget(
|
||||
icon: Icons.insert_chart,
|
||||
selected: postKind == PostKind.SURVEY,
|
||||
onTap: _pickSurvey,
|
||||
),
|
||||
|
||||
// Specify YouTube video ID
|
||||
_PostOptionWidget(
|
||||
icon: Icons.ondemand_video,
|
||||
selected: postKind == PostKind.YOUTUBE,
|
||||
onTap: _pickYouTubeVideo,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
Container(width: 20),
|
||||
|
||||
// Post visibility level
|
||||
_PostOptionWidget(
|
||||
icon: PostVisibilityLevelsMapIcons[_postVisibilityLevel],
|
||||
selected: false,
|
||||
customColor: Colors.black,
|
||||
onTap: _changeVisibilityLevel,
|
||||
),
|
||||
|
||||
// Submit post button
|
||||
_isCreating
|
||||
? Container()
|
||||
: FlatButton(
|
||||
child: Text(tr("Send").toUpperCase()),
|
||||
onPressed: canSubmitForm ? _submitForm : null,
|
||||
color: _ActiveButtonsColor,
|
||||
textColor: _ActiveButtonsTextColor,
|
||||
disabledColor: _InactiveButtonsColor,
|
||||
disabledTextColor: _InactiveButtonsTextColor,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -338,7 +344,6 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
|
||||
|
||||
/// Pick a new YouTube video
|
||||
Future<void> _pickYouTubeVideo() async {
|
||||
|
||||
final youtubeID = await showInputYouTubeIDDialog(context, _youtubeID);
|
||||
|
||||
if (youtubeID == null) return;
|
||||
@ -347,7 +352,6 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
|
||||
setState(() {
|
||||
_youtubeID = youtubeID;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// Submit new post
|
||||
|
Loading…
Reference in New Issue
Block a user