-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
馃 Optimized the Settings Screen code
- Loading branch information
1 parent
8dab9d4
commit 7ef9697
Showing
4 changed files
with
80 additions
and
39 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
app/src/main/java/com/aritra/notify/components/actions/SettingsSwitchCard.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,69 @@ | ||
package com.aritra.notify.components.actions | ||
|
||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Card | ||
import androidx.compose.material3.CardDefaults | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Switch | ||
import androidx.compose.material3.SwitchDefaults | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.semantics.contentDescription | ||
import androidx.compose.ui.semantics.semantics | ||
import androidx.compose.ui.text.font.Font | ||
import androidx.compose.ui.text.font.FontFamily | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import com.aritra.notify.R | ||
|
||
@Composable | ||
fun SettingsSwitchCard( | ||
isDarkMode: Boolean, | ||
onToggleTheme: (Boolean) -> Unit | ||
) { | ||
Card( | ||
modifier = Modifier | ||
.clip(RoundedCornerShape(10.dp)) | ||
.fillMaxWidth() | ||
.background(MaterialTheme.colorScheme.surface), | ||
elevation = CardDefaults.cardElevation(5.dp) | ||
) { | ||
Row( | ||
modifier = Modifier | ||
.padding(16.dp) | ||
.fillMaxWidth(), | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
Icon( | ||
painter = painterResource(id = R.drawable.moon_icon), | ||
contentDescription = stringResource(R.string.icon), | ||
modifier = Modifier.size(30.dp), | ||
) | ||
Text( | ||
modifier = Modifier.padding(start = 10.dp), | ||
text = stringResource(R.string.dark_mode), | ||
fontSize = 20.sp, | ||
fontFamily = FontFamily(Font(R.font.poppins_semibold)) | ||
) | ||
Switch( | ||
modifier = Modifier | ||
.semantics { contentDescription = "Theme Switch" } | ||
.padding(start = 130.dp), | ||
checked = isDarkMode, | ||
onCheckedChange = onToggleTheme, | ||
) | ||
} | ||
} | ||
} |
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
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
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