-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Androapp 6035 mobile UI create dropdown menu component (#295)
* Add data class for `MenuItem` component * Add `MenuItem` component * Add `MenuItemSnapshotTest` * Add `MenuItemTest` * Fix `MenuItem` Label and supporting text truncate * Fix snapshot test * add Enrolment menu to menu item showcase * Add shadow to enrollment menu --------- Co-authored-by: Siddharth Agarwal <[email protected]>
- Loading branch information
Showing
9 changed files
with
1,181 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
586 changes: 586 additions & 0 deletions
586
common/src/commonMain/kotlin/org/hisp/dhis/common/screens/others/MenuItemScreen.kt
Large diffs are not rendered by default.
Oops, something went wrong.
149 changes: 149 additions & 0 deletions
149
...m/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/MenuItemSnapshotTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
package org.hisp.dhis.mobile.ui.designsystem | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.automirrored.outlined.ArrowRight | ||
import androidx.compose.material.icons.outlined.Done | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
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.menuItem.MenuItem | ||
import org.hisp.dhis.mobile.ui.designsystem.component.menuItem.MenuItemData | ||
import org.hisp.dhis.mobile.ui.designsystem.component.menuItem.MenuItemState | ||
import org.hisp.dhis.mobile.ui.designsystem.component.menuItem.MenuItemStyle | ||
import org.hisp.dhis.mobile.ui.designsystem.component.menuItem.MenuLeadingElement | ||
import org.hisp.dhis.mobile.ui.designsystem.component.menuItem.MenuTrailingElement | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class MenuItemSnapshotTest { | ||
@get:Rule | ||
val paparazzi = paparazzi() | ||
|
||
@Test | ||
fun launchMenuItemTest() { | ||
paparazzi.snapshot { | ||
ColumnScreenContainer("Menu Item") { | ||
ColumnComponentContainer("Menu item") { | ||
Column( | ||
modifier = Modifier.fillMaxWidth(), | ||
verticalArrangement = Arrangement.spacedBy(20.dp), | ||
) { | ||
Row( | ||
horizontalArrangement = Arrangement.spacedBy(20.dp), | ||
) { | ||
MenuItem( | ||
modifier = Modifier.weight(1f), | ||
menuItemData = MenuItemData( | ||
label = "Label", | ||
supportingText = "Support Text", | ||
showDivider = true, | ||
leadingElement = MenuLeadingElement.Icon( | ||
icon = Icons.Outlined.Done, | ||
), | ||
trailingElement = MenuTrailingElement.Icon( | ||
icon = Icons.AutoMirrored.Outlined.ArrowRight, | ||
), | ||
), | ||
) {} | ||
|
||
MenuItem( | ||
modifier = Modifier.weight(1f), | ||
menuItemData = MenuItemData( | ||
label = "Label", | ||
supportingText = "Support Text", | ||
showDivider = true, | ||
style = MenuItemStyle.ALERT, | ||
leadingElement = MenuLeadingElement.Icon( | ||
icon = Icons.Outlined.Done, | ||
), | ||
trailingElement = MenuTrailingElement.Icon( | ||
icon = Icons.AutoMirrored.Outlined.ArrowRight, | ||
), | ||
), | ||
) {} | ||
} | ||
|
||
Row( | ||
horizontalArrangement = Arrangement.spacedBy(20.dp), | ||
) { | ||
MenuItem( | ||
modifier = Modifier.weight(1f), | ||
menuItemData = MenuItemData( | ||
label = "Label", | ||
supportingText = "Support Text", | ||
showDivider = true, | ||
state = MenuItemState.SELECTED, | ||
leadingElement = MenuLeadingElement.Icon( | ||
icon = Icons.Outlined.Done, | ||
), | ||
trailingElement = MenuTrailingElement.Icon( | ||
icon = Icons.AutoMirrored.Outlined.ArrowRight, | ||
), | ||
), | ||
) {} | ||
|
||
MenuItem( | ||
modifier = Modifier.weight(1f), | ||
menuItemData = MenuItemData( | ||
label = "Label", | ||
supportingText = "Support Text", | ||
showDivider = true, | ||
state = MenuItemState.SELECTED, | ||
style = MenuItemStyle.ALERT, | ||
leadingElement = MenuLeadingElement.Icon( | ||
icon = Icons.Outlined.Done, | ||
), | ||
trailingElement = MenuTrailingElement.Icon( | ||
icon = Icons.AutoMirrored.Outlined.ArrowRight, | ||
), | ||
), | ||
) {} | ||
} | ||
|
||
Row( | ||
horizontalArrangement = Arrangement.spacedBy(20.dp), | ||
) { | ||
MenuItem( | ||
modifier = Modifier.weight(1f), | ||
menuItemData = MenuItemData( | ||
label = "Label", | ||
supportingText = "Support Text", | ||
showDivider = true, | ||
state = MenuItemState.DISABLED, | ||
leadingElement = MenuLeadingElement.Icon( | ||
icon = Icons.Outlined.Done, | ||
), | ||
trailingElement = MenuTrailingElement.Icon( | ||
icon = Icons.AutoMirrored.Outlined.ArrowRight, | ||
), | ||
), | ||
) {} | ||
|
||
MenuItem( | ||
modifier = Modifier.weight(1f), | ||
menuItemData = MenuItemData( | ||
label = "Label", | ||
supportingText = "Support Text", | ||
showDivider = true, | ||
state = MenuItemState.DISABLED, | ||
style = MenuItemStyle.ALERT, | ||
leadingElement = MenuLeadingElement.Icon( | ||
icon = Icons.Outlined.Done, | ||
), | ||
trailingElement = MenuTrailingElement.Icon( | ||
icon = Icons.AutoMirrored.Outlined.ArrowRight, | ||
), | ||
), | ||
) {} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.