Skip to content

Commit

Permalink
more tweaks to sliders
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Jan 9, 2023
1 parent 15b568d commit cb9f517
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fun MainScreen() {
UpdateInfoButton()
}
Spacer(Modifier.width(10.dp))
SettingsButton(!state.isDownloading && state.operationsQueued && state.minecraftValid)
SettingsButton()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fun LoginMicrosoftButton(enabled: Boolean) {

Button(
enabled = enabled,
onClick = { /*TODO Login with Microsoft*/},
onClick = { startMicrosoftLoginProcess() },
colors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.primaryContainer,
contentColor = MaterialTheme.colorScheme.primary
Expand All @@ -30,3 +30,11 @@ fun LoginMicrosoftButton(enabled: Boolean) {
}
}
}

private fun startMicrosoftLoginProcess() {

}

private fun microsoftOAuth2Flow() {

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import com.mineinabyss.launchy.ui.screens.Screen
import com.mineinabyss.launchy.ui.screens.screen

@Composable
fun SettingsButton(enabled: Boolean) {
Button(enabled = enabled, onClick = { screen = Screen.Settings }) {
fun SettingsButton() {
Button(onClick = { screen = Screen.Settings }) {
Icon(Icons.Rounded.Settings, contentDescription = "Settings")
Text("Settings")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fun JavaGroup() {
) {
Spacer(Modifier.width(10.dp))
val minRam = SliderSwitch(label = "Minimum RAM", valueRange = 1..12).roundToInt()
val maxRam = SliderSwitch(label = "Maximum RAM:", valueRange = 1..12).roundToInt()
val maxRam = maxOf(minRam, SliderSwitch(label = "Maximum RAM:", valueRange = 1..12).roundToInt())
// Figure out way to handle this, probably storing via state or something
state.clientSettings = ClientSettings(state.clientSettings.minecraft, JavaSettings(minRam, maxRam))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.mineinabyss.launchy.ui.screens.settings

import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.foundation.layout.width
import androidx.compose.material.LocalTextStyle
import androidx.compose.material.Slider
import androidx.compose.material.SliderDefaults
import androidx.compose.material.Text
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
Expand All @@ -10,12 +13,23 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import kotlin.math.roundToLong

@OptIn(ExperimentalMaterialApi::class)
@Composable
fun RamSlider(
label: String = "",
modifier: Modifier = Modifier,
valueRange: IntRange = 1..16,
minRam: Int? = null
) {
SliderSwitch(label, modifier, valueRange)
return
}

@Composable
fun SliderSwitch(
label: String = "",
modifier: Modifier = Modifier,
valueRange: IntRange = 1..16,
minRam: Float? = null
): Float {
var sliderPosition by remember { mutableStateOf(2f) }
var sliderPos by remember { mutableStateOf(sliderPosition.toString()) }
Expand All @@ -27,7 +41,7 @@ fun SliderSwitch(
modifier = modifier.width(100.dp),
onValueChange = {
println("$sliderPos $sliderPosition")
sliderPosition = sliderPos.toFloatOrNull() ?: sliderPosition
sliderPosition = minRam?.let { maxOf(it, (sliderPos.toFloatOrNull() ?: sliderPosition)) } ?: (sliderPos.toFloatOrNull() ?: sliderPosition)
}
)
// This is called too often, and should only be called when textfield triggers onValueChange but cant? not sure
Expand Down

0 comments on commit cb9f517

Please sign in to comment.