Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	android/build.gradle.kts
#	common/build.gradle.kts
#	common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt
#	common/src/commonMain/kotlin/org/hisp/dhis/common/screens/Components.kt
#	common/src/commonMain/kotlin/org/hisp/dhis/common/screens/ImageBlockScreen.kt
#	common/src/commonMain/kotlin/org/hisp/dhis/common/screens/InputDropDownScreen.kt
#	designsystem/build.gradle.kts
#	designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicInputImage.kt
#	designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BottomSheet.kt
#	designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/ImageBlock.kt
#	designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputDropDown.kt
#	designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputShell.kt
#	designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/theme/Theme.kt
#	designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicInputImageTest.kt
#	designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/ImageBlockTest.kt
#	designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputDropDownTest.kt
#	gradle.properties
  • Loading branch information
andresmr committed Dec 22, 2023
2 parents 4bebbcd + da1352c commit 0e3058f
Show file tree
Hide file tree
Showing 21 changed files with 81 additions and 37 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ kotlin {
sourceSets {
androidMain.dependencies {
implementation(project(":common"))
implementation("androidx.activity:activity-compose:1.8.1")
implementation("androidx.activity:activity-compose:1.8.2")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import org.hisp.dhis.common.screens.previews.lorem
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.DropdownItem
import org.hisp.dhis.mobile.ui.designsystem.component.InputDropDown
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package org.hisp.dhis.common.screens

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 org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.InputFileResource
import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState
Expand All @@ -17,6 +21,22 @@ fun InputFileResourceScreen() {
val currentFileName2 = "filename.extension"
val currentFileWeight2 = "524kb"

var inputFileResourceState by remember { mutableStateOf(UploadFileState.ADD) }

InputFileResource(
title = "Label",
buttonText = provideStringResource("add_file"),
fileName = currentFileName,
fileWeight = currentFileWeight,
uploadFileState = inputFileResourceState,
onSelectFile = {
inputFileResourceState = UploadFileState.LOADED
},
onUploadFile = {},
onClear = {
inputFileResourceState = UploadFileState.ADD
},
)
InputFileResource(
title = "Label",
buttonText = provideStringResource("add_file"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ fun InputImageScreen() {
uploadState = UploadState.LOADED
}
},
onImageClick = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -62,6 +63,7 @@ fun InputImageScreen() {
onShareButtonClick = {},
onResetButtonClicked = {},
onAddButtonClicked = {},
onImageClick = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -78,6 +80,7 @@ fun InputImageScreen() {
onShareButtonClick = {},
onResetButtonClicked = { },
onAddButtonClicked = {},
onImageClick = {},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ fun InputSignatureScreen() {
uploadState = UploadState.LOADED
}
},
onImageClick = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -62,6 +63,7 @@ fun InputSignatureScreen() {
onShareButtonClick = {},
onResetButtonClicked = {},
onAddButtonClicked = {},
onImageClick = {},
)
Spacer(Modifier.size(Spacing.Spacing18))

Expand All @@ -78,6 +80,7 @@ fun InputSignatureScreen() {
onShareButtonClick = {},
onResetButtonClicked = { },
onAddButtonClicked = {},
onImageClick = {},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import org.hisp.dhis.mobile.ui.designsystem.component.CheckBoxData
Expand All @@ -19,19 +19,19 @@ import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing
@Composable
fun InputYesOnlyCheckBoxScreen() {
ColumnComponentContainer {
var checkboxData by rememberSaveable {
var checkboxData by remember {
mutableStateOf(CheckBoxData(uid = "0", checked = false, enabled = true, textInput = "Label"))
}
var checkboxData1 by rememberSaveable {
var checkboxData1 by remember {
mutableStateOf(CheckBoxData(uid = "0", checked = true, enabled = true, textInput = "Label"))
}
var checkboxData2 by rememberSaveable {
var checkboxData2 by remember {
mutableStateOf(CheckBoxData(uid = "0", checked = false, enabled = true, textInput = "Label"))
}
val checkboxData3 by rememberSaveable {
val checkboxData3 by remember {
mutableStateOf(CheckBoxData(uid = "0", checked = false, enabled = true, textInput = "Label"))
}
val checkboxData4 by rememberSaveable {
val checkboxData4 by remember {
mutableStateOf(CheckBoxData(uid = "0", checked = true, enabled = true, textInput = "Label"))
}
InputYesOnlyCheckBox(
Expand Down
3 changes: 1 addition & 2 deletions designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ kotlin {
}

androidMain.dependencies {
api("androidx.activity:activity-compose:1.8.1")
api("androidx.activity:activity-compose:1.8.2")
api("androidx.appcompat:appcompat:1.6.1")
api("androidx.core:core-ktx:1.12.0")
implementation("androidx.compose.material3:material3:1.1.2")
implementation("com.google.zxing:core:3.5.2")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ internal fun <T> BasicInputImage(
Spacing.Spacing0
},
),
onImageClick = {
onImageClick.invoke()
focusRequester.requestFocus()
},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.material.ripple.LocalRippleTheme
import androidx.compose.material3.Checkbox
import androidx.compose.material3.CheckboxDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
Expand Down Expand Up @@ -49,7 +50,7 @@ fun CheckBox(

Row(
horizontalArrangement = Arrangement.spacedBy(Spacing.Spacing0, Alignment.Start),
verticalAlignment = Alignment.Top,
verticalAlignment = Alignment.CenterVertically,
modifier = modifier
.clickable(
interactionSource = interactionSource,
Expand Down Expand Up @@ -91,6 +92,7 @@ fun CheckBox(
.hoverPointerIcon(checkBoxData.enabled),
text = it,
color = textColor,
style = MaterialTheme.typography.bodyLarge,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2SCustomTextStyles
import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing.Spacing16
import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing.Spacing8
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor
import androidx.compose.ui.text.style.TextOverflow
import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor

private const val MAX_DROPDOWN_ITEMS = 6
Expand Down Expand Up @@ -249,6 +250,8 @@ private fun DropdownInputField(
TextColor.OnDisabledSurface
},
),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Box(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ fun <T> InputImage(
onShareButtonClick: () -> Unit,
onResetButtonClicked: () -> Unit,
onAddButtonClicked: () -> Unit,
onImageClick: () -> Unit,
) {
BasicInputImage(
title = title,
Expand All @@ -63,5 +64,6 @@ fun <T> InputImage(
onShareButtonClick = onShareButtonClick,
onResetButtonClicked = onResetButtonClicked,
onAddButtonClicked = onAddButtonClicked,
onImageClick = onImageClick,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
Expand All @@ -31,7 +31,6 @@ import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
import org.hisp.dhis.mobile.ui.designsystem.theme.Border
import org.hisp.dhis.mobile.ui.designsystem.theme.Outline
import org.hisp.dhis.mobile.ui.designsystem.theme.Radius
Expand Down Expand Up @@ -134,10 +133,12 @@ fun InputShell(
}
Box(Modifier.height(Spacing.Spacing2)) {
InputShellIndicator(
modifier = Modifier.align(Alignment.BottomStart),
color = indicatorColor,
thickness = indicatorThickness,
)
}

legend?.invoke(this)
if (state != InputShellState.DISABLED) supportingText?.invoke()
if (isRequiredField && state == InputShellState.ERROR && supportingText == null) SupportingText("Required", state = SupportingTextState.ERROR)
Expand All @@ -155,14 +156,18 @@ fun InputShell(
private fun InputShellRow(
modifier: Modifier = Modifier,
backgroundColor: Color,
content: @Composable (() -> Unit),
content: @Composable (RowScope.() -> Unit),
) {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
modifier = modifier.fillMaxWidth()
.background(backgroundColor)
.padding(Spacing.Spacing16, Spacing.Spacing8, Spacing.Spacing0, Spacing.Spacing6),
.padding(
start = Spacing.Spacing16,
top = Spacing.Spacing8,
end = Spacing.Spacing0,
bottom = Spacing.Spacing8,
),
) {
content()
}
Expand Down Expand Up @@ -196,16 +201,7 @@ private fun InputShellIndicator(
thickness: Dp = Border.Thin,
) {
Divider(
modifier = modifier
.fillMaxWidth()
.padding(
top = Spacing.Spacing0,
).offset {
IntOffset(
0,
if (thickness == Border.Thin) 0 else -2,
)
},
modifier = modifier.fillMaxWidth(),
thickness = thickness,
color = color,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ fun <T> InputSignature(
onShareButtonClick: () -> Unit,
onResetButtonClicked: () -> Unit,
onAddButtonClicked: () -> Unit,
onImageClick: () -> Unit,
) {
BasicInputImage(
title = title,
Expand All @@ -63,5 +64,6 @@ fun <T> InputSignature(
onShareButtonClick = onShareButtonClick,
onResetButtonClicked = onResetButtonClicked,
onAddButtonClicked = onAddButtonClicked,
onImageClick = onImageClick,
)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.hisp.dhis.mobile.ui.designsystem.component

import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -50,7 +49,6 @@ fun InputYesOnlyCheckBox(
inputField = {
CheckBox(
modifier = Modifier
.padding(bottom = Spacing.Spacing4)
.offset(x = -Spacing.Spacing8),
checkBoxData = CheckBoxData(
uid = checkBoxData.uid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.ripple.LocalRippleTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.RadioButton
import androidx.compose.material3.RadioButtonDefaults
import androidx.compose.material3.Text
Expand Down Expand Up @@ -42,7 +43,7 @@ fun RadioButton(
val interactionSource = if (radioButtonData.enabled) remember { MutableInteractionSource() } else MutableInteractionSource()
Row(
horizontalArrangement = Arrangement.spacedBy(Spacing.Spacing0, Alignment.Start),
verticalAlignment = Alignment.Top,
verticalAlignment = Alignment.CenterVertically,
modifier = modifier
.clickable(
interactionSource = interactionSource,
Expand Down Expand Up @@ -88,6 +89,7 @@ fun RadioButton(
} else {
TextColor.OnDisabledSurface
},
style = MaterialTheme.typography.bodyLarge,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ internal fun InputShellLabelText(
) {
Text(
text,
modifier = modifier,
modifier = modifier.padding(vertical = Spacing.Spacing2),
color = textColor,
style = MaterialTheme.typography.bodyMedium,
textAlign = TextAlign.Start,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ internal object DHIS2SCustomTextStyles {
letterSpacing = 0.15.sp,
)

val bodyLargeBold: TextStyle
@Composable
@ReadOnlyComposable
get() = MaterialTheme.typography.bodyLarge.copy(
fontWeight = FontWeight.Bold,
color = TextColor.OnSurface,
)
val bodyLargeBold = TextStyle(
fontSize = 16.sp,
lineHeight = 24.sp,
fontWeight = FontWeight.Bold,
color = TextColor.OnSurface,
letterSpacing = 0.5.sp,
)

val clickableSupportingText = SpanStyle(
fontSize = 14.sp,
Expand Down
Loading

0 comments on commit 0e3058f

Please sign in to comment.