Skip to content

Commit

Permalink
Fix icon button sizes (#3918)
Browse files Browse the repository at this point in the history
* Fix icon button sizes

* Merge fixes
  • Loading branch information
jpelgrom authored Oct 6, 2023
1 parent 6586314 commit 26c6bcd
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.homeassistant.companion.android.complications.views

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Check
import androidx.compose.runtime.Composable
Expand All @@ -12,9 +13,12 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.wear.compose.material3.Button
import androidx.wear.compose.material3.FilledIconButton
import androidx.wear.compose.material3.Icon
import androidx.wear.compose.material3.IconButtonDefaults
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.ToggleButton
import androidx.wear.compose.material3.touchTargetAwareSize
import androidx.wear.compose.navigation.SwipeDismissableNavHost
import androidx.wear.compose.navigation.composable
import androidx.wear.compose.navigation.rememberSwipeDismissableNavController
Expand Down Expand Up @@ -151,12 +155,17 @@ fun MainConfigView(
}

item {
Button(
modifier = Modifier.padding(top = 8.dp),
FilledIconButton(
modifier = Modifier.padding(top = 8.dp).touchTargetAwareSize(IconButtonDefaults.SmallButtonSize),
onClick = { onAcceptClicked() },
enabled = loaded && entity != null,
icon = { Icon(Icons.Filled.Check, stringResource(id = R.string.save)) }
) { }
enabled = loaded && entity != null
) {
Icon(
Icons.Filled.Check,
contentDescription = stringResource(id = R.string.save),
modifier = Modifier.size(IconButtonDefaults.iconSizeFor(IconButtonDefaults.SmallButtonSize))
)
}
}
} else {
item {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ import androidx.wear.compose.foundation.lazy.ScalingLazyColumn
import androidx.wear.compose.foundation.lazy.items
import androidx.wear.compose.foundation.lazy.rememberScalingLazyListState
import androidx.wear.compose.material3.Button
import androidx.wear.compose.material3.ButtonDefaults
import androidx.wear.compose.material3.FilledIconButton
import androidx.wear.compose.material3.Icon
import androidx.wear.compose.material3.IconButtonDefaults
import androidx.wear.compose.material3.LocalContentColor
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.touchTargetAwareSize
import androidx.wear.compose.navigation.SwipeDismissableNavHost
import androidx.wear.compose.navigation.composable
import androidx.wear.compose.navigation.rememberSwipeDismissableNavController
Expand All @@ -56,6 +58,7 @@ import io.homeassistant.companion.android.common.data.websocket.impl.entities.As
import io.homeassistant.companion.android.conversation.ConversationViewModel
import io.homeassistant.companion.android.theme.WearAppTheme
import io.homeassistant.companion.android.theme.getFilledTonalButtonColors
import io.homeassistant.companion.android.theme.wearColorScheme
import io.homeassistant.companion.android.util.KeepScreenOn
import io.homeassistant.companion.android.views.ListHeader
import io.homeassistant.companion.android.views.ThemeLazyColumn
Expand Down Expand Up @@ -193,22 +196,23 @@ fun ConversationResultView(
.clip(CircleShape)
)
}
Button(
FilledIconButton(
onClick = { onMicrophoneInput() },
colors =
if (inputIsActive) {
ButtonDefaults.buttonColors(containerColor = Color.Transparent, contentColor = Color.Black)
IconButtonDefaults.filledIconButtonColors(containerColor = Color.Transparent, contentColor = Color.Black)
} else {
ButtonDefaults.buttonColors()
IconButtonDefaults.filledIconButtonColors(containerColor = wearColorScheme.outlineVariant, contentColor = Color.White)
},
icon = {
Icon(
Icons.Filled.Mic,
contentDescription = stringResource(R.string.assist_start_listening),
tint = LocalContentColor.current
)
}
) { }
modifier = Modifier.touchTargetAwareSize(IconButtonDefaults.SmallButtonSize)
) {
Icon(
Icons.Filled.Mic,
contentDescription = stringResource(R.string.assist_start_listening),
modifier = Modifier.size(IconButtonDefaults.iconSizeFor(IconButtonDefaults.SmallButtonSize)),
tint = LocalContentColor.current
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.homeassistant.companion.android.home.views

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Check
import androidx.compose.runtime.Composable
Expand All @@ -16,11 +17,12 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
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.FilledIconButton
import androidx.wear.compose.material3.Icon
import androidx.wear.compose.material3.IconButtonDefaults
import androidx.wear.compose.material3.MaterialTheme
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.touchTargetAwareSize
import androidx.wear.tooling.preview.devices.WearDevices
import com.google.android.horologist.annotations.ExperimentalHorologistApi
import com.google.android.horologist.composables.picker.toRotaryScrollAdapter
Expand Down Expand Up @@ -66,14 +68,16 @@ fun RefreshIntervalPickerView(
color = wearColorScheme.primary
)
}
Button(
FilledIconButton(
onClick = { onSelectInterval(options[state.selectedOption]) },
colors = ButtonDefaults.buttonColors(),
modifier = Modifier,
icon = {
Icon(Icons.Filled.Check, stringResource(id = R.string.save))
}
) { }
modifier = Modifier.touchTargetAwareSize(IconButtonDefaults.SmallButtonSize)
) {
Icon(
Icons.Filled.Check,
contentDescription = stringResource(id = R.string.save),
modifier = Modifier.size(IconButtonDefaults.iconSizeFor(IconButtonDefaults.SmallButtonSize))
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.homeassistant.companion.android.home.views

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.runtime.Composable
Expand All @@ -14,9 +15,11 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.wear.compose.material3.Button
import androidx.wear.compose.material3.ButtonDefaults
import androidx.wear.compose.material3.FilledIconButton
import androidx.wear.compose.material3.Icon
import androidx.wear.compose.material3.IconButtonDefaults
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.touchTargetAwareSize
import androidx.wear.tooling.preview.devices.WearDevices
import com.mikepenz.iconics.compose.Image
import io.homeassistant.companion.android.data.SimplifiedEntity
Expand Down Expand Up @@ -73,14 +76,16 @@ fun SetShortcutsTileView(
}
if (shortcutEntities.size < 7) {
item {
Button(
modifier = Modifier.padding(top = 16.dp),
onClick = { onShortcutEntitySelectionChange(shortcutEntities.size) },
colors = ButtonDefaults.buttonColors(),
icon = {
Icon(Icons.Filled.Add, stringResource(id = commonR.string.add_shortcut))
}
) { }
FilledIconButton(
modifier = Modifier.padding(top = 16.dp).touchTargetAwareSize(IconButtonDefaults.SmallButtonSize),
onClick = { onShortcutEntitySelectionChange(shortcutEntities.size) }
) {
Icon(
Icons.Filled.Add,
contentDescription = stringResource(id = commonR.string.add_shortcut),
modifier = Modifier.size(IconButtonDefaults.iconSizeFor(IconButtonDefaults.SmallButtonSize))
)
}
}
}
}
Expand Down

0 comments on commit 26c6bcd

Please sign in to comment.