mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 21:09:21 +00:00
Improved post visibility picker dialog
This commit is contained in:
parent
a97ac81de2
commit
bd548fe532
@ -9,7 +9,7 @@ import 'package:meta/meta.dart';
|
|||||||
/// @author Pierre HUBERT
|
/// @author Pierre HUBERT
|
||||||
|
|
||||||
/// Show post visibility level picker and return selected visibility level
|
/// Show post visibility level picker and return selected visibility level
|
||||||
Future<PostVisibilityLevel> showPostVisibilityPicker({
|
Future<PostVisibilityLevel> showPostVisibilityPickerDialog({
|
||||||
@required BuildContext context,
|
@required BuildContext context,
|
||||||
@required PostVisibilityLevel initialLevel,
|
@required PostVisibilityLevel initialLevel,
|
||||||
@required bool isGroup,
|
@required bool isGroup,
|
||||||
@ -20,11 +20,28 @@ Future<PostVisibilityLevel> showPostVisibilityPicker({
|
|||||||
|
|
||||||
final newLevel = await showDialog<PostVisibilityLevel>(
|
final newLevel = await showDialog<PostVisibilityLevel>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (c) => AlertDialog(
|
builder: (c) => _PostVisibilityPickerWidget(
|
||||||
title: Text(tr("Select new post visibility level")),
|
isGroup: isGroup,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
// Show all options
|
return newLevel == null ? initialLevel : newLevel;
|
||||||
content: Column(
|
}
|
||||||
|
|
||||||
|
class _PostVisibilityPickerWidget extends StatelessWidget {
|
||||||
|
final bool isGroup;
|
||||||
|
|
||||||
|
const _PostVisibilityPickerWidget({Key key, @required this.isGroup})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext c) => AlertDialog(
|
||||||
|
title: Text(tr("Select new post visibility level")),
|
||||||
|
|
||||||
|
// Show all options
|
||||||
|
content: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(maxHeight: 200),
|
||||||
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
// Public
|
// Public
|
||||||
PostVisibilityLevelTile(
|
PostVisibilityLevelTile(
|
||||||
@ -58,17 +75,15 @@ Future<PostVisibilityLevel> showPostVisibilityPicker({
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
// Dialog actions
|
|
||||||
actions: <Widget>[
|
|
||||||
// Cancel
|
|
||||||
TextButton(
|
|
||||||
child: Text(tr("Cancel").toUpperCase()),
|
|
||||||
onPressed: () => Navigator.pop(c, null),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
|
||||||
|
|
||||||
return newLevel == null ? initialLevel : newLevel;
|
// Dialog actions
|
||||||
|
actions: <Widget>[
|
||||||
|
// Cancel
|
||||||
|
TextButton(
|
||||||
|
child: Text(tr("Cancel").toUpperCase()),
|
||||||
|
onPressed: () => Navigator.pop(c, null),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
@ -10,6 +10,7 @@ import 'package:comunic/models/comment.dart';
|
|||||||
import 'package:comunic/models/new_comment.dart';
|
import 'package:comunic/models/new_comment.dart';
|
||||||
import 'package:comunic/models/post.dart';
|
import 'package:comunic/models/post.dart';
|
||||||
import 'package:comunic/models/user.dart';
|
import 'package:comunic/models/user.dart';
|
||||||
|
import 'package:comunic/ui/dialogs/post_visibility_picker_dialog.dart';
|
||||||
import 'package:comunic/ui/tiles/comment_tile.dart';
|
import 'package:comunic/ui/tiles/comment_tile.dart';
|
||||||
import 'package:comunic/ui/widgets/account_image_widget.dart';
|
import 'package:comunic/ui/widgets/account_image_widget.dart';
|
||||||
import 'package:comunic/ui/widgets/countdown_widget.dart';
|
import 'package:comunic/ui/widgets/countdown_widget.dart';
|
||||||
@ -22,7 +23,6 @@ import 'package:comunic/utils/date_utils.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/navigation_utils.dart';
|
import 'package:comunic/utils/navigation_utils.dart';
|
||||||
import 'package:comunic/utils/post_utils.dart';
|
|
||||||
import 'package:comunic/utils/ui_utils.dart';
|
import 'package:comunic/utils/ui_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
@ -573,7 +573,7 @@ class _PostTileState extends State<PostTile> {
|
|||||||
|
|
||||||
/// Update post visibility level
|
/// Update post visibility level
|
||||||
Future<void> updatePostVisibilityLevel() async {
|
Future<void> updatePostVisibilityLevel() async {
|
||||||
final newLevel = await showPostVisibilityPicker(
|
final newLevel = await showPostVisibilityPickerDialog(
|
||||||
context: context,
|
context: context,
|
||||||
initialLevel: widget.post.visibilityLevel,
|
initialLevel: widget.post.visibilityLevel,
|
||||||
isGroup: widget.post.isGroupPost,
|
isGroup: widget.post.isGroupPost,
|
||||||
|
@ -6,10 +6,10 @@ 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/dialogs/post_visibility_picker_dialog.dart';
|
||||||
import 'package:comunic/ui/widgets/post_container_widget.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/ui_utils.dart';
|
import 'package:comunic/utils/ui_utils.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -219,7 +219,7 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
|
|||||||
|
|
||||||
/// Change post visibility level
|
/// Change post visibility level
|
||||||
Future<void> _changeVisibilityLevel() async {
|
Future<void> _changeVisibilityLevel() async {
|
||||||
final newLevel = await showPostVisibilityPicker(
|
final newLevel = await showPostVisibilityPickerDialog(
|
||||||
context: context,
|
context: context,
|
||||||
initialLevel: _postVisibilityLevel,
|
initialLevel: _postVisibilityLevel,
|
||||||
isGroup: widget.postTarget == PostTarget.GROUP_PAGE,
|
isGroup: widget.postTarget == PostTarget.GROUP_PAGE,
|
||||||
|
Loading…
Reference in New Issue
Block a user