Skip to content
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
9 changes: 5 additions & 4 deletions app/src/main/java/co/yml/coreui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.ui.Modifier
import co.yml.coreui.feature.ytag.ui.YTagActivity
import co.yml.coreui.core.ui.templates.AppBar
import co.yml.coreui.core.ui.theme.CoreUICatalogTheme
import co.yml.coreui.feature.ytag.ui.YTagActivity
import co.yml.coreui.ui.R
import co.yml.coreui.ui.presentation.CoreUIComponents
import dagger.hilt.android.AndroidEntryPoint
Expand All @@ -30,10 +30,11 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
setContent {
CoreUICatalogTheme {
Scaffold(modifier = Modifier.fillMaxSize(),
Scaffold(
modifier = Modifier.fillMaxSize(),
containerColor = CoreUICatalogTheme.colors.background,
topBar = { AppBar() })
{
topBar = { AppBar() }
) {
Column(
modifier = Modifier
.padding(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ fun CoreUIComponents(title: String, onClick: () -> Unit) {
)
)
.fillMaxWidth()
.height(48.dp), onClick = onClick,
.height(48.dp),
onClick = onClick,
colors = ButtonDefaults.buttonColors(containerColor = CoreUICatalogTheme.colors.button)
) {
Text(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package co.yml.coreui.common

import co.yml.coreui.core.common.di.DispatcherModule
import co.yml.coreui.core.common.di.DispatcherModule_ProvideNetworkDispatcherFactory.provideNetworkDispatcher
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertTrue
import org.junit.Test
import co.yml.coreui.core.common.di.DispatcherModule
import co.yml.coreui.core.common.di.DispatcherModule_ProvideNetworkDispatcherFactory.provideNetworkDispatcher

/**
* Test coroutine provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ import dagger.hilt.components.SingletonComponent
*/
@Module
@InstallIn(SingletonComponent::class)
interface RepositoryModule {

}
interface RepositoryModule
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ class TagViewContainerTesting {
}

@Test
fun tagViewContainer_tags_shown(){
fun tagViewContainer_tags_shown() {
launchTagViewContainer()

composeTestRule.onNodeWithText("Tag 1").assertIsDisplayed()
}

@Test
fun tagViewContainer_with_less_space_more_tag_shown(){
fun tagViewContainer_with_less_space_more_tag_shown() {
val tagViewContainerModifiers = TagViewContainerModifiers.Builder()
.width(150.dp)
.height(50.dp)
Expand Down
24 changes: 11 additions & 13 deletions core/ui/src/androidTest/java/co/yml/coreui/ui/ytag/TagViewTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import co.yml.coreui.core.ui.ytag.model.TagViewModifiers
import co.yml.coreui.core.ui.ytag.TagView
import co.yml.coreui.core.ui.ytag.model.TagViewModifiers
import org.junit.Rule
import org.junit.Test

Expand Down Expand Up @@ -50,7 +50,6 @@ class TagViewTest {

@Test
fun tagView_shown() {

launchYTag(text = "YTag")
composeTestRule.onNodeWithTag("tag_view", useUnmergedTree = true).printToString()

Expand Down Expand Up @@ -94,7 +93,6 @@ class TagViewTest {

@Test
fun tagView_leading_and_trailing_icon_shown() {

launchYTag(text = "YTag", leadingIcon = {
IconButton(onClick = {}, modifier = Modifier.testTag("leading_icon")) {
Icon(
Expand All @@ -103,20 +101,20 @@ class TagViewTest {
)
}
}, trailingIcon = {
IconButton(onClick = {}, modifier = Modifier.testTag("trailing_icon")) {
Icon(
painter = painterResource(id = R.drawable.ic_menu_mylocation),
contentDescription = null
)
}
})
IconButton(onClick = {}, modifier = Modifier.testTag("trailing_icon")) {
Icon(
painter = painterResource(id = R.drawable.ic_menu_mylocation),
contentDescription = null
)
}
})

composeTestRule.onNodeWithTag("leading_icon", useUnmergedTree = true).assertIsDisplayed()
composeTestRule.onNodeWithTag("trailing_icon", useUnmergedTree = true).assertIsDisplayed()
}

@Test
fun tag_with_modifiers_are_executed(){
fun tag_with_modifiers_are_executed() {
val tagViewModifiers = TagViewModifiers.Builder()
.minWidth(32.dp)
.minHeight(100.dp)
Expand All @@ -134,7 +132,7 @@ class TagViewTest {
.overFlow(TextOverflow.Ellipsis)
.softWrap(true)
.maxLines(1)
.onTextLayout { }
.onTextLayout { }
.style(TextStyle())
.enableBorder(true)
.borderColor(Color.Red)
Expand All @@ -145,7 +143,7 @@ class TagViewTest {
.tonalElevation(2.dp)
.shadowElevation(2.dp)
.containerPaddingValues(PaddingValues(4.dp))
.onCLick { }
.onCLick { }
.borderWidth(1.dp)
.build()

Expand Down
19 changes: 10 additions & 9 deletions core/ui/src/main/java/co/yml/coreui/core/ui/templates/AppBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ fun AppBar() {
}
}


/**
* Top app bars display information and actions at the top of a screen.
*
* @param title title of the screen
* @param onBackPressed implementation of back press event
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AppBarWithBackButton(title: String, onBackPressed: () -> Unit) {
Surface(shadowElevation = dimensionResource(id = R.dimen.padding_small)) {
Expand All @@ -69,38 +69,39 @@ fun AppBarWithBackButton(title: String, onBackPressed: () -> Unit) {
Icon(
painter = painterResource(id = R.drawable.ic_back_arrow),
contentDescription = "Back",
tint = Color.Black
tint = CoreUICatalogTheme.colors.primary
)
}
}
)
}
}


@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
CoreUICatalogTheme {
Scaffold(modifier = Modifier.fillMaxSize(),
Scaffold(
modifier = Modifier.fillMaxSize(),
containerColor = CoreUICatalogTheme.colors.background,
topBar = { AppBar() },
content = { Box(Modifier.padding(it)) {} })
content = { Box(Modifier.padding(it)) {} }
)
}
}


@Preview(showBackground = true)
@Composable
fun AppBarWithBackButton() {
CoreUICatalogTheme {
Scaffold(modifier = Modifier.fillMaxSize(),
Scaffold(
modifier = Modifier.fillMaxSize(),
containerColor = CoreUICatalogTheme.colors.background,
topBar = {
AppBarWithBackButton(title = stringResource(id = R.string.title_y_tag)) {
}
},
content = { Box(Modifier.padding(it)) {} })

content = { Box(Modifier.padding(it)) {} }
)
}
}
2 changes: 1 addition & 1 deletion core/ui/src/main/java/co/yml/coreui/core/ui/theme/Shape.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ data class CoreUICatalogShapes(
val large: RoundedCornerShape = RoundedCornerShape(0.dp)
)

internal val LocalShapes = staticCompositionLocalOf {CoreUICatalogShapes() }
internal val LocalShapes = staticCompositionLocalOf { CoreUICatalogShapes() }
Loading