Skip to content

Commit

Permalink
Merge pull request #221 from myofficework000/thread_comment_section
Browse files Browse the repository at this point in the history
added thread_comment_section
  • Loading branch information
myofficework000 authored Dec 15, 2023
2 parents 10803cb + 8072a62 commit c20420c
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.example.jetpack_compose_all_in_one

import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.example.jetpack_compose_all_in_one.demos.thread.ThreadCommentSection
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class ThreadCommentSectionTest {
private lateinit var icon: SemanticsNodeInteraction
private lateinit var firstOneMessageText: SemanticsNodeInteraction
private lateinit var sendMessageHereText: SemanticsNodeInteraction

@get:Rule
val composableRule = createComposeRule()

@Test
fun uiComponentTest() {
composableRule.setContent {
ThreadCommentSection()
}

icon = composableRule.onNodeWithTag("comment_icon")
firstOneMessageText = composableRule.onNodeWithTag("first_comment_static_text")
sendMessageHereText = composableRule.onNodeWithTag("start_conversation_static_text")

icon.assertExists()
firstOneMessageText.assertExists()
sendMessageHereText.assertExists()
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,58 @@
package com.example.jetpack_compose_all_in_one.demos.thread

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
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.material.icons.Icons
import androidx.compose.material.icons.rounded.Message
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.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.jetpack_compose_all_in_one.ui.theme.Purple40

@Composable
@Preview(showBackground = true)
fun ThreadCommentSection() {
Column(Modifier.fillMaxWidth()) {
Spacer(modifier = Modifier.height(200.dp))
Icon(
Icons.Rounded.Message,
contentDescription = "",
modifier = Modifier
.height(100.dp)
.width(100.dp)
.align(Alignment.CenterHorizontally)
.testTag("comment_icon"),
tint = Purple40
)
Text(
text = "Be the first to like & comment",
modifier = Modifier.align(Alignment.CenterHorizontally)
.padding(20.dp)
.testTag("first_comment_static_text"),
style = TextStyle(fontSize = 30.sp, fontWeight = FontWeight.Bold),
textAlign = TextAlign.Center
)
Text(
text = "Start a Conversation",
modifier = Modifier.align(Alignment.CenterHorizontally)
.padding(20.dp)
.testTag("start_conversation_static_text"),
style = TextStyle(fontSize = 20.sp, fontWeight = FontWeight.Medium),
textAlign = TextAlign.Center
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.example.jetpack_compose_all_in_one.demos.thread

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview

@Composable
@Preview(showBackground = true)
fun ThreadUI(){
Column(Modifier.fillMaxSize()) {
ThreadCommentSection()
}
}

0 comments on commit c20420c

Please sign in to comment.