Skip to content
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

feature: Differentiate between DirectionIndicator Left / Right #8

Merged
merged 5 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private fun LightOverlay(viewModel: LightControlViewModel) {
)
LightDashboardSymbol(
isLightEnabled = viewModel.isDirectionIndicatorSignaling,
painterResource = R.drawable.lights_direction_indicator_24,
painterResource = viewModel.directionIndicatorRes,
contentDescription = "Direction Indicator",
)
LightDashboardSymbol(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@

package org.eclipse.kuksa.demo.feature.light.viewmodel

import androidx.annotation.DrawableRes
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import org.eclipse.kuksa.demo.R
import org.eclipse.kuksa.vss.VssLights
import org.eclipse.kuksa.vsscore.model.VssProperty

Expand Down Expand Up @@ -52,6 +54,22 @@ class LightControlViewModel : ViewModel() {
isDirectionIndicatorLeftSignaling.value || isDirectionIndicatorRightSignaling.value
}

@get:DrawableRes
val directionIndicatorRes by derivedStateOf {
val isLeftSignalling = isDirectionIndicatorLeftSignaling.value
val isRightSignalling = isDirectionIndicatorRightSignaling.value

if (isLeftSignalling && isRightSignalling) {
return@derivedStateOf R.drawable.lights_direction_indicator_both_24
} else if (isLeftSignalling) {
return@derivedStateOf R.drawable.lights_direction_indicator_left_24
} else if (isRightSignalling) {
return@derivedStateOf R.drawable.lights_direction_indicator_right_24
}

return@derivedStateOf R.drawable.lights_direction_indicator_none_24
}

val isFogLightFrontOn by derivedStateOf {
vssLight.fog.front.isOn
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
android:viewportWidth="6.35"
android:viewportHeight="6.35">
<path
android:pathData="M2.9259,2.5007H1.8196V1.5725L0.3608,3.1333 1.8196,4.6942V3.766H2.9259V2.5007"
android:strokeWidth="0.0124087"
android:pathData="M2.9259,2.5007H1.8196V1.5725L0.3608,3.1333 1.8196,4.6942V3.766H2.9259V2.35"
android:strokeWidth="0.3"
android:fillColor="#000000"
android:strokeColor="#00000000"
android:strokeColor="#000000"
android:fillType="nonZero" />
<path
android:pathData="M3.3841,2.5007H4.4904V1.5725l1.4588,1.5609 -1.4588,1.5609V3.766H3.3841V2.5007"
android:strokeWidth="0.0124087"
android:pathData="M3.3841,2.5007H4.4904V1.5725l1.4588,1.5609 -1.4588,1.5609V3.766H3.3841V2.35"
android:strokeWidth="0.3"
android:fillColor="#000000"
android:strokeColor="#00000000"
android:strokeColor="#000000"
android:fillType="nonZero" />
</vector>
36 changes: 36 additions & 0 deletions app/src/main/res/drawable/lights_direction_indicator_left_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!--
~ Copyright (c) 2023 Contributors to the Eclipse Foundation
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
~ SPDX-License-Identifier: Apache-2.0
~
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="6.35"
android:viewportHeight="6.35">
<path
android:pathData="M2.9259,2.5007H1.8196V1.5725L0.3608,3.1333 1.8196,4.6942V3.766H2.9259V2.35"
android:strokeWidth="0.3"
android:fillColor="#000000"
android:strokeColor="#000000"
android:fillType="nonZero" />
<path
android:pathData="M3.3841,2.5007H4.4904V1.5725l1.4588,1.5609 -1.4588,1.5609V3.766H3.3841V2.35"
android:strokeWidth="0.3"
android:strokeColor="#000000"
android:fillType="nonZero" />
</vector>
35 changes: 35 additions & 0 deletions app/src/main/res/drawable/lights_direction_indicator_none_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
~ Copyright (c) 2023 Contributors to the Eclipse Foundation
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
~ SPDX-License-Identifier: Apache-2.0
~
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="6.35"
android:viewportHeight="6.35">
<path
android:pathData="M2.9259,2.5007H1.8196V1.5725L0.3608,3.1333 1.8196,4.6942V3.766H2.9259V2.35"
android:strokeWidth="0.3"
android:strokeColor="#000000"
android:fillType="nonZero"/>
<path
android:pathData="M3.3841,2.5007H4.4904V1.5725l1.4588,1.5609 -1.4588,1.5609V3.766H3.3841V2.35"
android:strokeWidth="0.3"
android:strokeColor="#000000"
android:fillType="nonZero"/>
</vector>
36 changes: 36 additions & 0 deletions app/src/main/res/drawable/lights_direction_indicator_right_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!--
~ Copyright (c) 2023 Contributors to the Eclipse Foundation
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
~ SPDX-License-Identifier: Apache-2.0
~
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="6.35"
android:viewportHeight="6.35">
<path
android:pathData="M2.9259,2.5007H1.8196V1.5725L0.3608,3.1333 1.8196,4.6942V3.766H2.9259V2.35"
android:strokeWidth="0.3"
android:strokeColor="#000000"
android:fillType="nonZero" />
<path
android:pathData="M3.3841,2.5007H4.4904V1.5725l1.4588,1.5609 -1.4588,1.5609V3.766H3.3841V2.35"
android:strokeWidth="0.3"
android:fillColor="#000000"
android:strokeColor="#000000"
android:fillType="nonZero" />
</vector>