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

Update Compose Multiplatform, Gradle and Kotlin #247

Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id("org.jetbrains.compose")
id("com.android.application")
kotlin("multiplatform")
alias(libs.plugins.compose.compiler)
}

kotlin {
Expand Down
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ plugins {
id("org.jlleitschuh.gradle.ktlint") version "11.5.1"
id("org.jetbrains.dokka") version "1.9.20"
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
alias(libs.plugins.compose.compiler)
}

/**
Expand All @@ -27,6 +28,9 @@ allprojects {
version.set("0.50.0")
verbose.set(true)
outputToConsole.set(true)
filter {
exclude("**/generated/**")
}
}

tasks.withType<KotlinCompile>().all {
Expand Down
1 change: 1 addition & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
id("com.android.library")
alias(libs.plugins.compose.compiler)
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -123,11 +123,11 @@ fun InputBarCodeScreen() {
Description("Barcode Block", textColor = TextColor.OnSurfaceVariant)

BarcodeBlock(data = "Barcode value")
Divider()
HorizontalDivider()
BarcodeBlock(data = "889026a1-d01e-4d34-8209-81e8ed5c614b")
Divider()
HorizontalDivider()
BarcodeBlock(data = "l;kw1jheoi1u23iop1")
Divider()
HorizontalDivider()
RowComponentContainer {
BarcodeBlock(data = "563ce8df-8e0b-420c-a63c-fe000b1d1f11")
BarcodeBlock(data = "378c472d-bb05-4174-9fe5-f6dbf8f5de36")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.Painter
import mobile_ui.common.generated.resources.Res
import mobile_ui.common.generated.resources.sample
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.ImageBlock
import org.hisp.dhis.mobile.ui.designsystem.component.InputImage
Expand All @@ -19,7 +21,6 @@ import org.hisp.dhis.mobile.ui.designsystem.component.Title
import org.hisp.dhis.mobile.ui.designsystem.component.UploadState
import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing
import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.painterResource
import java.util.Timer
import kotlin.concurrent.schedule
Expand Down Expand Up @@ -94,7 +95,6 @@ fun InputImageScreen() {
}
}

@OptIn(ExperimentalResourceApi::class)
@Composable
private fun provideSampleImage(): Painter =
painterResource("drawable/sample.png")
painterResource(Res.drawable.sample)
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.graphics.painter.Painter
import mobile_ui.common.generated.resources.Res
import mobile_ui.common.generated.resources.sample_signature
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState
import org.hisp.dhis.mobile.ui.designsystem.component.InputSignature
import org.hisp.dhis.mobile.ui.designsystem.component.SubTitle
import org.hisp.dhis.mobile.ui.designsystem.component.Title
import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing
import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.painterResource

@Composable
Expand Down Expand Up @@ -91,7 +92,6 @@ fun InputSignatureScreen() {
}
}

@OptIn(ExperimentalResourceApi::class)
@Composable
private fun provideSampleImage(): Painter =
painterResource("drawable/sample_signature.jpeg")
painterResource(Res.drawable.sample_signature)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.hisp.dhis.common.screens.actionInputs

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Login
import androidx.compose.material.icons.automirrored.outlined.Login
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -58,7 +58,7 @@ fun LoginScreen() {
text = "Log In",
icon = {
Icon(
imageVector = Icons.Outlined.Login,
imageVector = Icons.AutoMirrored.Outlined.Login,
contentDescription = "Login button",

)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.HelpOutline
import androidx.compose.material.icons.outlined.BookmarkBorder
import androidx.compose.material.icons.outlined.HelpOutline
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -75,7 +75,7 @@ fun BottomSheetHeaderScreen() {
title = "Title",
icon = {
Icon(
imageVector = Icons.Outlined.HelpOutline,
imageVector = Icons.AutoMirrored.Outlined.HelpOutline,
contentDescription = "Button",
tint = SurfaceColor.Primary,
)
Expand All @@ -92,7 +92,7 @@ fun BottomSheetHeaderScreen() {
headerTextAlignment = TextAlign.Start,
icon = {
Icon(
imageVector = Icons.Outlined.HelpOutline,
imageVector = Icons.AutoMirrored.Outlined.HelpOutline,
contentDescription = "Button",
tint = SurfaceColor.Primary,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -88,7 +88,7 @@ fun BottomSheetScreen() {
items(longLegendList) { item ->
Column {
Text(text = item.text, modifier = Modifier.padding(horizontal = 24.dp, vertical = 12.dp))
Divider()
HorizontalDivider()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ import org.hisp.dhis.mobile.ui.designsystem.component.ErrorBadge
fun BadgesScreen() {
ColumnComponentContainer(title = "Badges") {
Badge()
Badge(text = "3")
Badge(text = "32")
Badge(text = "321")
Badge(text = "4321")
}
ColumnComponentContainer(title = "Error badges") {
ErrorBadge()
ErrorBadge(text = "3")
ErrorBadge(text = "32")
ErrorBadge(text = "321")
ErrorBadge(text = "4321")
}
}
1 change: 1 addition & 0 deletions designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
id("com.android.library")
id("convention.publication")
id("app.cash.paparazzi").version("1.3.3")
alias(libs.plugins.compose.compiler)
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package org.hisp.dhis.mobile.ui.designsystem
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Login
import androidx.compose.material.icons.automirrored.outlined.Login
import androidx.compose.material3.Icon
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.TextFieldValue
import org.hisp.dhis.mobile.ui.designsystem.component.Button
Expand Down Expand Up @@ -61,7 +59,7 @@ class LoginSnapshotTest {
text = "Log In",
icon = {
Icon(
imageVector = Icons.Outlined.Login,
imageVector = Icons.AutoMirrored.Outlined.Login,
contentDescription = "Login button",

)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import androidx.compose.foundation.layout.offset
import androidx.compose.material.ripple.LocalRippleTheme
import androidx.compose.material3.AssistChip
import androidx.compose.material3.AssistChipDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
Expand Down Expand Up @@ -37,7 +36,6 @@ import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor
* @param onClick: Will be called when the user taps the chip.
* @param badge: the text to be displayed within the badge.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AssistChip(
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -75,6 +73,7 @@ fun AssistChip(
},
border = AssistChipDefaults.assistChipBorder(
borderColor = Outline.Dark,
enabled = enabled,
),
leadingIcon = {
icon?.invoke()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
package org.hisp.dhis.mobile.ui.designsystem.component

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
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

/**
* DHIS2 [Badge]) wraps Material 3's [Box].
* DHIS2 [Badge]) wraps [androidx.compose.material3.Badge].
* Badges are used to convey dynamic information,
* such as a count or status.
* A badge can include text, labels, or numbers.
Expand All @@ -32,22 +24,20 @@ fun Badge(
color: Color = SurfaceColor.Primary,
textColor: Color = TextColor.OnPrimary,
) {
Box(
modifier
.defaultMinSize(Spacing.Spacing6, Spacing.Spacing6)
.background(color, CircleShape),
) {
text?.let {
Text(
modifier = Modifier
.padding(horizontal = Spacing.Spacing4)
.padding(bottom = Spacing.Spacing1),
text = it,
textAlign = TextAlign.Center,
style = MaterialTheme.typography.labelSmall.copy(color = textColor),
)
}
}
androidx.compose.material3.Badge(
modifier = modifier,
containerColor = color,
content = if (text != null) {
{
Text(
text = text,
color = textColor,
)
}
} else {
null
},
)
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ 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.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
Expand All @@ -40,6 +40,7 @@ import androidx.compose.ui.unit.dp
import kotlinx.coroutines.launch
import org.hisp.dhis.mobile.ui.designsystem.component.internal.Keyboard
import org.hisp.dhis.mobile.ui.designsystem.component.internal.keyboardAsState
import org.hisp.dhis.mobile.ui.designsystem.theme.Border
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
Expand Down Expand Up @@ -245,10 +246,11 @@ fun BottomSheetShell(

if (showHeader || hasSearch) {
if (showSectionDivider) {
Divider(
HorizontalDivider(
modifier = Modifier.fillMaxWidth()
.padding(top = Spacing24, start = Spacing24, end = Spacing24),
color = TextColor.OnDisabledSurface,
thickness = Border.Thin,
)
} else {
Spacer(Modifier.requiredHeight(Spacing24))
Expand All @@ -271,9 +273,10 @@ fun BottomSheetShell(
) {
content.invoke()
if (showSectionDivider) {
Divider(
HorizontalDivider(
modifier = Modifier.fillMaxWidth().padding(top = Spacing8),
color = TextColor.OnDisabledSurface,
thickness = Border.Thin,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Done
import androidx.compose.material.ripple.LocalRippleTheme
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilterChip
import androidx.compose.material3.FilterChipDefaults
import androidx.compose.material3.Icon
Expand Down Expand Up @@ -37,7 +36,6 @@ import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor
* @param onSelected: Will be called when the user taps the chip.
* @param badge: the text to be displayed within the badge.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun FilterChip(
modifier: Modifier = Modifier,
Expand All @@ -58,6 +56,8 @@ fun FilterChip(
),
border = FilterChipDefaults.filterChipBorder(
borderColor = Outline.Dark,
enabled = true,
selected = selected,
),
leadingIcon = if (selected) {
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.compose.animation.core.tween
import androidx.compose.animation.core.updateTransition
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.ArrowBack
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material.icons.outlined.FileDownload
import androidx.compose.material.icons.outlined.Share
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -90,7 +90,7 @@ fun FullScreenImage(
modifier = Modifier.testTag("FULL_SCREEN_IMAGE_BACK_BUTTON"),
icon = {
Icon(
imageVector = Icons.Outlined.ArrowBack,
imageVector = Icons.AutoMirrored.Outlined.ArrowBack,
contentDescription = "Back Button",
tint = SurfaceColor.SurfaceBright,
)
Expand Down
Loading
Loading