Skip to content

Commit febad12

Browse files
committed
feat(message): message card component
1 parent 15294d8 commit febad12

File tree

16 files changed

+617
-16
lines changed

16 files changed

+617
-16
lines changed

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,24 @@ android {
4747
}
4848

4949
dependencies {
50-
5150
implementation 'androidx.core:core-ktx:1.7.0'
5251
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
5352
implementation 'androidx.activity:activity-compose:1.3.1'
5453
implementation "androidx.compose.ui:ui:$compose_version"
5554
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
5655
implementation 'androidx.compose.material3:material3:1.0.0-alpha11'
56+
implementation 'androidx.compose.ui:ui-viewbinding:1.4.0'
57+
implementation 'androidx.compose.ui:ui-util:1.4.0'
58+
implementation 'androidx.compose.material:material-icons-extended:1.4.0'
5759
testImplementation 'junit:junit:4.13.2'
5860
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
5961
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
6062
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
6163
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
6264
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
65+
def nav_version = "2.5.3"
66+
implementation("androidx.navigation:navigation-compose:$nav_version")
67+
implementation("io.coil-kt:coil-compose:2.3.0")
68+
// system bars customization
69+
implementation "com.google.accompanist:accompanist-systemuicontroller:0.28.0"
6370
}

app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools">
44

5+
<uses-permission android:name="android.permission.INTERNET"/>
6+
57
<application
68
android:allowBackup="true"
79
android:dataExtractionRules="@xml/data_extraction_rules"
@@ -11,6 +13,11 @@
1113
android:supportsRtl="true"
1214
android:theme="@style/Theme.ChatGPTLite"
1315
tools:targetApi="31">
16+
<activity
17+
android:name=".Conversations"
18+
android:exported="false"
19+
android:label="@string/title_activity_conversations"
20+
android:theme="@style/Theme.ChatGPTLite" />
1421
<activity
1522
android:name=".MainActivity"
1623
android:exported="true"

app/src/main/java/com/chatgptlite/wanted/MainActivity.kt

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,95 @@ import android.os.Bundle
44
import android.widget.ListView
55
import androidx.activity.ComponentActivity
66
import androidx.activity.compose.setContent
7+
import androidx.compose.foundation.gestures.detectTapGestures
8+
import androidx.compose.foundation.layout.Box
9+
import androidx.compose.foundation.layout.consumeWindowInsets
710
import androidx.compose.foundation.layout.fillMaxSize
8-
import androidx.compose.material3.MaterialTheme
9-
import androidx.compose.material3.Surface
10-
import androidx.compose.material3.Text
11+
import androidx.compose.foundation.layout.padding
12+
import androidx.compose.material3.*
1113
import androidx.compose.runtime.Composable
14+
import androidx.compose.runtime.SideEffect
1215
import androidx.compose.ui.Modifier
16+
import androidx.compose.ui.graphics.Color
17+
import androidx.compose.ui.graphics.toArgb
18+
import androidx.compose.ui.input.pointer.pointerInput
19+
import androidx.compose.ui.platform.ComposeView
1320
import androidx.compose.ui.tooling.preview.Preview
21+
import androidx.compose.ui.unit.dp
22+
import androidx.core.view.WindowCompat
23+
import androidx.navigation.findNavController
24+
import com.chatgptlite.wanted.ui.common.AppDrawer
25+
import com.chatgptlite.wanted.ui.common.AppScaffold
26+
import com.chatgptlite.wanted.ui.conversations.Conversations
1427
import com.chatgptlite.wanted.ui.theme.ChatGPTLiteTheme
28+
import androidx.compose.ui.viewinterop.AndroidView
29+
import androidx.compose.ui.viewinterop.AndroidViewBinding
30+
import androidx.core.content.ContextCompat
31+
import com.chatgptlite.wanted.ui.theme.BackGroundColor
32+
import com.google.accompanist.systemuicontroller.rememberSystemUiController
1533

1634
class MainActivity : ComponentActivity() {
35+
36+
@OptIn(ExperimentalMaterial3Api::class)
1737
override fun onCreate(savedInstanceState: Bundle?) {
1838
super.onCreate(savedInstanceState)
19-
setContent {
20-
ChatGPTLiteTheme {
21-
// A surface container using the 'background' color from the theme
22-
Surface(
23-
modifier = Modifier.fillMaxSize(),
24-
color = MaterialTheme.colorScheme.background
25-
) {
26-
Greeting("Android")
39+
40+
WindowCompat.setDecorFitsSystemWindows(window, true)
41+
42+
43+
setContentView(
44+
ComposeView(this).apply {
45+
consumeWindowInsets = false
46+
setContent {
47+
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
48+
val systemUiController = rememberSystemUiController()
49+
50+
SideEffect {
51+
systemUiController.setStatusBarColor(
52+
color = Color.Red,
53+
)
54+
}
55+
56+
AppScaffold(
57+
drawerState = drawerState,
58+
onChatClicked = {
59+
// findNavController().popBackStack(R.id.main, false)
60+
// scope.launch {
61+
// drawerState.close()
62+
// }
63+
},
64+
onProfileClicked = {
65+
// val bundle = bundleOf("userId" to it)
66+
// findNavController().navigate(R.id.nav_profile, bundle)
67+
// scope.launch {
68+
// drawerState.close()
69+
// }
70+
}
71+
) {
72+
Conversations()
73+
}
2774
}
2875
}
29-
}
76+
)
3077
}
3178
}
3279

3380
@Composable
3481
fun Greeting(name: String) {
35-
Text(text = "Hello $name!")
82+
Text(text = "Hello $name!", modifier = Modifier.pointerInput(Unit) {
83+
detectTapGestures(
84+
onPress = { offset -> },
85+
onDoubleTap = { offset -> },
86+
onLongPress = { offset -> },
87+
onTap = { offset -> }
88+
)
89+
// or other similar...
90+
})
3691
}
3792

3893
@Preview(showBackground = true)
3994
@Composable
4095
fun DefaultPreview() {
4196
ChatGPTLiteTheme {
42-
Greeting("Android")
4397
}
4498
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.chatgptlite.wanted.models
2+
3+
import androidx.compose.runtime.Immutable
4+
import java.util.Date
5+
6+
@Immutable
7+
data class MessageModel (
8+
val message: String,
9+
val isMe: Boolean,
10+
val createdAt: Date
11+
)

0 commit comments

Comments
 (0)