Skip to content

Commit

Permalink
Merge branch 'develop' into docs
Browse files Browse the repository at this point in the history
# Conflicts:
#	common/src/commonMain/kotlin/org/hisp/dhis/common/screens/cards/ListCardScreen.kt
#	designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputAge.kt
#	designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputDateTime.kt
#	designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/internal/DateTimeUtils.kt
  • Loading branch information
andresmr committed Oct 17, 2024
2 parents 98ef1f2 + a6e2209 commit 9347f7e
Show file tree
Hide file tree
Showing 55 changed files with 4,298 additions and 279 deletions.
21 changes: 21 additions & 0 deletions android/src/main/java/org/hisp/dhis/android/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.platform.LocalContext
import androidx.core.view.WindowCompat
import org.hisp.dhis.common.App
import org.hisp.dhis.mobile.ui.designsystem.component.model.LocationItemModel

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -28,6 +29,26 @@ class MainActivity : AppCompatActivity() {
.also { it.inPreferredConfig = Bitmap.Config.ARGB_8888 },
).asImageBitmap()
},
onLocationRequest = { locationQuery, locationSearchCallback ->

if (locationQuery.isNotBlank()) {
val fakeList = buildList<LocationItemModel> {
repeat(20) {
add(
LocationItemModel.SearchResult(
"Fake Location Title #$it",
"Fake Location Address, Fake Country, Fake City",
0.0,
0.0,
),
)
}
}
locationSearchCallback(fakeList)
} else {
locationSearchCallback(emptyList())
}
},
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
version = "0.3.0-SNAPSHOT"
version = "0.4.0-SNAPSHOT"
group = "org.hisp.dhis.mobile"

plugins {
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ kotlin {
implementation(compose.material3)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
implementation(project(":designsystem"))
api(project(":designsystem"))
}
commonTest.dependencies {
implementation(kotlin("test"))
Expand Down
30 changes: 27 additions & 3 deletions common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import org.hisp.dhis.common.screens.basicTextInputs.BasicTextInputsScreen
import org.hisp.dhis.common.screens.bottomSheets.BottomSheetsScreen
import org.hisp.dhis.common.screens.buttons.ButtonsScreen
import org.hisp.dhis.common.screens.cards.CardsScreen
import org.hisp.dhis.common.screens.location.LocationSearchBarScreen
import org.hisp.dhis.common.screens.menu.MenuScreen
import org.hisp.dhis.common.screens.others.BadgesScreen
import org.hisp.dhis.common.screens.others.ChipsScreen
import org.hisp.dhis.common.screens.others.IndicatorScreen
Expand All @@ -29,28 +31,44 @@ import org.hisp.dhis.common.screens.others.ProgressScreen
import org.hisp.dhis.common.screens.others.SearchBarScreen
import org.hisp.dhis.common.screens.others.SectionScreen
import org.hisp.dhis.common.screens.others.TagsScreen
import org.hisp.dhis.common.screens.others.TopBarScreen
import org.hisp.dhis.common.screens.parameter.ParameterSelectorScreen
import org.hisp.dhis.common.screens.toggleableInputs.ToggleableInputsScreen
import org.hisp.dhis.mobile.ui.designsystem.component.DropdownItem
import org.hisp.dhis.mobile.ui.designsystem.component.InputDropDown
import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState
import org.hisp.dhis.mobile.ui.designsystem.component.InputStyle
import org.hisp.dhis.mobile.ui.designsystem.component.MetadataAvatarSize
import org.hisp.dhis.mobile.ui.designsystem.component.model.LocationItemModel
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme
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

@Composable
fun App(imageBitmapLoader: (() -> ImageBitmap)? = null) {
fun App(
imageBitmapLoader: (() -> ImageBitmap)? = null,
onLocationRequest: (
(
locationQuery: String,
locationSearchCallback: (List<LocationItemModel>) -> Unit,
) -> Unit
)? = null,
) {
DHIS2Theme {
Main(imageBitmapLoader)
Main(imageBitmapLoader, onLocationRequest)
}
}

@Composable
fun Main(
imageBitmapLoader: (() -> ImageBitmap)?,
onLocationRequest: (
(
locationQuery: String,
locationSearchCallback: (List<LocationItemModel>) -> Unit,
) -> Unit
)?,
) {
val currentScreen = remember { mutableStateOf(Groups.NO_GROUP_SELECTED) }
var isComponentSelected by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -79,7 +97,8 @@ fun Main(
state = InputShellState.UNFOCUSED,
expanded = true,
selectedItem = DropdownItem(currentScreen.value.label),
inputStyle = InputStyle.DataInputStyle().apply { backGroundColor = SurfaceColor.SurfaceBright },
inputStyle = InputStyle.DataInputStyle()
.apply { backGroundColor = SurfaceColor.SurfaceBright },
)

when (currentScreen.value) {
Expand All @@ -100,7 +119,12 @@ fun Main(
Groups.TAGS -> TagsScreen()
Groups.SEARCH_BAR -> SearchBarScreen()
Groups.NAVIGATION_BAR -> NavigationBarScreen()
Groups.MENU -> MenuScreen()
Groups.NO_GROUP_SELECTED -> NoComponentSelectedScreen()
Groups.TOP_BAR -> TopBarScreen()
Groups.LOCATION_SEARCH_BAR -> LocationSearchBarScreen { locationQuery, locationCallback ->
onLocationRequest?.invoke(locationQuery, locationCallback)
}
}
} else {
NoComponentSelectedScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ enum class Groups(val label: String) {
INDICATOR("Indicators"),
PARAMETER_SELECTOR("Parameter selector"),
NAVIGATION_BAR("Navigation Bar"),
TOP_BAR("Top Bar"),
MENU("Menu"),
NO_GROUP_SELECTED("No group selected"),
LOCATION_SEARCH_BAR("Location Search Bar"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import org.hisp.dhis.mobile.ui.designsystem.component.AgeInputType
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer
import org.hisp.dhis.mobile.ui.designsystem.component.ColumnScreenContainer
import org.hisp.dhis.mobile.ui.designsystem.component.InputAge
import org.hisp.dhis.mobile.ui.designsystem.component.InputAgeModel
import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState
import org.hisp.dhis.mobile.ui.designsystem.component.LegendData
import org.hisp.dhis.mobile.ui.designsystem.component.TimeUnitValues
import org.hisp.dhis.mobile.ui.designsystem.component.state.InputAgeData
import org.hisp.dhis.mobile.ui.designsystem.component.state.rememberInputAgeState
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor

@Composable
Expand All @@ -24,100 +25,108 @@ fun InputAgeScreen() {

ColumnComponentContainer("Input Age Component - Idle") {
InputAge(
InputAgeModel(
title = "Label",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
),
inputType = inputType,
onValueChanged = { newInputType ->
inputType = newInputType
},
),
onValueChanged = { newInputType ->
inputType = newInputType ?: AgeInputType.None
},
)
}

ColumnComponentContainer("Input Age Component - Idle Disabled") {
InputAge(
InputAgeModel(
title = "Label",
inputType = AgeInputType.None,
state = InputShellState.DISABLED,
onValueChanged = { newInputType ->
inputType = newInputType
},
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
),
inputState = InputShellState.DISABLED,
),
onValueChanged = { newInputType ->
inputType = newInputType ?: AgeInputType.None
},
)
}

ColumnComponentContainer("Input Age Component - Date Of Birth") {
InputAge(
InputAgeModel(
title = "Label",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
),
inputType = AgeInputType.DateOfBirth(TextFieldValue("01011985")),
state = InputShellState.DISABLED,

onValueChanged = { newInputType ->
inputType = newInputType
},
inputState = InputShellState.DISABLED,
),
onValueChanged = { newInputType ->
inputType = newInputType ?: AgeInputType.None
},
)
}

ColumnComponentContainer("Input Age Component - Date Of Birth Required Error") {
InputAge(
InputAgeModel(
title = "Label",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
isRequired = true,
),
inputType = AgeInputType.DateOfBirth(TextFieldValue("010")),
state = InputShellState.ERROR,
isRequired = true,

onValueChanged = {
// no-op
},
inputState = InputShellState.ERROR,
),
onValueChanged = {
// no-op
},
)
}

ColumnComponentContainer("Input Age Component - Age Disabled") {
InputAge(
InputAgeModel(
title = "Label",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
),
inputType = AgeInputType.Age(value = TextFieldValue("56"), unit = TimeUnitValues.YEARS),
state = InputShellState.DISABLED,

onValueChanged = { newInputType ->
inputType = newInputType
},
inputState = InputShellState.DISABLED,
),
onValueChanged = { newInputType ->
inputType = newInputType ?: AgeInputType.None
},
)
}

ColumnComponentContainer("Input Age Component - Age Required Error") {
InputAge(
InputAgeModel(
title = "Label",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
isRequired = true,
),
inputType = AgeInputType.Age(value = TextFieldValue("56"), unit = TimeUnitValues.YEARS),
state = InputShellState.ERROR,
isRequired = true,

onValueChanged = {
// no-op
},
inputState = InputShellState.ERROR,
),
onValueChanged = {
// no-op
},
)
}

ColumnComponentContainer("Input Age Component - Legend") {
InputAge(
InputAgeModel(
title = "Label",
state = rememberInputAgeState(
inputAgeData = InputAgeData(
title = "Label",
isRequired = true,
),
inputType = AgeInputType.Age(value = TextFieldValue("56"), unit = TimeUnitValues.YEARS),
state = InputShellState.ERROR,
isRequired = true,

onValueChanged = {
// no-op
},
inputState = InputShellState.ERROR,
legendData = LegendData(SurfaceColor.CustomGreen, "Legend", popUpLegendDescriptionData = regularLegendList),
),
onValueChanged = {
// no-op
},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package org.hisp.dhis.common.screens.bottomSheets

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.MoveDown
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.text.style.TextAlign
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
Expand All @@ -30,6 +33,7 @@ fun OrgTreeBottomSheetScreen() {
var showTwoOrgTreeBottomSheet by rememberSaveable { mutableStateOf(false) }
var showMediumOrgTreeBottomSheet by rememberSaveable { mutableStateOf(false) }
var showLargeOrgTreeBottomSheet by rememberSaveable { mutableStateOf(false) }
var showTransferOrgBottomSheet by rememberSaveable { mutableStateOf(false) }

if (showOneOrgTreeBottomSheet) {
val orgTreeItemsRepo = remember { OrgTreeItemsFakeRepo() }
Expand Down Expand Up @@ -115,6 +119,31 @@ fun OrgTreeBottomSheetScreen() {
)
}

if (showTransferOrgBottomSheet) {
val orgTreeItemsRepo = remember { OrgTreeItemsFakeRepo() }
val oneOrgTreeItem by orgTreeItemsRepo.state.collectAsState(emptyList())

OrgBottomSheet(
title = "Transfer [tracked entity type]",
subtitle = "From [current owner org. unit] to...",
orgTreeItems = oneOrgTreeItem,
doneButtonText = "Transfer",
doneButtonIcon = Icons.Outlined.MoveDown,
headerTextAlignment = TextAlign.Left,
onDismiss = {
showTransferOrgBottomSheet = false
},
onSearch = orgTreeItemsRepo::search,
onItemClick = orgTreeItemsRepo::toggleItemExpansion,
onItemSelected = { uid, checked ->
orgTreeItemsRepo.toggleItemSelection(uid, checked)
},
onDone = {
// no-op
},
)
}

ColumnScreenContainer(title = BottomSheets.ORG_TREE_BOTTOM_SHEET.label) {
ColumnComponentContainer("Org Tree Bottom Sheet with single item") {
Button(
Expand Down Expand Up @@ -155,6 +184,16 @@ fun OrgTreeBottomSheetScreen() {
showLargeOrgTreeBottomSheet = !showLargeOrgTreeBottomSheet
}
}

ColumnComponentContainer("Transfer Org Tree Bottom Sheet") {
Button(
enabled = true,
ButtonStyle.FILLED,
text = "Show Transfer Org Tree Bottom Sheet",
) {
showTransferOrgBottomSheet = !showTransferOrgBottomSheet
}
}
}
}

Expand Down
Loading

0 comments on commit 9347f7e

Please sign in to comment.