Show students class permissions
This commit is contained in:
parent
dcb2490ec5
commit
19b7b70684
2 changed files with 123 additions and 92 deletions
|
|
@ -284,7 +284,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,8 +77,18 @@ 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) {
|
||||
final darkGray = Theme.of(context).colorScheme.primary;
|
||||
final lightGray = Theme.of(context).colorScheme.onPrimary;
|
||||
return Column(
|
||||
children: [
|
||||
// if (widget.showAdd)
|
||||
|
|
@ -138,107 +148,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 ?? false) ? 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 ?? false) {
|
||||
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) => (room?.isRoomAdmin ?? false)
|
||||
? updatePermission(
|
||||
() => rules.oneToOneChatClass = value,
|
||||
)
|
||||
: showNoPermission(),
|
||||
),
|
||||
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)!.createGroupChats),
|
||||
subtitle: Text(L10n.of(context)!.createGroupChatsDesc),
|
||||
value: rules.isCreateRooms,
|
||||
onChanged: (value) => (room?.isRoomAdmin ?? false)
|
||||
? updatePermission(
|
||||
() => rules.isCreateRooms = 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)!.shareVideo),
|
||||
subtitle: Text(L10n.of(context)!.shareVideoDesc),
|
||||
value: rules.isShareVideo,
|
||||
onChanged: (value) => (room?.isRoomAdmin ?? false)
|
||||
? updatePermission(
|
||||
() => rules.isShareVideo = 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)!.sharePhotos),
|
||||
subtitle: Text(L10n.of(context)!.sharePhotosDesc),
|
||||
value: rules.isSharePhoto,
|
||||
onChanged: (value) => (room?.isRoomAdmin ?? false)
|
||||
? updatePermission(
|
||||
() => rules.isSharePhoto = 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)!.shareFiles),
|
||||
subtitle: Text(L10n.of(context)!.shareFilesDesc),
|
||||
value: rules.isShareFiles,
|
||||
onChanged: (value) => (room?.isRoomAdmin ?? false)
|
||||
? updatePermission(
|
||||
() => rules.isShareFiles = 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)!.sendVoiceNotes),
|
||||
subtitle: Text(L10n.of(context)!.sendVoiceNotesDesc),
|
||||
value: rules.isVoiceNotes,
|
||||
onChanged: (value) => (room?.isRoomAdmin ?? false)
|
||||
? updatePermission(
|
||||
() => rules.isVoiceNotes = 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)!.shareLocation),
|
||||
subtitle: Text(L10n.of(context)!.shareLocationDesc),
|
||||
value: rules.isShareLocation,
|
||||
onChanged: (value) => (room?.isRoomAdmin ?? false)
|
||||
? updatePermission(
|
||||
() => rules.isShareLocation = 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,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue