From 8e142830e8671fe182e358d70865e33319bb8e91 Mon Sep 17 00:00:00 2001
From: Xavier Molloy <xavi.molloy@gmail.com>
Date: Fri, 15 Sep 2023 10:51:02 +0200
Subject: [PATCH] Update kotlin version and remove platform specific
 implementations, remove unnecessary dependencies

---
 designsystem/build.gradle.kts                 |   2 +-
 .../component/BottomSheetShell.kt             | 120 ------------------
 .../ui/designsystem/component/BottomSheet.kt  | 102 ++++++++++++++-
 .../component/BottomSheetShell.kt             |  25 ----
 gradle.properties                             |   2 +-
 5 files changed, 102 insertions(+), 149 deletions(-)
 delete mode 100644 designsystem/src/androidMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheetShell.kt
 delete mode 100644 designsystem/src/desktopMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheetShell.kt

diff --git a/designsystem/build.gradle.kts b/designsystem/build.gradle.kts
index eddfa8268..15b92066b 100644
--- a/designsystem/build.gradle.kts
+++ b/designsystem/build.gradle.kts
@@ -32,7 +32,7 @@ kotlin {
             dependencies {
                 api("androidx.activity:activity-compose:1.7.2")
                 api("androidx.appcompat:appcompat:1.6.1")
-                api("androidx.core:core-ktx:1.10.1")
+                api("androidx.core:core-ktx:1.12.0")
                 implementation("androidx.compose.material3:material3:1.2.0-alpha07")
                 implementation("com.google.zxing:core:3.5.2")
             }
diff --git a/designsystem/src/androidMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheetShell.kt b/designsystem/src/androidMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheetShell.kt
deleted file mode 100644
index a5f2024fe..000000000
--- a/designsystem/src/androidMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheetShell.kt
+++ /dev/null
@@ -1,120 +0,0 @@
-package org.hisp.dhis.mobile.ui.designsystem.component
-
-import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.fillMaxHeight
-import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.heightIn
-import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.rememberScrollState
-import androidx.compose.foundation.verticalScroll
-import androidx.compose.material.icons.Icons
-import androidx.compose.material.icons.outlined.Close
-import androidx.compose.material3.ExperimentalMaterial3Api
-import androidx.compose.material3.HorizontalDivider
-import androidx.compose.material3.Icon
-import androidx.compose.material3.ModalBottomSheet
-import androidx.compose.material3.rememberModalBottomSheetState
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.rememberCoroutineScope
-import androidx.compose.ui.Alignment
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.graphics.Color
-import kotlinx.coroutines.launch
-import org.hisp.dhis.mobile.ui.designsystem.theme.InternalSizeValues
-import org.hisp.dhis.mobile.ui.designsystem.theme.Shape
-import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing
-import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor
-import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor
-
-@OptIn(ExperimentalMaterial3Api::class)
-@Composable
-actual fun BottomSheetShell(
-    title: String,
-    subtitle: String?,
-    description: String?,
-    icon: @Composable (() -> Unit)?,
-    searchBar: @Composable (() -> Unit)?,
-    buttonBlock: @Composable (() -> Unit)?,
-    content: @Composable (() -> Unit)?,
-    modifier: Modifier,
-    onDismiss: () -> Unit,
-) {
-    val sheetState = rememberModalBottomSheetState(true)
-    val scope = rememberCoroutineScope()
-
-    ModalBottomSheet(
-        modifier = modifier,
-        containerColor = Color.Transparent,
-        onDismissRequest = {
-            onDismiss()
-        },
-        sheetState = sheetState,
-        dragHandle = {
-            Box(
-                modifier = Modifier.background(Color.Transparent)
-                    .padding(top = Spacing.Spacing72),
-            ) {
-                BottomSheetIconButton(
-                    icon = {
-                        Icon(
-                            imageVector = Icons.Outlined.Close,
-                            contentDescription = "Button",
-                            tint = SurfaceColor.SurfaceBright,
-                        )
-                    },
-                    modifier = Modifier.padding(bottom = Spacing.Spacing4),
-                ) {
-                    scope.launch {
-                        onDismiss()
-                    }
-                }
-            }
-        },
-    ) {
-        Column(
-            modifier = Modifier
-                .background(SurfaceColor.SurfaceBright, Shape.ExtraLargeTop)
-                .padding(Spacing.Spacing24)
-                .heightIn(Spacing.Spacing0, InternalSizeValues.Size800)
-                .verticalScroll(rememberScrollState()),
-            horizontalAlignment = Alignment.CenterHorizontally,
-        ) {
-            BottomSheetHeader(
-                title,
-                subtitle,
-                description,
-                icon,
-                modifier = Modifier
-                    .padding(horizontal = Spacing.Spacing24, vertical = Spacing.Spacing0),
-            )
-            searchBar?.invoke()
-            HorizontalDivider(
-                modifier = Modifier.fillMaxWidth()
-                    .padding(top = Spacing.Spacing24),
-                color = TextColor.OnDisabledSurface,
-            )
-            Box(
-                modifier = Modifier.align(Alignment.Start)
-                    .heightIn(Spacing.Spacing0, InternalSizeValues.Size386)
-                    .padding(bottom = Spacing.Spacing24),
-            ) {
-                Column(
-                    modifier = Modifier
-                        .verticalScroll(rememberScrollState())
-                        .fillMaxHeight(1f),
-                ) {
-                    content?.let {
-                        it.invoke()
-                        HorizontalDivider(
-                            modifier = Modifier.fillMaxWidth().padding(top = Spacing.Spacing8),
-                            color = TextColor.OnDisabledSurface,
-                        )
-                    }
-                }
-            }
-            buttonBlock?.invoke()
-        }
-    }
-}
diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheet.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheet.kt
index 5b17f23d4..25ffd01a6 100644
--- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheet.kt
+++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheet.kt
@@ -1,15 +1,35 @@
 package org.hisp.dhis.mobile.ui.designsystem.component
 
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.Column
 import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxHeight
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.heightIn
 import androidx.compose.foundation.layout.padding
 import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.outlined.Close
+import androidx.compose.material3.Divider
+import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.Icon
 import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.ModalBottomSheet
 import androidx.compose.material3.Text
+import androidx.compose.material3.rememberModalBottomSheetState
 import androidx.compose.runtime.Composable
+import androidx.compose.runtime.rememberCoroutineScope
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import kotlinx.coroutines.launch
+import org.hisp.dhis.mobile.ui.designsystem.theme.InternalSizeValues
+import org.hisp.dhis.mobile.ui.designsystem.theme.Shape
 import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing
+import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor
 import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor
 
 @Composable
@@ -70,8 +90,9 @@ fun BottomSheetHeader(
  * @param onDismiss: gives access to the onDismiss event
  * @param modifier allows a modifier to be passed externally
  */
+@OptIn(ExperimentalMaterial3Api::class)
 @Composable
-expect fun BottomSheetShell(
+fun BottomSheetShell(
     title: String,
     subtitle: String? = null,
     description: String? = null,
@@ -81,4 +102,81 @@ expect fun BottomSheetShell(
     content: @Composable (() -> Unit)? = null,
     modifier: Modifier = Modifier,
     onDismiss: () -> Unit,
-)
+) {
+    val sheetState = rememberModalBottomSheetState(true)
+    val scope = rememberCoroutineScope()
+
+    ModalBottomSheet(
+        modifier = modifier,
+        containerColor = Color.Transparent,
+        onDismissRequest = {
+            onDismiss()
+        },
+        sheetState = sheetState,
+        dragHandle = {
+            Box(
+                modifier = Modifier.background(Color.Transparent)
+                    .padding(top = Spacing.Spacing72),
+            ) {
+                BottomSheetIconButton(
+                    icon = {
+                        Icon(
+                            imageVector = Icons.Outlined.Close,
+                            contentDescription = "Button",
+                            tint = SurfaceColor.SurfaceBright,
+                        )
+                    },
+                    modifier = Modifier.padding(bottom = Spacing.Spacing4),
+                ) {
+                    scope.launch {
+                        onDismiss()
+                    }
+                }
+            }
+        },
+    ) {
+        Column(
+            modifier = Modifier
+                .background(SurfaceColor.SurfaceBright, Shape.ExtraLargeTop)
+                .padding(Spacing.Spacing24)
+                .heightIn(Spacing.Spacing0, InternalSizeValues.Size800)
+                .verticalScroll(rememberScrollState()),
+            horizontalAlignment = Alignment.CenterHorizontally,
+        ) {
+            BottomSheetHeader(
+                title,
+                subtitle,
+                description,
+                icon,
+                modifier = Modifier
+                    .padding(horizontal = Spacing.Spacing24, vertical = Spacing.Spacing0),
+            )
+            searchBar?.invoke()
+            Divider(
+                modifier = Modifier.fillMaxWidth()
+                    .padding(top = Spacing.Spacing24),
+                color = TextColor.OnDisabledSurface,
+            )
+            Box(
+                modifier = Modifier.align(Alignment.Start)
+                    .heightIn(Spacing.Spacing0, InternalSizeValues.Size386)
+                    .padding(bottom = Spacing.Spacing24),
+            ) {
+                Column(
+                    modifier = Modifier
+                        .verticalScroll(rememberScrollState())
+                        .fillMaxHeight(1f),
+                ) {
+                    content?.let {
+                        it.invoke()
+                        Divider(
+                            modifier = Modifier.fillMaxWidth().padding(top = Spacing.Spacing8),
+                            color = TextColor.OnDisabledSurface,
+                        )
+                    }
+                }
+            }
+            buttonBlock?.invoke()
+        }
+    }
+}
diff --git a/designsystem/src/desktopMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheetShell.kt b/designsystem/src/desktopMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheetShell.kt
deleted file mode 100644
index d7f0f92b9..000000000
--- a/designsystem/src/desktopMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheetShell.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.hisp.dhis.mobile.ui.designsystem.component
-
-import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.material3.Text
-import androidx.compose.runtime.Composable
-import androidx.compose.ui.Alignment
-import androidx.compose.ui.Modifier
-
-@Composable
-actual fun BottomSheetShell(
-    title: String,
-    subtitle: String?,
-    description: String?,
-    icon: @Composable (() -> Unit)?,
-    searchBar: @Composable (() -> Unit)?,
-    buttonBlock: @Composable (() -> Unit)?,
-    content: @Composable (() -> Unit)?,
-    modifier: Modifier,
-    onDismiss: () -> Unit,
-) {
-    Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
-        Text(text = "Component not implemented")
-    }
-}
diff --git a/gradle.properties b/gradle.properties
index f1cb0eaf7..ecf9dfef4 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -23,4 +23,4 @@ android.minSdk=21
 #Versions
 kotlin.version=1.9.10
 agp.version=8.1.1
-compose.version=1.5.1
\ No newline at end of file
+compose.version=1.5.10-beta01
\ No newline at end of file