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

Can change group virtual directory

This commit is contained in:
Pierre HUBERT 2020-05-01 20:10:25 +02:00
parent d889321b38
commit 519c68b092
4 changed files with 38 additions and 2 deletions

View File

@ -193,6 +193,16 @@ class GroupsHelper {
return groupInfo.info;
}
/// Check the availability of a virtual directory
///
/// Throws in case of error
static Future<void> checkVirtualDirectoryAvailability(
int groupID, String dir) async =>
await APIRequest(uri: "groups/checkVirtualDirectory", needLogin: true)
.addInt("groupID", groupID)
.addString("directory", dir)
.execWithThrow();
/// Update (set) new group settings
///
/// Throws in case of error

View File

@ -28,7 +28,7 @@ class Group {
final GroupVisibilityLevel visibilityLevel;
final GroupRegistrationLevel registrationLevel;
final GroupPostCreationLevel postCreationLevel;
final String virtualDirectory;
String virtualDirectory;
bool following;
Group({

View File

@ -1,3 +1,4 @@
import 'package:comunic/helpers/groups_helper.dart';
import 'package:comunic/helpers/settings_helper.dart';
import 'package:comunic/ui/widgets/safe_state.dart';
import 'package:comunic/utils/intl_utils.dart';
@ -8,7 +9,7 @@ import 'package:flutter/material.dart';
///
/// @author Pierre HUBERT
enum VirtualDirectoryTargetType { USER }
enum VirtualDirectoryTargetType { USER, GROUP }
enum _CheckStatus { EMPTY, PENDING, VALID, INVALID }
@ -122,6 +123,11 @@ class __VirtualDirectoryPickerState extends SafeState<_VirtualDirectoryPicker> {
case VirtualDirectoryTargetType.USER:
await SettingsHelper.checkUserDirectoryAvailability(value);
break;
case VirtualDirectoryTargetType.GROUP:
await GroupsHelper.checkVirtualDirectoryAvailability(
widget.id, value);
break;
}
if (_currentValue == value) {

View File

@ -1,5 +1,6 @@
import 'package:comunic/helpers/groups_helper.dart';
import 'package:comunic/models/advanced_group_info.dart';
import 'package:comunic/ui/dialogs/virtual_directory_dialog.dart';
import 'package:comunic/ui/widgets/async_screen_widget.dart';
import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
import 'package:comunic/ui/widgets/safe_state.dart';
@ -89,6 +90,25 @@ class _GroupSettingsScreenState extends SafeState<GroupSettingsScreen> {
_groupSettings.name = s;
_updateSettings();
}),
// Group virtual directory
SettingsTile(
title: tr("Virtual directory (optional)"),
subtitle: _groupSettings.virtualDirectory,
onTap: () async {
final newDir = await showVirtualDirectoryDialog(
context: context,
initialDirectory: _groupSettings.virtualDirectory,
id: _groupSettings.id,
type: VirtualDirectoryTargetType.GROUP,
);
if (newDir == null) return;
_groupSettings.virtualDirectory = newDir;
_updateSettings();
},
),
],
);
}