Skip to content

Commit

Permalink
Merge branch 'main' into fix-string-format-without-locale
Browse files Browse the repository at this point in the history
  • Loading branch information
starry-shivam authored Oct 17, 2023
2 parents d1e58c6 + 4a6447a commit f085cd3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ fun SettingItem(icon: Int, mainText: String, subText: String, onClick: () -> Uni
@ExperimentalMaterial3Api
@Composable
fun SettingItemWIthSwitch(
icon: Int, mainText: String, subText: String, switchState: MutableState<Boolean>
icon: Int,
mainText: String,
subText: String,
switchState: MutableState<Boolean>,
onCheckChange: (Boolean) -> Unit
) {
Card(
colors = CardDefaults.cardColors(
Expand Down Expand Up @@ -186,7 +190,7 @@ fun SettingItemWIthSwitch(
)
}
}
Switch(checked = switchState.value, onCheckedChange = { switchState.value = it })
Switch(checked = switchState.value, onCheckedChange = onCheckChange)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ import coil.annotation.ExperimentalCoilApi
import com.starry.myne.BuildConfig
import com.starry.myne.MainActivity
import com.starry.myne.R
import com.starry.myne.ui.navigation.Screens
import com.starry.myne.ui.common.CustomTopAppBar
import com.starry.myne.ui.navigation.Screens
import com.starry.myne.ui.screens.settings.viewmodels.SettingsViewModel
import com.starry.myne.ui.screens.settings.viewmodels.ThemeMode
import com.starry.myne.ui.theme.figeronaFont
import com.starry.myne.utils.getActivity
import kotlinx.coroutines.launch

@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
@ExperimentalCoilApi
Expand Down Expand Up @@ -274,6 +275,8 @@ fun DisplayOptionsUI(
context: Context,
snackbarHostState: SnackbarHostState,
) {
val coroutiScope = rememberCoroutineScope()

val displayValue =
when (viewModel.getThemeValue()) {
ThemeMode.Light.ordinal -> "Light"
Expand Down Expand Up @@ -312,23 +315,20 @@ fun DisplayOptionsUI(
icon = R.drawable.ic_settings_material_you,
mainText = stringResource(id = R.string.material_you_setting),
subText = materialYouDesc,
switchState = materialYouSwitch
switchState = materialYouSwitch,
onCheckChange = { materialYouValue ->
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
viewModel.setMaterialYou(materialYouValue)
materialYouSwitch.value = materialYouValue
} else {
viewModel.setMaterialYou(false)
materialYouSwitch.value = false
coroutiScope.launch { snackbarHostState.showSnackbar(context.getString(R.string.material_you_error)) }
}
}
)
}

if (materialYouSwitch.value) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
viewModel.setMaterialYou(true)
} else {
materialYouSwitch.value = false
LaunchedEffect(
key1 = true,
block = { snackbarHostState.showSnackbar(context.getString(R.string.material_you_error)) })
}
} else {
viewModel.setMaterialYou(false)
}

if (displayDialog.value) {
AlertDialog(onDismissRequest = {
displayDialog.value = false
Expand Down

0 comments on commit f085cd3

Please sign in to comment.