diff --git a/.idea/androidTestResultsUserPreferences.xml b/.idea/androidTestResultsUserPreferences.xml index 566425cd..5da62a9a 100644 --- a/.idea/androidTestResultsUserPreferences.xml +++ b/.idea/androidTestResultsUserPreferences.xml @@ -29,6 +29,19 @@ + + + + + + + @@ -42,6 +55,19 @@ + + + + + + + @@ -160,6 +186,19 @@ + + + + + + + @@ -186,6 +225,19 @@ + + + + + + + @@ -447,6 +499,19 @@ + + + + + + + @@ -487,6 +552,19 @@ + + + + + + + @@ -552,6 +630,19 @@ + + + + + + + @@ -578,6 +669,19 @@ + + + + + + + @@ -644,6 +748,19 @@ + + + + + + + diff --git a/tarkaui/build.gradle.kts b/tarkaui/build.gradle.kts index e1625556..3b5e8002 100644 --- a/tarkaui/build.gradle.kts +++ b/tarkaui/build.gradle.kts @@ -64,7 +64,7 @@ publishing { run { groupId = "com.tarkalabs" artifactId = getLibraryArtifactId() - version = "1.0.1" + version = "1.0.2" artifact("$buildDir/outputs/aar/${getLibraryArtifactId()}-release.aar") } } diff --git a/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavBurgerButton_darkTheme_false.png b/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavBurgerButton_darkTheme_false.png new file mode 100644 index 00000000..535f2c92 Binary files /dev/null and b/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavBurgerButton_darkTheme_false.png differ diff --git a/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavBurgerButton_darkTheme_true.png b/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavBurgerButton_darkTheme_true.png new file mode 100644 index 00000000..06389333 Binary files /dev/null and b/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavBurgerButton_darkTheme_true.png differ diff --git a/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavButton_darkTheme_false.png b/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavButton_darkTheme_false.png new file mode 100644 index 00000000..5a7c895e Binary files /dev/null and b/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavButton_darkTheme_false.png differ diff --git a/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavButton_darkTheme_true.png b/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavButton_darkTheme_true.png new file mode 100644 index 00000000..8fb96095 Binary files /dev/null and b/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavButton_darkTheme_true.png differ diff --git a/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavListButton_darkTheme_false.png b/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavListButton_darkTheme_false.png new file mode 100644 index 00000000..e4b4caad Binary files /dev/null and b/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavListButton_darkTheme_false.png differ diff --git a/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavListButton_darkTheme_true.png b/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavListButton_darkTheme_true.png new file mode 100644 index 00000000..fa938f4d Binary files /dev/null and b/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavListButton_darkTheme_true.png differ diff --git a/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavViewToggleButton_darkTheme_false.png b/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavViewToggleButton_darkTheme_false.png new file mode 100644 index 00000000..143c8a96 Binary files /dev/null and b/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavViewToggleButton_darkTheme_false.png differ diff --git a/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavViewToggleButton_darkTheme_true.png b/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavViewToggleButton_darkTheme_true.png new file mode 100644 index 00000000..beb3a1bd Binary files /dev/null and b/tarkaui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIFloatingNavButtonScreenShotTest__floatingNavViewToggleButton_darkTheme_true.png differ diff --git a/tarkaui/src/androidTest/java/com/tarkalabs/uicomponents/TUIDividerTest.kt b/tarkaui/src/androidTest/java/com/tarkalabs/uicomponents/TUIDividerTest.kt new file mode 100644 index 00000000..2be22d0e --- /dev/null +++ b/tarkaui/src/androidTest/java/com/tarkalabs/uicomponents/TUIDividerTest.kt @@ -0,0 +1,25 @@ +package com.tarkalabs.uicomponents + +import androidx.compose.ui.test.assertIsDisplayed +import androidx.compose.ui.test.junit4.createComposeRule +import androidx.compose.ui.test.onNodeWithTag +import com.tarkalabs.uicomponents.components.Orientation.HORIZONTAL +import com.tarkalabs.uicomponents.components.TUIDivider +import com.tarkalabs.uicomponents.components.TUIDividerTags +import org.junit.Rule +import org.junit.Test + +class TUIDividerTest { + @get:Rule val composeTestRule = createComposeRule() + + private val tags = TUIDividerTags(parentTag = "testTag") + + @Test fun divider_Displayed() { + composeTestRule.setContent { + TUIDivider( + tags = tags, orientation = HORIZONTAL + ) + } + composeTestRule.onNodeWithTag(tags.parentTag).assertIsDisplayed() + } +} \ No newline at end of file diff --git a/tarkaui/src/androidTest/java/com/tarkalabs/uicomponents/TUIFloatingNavButtonTest.kt b/tarkaui/src/androidTest/java/com/tarkalabs/uicomponents/TUIFloatingNavButtonTest.kt new file mode 100644 index 00000000..eb3953bf --- /dev/null +++ b/tarkaui/src/androidTest/java/com/tarkalabs/uicomponents/TUIFloatingNavButtonTest.kt @@ -0,0 +1,157 @@ +package com.tarkalabs.uicomponents + +import androidx.compose.ui.test.assertIsDisplayed +import androidx.compose.ui.test.junit4.createComposeRule +import androidx.compose.ui.test.onNodeWithTag +import androidx.compose.ui.test.performClick +import com.tarkalabs.tarkaicons.CalendarRtl24 +import com.tarkalabs.tarkaicons.Directions24 +import com.tarkalabs.tarkaicons.Diversity24 +import com.tarkalabs.tarkaicons.Map24 +import com.tarkalabs.tarkaicons.TarkaIcons +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButton +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonContentType.Burger +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonContentType.List +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonContentType.Navigation +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.BURGER +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.LIST +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.VIEW_TOGGLE +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonTags +import org.junit.Rule +import org.junit.Test +import org.mockito.kotlin.mock +import org.mockito.kotlin.verify + +class TUIFloatingNavButtonTest { + + @get:Rule val composable = createComposeRule() + private val tags = TUIFloatingNavButtonTags() + + + @Test fun floating_nav_btn_is_displayed() { + val onClick: () -> Unit = mock() + composable.run { + setContent { + TUIFloatingNavButton( + contentType = Navigation(TarkaIcons.Filled.Diversity24, text = "Test"), + onClicked = onClick, tags = tags + ) + } + onNodeWithTag(tags.parentTag).run { + assertIsDisplayed() + performClick() + verify(onClick)() + } + + onNodeWithTag(tags.leadingIconTag, true).assertIsDisplayed() + onNodeWithTag(tags.trailingIconTag, true).assertIsDisplayed() + } + } + + @Test fun floating_nav_btn_trailing_icon_is_not_displayed() { + val onClick: () -> Unit = mock() + composable.run { + setContent { + TUIFloatingNavButton( + contentType = Navigation(TarkaIcons.Filled.Diversity24, text = "Test"), + onClicked = onClick, tags = tags, style = VIEW_TOGGLE + ) + } + onNodeWithTag(tags.parentTag).run { + assertIsDisplayed() + performClick() + verify(onClick)() + } + + onNodeWithTag(tags.leadingIconTag, true).assertIsDisplayed() + onNodeWithTag(tags.trailingIconTag, true).assertDoesNotExist() + } + } + + @Test fun floating_nav_list_type_all_icons_are_displayed() { + val onIconOneClick: () -> Unit = mock() + val onIconTwoClick: () -> Unit = mock() + val onIconThreeClick: () -> Unit = mock() + + composable.run { + setContent { + TUIFloatingNavButton( + contentType = List( + iconOne = TarkaIcons.Filled.CalendarRtl24, + onIconOneClick = onIconOneClick, + iconTwo = TarkaIcons.Filled.Map24, + onIconTwoClick = onIconTwoClick, + iconThree = TarkaIcons.Filled.Directions24, + onIconThreeClick = onIconThreeClick + ), + style = LIST + ) + } + onNodeWithTag(tags.iconOneTag).run { + assertIsDisplayed() + performClick() + verify(onIconOneClick)() + } + onNodeWithTag(tags.iconTwoTag).run { + assertIsDisplayed() + performClick() + verify(onIconTwoClick)() + } + onNodeWithTag(tags.iconThreeTag).run { + assertIsDisplayed() + performClick() + verify(onIconThreeClick)() + } + } + } + + @Test fun floating_nav_list_type_few_icons_are_displayed() { + val onIconOneClick: () -> Unit = mock() + val onIconTwoClick: () -> Unit = mock() + + composable.run { + setContent { + TUIFloatingNavButton( + contentType = List( + iconOne = TarkaIcons.Filled.CalendarRtl24, + onIconOneClick = onIconOneClick, + iconTwo = TarkaIcons.Filled.Map24, + onIconTwoClick = onIconTwoClick, + ), + style = LIST + ) + } + onNodeWithTag(tags.iconOneTag).run { + assertIsDisplayed() + performClick() + verify(onIconOneClick)() + } + onNodeWithTag(tags.iconTwoTag).run { + assertIsDisplayed() + performClick() + verify(onIconTwoClick)() + } + onNodeWithTag(tags.iconThreeTag).run { + assertDoesNotExist() + } + } + } + + @Test fun floating_nav_burger_button_is_displayed() { + val onClick: () -> Unit = mock() + composable.run { + setContent { + TUIFloatingNavButton( + contentType = Burger, + style = BURGER, + onClicked = onClick + ) + } + onNodeWithTag(tags.burgerIconTag, true).run { + assertIsDisplayed() + performClick() + verify(onClick)() + } + } + } +} \ No newline at end of file diff --git a/tarkaui/src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUIDividerScreenshotTest.kt b/tarkaui/src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUIDividerScreenshotTest.kt new file mode 100644 index 00000000..8ccc62a8 --- /dev/null +++ b/tarkaui/src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUIDividerScreenshotTest.kt @@ -0,0 +1,76 @@ +package com.tarkalabs.uicomponents.screenshots + +import com.tarkalabs.uicomponents.components.HorizontalPaddingSize +import com.tarkalabs.uicomponents.components.HorizontalPaddingSize.L +import com.tarkalabs.uicomponents.components.HorizontalPaddingSize.M +import com.tarkalabs.uicomponents.components.HorizontalPaddingSize.S +import com.tarkalabs.uicomponents.components.HorizontalPaddingSize.XL +import com.tarkalabs.uicomponents.components.HorizontalPaddingSize.NONE +import com.tarkalabs.uicomponents.components.Orientation +import com.tarkalabs.uicomponents.components.Orientation.HORIZONTAL +import com.tarkalabs.uicomponents.components.Orientation.VERTICAL +import com.tarkalabs.uicomponents.components.TUIDivider +import com.tarkalabs.uicomponents.components.TUIDividerTags +import com.tarkalabs.uicomponents.components.VerticalPaddingSize +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.Parameterized + +@RunWith(Parameterized::class) +class TUIDividerScreenshotTest( + private val darkTheme: Boolean, + private val orientation: Orientation, + private val tuiDividerTags: TUIDividerTags, + private val horizontalPaddingSize: HorizontalPaddingSize, + private val verticalPaddingSize: VerticalPaddingSize, + private val testName: String, +) : ComposeScreenshotComparator() { + + companion object { + @JvmStatic + @Parameterized.Parameters + fun data(): Collection> { + val darkThemeValues = listOf(true, false) + val orientationValues = listOf(HORIZONTAL, VERTICAL) + val tuiDividerTags = TUIDividerTags("TUIDivider") + val horizontalPaddingSize = listOf(NONE, S, M, L, XL) + val verticalPaddingSize = listOf(VerticalPaddingSize.NONE, VerticalPaddingSize.M) + + val testData = arrayListOf>() + + for (darkTheme in darkThemeValues) { + for (orientation in orientationValues) { + for (horizontalPadding in horizontalPaddingSize) { + for (verticalPadding in verticalPaddingSize) { + + val testName = + "darkTheme_${darkTheme}_orientationValues_${orientation}" + + "_horizontalPadding_${horizontalPadding}_verticalPadding_${verticalPadding}" + testData.add( + arrayOf( + darkTheme, + orientation, + tuiDividerTags, + horizontalPadding, + verticalPadding, + testName + ) + ) + } + } + } + } + return testData + } + } + + @Test + fun test_tui_divider_with_all_possible_params() { + compareScreenshotFor(darkTheme = darkTheme, imageName = testName) { + TUIDivider( + orientation = orientation, tags = tuiDividerTags, + horizontalPadding = horizontalPaddingSize, verticalPadding = verticalPaddingSize + ) + } + } +} \ No newline at end of file diff --git a/tarkaui/src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUIFloatingNavButtonScreenShotTest.kt b/tarkaui/src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUIFloatingNavButtonScreenShotTest.kt new file mode 100644 index 00000000..1e61346f --- /dev/null +++ b/tarkaui/src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUIFloatingNavButtonScreenShotTest.kt @@ -0,0 +1,68 @@ +package com.tarkalabs.uicomponents.screenshots + +import com.tarkalabs.tarkaicons.CalendarRtl24 +import com.tarkalabs.tarkaicons.Directions24 +import com.tarkalabs.tarkaicons.Diversity24 +import com.tarkalabs.tarkaicons.Map24 +import com.tarkalabs.tarkaicons.TarkaIcons +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButton +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonContentType.Burger +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonContentType.List +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonContentType.Navigation +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.BURGER +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.LIST +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.NAVIGATION +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.VIEW_TOGGLE +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.Parameterized + +@RunWith(Parameterized::class) +class TUIFloatingNavButtonScreenShotTest( + private val darkTheme: Boolean, + private val testName: String, +) : ComposeScreenshotComparator() { + + companion object { + @JvmStatic + @Parameterized.Parameters + fun data(): Collection> { + return mutableListOf>().apply { + for (darkTheme in listOf(true, false)) { + val testName = "darkTheme_${darkTheme}" + add(arrayOf(darkTheme, testName)) + } + } + } + } + + @Test fun floatingNavButton() = compareScreenshotFor(darkTheme, "_floatingNavButton_$testName") { + TUIFloatingNavButton( + contentType = Navigation(leadingIcon = TarkaIcons.Filled.Diversity24, text = "Overview"), + style = NAVIGATION + ) + } + + @Test fun floatingNavViewToggleButton() = + compareScreenshotFor(darkTheme, "_floatingNavViewToggleButton_$testName") { + TUIFloatingNavButton( + contentType = Navigation(leadingIcon = TarkaIcons.Filled.Diversity24, text = "Overview"), + style = VIEW_TOGGLE + ) + } + + @Test fun floatingNavBurgerButton() = + compareScreenshotFor(darkTheme, "_floatingNavBurgerButton_$testName") { + TUIFloatingNavButton(contentType = Burger, style = BURGER) + } + + @Test fun floatingNavListButton() = + compareScreenshotFor(darkTheme, "_floatingNavListButton_$testName") { + TUIFloatingNavButton( + contentType = List( + iconOne = TarkaIcons.Filled.CalendarRtl24, iconTwo = TarkaIcons.Filled.Map24, + iconThree = TarkaIcons.Filled.Directions24 + ), style = LIST + ) + } +} \ No newline at end of file diff --git a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIAppTopBar.kt b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIAppTopBar.kt index e72b0019..a74b30f8 100644 --- a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIAppTopBar.kt +++ b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIAppTopBar.kt @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.wrapContentHeight -import androidx.compose.material3.Divider import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar @@ -200,7 +199,7 @@ import com.tarkalabs.uicomponents.theme.TUITheme scrollBehavior = scrollBehavior, ) } - Divider(modifier = Modifier.fillMaxWidth(), color = TUITheme.colors.surfaceVariant) + TUIDivider() } } diff --git a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIDivider.kt b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIDivider.kt new file mode 100644 index 00000000..3dd4d42b --- /dev/null +++ b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIDivider.kt @@ -0,0 +1,128 @@ +package com.tarkalabs.uicomponents.components + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.material3.Divider +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import com.tarkalabs.uicomponents.components.HorizontalPaddingSize.L +import com.tarkalabs.uicomponents.components.HorizontalPaddingSize.NONE +import com.tarkalabs.uicomponents.components.Orientation.HORIZONTAL +import com.tarkalabs.uicomponents.components.Orientation.VERTICAL +import com.tarkalabs.uicomponents.components.VerticalPaddingSize.M +import com.tarkalabs.uicomponents.theme.TUITheme + +/** + * + * TUIDivider creates a divider , in two orientations Horizontal and Vertical. + * + * @param orientation: The orientation of divider is passed as param (Horizontal or Vertical) + * @param thickness: The thickness of divider , default is one. + * @param horizontalPadding: Horizontal padding of this divider. + * @param verticalPadding: The Vertical padding of this divider. + * @param tags: The test tag for the row. + * @param color: The color of the divider, by default we're using surfaceVariantHover. + * + * Example usage: + * + * TUIDivider( + * orientation = HORIZONTAL, + * thickness = 2, + * horizontalPadding = L, + * verticalPadding = M, + * ) + * + */ + +@Composable +fun TUIDivider( + modifier: Modifier = Modifier, + orientation: Orientation = HORIZONTAL, + thickness: Int = 1, + color: Color = TUITheme.colors.surfaceVariantHover, + horizontalPadding: HorizontalPaddingSize = NONE, + verticalPadding: VerticalPaddingSize = VerticalPaddingSize.NONE, + tags: TUIDividerTags = TUIDividerTags(), +) { + when (orientation) { + VERTICAL -> { + //todo vertical divider is not yet implemented in any of the components so we don't know height + // .height(40.dp) + Row { + HorizontalSpacer(space = horizontalPadding.size) + Divider( + modifier = modifier + .fillMaxHeight() + .width(thickness.dp) + .padding(vertical = verticalPadding.size.dp) + .testTag(tag = tags.parentTag), + color = color + ) + HorizontalSpacer(space = horizontalPadding.size) + } + } + + HORIZONTAL -> { + Column { + VerticalSpacer(space = verticalPadding.size) + Divider( + modifier = modifier + .fillMaxWidth() + .height(thickness.dp) + .padding(horizontal = horizontalPadding.size.dp) + .testTag(tag = tags.parentTag), + color = color, + ) + VerticalSpacer(space = verticalPadding.size) + } + } + } +} + +@Preview +@Composable +fun TestTUIDivider() { + TUIDivider( + orientation = VERTICAL, + thickness = 20, + horizontalPadding = L, + verticalPadding = M, + ) + TUIDivider( + orientation = HORIZONTAL, + thickness = 20, + horizontalPadding = L, + verticalPadding = M, + ) +} + +data class TUIDividerTags( + val parentTag: String = "TUIDivider", +) + +enum class Orientation { + VERTICAL, + HORIZONTAL +} + +enum class HorizontalPaddingSize(val size: Int) { + XL(32), + L(24), + M(16), + S(8), + NONE(0); +} + +enum class VerticalPaddingSize(val size: Int) { + M(8), + NONE(0) +} diff --git a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIMobileButtonBlock.kt b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIMobileButtonBlock.kt index af2a8766..e5a60618 100644 --- a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIMobileButtonBlock.kt +++ b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIMobileButtonBlock.kt @@ -51,7 +51,7 @@ fun TUIMobileButtonBlock( tags: TUIMobileButtonBlockTags = TUIMobileButtonBlockTags() ) { Column(modifier.fillMaxWidth()) { - Divider(color = TUITheme.colors.surfaceVariant, thickness = 1.dp) + TUIDivider() Row( Modifier .background(TUITheme.colors.surface50) diff --git a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIMobileOverlayHeader.kt b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIMobileOverlayHeader.kt index bb171f7f..290de214 100644 --- a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIMobileOverlayHeader.kt +++ b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIMobileOverlayHeader.kt @@ -137,7 +137,9 @@ fun TUIMobileOverlayHeader( is HeaderWithTrailingIcon -> { HeaderText( - title = style.title, textAlign = TextAlign.Start, modifier = Modifier.weight(1f).padding(start = 16.dp) + title = style.title, textAlign = TextAlign.Start, modifier = Modifier + .weight(1f) + .padding(start = 16.dp) ) TUIIconButton( @@ -153,6 +155,21 @@ fun TUIMobileOverlayHeader( } } } + when(style) { + is HeaderWithBackIcon -> { + VerticalSpacer(space = 8) + TUIDivider() + } + is HeaderWithTitle -> { + VerticalSpacer(space = 16) + TUIDivider() + } + is HeaderWithTrailingIcon -> { + VerticalSpacer(space = 12) + TUIDivider() + } + None -> {} + } } } } diff --git a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIMultiLevelSelectorHeader.kt b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIMultiLevelSelectorHeader.kt index 943dbde2..5b139744 100644 --- a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIMultiLevelSelectorHeader.kt +++ b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUIMultiLevelSelectorHeader.kt @@ -35,8 +35,6 @@ object TUIMultiLevelSelectorHeader { * @param modifier Modifier for the header layout and appearance. * @param isSelected Boolean indicating whether the header is selected. * @param title Title text to be displayed in the header. - * @param leadingIcon Icon to be displayed on the leading (left) side of the header. - * @param trailingIcon Icon to be displayed on the trailing (right) side of the header (optional). * @param paddingValues Padding values for the header content. * @param tags Tags used for testing and identifying this Composable. * @param onClick Lambda function invoked when the header is clicked. diff --git a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUITextRow.kt b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUITextRow.kt index 9b41c504..231db87e 100644 --- a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUITextRow.kt +++ b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/TUITextRow.kt @@ -68,7 +68,7 @@ import com.tarkalabs.uicomponents.theme.TUITheme @Composable fun TUITextRow( title: String, style: TextRowStyle = Title, - modifier: Modifier = Modifier.fillMaxWidth(), + modifier: Modifier = Modifier, iconOne: TarkaIcon? = null, iconTwo: TarkaIcon? = null, buttonTitle: String? = null, diff --git a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/email/TUIEmailField.kt b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/email/TUIEmailField.kt index 25757bbb..bfda1714 100644 --- a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/email/TUIEmailField.kt +++ b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/email/TUIEmailField.kt @@ -17,7 +17,6 @@ import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.Button -import androidx.compose.material3.Divider import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Text import androidx.compose.material3.TextField @@ -33,7 +32,6 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment -import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester @@ -54,6 +52,7 @@ import com.tarkalabs.tarkaicons.TarkaIcons.Filled import com.tarkalabs.uicomponents.components.ChipType.Input import com.tarkalabs.uicomponents.components.TUIChip import com.tarkalabs.uicomponents.components.TUIChipTags +import com.tarkalabs.uicomponents.components.TUIDivider import com.tarkalabs.uicomponents.components.base.IconButtonStyle.GHOST import com.tarkalabs.uicomponents.components.base.TUIIconButton import com.tarkalabs.uicomponents.components.base.TUIIconButtonTags @@ -75,7 +74,7 @@ import kotlinx.coroutines.launch * @param onInvalidEmail The callback function to be invoked when user enter a invalid email address. */ @OptIn( - ExperimentalLayoutApi::class, ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class + ExperimentalLayoutApi::class, ExperimentalMaterial3Api::class ) @Composable fun TUIEmailField( modifier: Modifier = Modifier, title: String, @@ -219,9 +218,9 @@ import kotlinx.coroutines.launch ) } - Divider( - color = if (showTextField ) TUITheme.colors.primary else TUITheme.colors.surfaceVariant, - thickness = 2.dp, + TUIDivider( + color = if (showTextField) TUITheme.colors.primary else TUITheme.colors.surfaceVariant, + thickness = 2, modifier = Modifier.padding(top = 10.dp) ) diff --git a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/tab/TUIFloatingNavBar.kt b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/tab/TUIFloatingNavBar.kt index 731d6a88..f54196c3 100644 --- a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/tab/TUIFloatingNavBar.kt +++ b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/tab/TUIFloatingNavBar.kt @@ -44,7 +44,7 @@ import com.tarkalabs.uicomponents.theme.TUITheme horizontalArrangement = Arrangement.SpaceAround, modifier = modifier .horizontalScroll(rememberScrollState()) - .background(color = TUITheme.colors.onPrimary, shape = RoundedCornerShape(32.dp)) + .background(color = TUITheme.colors.primaryAltHover, shape = RoundedCornerShape(32.dp)) .border( width = 1.dp, color = TUITheme.colors.primaryAltHover, diff --git a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/tab/TUIFloatingNavButton.kt b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/tab/TUIFloatingNavButton.kt new file mode 100644 index 00000000..7f2d4b4a --- /dev/null +++ b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/tab/TUIFloatingNavButton.kt @@ -0,0 +1,234 @@ +package com.tarkalabs.uicomponents.components.tab + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Icon +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import com.tarkalabs.tarkaicons.CalendarRtl24 +import com.tarkalabs.tarkaicons.ChevronDown24 +import com.tarkalabs.tarkaicons.Directions24 +import com.tarkalabs.tarkaicons.Diversity24 +import com.tarkalabs.tarkaicons.Map24 +import com.tarkalabs.tarkaicons.Navigation24 +import com.tarkalabs.tarkaicons.TarkaIcon +import com.tarkalabs.tarkaicons.TarkaIcons +import com.tarkalabs.uicomponents.components.VerticalSpacer +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonContentType.Burger +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonContentType.List +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonContentType.Navigation +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.BURGER +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.LIST +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.NAVIGATION +import com.tarkalabs.uicomponents.components.tab.TUIFloatingNavButtonStyle.VIEW_TOGGLE +import com.tarkalabs.uicomponents.extentions.clickableWithoutRipple +import com.tarkalabs.uicomponents.theme.TUITheme + +enum class TUIFloatingNavButtonStyle { + NAVIGATION, + VIEW_TOGGLE, + LIST, + BURGER; + + companion object { + val defaultStyle: TUIFloatingNavButtonStyle = NAVIGATION + } +} + +sealed class TUIFloatingNavButtonContentType { + data class List( + val iconOne: TarkaIcon? = null, + val onIconOneClick: (() -> Unit)? = null, + val iconTwo: TarkaIcon? = null, + val onIconTwoClick: (() -> Unit)? = null, + val iconThree: TarkaIcon? = null, + val onIconThreeClick: (() -> Unit)? = null + ) : TUIFloatingNavButtonContentType() + + data class Navigation( + val leadingIcon: TarkaIcon? = null, + val text: String, + ) : TUIFloatingNavButtonContentType() + + object Burger : TUIFloatingNavButtonContentType() +} + +@Composable fun TUIFloatingNavButton( + modifier: Modifier = Modifier, + style: TUIFloatingNavButtonStyle = TUIFloatingNavButtonStyle.defaultStyle, + contentType: TUIFloatingNavButtonContentType, + onClicked: (() -> Unit)? = null, + tags: TUIFloatingNavButtonTags = TUIFloatingNavButtonTags() +) { + Row(modifier = modifier + .wrapContentSize() + .clickableWithoutRipple { + if (style != LIST && onClicked != null) { + onClicked() + } + } + .background(shape = RoundedCornerShape(32.dp), color = TUITheme.colors.primaryAltHover) + .testTag(tags.parentTag)) { + + when (contentType) { + is Burger -> TUIFloatingNavBurgerButton() + + is Navigation -> TUIFloatingNavTypeButton(contentType, style) + + is List -> TUIFloatingNavListButton(contentType) + } + } +} + +@Composable +private fun TUIFloatingNavTypeButton( + contentType: Navigation, + style: TUIFloatingNavButtonStyle, + tags: TUIFloatingNavButtonTags = TUIFloatingNavButtonTags(), +) { + Row( + modifier = Modifier.padding(horizontal = 16.dp, vertical = 16.dp), + verticalAlignment = Alignment.CenterVertically + ) { + + if (contentType.leadingIcon != null) Icon( + modifier = Modifier.testTag(tags.leadingIconTag), + painter = painterResource(id = contentType.leadingIcon.iconRes), + contentDescription = contentType.leadingIcon.contentDescription, + tint = TUITheme.colors.primary, + ) + + Text( + modifier = Modifier.padding(horizontal = 8.dp), + text = contentType.text, + style = TUITheme.typography.heading6, + color = TUITheme.colors.primary + ) + + if (style == NAVIGATION) { + Icon( + modifier = Modifier.testTag(tags.trailingIconTag), + painter = painterResource(id = TarkaIcons.Filled.ChevronDown24.iconRes), + contentDescription = TarkaIcons.Filled.ChevronDown24.contentDescription, + tint = TUITheme.colors.primary, + ) + } + } +} + +@Composable fun TUIFloatingNavListButton( + contentType: List, + tags: TUIFloatingNavButtonTags = TUIFloatingNavButtonTags(), +) { + Row( + modifier = Modifier + .padding(horizontal = 4.dp, vertical = 4.dp), + verticalAlignment = Alignment.CenterVertically + ) { + if (contentType.iconOne != null) { + Icon( + modifier = Modifier + .padding(12.dp) + .clickableWithoutRipple { + if (contentType.onIconOneClick != null) { + contentType.onIconOneClick.invoke() + } + } + .testTag(tags.iconOneTag), + painter = painterResource(id = contentType.iconOne.iconRes), + contentDescription = contentType.iconOne.contentDescription, + tint = TUITheme.colors.primary + ) + } + if (contentType.iconTwo != null) { + Icon( + modifier = Modifier + .padding(12.dp) + .clickableWithoutRipple { + if (contentType.onIconTwoClick != null) { + contentType.onIconTwoClick.invoke() + } + } + .testTag(tags.iconTwoTag), + painter = painterResource(id = contentType.iconTwo.iconRes), + contentDescription = contentType.iconTwo.contentDescription, + tint = TUITheme.colors.primary, + ) + } + if (contentType.iconThree != null) { + Icon( + modifier = Modifier + .padding(12.dp) + .clickableWithoutRipple { + if (contentType.onIconThreeClick != null) { + contentType.onIconThreeClick.invoke() + } + } + .testTag(tags.iconThreeTag), + painter = painterResource(id = contentType.iconThree.iconRes), + contentDescription = contentType.iconThree.contentDescription, + tint = TUITheme.colors.primary + ) + } + } +} + +@Composable +fun TUIFloatingNavBurgerButton(tags: TUIFloatingNavButtonTags = TUIFloatingNavButtonTags()) { + Icon( + modifier = Modifier + .padding(12.dp) + .testTag(tags.burgerIconTag), + painter = painterResource(id = TarkaIcons.Filled.Navigation24.iconRes), + contentDescription = TarkaIcons.Filled.Navigation24.contentDescription, + tint = TUITheme.colors.primary + ) +} + + +data class TUIFloatingNavButtonTags( + val parentTag: String = "TUIFloatingNavButton", + val leadingIconTag: String = "TUIFloatingNavButton_LeadingIcon", + val trailingIconTag: String = "TUIFloatingNavButton_TrailingIcon", + val iconOneTag: String = "TUIFloatingNavButton_Icon_One", + val iconTwoTag: String = "TUIFloatingNavButton_Icon_Two", + val iconThreeTag: String = "TUIFloatingNavButton_Icon_Three", + val burgerIconTag: String = "TUIFloatingNavButton_Burger_Icon" +) + +@Preview @Composable fun TUIFloatingNavButtonPreview() { + TUITheme { + Column( + horizontalAlignment = Alignment.CenterHorizontally + ) { + VerticalSpacer(space = 40) + TUIFloatingNavButton( + contentType = Navigation(leadingIcon = TarkaIcons.Filled.Diversity24, "Overview"), + ) + VerticalSpacer(space = 40) + TUIFloatingNavButton( + contentType = List( + iconOne = TarkaIcons.Regular.CalendarRtl24, iconTwo = TarkaIcons.Regular.Map24, + iconThree = TarkaIcons.Regular.Directions24 + ), style = LIST + ) + VerticalSpacer(space = 40) + TUIFloatingNavButton( + contentType = Navigation(leadingIcon = TarkaIcons.Filled.Diversity24, "Overview"), + style = VIEW_TOGGLE + ) + VerticalSpacer(space = 40) + TUIFloatingNavButton(contentType = Burger, style = BURGER) + } + } +} \ No newline at end of file diff --git a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/tab/TUIFloatingTab.kt b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/tab/TUIFloatingTab.kt index 68fe97ac..a9760044 100644 --- a/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/tab/TUIFloatingTab.kt +++ b/tarkaui/src/main/java/com/tarkalabs/uicomponents/components/tab/TUIFloatingTab.kt @@ -64,7 +64,7 @@ import com.tarkalabs.uicomponents.theme.TUITheme Text( modifier = Modifier.padding(16.dp), text = title, - style = TUITheme.typography.body6, + style = TUITheme.typography.heading6, color = if (selected) TUITheme.colors.onPrimary else TUITheme.colors.primary ) }