merge conflicts, also translate to l2 in message translation card if original sent lang code is null

pull/1384/head
ggurdin 1 year ago
commit a3763f0306

@ -282,7 +282,7 @@ class ChatDetailsView extends StatelessWidget {
// roomId: controller.roomId,
// startOpen: false,
// ),
if (room.pangeaRoomRules != null && room.isRoomAdmin)
if (room.pangeaRoomRules != null)
RoomRulesEditor(
roomId: controller.roomId,
startOpen: false,

@ -77,6 +77,14 @@ class RoomRulesState extends State<RoomRulesEditor> {
// rules = PangeaRoomRules();
// }
void showNoPermission() {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(L10n.of(context)!.noPermission),
),
);
}
@override
Widget build(BuildContext context) {
return Column(
@ -138,107 +146,128 @@ class RoomRulesState extends State<RoomRulesEditor> {
height: isOpen ? null : 0,
child: Padding(
padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 8.0),
child: Column(
children: [
for (final setting in ToolSetting.values)
Column(
children: [
ListTile(
title: Text(
"${setting.toolName(
context,
)}: ${rules.languageToolPermissionsText(
child: Opacity(
opacity: (room?.isRoomAdmin ?? true) ? 1 : 0.5,
child: Column(
children: [
for (final setting in ToolSetting.values)
Column(
children: [
ListTile(
title: Text(
"${setting.toolName(
context,
)}: ${rules.languageToolPermissionsText(
context,
setting,
)}",
),
subtitle: Text(setting.toolDescription(context)),
),
Slider(
value: rules.getToolSettings(setting).toDouble(),
onChanged: (value) {
if (room?.isRoomAdmin ?? true) {
updatePermission(() {
rules.setLanguageToolSetting(
setting,
value.toInt(),
);
});
} else {
showNoPermission();
}
},
divisions: 2,
max: 2,
min: 0,
label: rules.languageToolPermissionsText(
context,
setting,
)}",
),
subtitle: Text(setting.toolDescription(context)),
),
Slider(
value: rules.getToolSettings(setting).toDouble(),
onChanged: (value) {
updatePermission(() {
rules.setLanguageToolSetting(
setting,
value.toInt(),
);
});
},
divisions: 2,
max: 2,
min: 0,
label: rules.languageToolPermissionsText(
context,
setting,
),
),
),
],
),
SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.oneToOneChatsWithinClass),
subtitle:
Text(L10n.of(context)!.oneToOneChatsWithinClassDesc),
value: rules.oneToOneChatClass,
onChanged: (value) => updatePermission(
() => rules.oneToOneChatClass = value,
],
),
SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.oneToOneChatsWithinClass),
subtitle:
Text(L10n.of(context)!.oneToOneChatsWithinClassDesc),
value: rules.oneToOneChatClass,
onChanged: (value) => (room?.isRoomAdmin ?? true)
? updatePermission(
() => rules.oneToOneChatClass = value,
)
: showNoPermission(),
),
),
SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.createGroupChats),
subtitle: Text(L10n.of(context)!.createGroupChatsDesc),
value: rules.isCreateRooms,
onChanged: (value) => updatePermission(
() => rules.isCreateRooms = value,
SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.createGroupChats),
subtitle: Text(L10n.of(context)!.createGroupChatsDesc),
value: rules.isCreateRooms,
onChanged: (value) => (room?.isRoomAdmin ?? true)
? updatePermission(
() => rules.isCreateRooms = value,
)
: showNoPermission(),
),
),
SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.shareVideo),
subtitle: Text(L10n.of(context)!.shareVideoDesc),
value: rules.isShareVideo,
onChanged: (value) => updatePermission(
() => rules.isShareVideo = value,
SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.shareVideo),
subtitle: Text(L10n.of(context)!.shareVideoDesc),
value: rules.isShareVideo,
onChanged: (value) => (room?.isRoomAdmin ?? true)
? updatePermission(
() => rules.isShareVideo = value,
)
: showNoPermission(),
),
),
SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.sharePhotos),
subtitle: Text(L10n.of(context)!.sharePhotosDesc),
value: rules.isSharePhoto,
onChanged: (value) => updatePermission(
() => rules.isSharePhoto = value,
SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.sharePhotos),
subtitle: Text(L10n.of(context)!.sharePhotosDesc),
value: rules.isSharePhoto,
onChanged: (value) => (room?.isRoomAdmin ?? true)
? updatePermission(
() => rules.isSharePhoto = value,
)
: showNoPermission(),
),
),
SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.shareFiles),
subtitle: Text(L10n.of(context)!.shareFilesDesc),
value: rules.isShareFiles,
onChanged: (value) => updatePermission(
() => rules.isShareFiles = value,
SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.shareFiles),
subtitle: Text(L10n.of(context)!.shareFilesDesc),
value: rules.isShareFiles,
onChanged: (value) => (room?.isRoomAdmin ?? true)
? updatePermission(
() => rules.isShareFiles = value,
)
: showNoPermission(),
),
),
SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.sendVoiceNotes),
subtitle: Text(L10n.of(context)!.sendVoiceNotesDesc),
value: rules.isVoiceNotes,
onChanged: (value) => updatePermission(
() => rules.isVoiceNotes = value,
SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.sendVoiceNotes),
subtitle: Text(L10n.of(context)!.sendVoiceNotesDesc),
value: rules.isVoiceNotes,
onChanged: (value) => (room?.isRoomAdmin ?? true)
? updatePermission(
() => rules.isVoiceNotes = value,
)
: showNoPermission(),
),
),
SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.shareLocation),
subtitle: Text(L10n.of(context)!.shareLocationDesc),
value: rules.isShareLocation,
onChanged: (value) => updatePermission(
() => rules.isShareLocation = value,
SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.shareLocation),
subtitle: Text(L10n.of(context)!.shareLocationDesc),
value: rules.isShareLocation,
onChanged: (value) => (room?.isRoomAdmin ?? true)
? updatePermission(
() => rules.isShareLocation = value,
)
: showNoPermission(),
),
),
],
],
),
),
),
),

@ -37,7 +37,9 @@ class MessageTranslationCardState extends State<MessageTranslationCard> {
if (widget.immersionMode) return l1Code;
final String? originalWrittenCode =
widget.messageEvent.originalWritten?.content.langCode;
return l1Code == originalWrittenCode ? l2Code : l1Code;
return (l1Code == originalWrittenCode || originalWrittenCode == null)
? l2Code
: l1Code;
}
Future<void> fetchRepresentation(BuildContext context) async {

Loading…
Cancel
Save