mirror of
https://github.com/home-assistant/android
synced 2024-10-01 13:53:53 +00:00
Fix Picker rotary input on some devices and update design (#3919)
This commit is contained in:
parent
f23a6cb046
commit
f2e9541264
|
@ -2,7 +2,6 @@ package io.homeassistant.companion.android.home.views
|
|||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Check
|
||||
import androidx.compose.runtime.Composable
|
||||
|
@ -10,15 +9,17 @@ import androidx.compose.runtime.CompositionLocalProvider
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.wear.compose.material.Picker
|
||||
import androidx.wear.compose.material.rememberPickerState
|
||||
import androidx.wear.compose.material3.Button
|
||||
import androidx.wear.compose.material3.ButtonDefaults
|
||||
import androidx.wear.compose.material3.Icon
|
||||
import androidx.wear.compose.material3.MaterialTheme
|
||||
import androidx.wear.compose.material3.Text
|
||||
import androidx.wear.tooling.preview.devices.WearDevices
|
||||
import com.google.android.horologist.annotations.ExperimentalHorologistApi
|
||||
|
@ -39,8 +40,7 @@ fun RefreshIntervalPickerView(
|
|||
val initialIndex = options.indexOf(currentInterval)
|
||||
val state = rememberPickerState(
|
||||
initialNumberOfOptions = options.size,
|
||||
initiallySelectedOption = if (initialIndex != -1) initialIndex else 0,
|
||||
repeatItems = true
|
||||
initiallySelectedOption = if (initialIndex != -1) initialIndex else 0
|
||||
)
|
||||
|
||||
Column(
|
||||
|
@ -53,13 +53,17 @@ fun RefreshIntervalPickerView(
|
|||
contentDescription = stringResource(R.string.refresh_interval),
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(all = 8.dp)
|
||||
.rotaryWithSnap(state.toRotaryScrollAdapter())
|
||||
) {
|
||||
Text(
|
||||
intervalToString(LocalContext.current, options[it]),
|
||||
fontSize = 24.sp,
|
||||
color = if (it != this.selectedOption) wearColorScheme.onBackground else wearColorScheme.primary
|
||||
text = intervalToString(LocalContext.current, options[it]),
|
||||
style = with(LocalDensity.current) {
|
||||
MaterialTheme.typography.displayMedium.copy(
|
||||
fontWeight = FontWeight.Medium,
|
||||
fontSize = MaterialTheme.typography.displayMedium.fontSize.value.dp.toSp() // Ignore text scaling
|
||||
)
|
||||
},
|
||||
color = wearColorScheme.primary
|
||||
)
|
||||
}
|
||||
Button(
|
||||
|
|
Loading…
Reference in a new issue