1
0
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:
Pierre HUBERT 2020-05-16 09:20:17 +02:00
parent bc3972082c
commit 922fce541f

View File

@ -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_url_dialog.dart';
import 'package:comunic/ui/dialogs/input_youtube_link_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/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/files_utils.dart';
import 'package:comunic/utils/intl_utils.dart'; import 'package:comunic/utils/intl_utils.dart';
import 'package:comunic/utils/post_utils.dart'; import 'package:comunic/utils/post_utils.dart';
@ -99,108 +100,113 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return PostContainer(
children: <Widget>[ child: Card(
// Post text content child: Column(
Padding( children: <Widget>[
padding: const EdgeInsets.only(left: 8.0, right: 8.0), // Post text content
child: TextField( Padding(
controller: _postTextController, padding: const EdgeInsets.only(left: 8.0, right: 8.0),
minLines: 3, child: TextField(
maxLines: 10, controller: _postTextController,
decoration: InputDecoration(hintText: tr("Create a new post...")), minLines: 3,
onChanged: (s) => setState(() {}), 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,
),
],
),
),
), ),
),
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 // Include image button
_PostOptionWidget( _PostOptionWidget(
icon: PostVisibilityLevelsMapIcons[_postVisibilityLevel], icon: Icons.image,
selected: false, selected: postKind == PostKind.IMAGE,
customColor: Colors.black, onTap: _pickImageForPost,
onTap: _changeVisibilityLevel, ),
),
// Submit post button // Web link
_isCreating _PostOptionWidget(
? Container() icon: Icons.link,
: FlatButton( selected: postKind == PostKind.WEB_LINK,
child: Text(tr("Send").toUpperCase()), onTap: _pickURLForPost,
onPressed: canSubmitForm ? _submitForm : null, ),
color: _ActiveButtonsColor,
textColor: _ActiveButtonsTextColor, // Include PDF button
disabledColor: _InactiveButtonsColor, _PostOptionWidget(
disabledTextColor: _InactiveButtonsTextColor, 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 /// Pick a new YouTube video
Future<void> _pickYouTubeVideo() async { Future<void> _pickYouTubeVideo() async {
final youtubeID = await showInputYouTubeIDDialog(context, _youtubeID); final youtubeID = await showInputYouTubeIDDialog(context, _youtubeID);
if (youtubeID == null) return; if (youtubeID == null) return;
@ -347,7 +352,6 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
setState(() { setState(() {
_youtubeID = youtubeID; _youtubeID = youtubeID;
}); });
} }
/// Submit new post /// Submit new post