Replaced math based approach with bitwise operations

This commit is contained in:
Jakob Meier 2023-04-01 12:26:58 +02:00
parent 916ea41159
commit b73362c101
No known key found for this signature in database
GPG key ID: 66BDC7E6A01A6152

View file

@ -69,14 +69,18 @@ class _EditRoomPermissionSetPageState extends State<EditRoomPermissionSetPage> {
itemBuilder: (context, index) {
final item = items[index];
final int col = pow(2, index + 1) as int;
final int col = pow(2, index) as int;
return SwitchListTile(
title: Text(RoomPermission.name(item, context)),
subtitle: Text(RoomPermission.describe(item, context)),
onChanged: (state) {
setState(() {
permissions += (state ? 1 : -1) * col;
if (state) {
permissions |= col;
} else {
permissions &= ~col;
}
});
},
value: permissions & col != 0);