-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from myofficework000/thread_comment_section
added thread_comment_section
- Loading branch information
Showing
3 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
app/src/androidTest/java/com/example/jetpack_compose_all_in_one/ThreadCommentSectionTest.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,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() | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...src/main/java/com/example/jetpack_compose_all_in_one/demos/thread/ThreadCommentSection.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 |
---|---|---|
@@ -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 | ||
) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/example/jetpack_compose_all_in_one/demos/thread/ThreadUI.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,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() | ||
} | ||
} |