Show students class permissions

pull/1186/head
Kelrap 1 year ago
parent dcb2490ec5
commit 19b7b70684

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

@ -77,8 +77,18 @@ class RoomRulesState extends State<RoomRulesEditor> {
// rules = PangeaRoomRules(); // rules = PangeaRoomRules();
// } // }
void showNoPermission() {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(L10n.of(context)!.noPermission),
),
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final darkGray = Theme.of(context).colorScheme.primary;
final lightGray = Theme.of(context).colorScheme.onPrimary;
return Column( return Column(
children: [ children: [
// if (widget.showAdd) // if (widget.showAdd)
@ -138,6 +148,8 @@ class RoomRulesState extends State<RoomRulesEditor> {
height: isOpen ? null : 0, height: isOpen ? null : 0,
child: Padding( child: Padding(
padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 8.0), padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 8.0),
child: Opacity(
opacity: (room?.isRoomAdmin ?? false) ? 1 : 0.5,
child: Column( child: Column(
children: [ children: [
for (final setting in ToolSetting.values) for (final setting in ToolSetting.values)
@ -157,12 +169,16 @@ class RoomRulesState extends State<RoomRulesEditor> {
Slider( Slider(
value: rules.getToolSettings(setting).toDouble(), value: rules.getToolSettings(setting).toDouble(),
onChanged: (value) { onChanged: (value) {
if (room?.isRoomAdmin ?? false) {
updatePermission(() { updatePermission(() {
rules.setLanguageToolSetting( rules.setLanguageToolSetting(
setting, setting,
value.toInt(), value.toInt(),
); );
}); });
} else {
showNoPermission();
}
}, },
divisions: 2, divisions: 2,
max: 2, max: 2,
@ -180,68 +196,83 @@ class RoomRulesState extends State<RoomRulesEditor> {
subtitle: subtitle:
Text(L10n.of(context)!.oneToOneChatsWithinClassDesc), Text(L10n.of(context)!.oneToOneChatsWithinClassDesc),
value: rules.oneToOneChatClass, value: rules.oneToOneChatClass,
onChanged: (value) => updatePermission( onChanged: (value) => (room?.isRoomAdmin ?? false)
? updatePermission(
() => rules.oneToOneChatClass = value, () => rules.oneToOneChatClass = value,
), )
: showNoPermission(),
), ),
SwitchListTile.adaptive( SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor, activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.createGroupChats), title: Text(L10n.of(context)!.createGroupChats),
subtitle: Text(L10n.of(context)!.createGroupChatsDesc), subtitle: Text(L10n.of(context)!.createGroupChatsDesc),
value: rules.isCreateRooms, value: rules.isCreateRooms,
onChanged: (value) => updatePermission( onChanged: (value) => (room?.isRoomAdmin ?? false)
? updatePermission(
() => rules.isCreateRooms = value, () => rules.isCreateRooms = value,
), )
: showNoPermission(),
), ),
SwitchListTile.adaptive( SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor, activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.shareVideo), title: Text(L10n.of(context)!.shareVideo),
subtitle: Text(L10n.of(context)!.shareVideoDesc), subtitle: Text(L10n.of(context)!.shareVideoDesc),
value: rules.isShareVideo, value: rules.isShareVideo,
onChanged: (value) => updatePermission( onChanged: (value) => (room?.isRoomAdmin ?? false)
? updatePermission(
() => rules.isShareVideo = value, () => rules.isShareVideo = value,
), )
: showNoPermission(),
), ),
SwitchListTile.adaptive( SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor, activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.sharePhotos), title: Text(L10n.of(context)!.sharePhotos),
subtitle: Text(L10n.of(context)!.sharePhotosDesc), subtitle: Text(L10n.of(context)!.sharePhotosDesc),
value: rules.isSharePhoto, value: rules.isSharePhoto,
onChanged: (value) => updatePermission( onChanged: (value) => (room?.isRoomAdmin ?? false)
? updatePermission(
() => rules.isSharePhoto = value, () => rules.isSharePhoto = value,
), )
: showNoPermission(),
), ),
SwitchListTile.adaptive( SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor, activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.shareFiles), title: Text(L10n.of(context)!.shareFiles),
subtitle: Text(L10n.of(context)!.shareFilesDesc), subtitle: Text(L10n.of(context)!.shareFilesDesc),
value: rules.isShareFiles, value: rules.isShareFiles,
onChanged: (value) => updatePermission( onChanged: (value) => (room?.isRoomAdmin ?? false)
? updatePermission(
() => rules.isShareFiles = value, () => rules.isShareFiles = value,
), )
: showNoPermission(),
), ),
SwitchListTile.adaptive( SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor, activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.sendVoiceNotes), title: Text(L10n.of(context)!.sendVoiceNotes),
subtitle: Text(L10n.of(context)!.sendVoiceNotesDesc), subtitle: Text(L10n.of(context)!.sendVoiceNotesDesc),
value: rules.isVoiceNotes, value: rules.isVoiceNotes,
onChanged: (value) => updatePermission( onChanged: (value) => (room?.isRoomAdmin ?? false)
? updatePermission(
() => rules.isVoiceNotes = value, () => rules.isVoiceNotes = value,
), )
: showNoPermission(),
), ),
SwitchListTile.adaptive( SwitchListTile.adaptive(
activeColor: AppConfig.activeToggleColor, activeColor: AppConfig.activeToggleColor,
title: Text(L10n.of(context)!.shareLocation), title: Text(L10n.of(context)!.shareLocation),
subtitle: Text(L10n.of(context)!.shareLocationDesc), subtitle: Text(L10n.of(context)!.shareLocationDesc),
value: rules.isShareLocation, value: rules.isShareLocation,
onChanged: (value) => updatePermission( onChanged: (value) => (room?.isRoomAdmin ?? false)
? updatePermission(
() => rules.isShareLocation = value, () => rules.isShareLocation = value,
), )
: showNoPermission(),
), ),
], ],
), ),
), ),
), ),
),
], ],
); );
} }

Loading…
Cancel
Save