mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-03 19:54:12 +00:00 
			
		
		
		
	Improved post visibility picker dialog
This commit is contained in:
		@@ -1,74 +0,0 @@
 | 
			
		||||
import 'package:comunic/enums/post_visibility_level.dart';
 | 
			
		||||
import 'package:comunic/ui/tiles/post_visibility_level_tile.dart';
 | 
			
		||||
import 'package:comunic/utils/intl_utils.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
import 'package:meta/meta.dart';
 | 
			
		||||
 | 
			
		||||
/// Post utilities
 | 
			
		||||
///
 | 
			
		||||
/// @author Pierre HUBERT
 | 
			
		||||
 | 
			
		||||
/// Show post visibility level picker and return selected visibility level
 | 
			
		||||
Future<PostVisibilityLevel> showPostVisibilityPicker({
 | 
			
		||||
  @required BuildContext context,
 | 
			
		||||
  @required PostVisibilityLevel initialLevel,
 | 
			
		||||
  @required bool isGroup,
 | 
			
		||||
}) async {
 | 
			
		||||
  assert(context != null);
 | 
			
		||||
  assert(initialLevel != null);
 | 
			
		||||
  assert(isGroup != null);
 | 
			
		||||
 | 
			
		||||
  final newLevel = await showDialog<PostVisibilityLevel>(
 | 
			
		||||
    context: context,
 | 
			
		||||
    builder: (c) => AlertDialog(
 | 
			
		||||
          title: Text(tr("Select new post visibility level")),
 | 
			
		||||
 | 
			
		||||
          // Show all options
 | 
			
		||||
          content: Column(
 | 
			
		||||
            children: <Widget>[
 | 
			
		||||
              // Public
 | 
			
		||||
              PostVisibilityLevelTile(
 | 
			
		||||
                level: PostVisibilityLevel.PUBLIC,
 | 
			
		||||
                title: tr("Public"),
 | 
			
		||||
                onSelect: (o) => Navigator.pop(c, o),
 | 
			
		||||
              ),
 | 
			
		||||
 | 
			
		||||
              // Friends only (User page only)
 | 
			
		||||
              PostVisibilityLevelTile(
 | 
			
		||||
                level: PostVisibilityLevel.FRIENDS,
 | 
			
		||||
                title: tr("Friends only"),
 | 
			
		||||
                onSelect: (o) => Navigator.pop(c, o),
 | 
			
		||||
                visible: !isGroup,
 | 
			
		||||
              ),
 | 
			
		||||
 | 
			
		||||
              // User only (User page only)
 | 
			
		||||
              PostVisibilityLevelTile(
 | 
			
		||||
                level: PostVisibilityLevel.USER,
 | 
			
		||||
                title: tr("Me only"),
 | 
			
		||||
                onSelect: (o) => Navigator.pop(c, o),
 | 
			
		||||
                visible: !isGroup,
 | 
			
		||||
              ),
 | 
			
		||||
 | 
			
		||||
              // Group members only (Group page only)
 | 
			
		||||
              PostVisibilityLevelTile(
 | 
			
		||||
                level: PostVisibilityLevel.GROUP_MEMBERS,
 | 
			
		||||
                title: tr("Group members only"),
 | 
			
		||||
                onSelect: (o) => Navigator.pop(c, o),
 | 
			
		||||
                visible: isGroup,
 | 
			
		||||
              ),
 | 
			
		||||
            ],
 | 
			
		||||
          ),
 | 
			
		||||
 | 
			
		||||
          // Dialog actions
 | 
			
		||||
          actions: <Widget>[
 | 
			
		||||
            // Cancel
 | 
			
		||||
            TextButton(
 | 
			
		||||
              child: Text(tr("Cancel").toUpperCase()),
 | 
			
		||||
              onPressed: () => Navigator.pop(c, null),
 | 
			
		||||
            ),
 | 
			
		||||
          ],
 | 
			
		||||
        ),
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  return newLevel == null ? initialLevel : newLevel;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user