1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 12:59:21 +00:00

Improved post visibility picker dialog

This commit is contained in:
Pierre HUBERT 2021-03-17 17:53:07 +01:00
parent a97ac81de2
commit bd548fe532
3 changed files with 35 additions and 20 deletions

View File

@ -9,7 +9,7 @@ import 'package:meta/meta.dart';
/// @author Pierre HUBERT
/// Show post visibility level picker and return selected visibility level
Future<PostVisibilityLevel> showPostVisibilityPicker({
Future<PostVisibilityLevel> showPostVisibilityPickerDialog({
@required BuildContext context,
@required PostVisibilityLevel initialLevel,
@required bool isGroup,
@ -20,11 +20,28 @@ Future<PostVisibilityLevel> showPostVisibilityPicker({
final newLevel = await showDialog<PostVisibilityLevel>(
context: context,
builder: (c) => AlertDialog(
builder: (c) => _PostVisibilityPickerWidget(
isGroup: isGroup,
),
);
return newLevel == null ? initialLevel : newLevel;
}
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: Column(
content: ConstrainedBox(
constraints: BoxConstraints(maxHeight: 200),
child: Column(
children: <Widget>[
// Public
PostVisibilityLevelTile(
@ -58,6 +75,7 @@ Future<PostVisibilityLevel> showPostVisibilityPicker({
),
],
),
),
// Dialog actions
actions: <Widget>[
@ -67,8 +85,5 @@ Future<PostVisibilityLevel> showPostVisibilityPicker({
onPressed: () => Navigator.pop(c, null),
),
],
),
);
return newLevel == null ? initialLevel : newLevel;
}

View File

@ -10,6 +10,7 @@ import 'package:comunic/models/comment.dart';
import 'package:comunic/models/new_comment.dart';
import 'package:comunic/models/post.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/widgets/account_image_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/intl_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:flutter/material.dart';
import 'package:flutter/rendering.dart';
@ -573,7 +573,7 @@ class _PostTileState extends State<PostTile> {
/// Update post visibility level
Future<void> updatePostVisibilityLevel() async {
final newLevel = await showPostVisibilityPicker(
final newLevel = await showPostVisibilityPickerDialog(
context: context,
initialLevel: widget.post.visibilityLevel,
isGroup: widget.post.isGroupPost,

View File

@ -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_youtube_link_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/utils/files_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:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
@ -219,7 +219,7 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
/// Change post visibility level
Future<void> _changeVisibilityLevel() async {
final newLevel = await showPostVisibilityPicker(
final newLevel = await showPostVisibilityPickerDialog(
context: context,
initialLevel: _postVisibilityLevel,
isGroup: widget.postTarget == PostTarget.GROUP_PAGE,