-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Refactor ManageTilesView to Material3 #7052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 41 commits
13062f7
42bc0bf
0ac8be8
6ffa26c
f404e7d
1337c97
aa5ad24
32b736f
f3be433
fdd3f1d
fb40613
9fc67f6
a017d11
b85f45a
71acbb2
b7c109a
36d00f8
c74d8ca
b9af4c6
4a386c8
02a95fd
7afc3ad
18d44f6
70d4eb7
ad1daf9
72e5fa5
7d06a1a
ec7f493
1c1658b
cad9ce3
e86ef4f
a0395f2
89f008c
c70e70a
196ddf8
66fd9db
ea985c1
112057e
a35c118
1661061
39e264a
489da9f
149b212
355cd41
ad0681d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package io.homeassistant.companion.android.settings.qs | ||
|
|
||
| import androidx.compose.runtime.Stable | ||
| import com.mikepenz.iconics.typeface.IIcon | ||
| import io.homeassistant.companion.android.common.R as commonR | ||
| import io.homeassistant.companion.android.common.compose.composable.HADropdownItem | ||
| import io.homeassistant.companion.android.common.data.integration.Entity | ||
| import io.homeassistant.companion.android.common.data.servers.ServerManager | ||
| import io.homeassistant.companion.android.common.data.websocket.impl.entities.AreaRegistryResponse | ||
| import io.homeassistant.companion.android.common.data.websocket.impl.entities.DeviceRegistryResponse | ||
| import io.homeassistant.companion.android.common.data.websocket.impl.entities.EntityRegistryResponse | ||
| import io.homeassistant.companion.android.database.server.Server | ||
|
|
||
| @Stable | ||
| internal data class ManageTilesState( | ||
| val selectedTileId: String = "", | ||
| val servers: List<Server> = emptyList(), | ||
| val sortedEntities: List<Entity> = emptyList(), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it called sorted? It is filtered for sure but not sorted.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure too..I just used the name as is I'll change it |
||
| val entityRegistry: List<EntityRegistryResponse> = emptyList(), | ||
| val deviceRegistry: List<DeviceRegistryResponse> = emptyList(), | ||
| val areaRegistry: List<AreaRegistryResponse> = emptyList(), | ||
| val selectedServerId: Int = ServerManager.SERVER_ID_ACTIVE, | ||
| val selectedIconId: String? = null, | ||
| val selectedIcon: IIcon? = null, | ||
| val selectedEntityId: String = "", | ||
| val tileLabel: String = "", | ||
| val tileSubtitle: String = "", | ||
| val submitButtonLabel: Int = commonR.string.tile_save, | ||
| val selectedShouldVibrate: Boolean = false, | ||
| val tileAuthRequired: Boolean = false, | ||
| val showSubtitle: Boolean = false, | ||
| val tileSlotsDropdownItems: List<HADropdownItem<String>> = emptyList(), | ||
| val serversDropdownItems: List<HADropdownItem<Int>> = emptyList(), | ||
| ) { | ||
| val showServerSelector = servers.size > 1 || | ||
| servers.none { server -> server.id == selectedServerId } | ||
|
|
||
| val showResetIcon = selectedIconId != null && selectedEntityId.isNotBlank() | ||
|
|
||
| val submitEnabled = tileLabel.isNotBlank() && | ||
| servers.any { it.id == selectedServerId } && | ||
| sortedEntities.any { it.entityId == selectedEntityId } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add some small unit tests for this logic |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep it like this but I think we could drop this line and look at the HaDropdownItem only since the key is the ID of the server.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed servers property