diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/sheet/AdaptiveLine.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/sheet/AdaptiveLine.kt deleted file mode 100644 index 3f49e93..0000000 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/sheet/AdaptiveLine.kt +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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 - * - */ - -package org.eclipse.kuksa.companion.feature.home.view.sheet - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.width -import androidx.compose.material3.windowsizeclass.WindowSizeClass -import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.platform.LocalConfiguration -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.dp -import org.eclipse.kuksa.companion.PREVIEW_HEIGHT_DP -import org.eclipse.kuksa.companion.PREVIEW_WIDTH_DP -import org.eclipse.kuksa.companion.extension.windowSizeClass - -/** - * AdaptiveLine draws a line depending on the [WindowWidthSizeClass] of the device. If the device has a - * [WindowWidthSizeClass] of [WindowWidthSizeClass.Compact] it will draw a horizontal line, otherwise it will draw a - * horizontal line. - */ -@Composable -fun AdaptiveLine( - windowSizeClass: WindowSizeClass, - modifier: Modifier = Modifier, - length: Dp = 50.dp, - thickness: Dp = 4.dp, - color: Color = Color.LightGray, -) { - if (windowSizeClass.widthSizeClass == WindowWidthSizeClass.Compact) { - HorizontalLine(modifier, length, thickness, color) - } else { - VerticalLine(modifier, length, thickness, color) - } -} - -@Composable -fun HorizontalLine( - modifier: Modifier = Modifier, - length: Dp = 50.dp, - thickness: Dp = 4.dp, - color: Color = Color.LightGray, -) { - Spacer( - modifier = modifier - .background(color) - .width(length) - .height(thickness), - ) -} - -@Composable -fun VerticalLine( - modifier: Modifier = Modifier, - length: Dp = 50.dp, - thickness: Dp = 4.dp, - color: Color = Color.LightGray, -) { - Spacer( - modifier = modifier - .background(color) - .width(thickness) - .height(length), - ) -} - -@Composable -@Preview(widthDp = PREVIEW_WIDTH_DP, heightDp = PREVIEW_HEIGHT_DP) -@Preview(widthDp = PREVIEW_HEIGHT_DP, heightDp = PREVIEW_WIDTH_DP) -private fun AdaptiveLinePreview() { - val windowSizeClass = LocalConfiguration.current.windowSizeClass - Box { - AdaptiveLine(windowSizeClass = windowSizeClass) - } -} - -@Composable -@Preview -private fun HorizontalLinePreview() { - HorizontalLine() -} - -@Composable -@Preview -private fun VerticalLinePreview() { - VerticalLine() -} diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/sheet/AdaptiveSheetLayoutBak.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/sheet/AdaptiveSheetLayoutBak.kt deleted file mode 100644 index 95dc5cc..0000000 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/sheet/AdaptiveSheetLayoutBak.kt +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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 - * - */ - -package org.eclipse.kuksa.companion.feature.home.view.sheet - -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxHeight -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.width -import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.windowsizeclass.WindowSizeClass -import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.platform.LocalConfiguration -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp -import androidx.compose.ui.zIndex -import androidx.constraintlayout.compose.ConstraintLayout -import org.eclipse.kuksa.companion.PREVIEW_HEIGHT_DP -import org.eclipse.kuksa.companion.PREVIEW_WIDTH_DP -import org.eclipse.kuksa.companion.SHEET_COLLAPSED_HEIGHT -import org.eclipse.kuksa.companion.SHEET_EXPANDED_HEIGHT -import org.eclipse.kuksa.companion.extension.windowSizeClass - -/** - * AdaptiveSheetView adds a lash, which can be expanded on click to contain additional content. While it will be placed - * on the bottom for devices with a [WindowWidthSizeClass] of [WindowWidthSizeClass.Compact] it will be placed on the - * "end" for devices with a WindowWidthSizeClass which is higher. - */ -@Composable -fun AdaptiveSheetViewBak( - windowSizeClass: WindowSizeClass, - modifier: Modifier = Modifier, - sheetContent: @Composable () -> Unit, -) { - var isExpanded by remember { - mutableStateOf(false) - } - - ConstraintLayout(modifier = modifier.fillMaxSize()) { - val sheetRef = createRef() - - val sheetModifier = when (windowSizeClass.widthSizeClass) { - WindowWidthSizeClass.Compact -> { - Modifier - .height(if (isExpanded) SHEET_EXPANDED_HEIGHT.dp else SHEET_COLLAPSED_HEIGHT.dp) - .fillMaxWidth() - .zIndex(2F) - .clickable { isExpanded = !isExpanded } - .background(Color.White) - .constrainAs(sheetRef) { - bottom.linkTo(parent.bottom) - } - } - - else -> { - Modifier - .fillMaxHeight() - .width(if (isExpanded) SHEET_EXPANDED_HEIGHT.dp else SHEET_COLLAPSED_HEIGHT.dp) - .zIndex(2F) - .clickable { isExpanded = !isExpanded } - .background(Color.White) - .constrainAs(sheetRef) { - end.linkTo(parent.end) - } - } - } - - Box( - modifier = sheetModifier, - ) { - if (isExpanded) { - sheetContent() - } else { - AdaptiveLine(modifier = Modifier.align(Alignment.Center), windowSizeClass = windowSizeClass) - } - } - } -} - -@OptIn(ExperimentalMaterial3Api::class) -@Composable -@Preview(widthDp = PREVIEW_WIDTH_DP, heightDp = PREVIEW_HEIGHT_DP) -@Preview(widthDp = PREVIEW_HEIGHT_DP, heightDp = PREVIEW_WIDTH_DP) -private fun AdaptiveSheetViewPreview() { - val windowSizeClass = LocalConfiguration.current.windowSizeClass - AdaptiveSheetView(windowSizeClass) { - } -}