-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added changes to add a mentions section
- Loading branch information
1 parent
fbeade6
commit 9a86022
Showing
3 changed files
with
93 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...eio/discordjetpackcompose/ui/routes/dashboard/notifications/components/MentionsSection.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package dev.baseio.discordjetpackcompose.ui.routes.dashboard.notifications.components | ||
|
||
import androidx.compose.material.Switch | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.* | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.AnnotatedString | ||
import androidx.compose.ui.text.SpanStyle | ||
import androidx.compose.ui.text.buildAnnotatedString | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.withStyle | ||
import dev.baseio.discordjetpackcompose.R | ||
import dev.baseio.discordjetpackcompose.ui.routes.dashboard.serverinfo.DiscordSwitchColors | ||
|
||
@Composable | ||
fun MentionsSection( | ||
isMute: Boolean | ||
) { | ||
var suppressEveryoneMentions by remember { mutableStateOf(false) } | ||
var suppressRoleMentions by remember { mutableStateOf(false) } | ||
var suppressPush by remember { mutableStateOf(false) } | ||
|
||
SwitchItem( | ||
onClick = { | ||
suppressEveryoneMentions = !suppressEveryoneMentions | ||
}, | ||
title = buildAnnotatedString { | ||
append(stringResource(id = R.string.suppress)) | ||
withStyle(style = SpanStyle(fontWeight = FontWeight.Bold)){ | ||
append(" "+stringResource(id = R.string.at_everyone)) | ||
} | ||
append(" "+stringResource(id = R.string.and)) | ||
withStyle(style = SpanStyle(fontWeight = FontWeight.Bold)){ | ||
append(" "+stringResource(id = R.string.at_here)) | ||
} | ||
}, | ||
disabled = false, | ||
isChecked = suppressEveryoneMentions | ||
) | ||
SwitchItem( | ||
onClick = { | ||
suppressRoleMentions = !suppressRoleMentions | ||
}, | ||
title = buildAnnotatedString { append(stringResource(id = R.string.role_mentions)) }, | ||
disabled = false, | ||
isChecked = suppressRoleMentions | ||
) | ||
SwitchItem( | ||
onClick = { | ||
if (isMute) return@SwitchItem | ||
suppressPush = !suppressPush | ||
}, | ||
title = buildAnnotatedString { append(stringResource(id = R.string.mobile_push)) }, | ||
disabled = isMute, | ||
isChecked = suppressPush | ||
) | ||
} | ||
|
||
@Composable | ||
fun SwitchItem( | ||
onClick: () -> Unit, | ||
title: AnnotatedString, | ||
disabled: Boolean, | ||
isChecked: Boolean | ||
) { | ||
SectionItem( | ||
disabled = disabled, | ||
onClick = onClick, | ||
leadingComposable = { | ||
Text( | ||
text = title, | ||
color = Color.LightGray | ||
) | ||
}, | ||
trailingComposable = { | ||
Switch( | ||
checked = isChecked, | ||
onCheckedChange = { onClick() }, | ||
colors = DiscordSwitchColors | ||
) | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters