fluffychat merge - resolve conflicts

pull/1384/head
ggurdin 1 year ago
commit 2a710841a6
No known key found for this signature in database
GPG Key ID: A01CB41737CBB478

@ -677,7 +677,7 @@
"type": "text", "type": "text",
"placeholders": {} "placeholders": {}
}, },
"defaultPermissionLevel": "Default permission level", "defaultPermissionLevel": "Default permission level for new users",
"@defaultPermissionLevel": { "@defaultPermissionLevel": {
"type": "text", "type": "text",
"placeholders": {} "placeholders": {}
@ -4152,5 +4152,33 @@
"type": "text", "type": "text",
"space": {} "space": {}
}, },
"markAsUnread": "Mark as unread" "markAsUnread": "Mark as unread",
"userLevel": "{level} - User",
"@userLevel": {
"type": "text",
"placeholders": {
"level": {}
}
},
"moderatorLevel": "{level} - Moderator",
"@moderatorLevel": {
"type": "text",
"placeholders": {
"level": {}
}
},
"adminLevel": "{level} - Admin",
"@adminLevel": {
"type": "text",
"placeholders": {
"level": {}
}
},
"changeGeneralChatSettings": "Change general chat settings",
"inviteOtherUsers": "Invite other users to this chat",
"changeTheChatPermissions": "Change the chat permissions",
"changeTheVisibilityOfChatHistory": "Change the visibility of the chat history",
"changeTheCanonicalRoomAlias": "Change the main public chat address",
"sendRoomNotifications": "Send a @room notifications",
"changeTheDescriptionOfTheGroup": "Change the description of the chat"
} }

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -6,7 +8,7 @@ import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/utils/localized_exception_extension.dart'; import 'package:fluffychat/utils/error_reporter.dart';
import 'package:fluffychat/utils/size_string.dart'; import 'package:fluffychat/utils/size_string.dart';
import '../../utils/resize_image.dart'; import '../../utils/resize_image.dart';
@ -42,19 +44,20 @@ class SendFileDialogState extends State<SendFileDialog> {
}, },
); );
} }
final scaffoldMessenger = ScaffoldMessenger.of(context); try {
widget.room await widget.room.sendFileEvent(
.sendFileEvent(
file, file,
thumbnail: thumbnail, thumbnail: thumbnail,
shrinkImageMaxDimension: origImage ? null : 1600, shrinkImageMaxDimension: origImage ? null : 1600,
)
.catchError((e) {
scaffoldMessenger.showSnackBar(
SnackBar(content: Text((e as Object).toLocalizedString(context))),
); );
return null; } on IOException catch (_) {
}); } on FileTooBigMatrixException catch (_) {
} catch (e, s) {
if (mounted) {
ErrorReporter(context, 'Unable to send file').onErrorCallback(e, s);
}
rethrow;
}
} }
Navigator.of(context, rootNavigator: false).pop(); Navigator.of(context, rootNavigator: false).pop();

@ -24,6 +24,36 @@ class ChatAccessSettingsController extends State<ChatAccessSettings> {
bool guestAccessLoading = false; bool guestAccessLoading = false;
Room get room => Matrix.of(context).client.getRoomById(widget.roomId)!; Room get room => Matrix.of(context).client.getRoomById(widget.roomId)!;
String get roomVersion =>
room
.getState(EventTypes.RoomCreate)!
.content
.tryGet<String>('room_version') ??
'Unknown';
/// Calculates which join rules are available based on the information on
/// https://spec.matrix.org/v1.11/rooms/#feature-matrix
List<JoinRules> get availableJoinRules {
final joinRules = Set<JoinRules>.from(JoinRules.values);
final roomVersionInt = int.tryParse(roomVersion);
// Knock is only supported for rooms up from version 7:
if (roomVersionInt != null && roomVersionInt <= 6) {
joinRules.remove(JoinRules.knock);
}
// Not yet supported in FluffyChat:
joinRules.remove(JoinRules.restricted);
joinRules.remove(JoinRules.knockRestricted);
// If an unsupported join rule is the current join rule, display it:
final currentJoinRule = room.joinRules;
if (currentJoinRule != null) joinRules.add(currentJoinRule);
return joinRules.toList();
}
void setJoinRule(JoinRules? newJoinRules) async { void setJoinRule(JoinRules? newJoinRules) async {
if (newJoinRules == null) return; if (newJoinRules == null) return;
setState(() { setState(() {

@ -66,7 +66,7 @@ class ChatAccessSettingsPageView extends StatelessWidget {
), ),
), ),
), ),
for (final joinRule in JoinRules.values) for (final joinRule in controller.availableJoinRules)
if (joinRule != JoinRules.private) if (joinRule != JoinRules.private)
RadioListTile<JoinRules>.adaptive( RadioListTile<JoinRules>.adaptive(
title: Text( title: Text(

@ -1,6 +1,4 @@
import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/pangea/extensions/client_extension/client_extension.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
@ -29,7 +27,7 @@ class PermissionsListTile extends StatelessWidget {
case 'events_default': case 'events_default':
return L10n.of(context)!.sendMessages; return L10n.of(context)!.sendMessages;
case 'state_default': case 'state_default':
return L10n.of(context)!.configureChat; return L10n.of(context)!.changeGeneralChatSettings;
case 'ban': case 'ban':
return L10n.of(context)!.banFromChat; return L10n.of(context)!.banFromChat;
case 'kick': case 'kick':
@ -37,23 +35,25 @@ class PermissionsListTile extends StatelessWidget {
case 'redact': case 'redact':
return L10n.of(context)!.deleteMessage; return L10n.of(context)!.deleteMessage;
case 'invite': case 'invite':
return L10n.of(context)!.inviteContact; return L10n.of(context)!.inviteOtherUsers;
} }
} else if (category == 'notifications') { } else if (category == 'notifications') {
switch (permissionKey) { switch (permissionKey) {
case 'rooms': case 'rooms':
return L10n.of(context)!.notifications; return L10n.of(context)!.sendRoomNotifications;
} }
} else if (category == 'events') { } else if (category == 'events') {
switch (permissionKey) { switch (permissionKey) {
case EventTypes.RoomName: case EventTypes.RoomName:
return L10n.of(context)!.changeTheNameOfTheGroup; return L10n.of(context)!.changeTheNameOfTheGroup;
case EventTypes.RoomTopic:
return L10n.of(context)!.changeTheDescriptionOfTheGroup;
case EventTypes.RoomPowerLevels: case EventTypes.RoomPowerLevels:
return L10n.of(context)!.chatPermissions; return L10n.of(context)!.changeTheChatPermissions;
case EventTypes.HistoryVisibility: case EventTypes.HistoryVisibility:
return L10n.of(context)!.visibilityOfTheChatHistory; return L10n.of(context)!.changeTheVisibilityOfChatHistory;
case EventTypes.RoomCanonicalAlias: case EventTypes.RoomCanonicalAlias:
return L10n.of(context)!.setInvitationLink; return L10n.of(context)!.changeTheCanonicalRoomAlias;
case EventTypes.RoomAvatar: case EventTypes.RoomAvatar:
return L10n.of(context)!.editRoomAvatar; return L10n.of(context)!.editRoomAvatar;
case EventTypes.RoomTombstone: case EventTypes.RoomTombstone:
@ -69,41 +69,40 @@ class PermissionsListTile extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final color = permission >= 100
? Colors.orangeAccent
: permission >= 50
? Colors.blueAccent
: Colors.greenAccent;
return ListTile( return ListTile(
title: Text(getLocalizedPowerLevelString(context)), title: Text(
subtitle: Text( getLocalizedPowerLevelString(context),
// #Pangea style: Theme.of(context).textTheme.titleSmall,
// L10n.of(context)!.minimumPowerLevel(permission.toString()),
L10n.of(context)!.minimumPowerLevel(
Matrix.of(context).client.powerLevelName(
permission,
L10n.of(context)!,
) ??
permission.toString(),
),
// Pangea#
), ),
trailing: Material( trailing: Material(
color: color.withAlpha(64),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2), borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
color: Theme.of(context).colorScheme.onInverseSurface, side: BorderSide(color: color),
),
child: DropdownButton<int>( child: DropdownButton<int>(
padding: const EdgeInsets.symmetric(horizontal: 8.0), padding: const EdgeInsets.symmetric(horizontal: 8.0),
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2), borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
underline: const SizedBox.shrink(), underline: const SizedBox.shrink(),
onChanged: canEdit ? onChanged : null, onChanged: canEdit ? onChanged : null,
value: {0, 50, 100}.contains(permission) ? permission : null, value: permission,
items: [ items: [
DropdownMenuItem( DropdownMenuItem(
value: 0, value: permission < 50 ? permission : 0,
child: Text(L10n.of(context)!.user), child: Text(L10n.of(context)!.userLevel(permission)),
), ),
DropdownMenuItem( DropdownMenuItem(
value: 50, value: permission < 100 && permission >= 50 ? permission : 50,
child: Text(L10n.of(context)!.moderator), child: Text(L10n.of(context)!.moderatorLevel(permission)),
), ),
DropdownMenuItem( DropdownMenuItem(
value: 100, value: permission >= 100 ? permission : 100,
child: Text(L10n.of(context)!.admin), child: Text(L10n.of(context)!.adminLevel(permission)),
), ),
DropdownMenuItem( DropdownMenuItem(
value: null, value: null,

Loading…
Cancel
Save