Skip to content

Commit 92d47dd

Browse files
committed
feat(ui/ux): done layout conversations & drawer history
1 parent febad12 commit 92d47dd

File tree

11 files changed

+413
-138
lines changed

11 files changed

+413
-138
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
android:supportsRtl="true"
1414
android:theme="@style/Theme.ChatGPTLite"
1515
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" />
2116
<activity
2217
android:name=".MainActivity"
2318
android:exported="true"

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

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,90 @@
11
package com.chatgptlite.wanted
22

3+
import android.annotation.SuppressLint
4+
import android.os.Build
35
import android.os.Bundle
4-
import android.widget.ListView
6+
import android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
7+
import android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE
8+
import android.view.Window
9+
import android.view.WindowManager
510
import androidx.activity.ComponentActivity
6-
import androidx.activity.compose.setContent
711
import androidx.compose.foundation.gestures.detectTapGestures
8-
import androidx.compose.foundation.layout.Box
9-
import androidx.compose.foundation.layout.consumeWindowInsets
10-
import androidx.compose.foundation.layout.fillMaxSize
11-
import androidx.compose.foundation.layout.padding
12+
import androidx.compose.foundation.layout.*
1213
import androidx.compose.material3.*
1314
import androidx.compose.runtime.Composable
1415
import androidx.compose.runtime.SideEffect
16+
import androidx.compose.runtime.rememberCoroutineScope
1517
import androidx.compose.ui.Modifier
1618
import androidx.compose.ui.graphics.Color
1719
import androidx.compose.ui.graphics.toArgb
1820
import androidx.compose.ui.input.pointer.pointerInput
1921
import androidx.compose.ui.platform.ComposeView
2022
import androidx.compose.ui.tooling.preview.Preview
21-
import androidx.compose.ui.unit.dp
2223
import androidx.core.view.WindowCompat
23-
import androidx.navigation.findNavController
24-
import com.chatgptlite.wanted.ui.common.AppDrawer
24+
import com.chatgptlite.wanted.ui.common.AppBar
2525
import com.chatgptlite.wanted.ui.common.AppScaffold
2626
import com.chatgptlite.wanted.ui.conversations.Conversations
2727
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
3228
import com.google.accompanist.systemuicontroller.rememberSystemUiController
29+
import kotlinx.coroutines.launch
30+
3331

3432
class MainActivity : ComponentActivity() {
3533

34+
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
3635
@OptIn(ExperimentalMaterial3Api::class)
3736
override fun onCreate(savedInstanceState: Bundle?) {
3837
super.onCreate(savedInstanceState)
3938

4039
WindowCompat.setDecorFitsSystemWindows(window, true)
4140

42-
4341
setContentView(
4442
ComposeView(this).apply {
4543
consumeWindowInsets = false
4644
setContent {
4745
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
48-
val systemUiController = rememberSystemUiController()
49-
50-
SideEffect {
51-
systemUiController.setStatusBarColor(
52-
color = Color.Red,
53-
)
54-
}
5546

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)
47+
// Intercepts back navigation when the drawer is open
48+
val scope = rememberCoroutineScope()
49+
// if (drawerState.isOpen) {
50+
// BackPressHandler {
6751
// scope.launch {
6852
// drawerState.close()
6953
// }
54+
// }
55+
// }
56+
57+
ChatGPTLiteTheme() {
58+
Surface(
59+
color = MaterialTheme.colorScheme.background,
60+
) {
61+
AppScaffold(
62+
drawerState = drawerState,
63+
onChatClicked = {
64+
scope.launch {
65+
drawerState.close()
66+
}
67+
},
68+
onProfileClicked = {
69+
}
70+
) {
71+
Scaffold(
72+
modifier = Modifier.safeContentPadding(),
73+
topBar = {
74+
AppBar(
75+
onClickMenu = {
76+
scope.launch {
77+
drawerState.open()
78+
}
79+
}
80+
)
81+
},
82+
content = {
83+
Conversations()
84+
},
85+
)
86+
}
7087
}
71-
) {
72-
Conversations()
7388
}
7489
}
7590
}
@@ -84,7 +99,7 @@ fun Greeting(name: String) {
8499
onPress = { offset -> },
85100
onDoubleTap = { offset -> },
86101
onLongPress = { offset -> },
87-
onTap = { offset -> }
102+
onTap = { offset -> }
88103
)
89104
// or other similar...
90105
})
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
package com.chatgptlite.wanted.data.fake
2+
3+
import com.chatgptlite.wanted.models.MessageModel
4+
import java.util.*
5+
6+
val fakeMessages: List<MessageModel> = listOf(
7+
MessageModel(
8+
isMe = true,
9+
message = "What's flutter",
10+
createdAt = Date()
11+
),
12+
MessageModel(
13+
isMe = false,
14+
message = "Flutter is...",
15+
createdAt = Date()
16+
),
17+
MessageModel(
18+
isMe = true,
19+
message = "Who is lambiengcode?",
20+
createdAt = Date()
21+
),
22+
MessageModel(
23+
isMe = false,
24+
message = "I'm Kai (lambiengcode), currently working as the Technical Leader at Askany and Waodate. Computador Also, I'm a freelancer. If you have a need for a mobile application or website, contact me by email: [email protected]",
25+
createdAt = Date()
26+
),
27+
MessageModel(
28+
isMe = true,
29+
message = "What's flutter",
30+
createdAt = Date()
31+
),
32+
MessageModel(
33+
isMe = false,
34+
message = "Flutter is...",
35+
createdAt = Date()
36+
),
37+
MessageModel(
38+
isMe = true,
39+
message = "Who is lambiengcode?",
40+
createdAt = Date()
41+
),
42+
MessageModel(
43+
isMe = false,
44+
message = "I'm Kai (lambiengcode), currently working as the Technical Leader at Askany and Waodate. Computador Also, I'm a freelancer. If you have a need for a mobile application or website, contact me by email: [email protected]",
45+
createdAt = Date()
46+
),
47+
MessageModel(
48+
isMe = true,
49+
message = "What's flutter",
50+
createdAt = Date()
51+
),
52+
MessageModel(
53+
isMe = false,
54+
message = "Flutter is...",
55+
createdAt = Date()
56+
),
57+
MessageModel(
58+
isMe = true,
59+
message = "Who is lambiengcode?",
60+
createdAt = Date()
61+
),
62+
MessageModel(
63+
isMe = false,
64+
message = "I'm Kai (lambiengcode), currently working as the Technical Leader at Askany and Waodate. Computador Also, I'm a freelancer. If you have a need for a mobile application or website, contact me by email: [email protected]",
65+
createdAt = Date()
66+
),
67+
MessageModel(
68+
isMe = true,
69+
message = "What's flutter",
70+
createdAt = Date()
71+
),
72+
MessageModel(
73+
isMe = false,
74+
message = "Flutter is...",
75+
createdAt = Date()
76+
),
77+
MessageModel(
78+
isMe = true,
79+
message = "Who is lambiengcode?",
80+
createdAt = Date()
81+
),
82+
MessageModel(
83+
isMe = false,
84+
message = "I'm Kai (lambiengcode), currently working as the Technical Leader at Askany and Waodate. Computador Also, I'm a freelancer. If you have a need for a mobile application or website, contact me by email: [email protected]",
85+
createdAt = Date()
86+
),
87+
MessageModel(
88+
isMe = true,
89+
message = "What's flutter",
90+
createdAt = Date()
91+
),
92+
MessageModel(
93+
isMe = false,
94+
message = "Flutter is...",
95+
createdAt = Date()
96+
),
97+
MessageModel(
98+
isMe = true,
99+
message = "Who is lambiengcode?",
100+
createdAt = Date()
101+
),
102+
MessageModel(
103+
isMe = false,
104+
message = "I'm Kai (lambiengcode), currently working as the Technical Leader at Askany and Waodate. Computador Also, I'm a freelancer. If you have a need for a mobile application or website, contact me by email: [email protected]",
105+
createdAt = Date()
106+
),
107+
MessageModel(
108+
isMe = true,
109+
message = "What's flutter",
110+
createdAt = Date()
111+
),
112+
MessageModel(
113+
isMe = false,
114+
message = "Flutter is...",
115+
createdAt = Date()
116+
),
117+
MessageModel(
118+
isMe = true,
119+
message = "Who is lambiengcode?",
120+
createdAt = Date()
121+
),
122+
MessageModel(
123+
isMe = false,
124+
message = "I'm Kai (lambiengcode), currently working as the Technical Leader at Askany and Waodate. Computador Also, I'm a freelancer. If you have a need for a mobile application or website, contact me by email: [email protected]",
125+
createdAt = Date()
126+
),
127+
)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.chatgptlite.wanted.ui.common
2+
3+
import androidx.compose.foundation.layout.*
4+
import androidx.compose.material.icons.Icons
5+
import androidx.compose.material.icons.filled.Menu
6+
import androidx.compose.material3.*
7+
import androidx.compose.runtime.Composable
8+
import androidx.compose.runtime.mutableStateOf
9+
import androidx.compose.runtime.remember
10+
import androidx.compose.ui.Alignment
11+
import androidx.compose.ui.Modifier
12+
import androidx.compose.ui.graphics.Color
13+
import androidx.compose.ui.platform.LocalDensity
14+
import androidx.compose.ui.text.font.FontWeight
15+
import androidx.compose.ui.text.style.TextAlign
16+
import androidx.compose.ui.unit.dp
17+
import androidx.compose.ui.unit.sp
18+
import com.chatgptlite.wanted.ui.conversations.ui.theme.ChatGPTLiteTheme
19+
import com.chatgptlite.wanted.ui.theme.BackGroundColor
20+
21+
@Composable
22+
fun AppBar(onClickMenu: () -> Unit) {
23+
24+
ChatGPTLiteTheme() {
25+
Surface(
26+
shadowElevation = 4.dp,
27+
tonalElevation = 0.dp,
28+
) {
29+
CenterAlignedTopAppBar (
30+
title = {
31+
Box {
32+
Row(verticalAlignment = Alignment.CenterVertically) {
33+
Text(
34+
text = "ChatGPT",
35+
textAlign = TextAlign.Center,
36+
fontSize = 18.sp,
37+
fontWeight = FontWeight.SemiBold
38+
)
39+
}
40+
}
41+
},
42+
navigationIcon = {
43+
IconButton(onClick = {
44+
onClickMenu()
45+
}) {
46+
Icon(Icons.Filled.Menu, "backIcon", modifier = Modifier.size(26.dp))
47+
}
48+
},
49+
colors = TopAppBarDefaults.smallTopAppBarColors(
50+
containerColor = BackGroundColor,
51+
titleContentColor = Color.White,
52+
),
53+
)
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)