From 7902a9fa6349bf494bc574fa8c9cb0eb9e20f161 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Wed, 17 Apr 2024 00:18:25 +0900 Subject: [PATCH 01/17] =?UTF-8?q?feat/#6:=202=EC=A3=BC=EC=B0=A8=20?= =?UTF-8?q?=EA=B3=BC=EC=A0=9C=20(=ED=86=B5=EC=A7=9C=20=EC=BB=A4=EB=B0=8B?= =?UTF-8?q?=20=EC=A3=84=EC=86=A1=ED=95=A9=EB=8B=88=EB=8B=A4...)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/sopt/now/compose/Friend.kt | 9 ++ .../com/sopt/now/compose/FriendProfileItem.kt | 50 ++++++ .../main/java/com/sopt/now/compose/HomeUi.kt | 102 ++++++++++++ .../java/com/sopt/now/compose/MainActivity.kt | 145 +++++++++++------- .../com/sopt/now/compose/NavigationData.kt | 8 + .../java/com/sopt/now/compose/ProfileUi.kt | 58 +++++++ .../main/java/com/sopt/now/compose/User.kt | 9 ++ .../com/sopt/now/compose/UserProfileItem.kt | 51 ++++++ 8 files changed, 379 insertions(+), 53 deletions(-) create mode 100644 app/src/main/java/com/sopt/now/compose/Friend.kt create mode 100644 app/src/main/java/com/sopt/now/compose/FriendProfileItem.kt create mode 100644 app/src/main/java/com/sopt/now/compose/HomeUi.kt create mode 100644 app/src/main/java/com/sopt/now/compose/NavigationData.kt create mode 100644 app/src/main/java/com/sopt/now/compose/ProfileUi.kt create mode 100644 app/src/main/java/com/sopt/now/compose/User.kt create mode 100644 app/src/main/java/com/sopt/now/compose/UserProfileItem.kt diff --git a/app/src/main/java/com/sopt/now/compose/Friend.kt b/app/src/main/java/com/sopt/now/compose/Friend.kt new file mode 100644 index 0000000..df0ec70 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/Friend.kt @@ -0,0 +1,9 @@ +package com.sopt.now.compose + +import androidx.compose.ui.graphics.vector.ImageVector + +data class Friend( + val profileImage: ImageVector, + val name: String, + val selfDescription: String, +) \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/FriendProfileItem.kt b/app/src/main/java/com/sopt/now/compose/FriendProfileItem.kt new file mode 100644 index 0000000..c843186 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/FriendProfileItem.kt @@ -0,0 +1,50 @@ +package com.sopt.now.compose + +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +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.text.font.FontWeight +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp + + +@Composable +fun FriendProfileItem(friend: Friend) { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 10.dp), + verticalAlignment = Alignment.CenterVertically + ) { + Icon( + modifier = Modifier.size(50.dp), + imageVector = friend.profileImage, + contentDescription = null + ) + Spacer(modifier = Modifier.width(10.dp)) + Text( + text = friend.name, + fontSize = 14.sp, + fontWeight = FontWeight.Bold, + overflow = TextOverflow.Ellipsis, + maxLines = 1 + ) + Spacer(modifier = Modifier.width(30.dp)) + Spacer(modifier = Modifier.weight(1f)) + Text( + text = friend.selfDescription, + fontSize = 10.sp, + overflow = TextOverflow.Ellipsis, + maxLines = 1 + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/HomeUi.kt b/app/src/main/java/com/sopt/now/compose/HomeUi.kt new file mode 100644 index 0000000..907ff74 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/HomeUi.kt @@ -0,0 +1,102 @@ +package com.sopt.now.compose + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Person +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp + +@Composable +fun HomeUi() { + Column( + modifier = Modifier + .fillMaxSize() + .padding(horizontal = 10.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { + LazyColumn { + items(userList) { + UserProfileItem(it) + } + items(friendList) { + FriendProfileItem(it) + } + } + } +} +val userList = listOf( + User( + profileImage = Icons.Filled.Person, + name = "송혜음", + selfDescription = "컴포즈 커피 최고" + ) +) + +val friendList = listOf( + Friend( + profileImage = Icons.Filled.Person, + name = "이의경", + selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지?" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "우상욱", + selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "배지현", + selfDescription = "표정 풀자 ^^" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "이의경", + selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지?" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "우상욱", + selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "배지현", + selfDescription = "표정 풀자 ^^" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "이의경", + selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지?" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "우상욱", + selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "배지현", + selfDescription = "표정 풀자 ^^" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "이의경", + selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지?" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "우상욱", + selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "배지현", + selfDescription = "표정 풀자 ^^" + ) +) diff --git a/app/src/main/java/com/sopt/now/compose/MainActivity.kt b/app/src/main/java/com/sopt/now/compose/MainActivity.kt index dbd27e7..efaeaf9 100644 --- a/app/src/main/java/com/sopt/now/compose/MainActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/MainActivity.kt @@ -3,20 +3,40 @@ package com.sopt.now.compose import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Home +import androidx.compose.material.icons.filled.Person +import androidx.compose.material.icons.filled.Search +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.NavigationBar +import androidx.compose.material3.NavigationBarItem +import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults.topAppBarColors import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.res.painterResource +import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -27,7 +47,6 @@ class MainActivity : ComponentActivity() { super.onCreate(savedInstanceState) setContent { NOWSOPTAndroidTheme { - // A surface container using the 'background' color from the theme Surface( modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background @@ -35,67 +54,87 @@ class MainActivity : ComponentActivity() { val userId = intent.getStringExtra("userId") val userPw = intent.getStringExtra("userPw") val userNick = intent.getStringExtra("userNick") - MainUI(userId,userPw,userNick) + ScaffoldExample(userId, userPw, userNick) } } } } } -//메인화면 + +@OptIn(ExperimentalMaterial3Api::class) @Composable -fun MainUI(userId: String?="", userPw:String?="", userNick:String?=""){ - Column( - modifier = Modifier - .fillMaxSize() - .padding(30.dp), - horizontalAlignment = Alignment.CenterHorizontally - ) { - Text( - text = stringResource(R.string.app_name), - fontSize = 30.sp - ) - Text( - text = stringResource(R.string.text_main_title2), - fontSize = 20.sp - ) - Spacer(modifier = Modifier.height(50.dp),) - Image( - painter = painterResource(id = R.drawable.cute), - contentDescription = "귀여운 뱁새" - ) - Spacer(modifier = Modifier.height(50.dp),) - Text( - text = "ID", - fontSize = 20.sp - ) - Text( - text = "$userId", - fontSize = 15.sp - ) - Spacer(modifier = Modifier.height(50.dp),) - Text( - text = stringResource(R.string.text_pw), - fontSize = 20.sp - ) - Text( - text = "$userPw", - fontSize = 15.sp - ) - Spacer(modifier = Modifier.height(50.dp),) - Text( - text = stringResource(R.string.text_nick), - fontSize = 20.sp - ) - Text( - text = "$userNick", - fontSize = 15.sp +fun ScaffoldExample(userId: String? = "", userPw: String? = "", userNick: String? = "") { + var selectedItem by remember { mutableIntStateOf(0) } + val items = listOf( + BottomNavigationItem( + icon = Icons.Filled.Home, + label = "Home" + ), + BottomNavigationItem( + icon = Icons.Filled.Search, + label = "Search" + ), + BottomNavigationItem( + icon = Icons.Filled.Person, + label = "Profile" ) + ) + + Scaffold( + topBar = { + TopAppBar( + colors = topAppBarColors( + containerColor = MaterialTheme.colorScheme.primaryContainer, + titleContentColor = MaterialTheme.colorScheme.primary, + ), + title = { + Text( + text = stringResource(R.string.app_name), + fontSize = 30.sp, + fontWeight = FontWeight.Bold + ) + } + ) + }, + bottomBar = { + NavigationBar { + items.forEachIndexed { index, item -> + NavigationBarItem( + icon = { Icon(item.icon, contentDescription = item.label) }, + label = { Text(item.label) }, + selected = selectedItem == index, + onClick = { selectedItem = index } + ) + } + } + }, + ) { innerPadding -> + Column( + modifier = Modifier + .padding(innerPadding), + verticalArrangement = Arrangement.spacedBy(16.dp), + ) { + when (selectedItem) { + 0 -> { + HomeUi() + } + + 1 -> { + Text(text = "Search") + } + + 2 -> { + ProfileUi(userId, userPw, userNick) + } + } + + } } } @Preview(showBackground = true) @Composable fun GreetingPreview() { NOWSOPTAndroidTheme { - MainUI() + ScaffoldExample() } } \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/NavigationData.kt b/app/src/main/java/com/sopt/now/compose/NavigationData.kt new file mode 100644 index 0000000..efc4679 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/NavigationData.kt @@ -0,0 +1,8 @@ +package com.sopt.now.compose + +import androidx.compose.ui.graphics.vector.ImageVector + +data class BottomNavigationItem( + val icon: ImageVector, + val label: String +) \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/ProfileUi.kt b/app/src/main/java/com/sopt/now/compose/ProfileUi.kt new file mode 100644 index 0000000..4060268 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/ProfileUi.kt @@ -0,0 +1,58 @@ +package com.sopt.now.compose + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp + +@Composable +fun ProfileUi(userId: String? = "", userPw: String? = "", userNick: String? = "") { + Column( + modifier = Modifier + .fillMaxSize() + .padding(30.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Image( + painter = painterResource(id = R.drawable.cute), + contentDescription = "귀여운 뱁새" + ) + Spacer(modifier = Modifier.height(50.dp)) + Text( + text = "ID", + fontSize = 20.sp + ) + Text( + text = "$userId", + fontSize = 15.sp + ) + Spacer(modifier = Modifier.height(50.dp)) + Text( + text = stringResource(R.string.text_pw), + fontSize = 20.sp + ) + Text( + text = "$userPw", + fontSize = 15.sp + ) + Spacer(modifier = Modifier.height(50.dp)) + Text( + text = stringResource(R.string.text_nick), + fontSize = 20.sp + ) + Text( + text = "$userNick", + fontSize = 15.sp + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/User.kt b/app/src/main/java/com/sopt/now/compose/User.kt new file mode 100644 index 0000000..0766754 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/User.kt @@ -0,0 +1,9 @@ +package com.sopt.now.compose + +import androidx.compose.ui.graphics.vector.ImageVector + +data class User( + val profileImage: ImageVector, + val name: String, + val selfDescription: String, +) \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/UserProfileItem.kt b/app/src/main/java/com/sopt/now/compose/UserProfileItem.kt new file mode 100644 index 0000000..6609c53 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/UserProfileItem.kt @@ -0,0 +1,51 @@ +package com.sopt.now.compose + +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +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.text.font.FontWeight +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp + + +@Composable +fun UserProfileItem(user: User) { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 10.dp), + verticalAlignment = Alignment.CenterVertically + ) { + Icon( + modifier = Modifier.size(50.dp), + imageVector = user.profileImage, + contentDescription = null + ) + Spacer(modifier = Modifier.width(10.dp)) + Text( + text = user.name, + fontSize = 18.sp, + fontWeight = FontWeight.Bold, + overflow = TextOverflow.Ellipsis, + maxLines = 1 + ) + Spacer(modifier = Modifier.width(30.dp)) + Spacer(modifier = Modifier.weight(1f)) + Text( + text = user.selfDescription, + fontSize = 14.sp, + fontWeight = FontWeight.Bold, + overflow = TextOverflow.Ellipsis, + maxLines = 1 + ) + } +} \ No newline at end of file From ef34ff3f42134a6c0a1175fee2b4a251cf00a897 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Wed, 17 Apr 2024 00:23:06 +0900 Subject: [PATCH 02/17] =?UTF-8?q?chore/#6:=20=ED=95=A8=EC=88=98=EB=AA=85?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/sopt/now/compose/MainActivity.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/MainActivity.kt b/app/src/main/java/com/sopt/now/compose/MainActivity.kt index efaeaf9..02f5a7b 100644 --- a/app/src/main/java/com/sopt/now/compose/MainActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/MainActivity.kt @@ -54,7 +54,7 @@ class MainActivity : ComponentActivity() { val userId = intent.getStringExtra("userId") val userPw = intent.getStringExtra("userPw") val userNick = intent.getStringExtra("userNick") - ScaffoldExample(userId, userPw, userNick) + MainUi(userId, userPw, userNick) } } } @@ -63,7 +63,7 @@ class MainActivity : ComponentActivity() { @OptIn(ExperimentalMaterial3Api::class) @Composable -fun ScaffoldExample(userId: String? = "", userPw: String? = "", userNick: String? = "") { +fun MainUi(userId: String? = "", userPw: String? = "", userNick: String? = "") { var selectedItem by remember { mutableIntStateOf(0) } val items = listOf( BottomNavigationItem( @@ -135,6 +135,6 @@ fun ScaffoldExample(userId: String? = "", userPw: String? = "", userNick: String @Composable fun GreetingPreview() { NOWSOPTAndroidTheme { - ScaffoldExample() + MainUi() } } \ No newline at end of file From fab60f38631625306b36329069ac79b627285431 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Wed, 17 Apr 2024 00:31:19 +0900 Subject: [PATCH 03/17] =?UTF-8?q?del/#6:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/sopt/now/compose/MainActivity.kt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/MainActivity.kt b/app/src/main/java/com/sopt/now/compose/MainActivity.kt index 02f5a7b..a9c0206 100644 --- a/app/src/main/java/com/sopt/now/compose/MainActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/MainActivity.kt @@ -5,13 +5,8 @@ import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Home import androidx.compose.material.icons.filled.Person @@ -31,12 +26,9 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp From ecae46e186210248b349d16dfb4ff51340c3798e Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Wed, 17 Apr 2024 00:57:55 +0900 Subject: [PATCH 04/17] =?UTF-8?q?mod/#6:=20=EB=A7=88=EC=9D=B4=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80(=ED=94=84=EB=A1=9C=ED=95=84)=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sopt/now/compose/MainActivity.kt | 119 +++++++++--------- .../java/com/sopt/now/compose/ProfileUi.kt | 8 +- 2 files changed, 64 insertions(+), 63 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/MainActivity.kt b/app/src/main/java/com/sopt/now/compose/MainActivity.kt index a9c0206..21d1971 100644 --- a/app/src/main/java/com/sopt/now/compose/MainActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/MainActivity.kt @@ -55,71 +55,72 @@ class MainActivity : ComponentActivity() { @OptIn(ExperimentalMaterial3Api::class) @Composable -fun MainUi(userId: String? = "", userPw: String? = "", userNick: String? = "") { - var selectedItem by remember { mutableIntStateOf(0) } - val items = listOf( - BottomNavigationItem( - icon = Icons.Filled.Home, - label = "Home" - ), - BottomNavigationItem( - icon = Icons.Filled.Search, - label = "Search" - ), - BottomNavigationItem( - icon = Icons.Filled.Person, - label = "Profile" +fun MainUi(userId: String?, userPw: String?, userNick: String?) { + if(userId!=null&&userPw!=null&&userNick!=null) { + var selectedItem by remember { mutableIntStateOf(0) } + val items = listOf( + BottomNavigationItem( + icon = Icons.Filled.Home, + label = "Home" + ), + BottomNavigationItem( + icon = Icons.Filled.Search, + label = "Search" + ), + BottomNavigationItem( + icon = Icons.Filled.Person, + label = "Profile" + ) ) - ) - Scaffold( - topBar = { - TopAppBar( - colors = topAppBarColors( - containerColor = MaterialTheme.colorScheme.primaryContainer, - titleContentColor = MaterialTheme.colorScheme.primary, - ), - title = { - Text( - text = stringResource(R.string.app_name), - fontSize = 30.sp, - fontWeight = FontWeight.Bold - ) - } - ) - }, - bottomBar = { - NavigationBar { - items.forEachIndexed { index, item -> - NavigationBarItem( - icon = { Icon(item.icon, contentDescription = item.label) }, - label = { Text(item.label) }, - selected = selectedItem == index, - onClick = { selectedItem = index } - ) - } - } - }, - ) { innerPadding -> - Column( - modifier = Modifier - .padding(innerPadding), - verticalArrangement = Arrangement.spacedBy(16.dp), - ) { - when (selectedItem) { - 0 -> { - HomeUi() + Scaffold( + topBar = { + TopAppBar( + colors = topAppBarColors( + containerColor = MaterialTheme.colorScheme.primaryContainer, + titleContentColor = MaterialTheme.colorScheme.primary, + ), + title = { + Text( + text = stringResource(R.string.app_name), + fontSize = 30.sp, + fontWeight = FontWeight.Bold + ) + } + ) + }, + bottomBar = { + NavigationBar { + items.forEachIndexed { index, item -> + NavigationBarItem( + icon = { Icon(item.icon, contentDescription = item.label) }, + label = { Text(item.label) }, + selected = selectedItem == index, + onClick = { selectedItem = index } + ) + } } + }, + ) { innerPadding -> + Column( + modifier = Modifier + .padding(innerPadding), + verticalArrangement = Arrangement.spacedBy(16.dp), + ) { + when (selectedItem) { + 0 -> { + HomeUi() + } - 1 -> { - Text(text = "Search") - } + 1 -> { + Text(text = "Search") + } - 2 -> { - ProfileUi(userId, userPw, userNick) + 2 -> { + ProfileUi(userId, userPw, userNick) + } } } - } } } @@ -127,6 +128,6 @@ fun MainUi(userId: String? = "", userPw: String? = "", userNick: String? = "") { @Composable fun GreetingPreview() { NOWSOPTAndroidTheme { - MainUi() + MainUi("아이디","비밀번호","닉네임") } } \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/ProfileUi.kt b/app/src/main/java/com/sopt/now/compose/ProfileUi.kt index 4060268..b5a57f4 100644 --- a/app/src/main/java/com/sopt/now/compose/ProfileUi.kt +++ b/app/src/main/java/com/sopt/now/compose/ProfileUi.kt @@ -16,7 +16,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @Composable -fun ProfileUi(userId: String? = "", userPw: String? = "", userNick: String? = "") { +fun ProfileUi(userId: String, userPw: String, userNick: String) { Column( modifier = Modifier .fillMaxSize() @@ -33,7 +33,7 @@ fun ProfileUi(userId: String? = "", userPw: String? = "", userNick: String? = "" fontSize = 20.sp ) Text( - text = "$userId", + text = userId, fontSize = 15.sp ) Spacer(modifier = Modifier.height(50.dp)) @@ -42,7 +42,7 @@ fun ProfileUi(userId: String? = "", userPw: String? = "", userNick: String? = "" fontSize = 20.sp ) Text( - text = "$userPw", + text = userPw, fontSize = 15.sp ) Spacer(modifier = Modifier.height(50.dp)) @@ -51,7 +51,7 @@ fun ProfileUi(userId: String? = "", userPw: String? = "", userNick: String? = "" fontSize = 20.sp ) Text( - text = "$userNick", + text = userNick, fontSize = 15.sp ) } From ea1f0047ab0f8309df68fbf066c8a6abcb381276 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Wed, 17 Apr 2024 00:59:59 +0900 Subject: [PATCH 05/17] =?UTF-8?q?del/#6:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/sopt/now/compose/SignUpActivity.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt index 2e1d72c..384a3c9 100644 --- a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt @@ -5,7 +5,6 @@ import android.os.Bundle import android.widget.Toast import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize @@ -24,7 +23,6 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview From 3de8f5c6ab01017d335e2d311418b708f6843d38 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Wed, 17 Apr 2024 01:07:49 +0900 Subject: [PATCH 06/17] =?UTF-8?q?rename/#6:=20=ED=8C=8C=EC=9D=BC=EB=AA=85?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../now/compose/{NavigationData.kt => BottomNavigationItem.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/src/main/java/com/sopt/now/compose/{NavigationData.kt => BottomNavigationItem.kt} (100%) diff --git a/app/src/main/java/com/sopt/now/compose/NavigationData.kt b/app/src/main/java/com/sopt/now/compose/BottomNavigationItem.kt similarity index 100% rename from app/src/main/java/com/sopt/now/compose/NavigationData.kt rename to app/src/main/java/com/sopt/now/compose/BottomNavigationItem.kt From 807561c2492fd92c638ef458064f1dfd0e50df25 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Thu, 18 Apr 2024 23:21:06 +0900 Subject: [PATCH 07/17] =?UTF-8?q?mod/#6:=20=EC=BB=B4=ED=8F=AC=EC=A0=80?= =?UTF-8?q?=EB=B8=94=20=EB=82=B4=20=ED=95=A8=EC=88=98=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sopt/now/compose/SignUpActivity.kt | 125 +++++++++--------- 1 file changed, 66 insertions(+), 59 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt index 384a3c9..2cf1991 100644 --- a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt @@ -1,5 +1,6 @@ package com.sopt.now.compose +import android.content.Context import android.content.Intent import android.os.Bundle import android.widget.Toast @@ -46,96 +47,102 @@ class SignUpActivity : ComponentActivity() { } } } -//회원가입 화면 + +fun isSignUpAvailable(context: Context,id: String,pw: String,nick: String,etc: String) { + val intent = Intent(context, LoginActivity::class.java) + val message = when { + id.isEmpty() || pw.isEmpty() || nick.isEmpty() || etc.isEmpty() -> R.string.sign_up_blank_error + id.length !in 6..10 -> R.string.sign_up_id_error + pw.length !in 8..12 -> R.string.sign_up_pw_error + nick.isBlank() || nick.length != nick.trim().length -> R.string.sign_up_nick_error + etc.length !in 1..Int.MAX_VALUE -> R.string.sign_up_etc_error + else -> { + intent.putExtra("userId", id).putExtra("userPw", pw).putExtra("userNick", nick) + context.startActivity(intent) + R.string.sign_up_success + } + } + Toast.makeText(context, message, Toast.LENGTH_SHORT).show() +} + @Composable - fun SignUpUI() { +fun SignUpUI() { val context = LocalContext.current var id by remember { mutableStateOf("") } var pw by remember { mutableStateOf("") } var nick by remember { mutableStateOf("") } var etc by remember { mutableStateOf("") } - Column ( - modifier = Modifier - .fillMaxSize() - .padding(30.dp), - horizontalAlignment = Alignment.CenterHorizontally - ){ + Column( + modifier = Modifier + .fillMaxSize() + .padding(30.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { Text( text = "SIGN UP", fontSize = 30.sp ) - Spacer(modifier = Modifier.height(50.dp),) + Spacer(modifier = Modifier.height(50.dp)) Text( text = "ID", - fontSize = 20.sp) + fontSize = 20.sp + ) TextField( - value = id, - label = { Text(stringResource(R.string.tf_label_id)) }, - onValueChange = { id = it }, - placeholder = {Text(stringResource(R.string.tf_ph_id))}, - singleLine = true - ) - Spacer(modifier = Modifier.height(50.dp),) + value = id, + label = { Text(stringResource(R.string.tf_label_id)) }, + onValueChange = { id = it }, + placeholder = { Text(stringResource(R.string.tf_ph_id)) }, + singleLine = true + ) + Spacer(modifier = Modifier.height(50.dp)) Text( text = stringResource(R.string.text_pw), - fontSize = 20.sp) + fontSize = 20.sp + ) TextField( - value = pw, - label = { Text(stringResource(R.string.tf_label_pw)) }, - onValueChange = { pw = it }, - placeholder = {Text(stringResource(R.string.tf_ph_pw))}, - singleLine = true - ) - Spacer(modifier = Modifier.height(50.dp),) + value = pw, + label = { Text(stringResource(R.string.tf_label_pw)) }, + onValueChange = { pw = it }, + placeholder = { Text(stringResource(R.string.tf_ph_pw)) }, + singleLine = true + ) + Spacer(modifier = Modifier.height(50.dp)) Text( text = stringResource(R.string.text_nick), - fontSize = 20.sp) + fontSize = 20.sp + ) TextField( - value = nick, - label = { Text(stringResource(R.string.tf_label_nick)) }, - onValueChange = { nick = it }, - placeholder = {Text(stringResource(R.string.tf_ph_nick))}, - singleLine = true - ) - Spacer(modifier = Modifier.height(50.dp),) + value = nick, + label = { Text(stringResource(R.string.tf_label_nick)) }, + onValueChange = { nick = it }, + placeholder = { Text(stringResource(R.string.tf_ph_nick)) }, + singleLine = true + ) + Spacer(modifier = Modifier.height(50.dp)) Text( text = "하고싶은 말", - fontSize = 20.sp) + fontSize = 20.sp + ) TextField( - value = etc, - label = { Text(stringResource(R.string.tf_label_etc)) }, - onValueChange = { etc = it }, - placeholder = {Text(stringResource(R.string.tf_ph_etc))}, - singleLine = true - ) + value = etc, + label = { Text(stringResource(R.string.tf_label_etc)) }, + onValueChange = { etc = it }, + placeholder = { Text(stringResource(R.string.tf_ph_etc)) }, + singleLine = true + ) Spacer(modifier = Modifier.weight(1f)) Button( onClick = { - //회원가입 조건에 맞는지 검사 - val message = when { - id.isEmpty() || pw.isEmpty() || nick.isEmpty() || etc.isEmpty() -> context.getString( - R.string.sign_up_blank_error - ) - id.length !in 6..10 -> context.getString(R.string.sign_up_id_error) - pw.length !in 8..12 -> context.getString(R.string.sign_up_pw_error) - nick.isBlank() || nick.length != nick.trim().length -> context.getString(R.string.sign_up_nick_error) - etc.length !in 1..Int.MAX_VALUE -> context.getString(R.string.sign_up_etc_error) - else -> { - val intent = Intent(context,LoginActivity::class.java) - intent.putExtra("userId", id).putExtra("userPw", pw).putExtra("userNick", nick) - context.startActivity(intent) - context.getString(R.string.sign_up_success) - } - } - Toast.makeText(context, message, Toast.LENGTH_SHORT).show() - }, + isSignUpAvailable(context,id,pw,nick,etc) + }, modifier = Modifier.fillMaxWidth() ) { Text(stringResource(R.string.btn_sign_up)) } - } } +} + @Preview(showBackground = true) @Composable fun GreetingPreview3() { From 7ed99ae7afe706e24928a237d9a01dfad922e1e0 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Thu, 18 Apr 2024 23:34:50 +0900 Subject: [PATCH 08/17] =?UTF-8?q?mod/#6:=20=EC=BB=B4=ED=8F=AC=EC=A0=80?= =?UTF-8?q?=EB=B8=94=20=EB=82=B4=20=ED=95=A8=EC=88=98=20=EB=B6=84=EB=A6=AC?= =?UTF-8?q?(=EB=A1=9C=EA=B7=B8=EC=9D=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sopt/now/compose/LoginActivity.kt | 62 ++++++++++++------- .../com/sopt/now/compose/SignUpActivity.kt | 2 +- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/LoginActivity.kt b/app/src/main/java/com/sopt/now/compose/LoginActivity.kt index a4fb7ed..f53a443 100644 --- a/app/src/main/java/com/sopt/now/compose/LoginActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/LoginActivity.kt @@ -1,5 +1,6 @@ package com.sopt.now.compose +import android.content.Context import android.content.Intent import android.os.Bundle import android.widget.Toast @@ -47,15 +48,36 @@ class LoginActivity : ComponentActivity() { val userId = intent.getStringExtra("userId") val userPw = intent.getStringExtra("userPw") val userNick = intent.getStringExtra("userNick") - LoginUI(userId,userPw,userNick) + LoginUI(userId, userPw, userNick) } } } } } -//로그인 화면 + +fun isLoginAvailable( + context: Context, + userId: String?, + userPw: String?, + userNick: String?, + id: String?, + pw: String? +) { + val message = when { + userId != id || userPw != pw -> R.string.login_error + else -> { + val intent = Intent(context, MainActivity::class.java) + intent.putExtra("userId", userId).putExtra("userPw", userPw) + .putExtra("userNick", userNick) + context.startActivity(intent) + R.string.login_success + } + } + Toast.makeText(context, message, Toast.LENGTH_SHORT).show() +} + @Composable -fun LoginUI(userId: String?="", userPw:String?="", userNick:String?="") { +fun LoginUI(userId: String?, userPw: String?, userNick: String?) { val context = LocalContext.current var id by remember { mutableStateOf("") } var pw by remember { mutableStateOf("") } @@ -76,41 +98,32 @@ fun LoginUI(userId: String?="", userPw:String?="", userNick:String?="") { ) TextField( value = id, - onValueChange = {id = it}, + onValueChange = { id = it }, modifier = Modifier .fillMaxWidth() .padding(10.dp), - placeholder = {Text(stringResource(R.string.tf_login_id))}, + placeholder = { Text(stringResource(R.string.tf_login_id)) }, singleLine = true, - leadingIcon = { Icon(Icons.Filled.Person,contentDescription = "User Icon") } - ) + leadingIcon = { Icon(Icons.Filled.Person, contentDescription = "User Icon") } + ) Spacer(modifier = Modifier.height(30.dp)) Text(text = stringResource(R.string.text_pw)) TextField( value = pw, - onValueChange = {pw = it}, + onValueChange = { pw = it }, modifier = Modifier .fillMaxWidth() .padding(10.dp), - placeholder = {Text(stringResource(R.string.tf_login_pw))}, + placeholder = { Text(stringResource(R.string.tf_login_pw)) }, singleLine = true, visualTransformation = PasswordVisualTransformation(), - leadingIcon = { Icon(Icons.Filled.Person,contentDescription = "User Icon") }, + leadingIcon = { Icon(Icons.Filled.Person, contentDescription = "User Icon") }, ) Spacer(modifier = Modifier.weight(1f)) Button( onClick = { - val message = when{ - userId != id || userPw != pw -> context.getString(R.string.login_error) - else -> { - val intent = Intent(context, MainActivity::class.java) - intent.putExtra("userId",userId).putExtra("userPw", userPw).putExtra("userNick", userNick) - context.startActivity(intent) - context.getString(R.string.login_success) - } - } - Toast.makeText(context,message,Toast.LENGTH_SHORT).show() - }, + isLoginAvailable(context, userId, userPw, userNick, id, pw) + }, modifier = Modifier .fillMaxWidth() ) { @@ -119,9 +132,9 @@ fun LoginUI(userId: String?="", userPw:String?="", userNick:String?="") { Spacer(modifier = Modifier.height(20.dp)) Button( onClick = { - val intent = Intent(context,SignUpActivity::class.java) + val intent = Intent(context, SignUpActivity::class.java) context.startActivity(intent) - }, + }, modifier = Modifier .fillMaxWidth() ) { @@ -129,10 +142,11 @@ fun LoginUI(userId: String?="", userPw:String?="", userNick:String?="") { } } } + @Preview(showBackground = true) @Composable fun GreetingPreview2() { NOWSOPTAndroidTheme { - LoginUI() + LoginUI("아이디", "비밀번호", "닉네임") } } \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt index 2cf1991..66ab74b 100644 --- a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt @@ -49,7 +49,6 @@ class SignUpActivity : ComponentActivity() { } fun isSignUpAvailable(context: Context,id: String,pw: String,nick: String,etc: String) { - val intent = Intent(context, LoginActivity::class.java) val message = when { id.isEmpty() || pw.isEmpty() || nick.isEmpty() || etc.isEmpty() -> R.string.sign_up_blank_error id.length !in 6..10 -> R.string.sign_up_id_error @@ -57,6 +56,7 @@ fun isSignUpAvailable(context: Context,id: String,pw: String,nick: String,etc: S nick.isBlank() || nick.length != nick.trim().length -> R.string.sign_up_nick_error etc.length !in 1..Int.MAX_VALUE -> R.string.sign_up_etc_error else -> { + val intent = Intent(context, LoginActivity::class.java) intent.putExtra("userId", id).putExtra("userPw", pw).putExtra("userNick", nick) context.startActivity(intent) R.string.sign_up_success From 1fbcccd83ae51df9883dc9a4f2fb7474e2a422f0 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Thu, 18 Apr 2024 23:37:16 +0900 Subject: [PATCH 09/17] =?UTF-8?q?chore/#6:=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=95=84=EB=9E=98=EB=A1=9C=20=EB=B3=B4=EB=82=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sopt/now/compose/LoginActivity.kt | 41 +++++++++---------- .../com/sopt/now/compose/SignUpActivity.kt | 33 ++++++++------- 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/LoginActivity.kt b/app/src/main/java/com/sopt/now/compose/LoginActivity.kt index f53a443..8518beb 100644 --- a/app/src/main/java/com/sopt/now/compose/LoginActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/LoginActivity.kt @@ -55,27 +55,6 @@ class LoginActivity : ComponentActivity() { } } -fun isLoginAvailable( - context: Context, - userId: String?, - userPw: String?, - userNick: String?, - id: String?, - pw: String? -) { - val message = when { - userId != id || userPw != pw -> R.string.login_error - else -> { - val intent = Intent(context, MainActivity::class.java) - intent.putExtra("userId", userId).putExtra("userPw", userPw) - .putExtra("userNick", userNick) - context.startActivity(intent) - R.string.login_success - } - } - Toast.makeText(context, message, Toast.LENGTH_SHORT).show() -} - @Composable fun LoginUI(userId: String?, userPw: String?, userNick: String?) { val context = LocalContext.current @@ -143,6 +122,26 @@ fun LoginUI(userId: String?, userPw: String?, userNick: String?) { } } +fun isLoginAvailable( + context: Context, + userId: String?, + userPw: String?, + userNick: String?, + id: String?, + pw: String? +) { + val message = when { + userId != id || userPw != pw -> R.string.login_error + else -> { + val intent = Intent(context, MainActivity::class.java) + intent.putExtra("userId", userId).putExtra("userPw", userPw) + .putExtra("userNick", userNick) + context.startActivity(intent) + R.string.login_success + } + } + Toast.makeText(context, message, Toast.LENGTH_SHORT).show() +} @Preview(showBackground = true) @Composable fun GreetingPreview2() { diff --git a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt index 66ab74b..5aa839e 100644 --- a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt @@ -48,23 +48,6 @@ class SignUpActivity : ComponentActivity() { } } -fun isSignUpAvailable(context: Context,id: String,pw: String,nick: String,etc: String) { - val message = when { - id.isEmpty() || pw.isEmpty() || nick.isEmpty() || etc.isEmpty() -> R.string.sign_up_blank_error - id.length !in 6..10 -> R.string.sign_up_id_error - pw.length !in 8..12 -> R.string.sign_up_pw_error - nick.isBlank() || nick.length != nick.trim().length -> R.string.sign_up_nick_error - etc.length !in 1..Int.MAX_VALUE -> R.string.sign_up_etc_error - else -> { - val intent = Intent(context, LoginActivity::class.java) - intent.putExtra("userId", id).putExtra("userPw", pw).putExtra("userNick", nick) - context.startActivity(intent) - R.string.sign_up_success - } - } - Toast.makeText(context, message, Toast.LENGTH_SHORT).show() -} - @Composable fun SignUpUI() { val context = LocalContext.current @@ -142,6 +125,22 @@ fun SignUpUI() { } } } +fun isSignUpAvailable(context: Context,id: String,pw: String,nick: String,etc: String) { + val message = when { + id.isEmpty() || pw.isEmpty() || nick.isEmpty() || etc.isEmpty() -> R.string.sign_up_blank_error + id.length !in 6..10 -> R.string.sign_up_id_error + pw.length !in 8..12 -> R.string.sign_up_pw_error + nick.isBlank() || nick.length != nick.trim().length -> R.string.sign_up_nick_error + etc.length !in 1..Int.MAX_VALUE -> R.string.sign_up_etc_error + else -> { + val intent = Intent(context, LoginActivity::class.java) + intent.putExtra("userId", id).putExtra("userPw", pw).putExtra("userNick", nick) + context.startActivity(intent) + R.string.sign_up_success + } + } + Toast.makeText(context, message, Toast.LENGTH_SHORT).show() +} @Preview(showBackground = true) @Composable From b5228b01185efe52f4042315351281e170c6fae6 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Thu, 18 Apr 2024 23:48:05 +0900 Subject: [PATCH 10/17] =?UTF-8?q?chore/#6:=20scope=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=B4=EB=B3=B4=EA=B8=B0..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/sopt/now/compose/LoginActivity.kt | 8 +++++--- app/src/main/java/com/sopt/now/compose/SignUpActivity.kt | 7 +++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/LoginActivity.kt b/app/src/main/java/com/sopt/now/compose/LoginActivity.kt index 8518beb..1766a6f 100644 --- a/app/src/main/java/com/sopt/now/compose/LoginActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/LoginActivity.kt @@ -133,9 +133,11 @@ fun isLoginAvailable( val message = when { userId != id || userPw != pw -> R.string.login_error else -> { - val intent = Intent(context, MainActivity::class.java) - intent.putExtra("userId", userId).putExtra("userPw", userPw) - .putExtra("userNick", userNick) + val intent = Intent(context, MainActivity::class.java).apply { + putExtra("userId", userId) + putExtra("userPw", userPw) + putExtra("userNick", userNick) + } context.startActivity(intent) R.string.login_success } diff --git a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt index 5aa839e..3216b97 100644 --- a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt @@ -133,8 +133,11 @@ fun isSignUpAvailable(context: Context,id: String,pw: String,nick: String,etc: S nick.isBlank() || nick.length != nick.trim().length -> R.string.sign_up_nick_error etc.length !in 1..Int.MAX_VALUE -> R.string.sign_up_etc_error else -> { - val intent = Intent(context, LoginActivity::class.java) - intent.putExtra("userId", id).putExtra("userPw", pw).putExtra("userNick", nick) + val intent = Intent(context, LoginActivity::class.java).apply{ + putExtra("userId", id) + putExtra("userPw", pw) + putExtra("userNick", nick) + } context.startActivity(intent) R.string.sign_up_success } From 164ef70c8f9580f190b8f6974f85ea4a58129f89 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Thu, 18 Apr 2024 23:59:44 +0900 Subject: [PATCH 11/17] =?UTF-8?q?chore/#6:=20=EB=8D=B0=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/sopt/now/compose/HomeUi.kt | 18 ++++++++++++++++-- app/src/main/java/com/sopt/now/compose/User.kt | 2 +- .../com/sopt/now/compose/UserProfileItem.kt | 13 +++++++++---- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/HomeUi.kt b/app/src/main/java/com/sopt/now/compose/HomeUi.kt index 907ff74..b830cd2 100644 --- a/app/src/main/java/com/sopt/now/compose/HomeUi.kt +++ b/app/src/main/java/com/sopt/now/compose/HomeUi.kt @@ -32,14 +32,28 @@ fun HomeUi() { } val userList = listOf( User( - profileImage = Icons.Filled.Person, + profileImage = R.drawable.cute, name = "송혜음", - selfDescription = "컴포즈 커피 최고" + selfDescription = "여러분 보고 시퍼yo 훌쩍훌쩍" ) ) val friendList = listOf( Friend( + profileImage = Icons.Filled.Person, + name = "박동민", + selfDescription = "곽의진...얼굴 재치 실력 모든걸 다 가진 남자... 하지만 밀양박씨 36대손인 나 박동민은 가지지 못했지" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "이석준", + selfDescription = "죄송합니다 저 도핑했습니다... 안드-로이더 \uD83D\uDC89" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "박유진", + selfDescription = "(ง˙∇˙)ว 에라 모르겠다" + ),Friend( profileImage = Icons.Filled.Person, name = "이의경", selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지?" diff --git a/app/src/main/java/com/sopt/now/compose/User.kt b/app/src/main/java/com/sopt/now/compose/User.kt index 0766754..3fda0e0 100644 --- a/app/src/main/java/com/sopt/now/compose/User.kt +++ b/app/src/main/java/com/sopt/now/compose/User.kt @@ -3,7 +3,7 @@ package com.sopt.now.compose import androidx.compose.ui.graphics.vector.ImageVector data class User( - val profileImage: ImageVector, + val profileImage: Int, val name: String, val selfDescription: String, ) \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/UserProfileItem.kt b/app/src/main/java/com/sopt/now/compose/UserProfileItem.kt index 6609c53..e8926e5 100644 --- a/app/src/main/java/com/sopt/now/compose/UserProfileItem.kt +++ b/app/src/main/java/com/sopt/now/compose/UserProfileItem.kt @@ -1,7 +1,9 @@ package com.sopt.now.compose +import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size @@ -11,6 +13,8 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp @@ -25,10 +29,11 @@ fun UserProfileItem(user: User) { .padding(vertical = 10.dp), verticalAlignment = Alignment.CenterVertically ) { - Icon( - modifier = Modifier.size(50.dp), - imageVector = user.profileImage, - contentDescription = null + Image( + modifier = Modifier.size(50.dp).aspectRatio(1F), + painter = painterResource(id = user.profileImage), + contentDescription = null, + contentScale = ContentScale.Crop ) Spacer(modifier = Modifier.width(10.dp)) Text( From 04e32f52e144809044e5e96d37fc6f1a5718f9dc Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 19 Apr 2024 00:08:37 +0900 Subject: [PATCH 12/17] =?UTF-8?q?ui/#6:=20=EC=9C=A0=EC=A0=80-=EC=B9=9C?= =?UTF-8?q?=EA=B5=AC=20=EA=B5=AC=EB=B6=84=EC=84=A0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/sopt/now/compose/HomeUi.kt | 4 ++++ app/src/main/java/com/sopt/now/compose/UserProfileItem.kt | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/sopt/now/compose/HomeUi.kt b/app/src/main/java/com/sopt/now/compose/HomeUi.kt index b830cd2..57cea31 100644 --- a/app/src/main/java/com/sopt/now/compose/HomeUi.kt +++ b/app/src/main/java/com/sopt/now/compose/HomeUi.kt @@ -7,9 +7,12 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Person +import androidx.compose.material3.Divider +import androidx.compose.material3.HorizontalDivider import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp @Composable @@ -23,6 +26,7 @@ fun HomeUi() { LazyColumn { items(userList) { UserProfileItem(it) + HorizontalDivider(thickness = 1.dp, color = Color.DarkGray) } items(friendList) { FriendProfileItem(it) diff --git a/app/src/main/java/com/sopt/now/compose/UserProfileItem.kt b/app/src/main/java/com/sopt/now/compose/UserProfileItem.kt index e8926e5..f937fc8 100644 --- a/app/src/main/java/com/sopt/now/compose/UserProfileItem.kt +++ b/app/src/main/java/com/sopt/now/compose/UserProfileItem.kt @@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width -import androidx.compose.material3.Icon import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment From 13839c3c4eae278b29026404ba49df8d33334596 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Sat, 27 Apr 2024 03:23:24 +0900 Subject: [PATCH 13/17] =?UTF-8?q?mod/#6:=20PR=20=EC=A0=81=EC=9A=A9=20-=20c?= =?UTF-8?q?ompanion=20object?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sopt/now/compose/SignUpActivity.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt index 3216b97..62cde69 100644 --- a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt @@ -29,6 +29,10 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import com.sopt.now.compose.SignUpActivity.Companion.MAX_ID_LENGTH +import com.sopt.now.compose.SignUpActivity.Companion.MAX_PW_LENGTH +import com.sopt.now.compose.SignUpActivity.Companion.MIN_ID_LENGTH +import com.sopt.now.compose.SignUpActivity.Companion.MIN_PW_LENGTH import com.sopt.now.compose.ui.theme.NOWSOPTAndroidTheme class SignUpActivity : ComponentActivity() { @@ -46,6 +50,12 @@ class SignUpActivity : ComponentActivity() { } } } + companion object { + const val MIN_ID_LENGTH = 6 + const val MAX_ID_LENGTH = 10 + const val MIN_PW_LENGTH = 8 + const val MAX_PW_LENGTH = 12 + } } @Composable @@ -128,8 +138,8 @@ fun SignUpUI() { fun isSignUpAvailable(context: Context,id: String,pw: String,nick: String,etc: String) { val message = when { id.isEmpty() || pw.isEmpty() || nick.isEmpty() || etc.isEmpty() -> R.string.sign_up_blank_error - id.length !in 6..10 -> R.string.sign_up_id_error - pw.length !in 8..12 -> R.string.sign_up_pw_error + id.length !in MIN_ID_LENGTH..MAX_ID_LENGTH -> R.string.sign_up_id_error + pw.length !in MIN_PW_LENGTH..MAX_PW_LENGTH -> R.string.sign_up_pw_error nick.isBlank() || nick.length != nick.trim().length -> R.string.sign_up_nick_error etc.length !in 1..Int.MAX_VALUE -> R.string.sign_up_etc_error else -> { From d61212e9c763b6a9ae112a5a5a2607957a44a49e Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Sat, 27 Apr 2024 03:31:15 +0900 Subject: [PATCH 14/17] =?UTF-8?q?mod/#6:=20PR=20=EC=A0=81=EC=9A=A9=20-=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sopt/now/compose/SignUpActivity.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt index 62cde69..61dec2b 100644 --- a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt @@ -143,18 +143,20 @@ fun isSignUpAvailable(context: Context,id: String,pw: String,nick: String,etc: S nick.isBlank() || nick.length != nick.trim().length -> R.string.sign_up_nick_error etc.length !in 1..Int.MAX_VALUE -> R.string.sign_up_etc_error else -> { - val intent = Intent(context, LoginActivity::class.java).apply{ - putExtra("userId", id) - putExtra("userPw", pw) - putExtra("userNick", nick) - } - context.startActivity(intent) + sendUserInfo(context,id,pw,nick) R.string.sign_up_success } } Toast.makeText(context, message, Toast.LENGTH_SHORT).show() } - +fun sendUserInfo(context: Context,id: String,pw: String,nick:String){ + val intent = Intent(context, LoginActivity::class.java).apply{ + putExtra("userId", id) + putExtra("userPw", pw) + putExtra("userNick", nick) + } + context.startActivity(intent) +} @Preview(showBackground = true) @Composable fun GreetingPreview3() { From 8fa89cc01bbcaedb05f09c6f57f7d9da63cd0941 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Sat, 27 Apr 2024 03:52:38 +0900 Subject: [PATCH 15/17] =?UTF-8?q?feat/#6:=20HOME=20=EB=B7=B0=EB=AA=A8?= =?UTF-8?q?=EB=8D=B8=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 + .../main/java/com/sopt/now/compose/HomeUi.kt | 93 +----------------- .../com/sopt/now/compose/HomeViewModel.kt | 96 +++++++++++++++++++ .../java/com/sopt/now/compose/MainActivity.kt | 4 +- 4 files changed, 104 insertions(+), 91 deletions(-) create mode 100644 app/src/main/java/com/sopt/now/compose/HomeViewModel.kt diff --git a/app/build.gradle b/app/build.gradle index f534bf6..4bd3749 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -62,4 +62,6 @@ dependencies { androidTestImplementation 'androidx.compose.ui:ui-test-junit4' debugImplementation 'androidx.compose.ui:ui-tooling' debugImplementation 'androidx.compose.ui:ui-test-manifest' + //view model + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2" } \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/HomeUi.kt b/app/src/main/java/com/sopt/now/compose/HomeUi.kt index 57cea31..95b8b02 100644 --- a/app/src/main/java/com/sopt/now/compose/HomeUi.kt +++ b/app/src/main/java/com/sopt/now/compose/HomeUi.kt @@ -5,9 +5,6 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.Person -import androidx.compose.material3.Divider import androidx.compose.material3.HorizontalDivider import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -16,7 +13,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp @Composable -fun HomeUi() { +fun HomeUi(viewModel: HomeViewModel) { Column( modifier = Modifier .fillMaxSize() @@ -24,97 +21,13 @@ fun HomeUi() { horizontalAlignment = Alignment.CenterHorizontally ) { LazyColumn { - items(userList) { + items(viewModel.userList) { UserProfileItem(it) HorizontalDivider(thickness = 1.dp, color = Color.DarkGray) } - items(friendList) { + items(viewModel.friendList) { FriendProfileItem(it) } } } } -val userList = listOf( - User( - profileImage = R.drawable.cute, - name = "송혜음", - selfDescription = "여러분 보고 시퍼yo 훌쩍훌쩍" - ) -) - -val friendList = listOf( - Friend( - profileImage = Icons.Filled.Person, - name = "박동민", - selfDescription = "곽의진...얼굴 재치 실력 모든걸 다 가진 남자... 하지만 밀양박씨 36대손인 나 박동민은 가지지 못했지" - ), - Friend( - profileImage = Icons.Filled.Person, - name = "이석준", - selfDescription = "죄송합니다 저 도핑했습니다... 안드-로이더 \uD83D\uDC89" - ), - Friend( - profileImage = Icons.Filled.Person, - name = "박유진", - selfDescription = "(ง˙∇˙)ว 에라 모르겠다" - ),Friend( - profileImage = Icons.Filled.Person, - name = "이의경", - selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지?" - ), - Friend( - profileImage = Icons.Filled.Person, - name = "우상욱", - selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐" - ), - Friend( - profileImage = Icons.Filled.Person, - name = "배지현", - selfDescription = "표정 풀자 ^^" - ), - Friend( - profileImage = Icons.Filled.Person, - name = "이의경", - selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지?" - ), - Friend( - profileImage = Icons.Filled.Person, - name = "우상욱", - selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐" - ), - Friend( - profileImage = Icons.Filled.Person, - name = "배지현", - selfDescription = "표정 풀자 ^^" - ), - Friend( - profileImage = Icons.Filled.Person, - name = "이의경", - selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지?" - ), - Friend( - profileImage = Icons.Filled.Person, - name = "우상욱", - selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐" - ), - Friend( - profileImage = Icons.Filled.Person, - name = "배지현", - selfDescription = "표정 풀자 ^^" - ), - Friend( - profileImage = Icons.Filled.Person, - name = "이의경", - selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지?" - ), - Friend( - profileImage = Icons.Filled.Person, - name = "우상욱", - selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐" - ), - Friend( - profileImage = Icons.Filled.Person, - name = "배지현", - selfDescription = "표정 풀자 ^^" - ) -) diff --git a/app/src/main/java/com/sopt/now/compose/HomeViewModel.kt b/app/src/main/java/com/sopt/now/compose/HomeViewModel.kt new file mode 100644 index 0000000..dc183ed --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/HomeViewModel.kt @@ -0,0 +1,96 @@ +package com.sopt.now.compose + +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Person +import androidx.lifecycle.ViewModel +import com.sopt.now.compose.Friend +import com.sopt.now.compose.R +import com.sopt.now.compose.User + +class HomeViewModel : ViewModel() { + + val userList = listOf( + User( + profileImage = R.drawable.cute, + name = "송혜음", + selfDescription = "여러분 보고 시퍼yo 훌쩍훌쩍" + ) + ) + + val friendList = listOf( + Friend( + profileImage = Icons.Filled.Person, + name = "박동민", + selfDescription = "곽의진...얼굴 재치 실력 모든걸 다 가진 남자... 하지만 밀양박씨 36대손인 나 박동민은 가지지 못했지" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "이석준", + selfDescription = "죄송합니다 저 도핑했습니다... 안드-로이더 \uD83D\uDC89" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "박유진", + selfDescription = "(ง˙∇˙)ว 에라 모르겠다" + ), Friend( + profileImage = Icons.Filled.Person, + name = "이의경", + selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지?" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "우상욱", + selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "배지현", + selfDescription = "표정 풀자 ^^" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "이의경", + selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지?" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "우상욱", + selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "배지현", + selfDescription = "표정 풀자 ^^" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "이의경", + selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지?" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "우상욱", + selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "배지현", + selfDescription = "표정 풀자 ^^" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "이의경", + selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지?" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "우상욱", + selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐" + ), + Friend( + profileImage = Icons.Filled.Person, + name = "배지현", + selfDescription = "표정 풀자 ^^" + ) + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/MainActivity.kt b/app/src/main/java/com/sopt/now/compose/MainActivity.kt index 21d1971..c173f92 100644 --- a/app/src/main/java/com/sopt/now/compose/MainActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/MainActivity.kt @@ -3,6 +3,7 @@ package com.sopt.now.compose import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent +import androidx.activity.viewModels import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize @@ -35,6 +36,7 @@ import androidx.compose.ui.unit.sp import com.sopt.now.compose.ui.theme.NOWSOPTAndroidTheme class MainActivity : ComponentActivity() { + private val viewModel by viewModels() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { @@ -109,7 +111,7 @@ fun MainUi(userId: String?, userPw: String?, userNick: String?) { ) { when (selectedItem) { 0 -> { - HomeUi() + HomeUi(HomeViewModel()) } 1 -> { From e8eb1957122cd697bb827e26ac10abf67969ba84 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Wed, 1 May 2024 16:23:31 +0900 Subject: [PATCH 16/17] =?UTF-8?q?mod#6/:PR=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/sopt/now/ApiFactory.kt | 23 +++++++ app/src/main/java/com/sopt/now/AuthService.kt | 12 ++++ .../java/com/sopt/now/RequestSignUpDto.kt | 16 +++++ .../java/com/sopt/now/ResponseSignUpDto.kt | 12 ++++ .../com/sopt/now/compose/FriendProfileItem.kt | 9 +-- .../now/compose/{HomeUi.kt => HomeScreen.kt} | 2 +- .../com/sopt/now/compose/HomeViewModel.kt | 3 - .../com/sopt/now/compose/LoginActivity.kt | 37 ++++++++--- .../java/com/sopt/now/compose/MainActivity.kt | 19 ++++-- .../{ProfileUi.kt => ProfileScreen.kt} | 0 .../com/sopt/now/compose/SignUpActivity.kt | 66 ++++++++++++++----- .../main/java/com/sopt/now/compose/User.kt | 2 - 12 files changed, 157 insertions(+), 44 deletions(-) create mode 100644 app/src/main/java/com/sopt/now/ApiFactory.kt create mode 100644 app/src/main/java/com/sopt/now/AuthService.kt create mode 100644 app/src/main/java/com/sopt/now/RequestSignUpDto.kt create mode 100644 app/src/main/java/com/sopt/now/ResponseSignUpDto.kt rename app/src/main/java/com/sopt/now/compose/{HomeUi.kt => HomeScreen.kt} (92%) rename app/src/main/java/com/sopt/now/compose/{ProfileUi.kt => ProfileScreen.kt} (100%) diff --git a/app/src/main/java/com/sopt/now/ApiFactory.kt b/app/src/main/java/com/sopt/now/ApiFactory.kt new file mode 100644 index 0000000..1e8a177 --- /dev/null +++ b/app/src/main/java/com/sopt/now/ApiFactory.kt @@ -0,0 +1,23 @@ +package com.sopt.now + +import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory +import kotlinx.serialization.json.Json +import okhttp3.MediaType.Companion.toMediaType +import retrofit2.Retrofit + +object ApiFactory { + private const val BASE_URL: String = BuildConfig.AUTH_BASE_URL + + val retrofit: Retrofit by lazy { + Retrofit.Builder() + .baseUrl(BASE_URL) + .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) + .build() + } + + inline fun create(): T = retrofit.create(T::class.java) +} + +object ServicePool { + val authService = ApiFactory.create() +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/AuthService.kt b/app/src/main/java/com/sopt/now/AuthService.kt new file mode 100644 index 0000000..c08c089 --- /dev/null +++ b/app/src/main/java/com/sopt/now/AuthService.kt @@ -0,0 +1,12 @@ +package com.sopt.now + +import retrofit2.Call +import retrofit2.http.Body +import retrofit2.http.POST + +interface AuthService { + @POST("member/join") //http 메소드 + fun signUp( + @Body request: RequestSignUpDto, + ): Call //비동기->callback +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/RequestSignUpDto.kt b/app/src/main/java/com/sopt/now/RequestSignUpDto.kt new file mode 100644 index 0000000..2763e87 --- /dev/null +++ b/app/src/main/java/com/sopt/now/RequestSignUpDto.kt @@ -0,0 +1,16 @@ +package com.sopt.now + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class RequestSignUpDto( + @SerialName("authenticationId") + val authenticationId: String, + @SerialName("password") + val password: String, + @SerialName("nickname") + val nickname: String, + @SerialName("phone") + val phone: String, +) diff --git a/app/src/main/java/com/sopt/now/ResponseSignUpDto.kt b/app/src/main/java/com/sopt/now/ResponseSignUpDto.kt new file mode 100644 index 0000000..ce55efe --- /dev/null +++ b/app/src/main/java/com/sopt/now/ResponseSignUpDto.kt @@ -0,0 +1,12 @@ +package com.sopt.now + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ResponseSignUpDto( + @SerialName("code") + val code: Int, + @SerialName("message") + val message: String, +) diff --git a/app/src/main/java/com/sopt/now/compose/FriendProfileItem.kt b/app/src/main/java/com/sopt/now/compose/FriendProfileItem.kt index c843186..2336e5b 100644 --- a/app/src/main/java/com/sopt/now/compose/FriendProfileItem.kt +++ b/app/src/main/java/com/sopt/now/compose/FriendProfileItem.kt @@ -11,6 +11,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp @@ -18,7 +19,7 @@ import androidx.compose.ui.unit.sp @Composable -fun FriendProfileItem(friend: Friend) { +fun FriendProfileItem(friendImg: ImageVector, friendName: String, friendDescription: String) { Row( modifier = Modifier .fillMaxWidth() @@ -27,12 +28,12 @@ fun FriendProfileItem(friend: Friend) { ) { Icon( modifier = Modifier.size(50.dp), - imageVector = friend.profileImage, + imageVector = friendImg, contentDescription = null ) Spacer(modifier = Modifier.width(10.dp)) Text( - text = friend.name, + text = friendName, fontSize = 14.sp, fontWeight = FontWeight.Bold, overflow = TextOverflow.Ellipsis, @@ -41,7 +42,7 @@ fun FriendProfileItem(friend: Friend) { Spacer(modifier = Modifier.width(30.dp)) Spacer(modifier = Modifier.weight(1f)) Text( - text = friend.selfDescription, + text = friendDescription, fontSize = 10.sp, overflow = TextOverflow.Ellipsis, maxLines = 1 diff --git a/app/src/main/java/com/sopt/now/compose/HomeUi.kt b/app/src/main/java/com/sopt/now/compose/HomeScreen.kt similarity index 92% rename from app/src/main/java/com/sopt/now/compose/HomeUi.kt rename to app/src/main/java/com/sopt/now/compose/HomeScreen.kt index 95b8b02..0e6bdb5 100644 --- a/app/src/main/java/com/sopt/now/compose/HomeUi.kt +++ b/app/src/main/java/com/sopt/now/compose/HomeScreen.kt @@ -26,7 +26,7 @@ fun HomeUi(viewModel: HomeViewModel) { HorizontalDivider(thickness = 1.dp, color = Color.DarkGray) } items(viewModel.friendList) { - FriendProfileItem(it) + FriendProfileItem(it.profileImage,it.name,it.selfDescription) } } } diff --git a/app/src/main/java/com/sopt/now/compose/HomeViewModel.kt b/app/src/main/java/com/sopt/now/compose/HomeViewModel.kt index dc183ed..798c74f 100644 --- a/app/src/main/java/com/sopt/now/compose/HomeViewModel.kt +++ b/app/src/main/java/com/sopt/now/compose/HomeViewModel.kt @@ -3,9 +3,6 @@ package com.sopt.now.compose import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Person import androidx.lifecycle.ViewModel -import com.sopt.now.compose.Friend -import com.sopt.now.compose.R -import com.sopt.now.compose.User class HomeViewModel : ViewModel() { diff --git a/app/src/main/java/com/sopt/now/compose/LoginActivity.kt b/app/src/main/java/com/sopt/now/compose/LoginActivity.kt index 1766a6f..7d429f9 100644 --- a/app/src/main/java/com/sopt/now/compose/LoginActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/LoginActivity.kt @@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Lock import androidx.compose.material.icons.filled.Person import androidx.compose.material3.Button import androidx.compose.material3.Icon @@ -40,7 +41,6 @@ class LoginActivity : ComponentActivity() { super.onCreate(savedInstanceState) setContent { NOWSOPTAndroidTheme { - // A surface container using the 'background' color from the theme Surface( modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background @@ -48,7 +48,17 @@ class LoginActivity : ComponentActivity() { val userId = intent.getStringExtra("userId") val userPw = intent.getStringExtra("userPw") val userNick = intent.getStringExtra("userNick") - LoginUI(userId, userPw, userNick) + var id by remember { mutableStateOf("") } + var pw by remember { mutableStateOf("") } + + LoginScreen( + userId, + userPw, + userNick, + id, + pw, + onIdChange = { id = it }, + onPwChange = { pw = it }) } } } @@ -56,10 +66,16 @@ class LoginActivity : ComponentActivity() { } @Composable -fun LoginUI(userId: String?, userPw: String?, userNick: String?) { +fun LoginScreen( + userId: String?, + userPw: String?, + userNick: String?, + id: String, + pw: String, + onIdChange: (String) -> Unit, + onPwChange: (String) -> Unit +) { val context = LocalContext.current - var id by remember { mutableStateOf("") } - var pw by remember { mutableStateOf("") } Column( modifier = Modifier @@ -77,7 +93,7 @@ fun LoginUI(userId: String?, userPw: String?, userNick: String?) { ) TextField( value = id, - onValueChange = { id = it }, + onValueChange = onIdChange, modifier = Modifier .fillMaxWidth() .padding(10.dp), @@ -89,14 +105,14 @@ fun LoginUI(userId: String?, userPw: String?, userNick: String?) { Text(text = stringResource(R.string.text_pw)) TextField( value = pw, - onValueChange = { pw = it }, + onValueChange = onPwChange, modifier = Modifier .fillMaxWidth() .padding(10.dp), placeholder = { Text(stringResource(R.string.tf_login_pw)) }, singleLine = true, visualTransformation = PasswordVisualTransformation(), - leadingIcon = { Icon(Icons.Filled.Person, contentDescription = "User Icon") }, + leadingIcon = { Icon(Icons.Filled.Lock, contentDescription = "Lock Icon") }, ) Spacer(modifier = Modifier.weight(1f)) Button( @@ -144,10 +160,11 @@ fun isLoginAvailable( } Toast.makeText(context, message, Toast.LENGTH_SHORT).show() } + @Preview(showBackground = true) @Composable -fun GreetingPreview2() { +fun LoginPreview() { NOWSOPTAndroidTheme { - LoginUI("아이디", "비밀번호", "닉네임") + LoginScreen("아이디", "비밀번호", "닉네임","","", onIdChange = {}, onPwChange = {}) } } \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/MainActivity.kt b/app/src/main/java/com/sopt/now/compose/MainActivity.kt index c173f92..96af1c5 100644 --- a/app/src/main/java/com/sopt/now/compose/MainActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/MainActivity.kt @@ -3,7 +3,6 @@ package com.sopt.now.compose import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.activity.viewModels import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize @@ -36,7 +35,6 @@ import androidx.compose.ui.unit.sp import com.sopt.now.compose.ui.theme.NOWSOPTAndroidTheme class MainActivity : ComponentActivity() { - private val viewModel by viewModels() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { @@ -48,7 +46,11 @@ class MainActivity : ComponentActivity() { val userId = intent.getStringExtra("userId") val userPw = intent.getStringExtra("userPw") val userNick = intent.getStringExtra("userNick") - MainUi(userId, userPw, userNick) + MainScreen( + userId, + userPw, + userNick + ) } } } @@ -57,8 +59,12 @@ class MainActivity : ComponentActivity() { @OptIn(ExperimentalMaterial3Api::class) @Composable -fun MainUi(userId: String?, userPw: String?, userNick: String?) { - if(userId!=null&&userPw!=null&&userNick!=null) { +fun MainScreen( + userId: String?, + userPw: String?, + userNick: String? +) { + if (userId != null && userPw != null && userNick != null) { var selectedItem by remember { mutableIntStateOf(0) } val items = listOf( BottomNavigationItem( @@ -126,10 +132,11 @@ fun MainUi(userId: String?, userPw: String?, userNick: String?) { } } } + @Preview(showBackground = true) @Composable fun GreetingPreview() { NOWSOPTAndroidTheme { - MainUi("아이디","비밀번호","닉네임") + MainScreen("아이디", "비밀번호", "닉네임") } } \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/ProfileUi.kt b/app/src/main/java/com/sopt/now/compose/ProfileScreen.kt similarity index 100% rename from app/src/main/java/com/sopt/now/compose/ProfileUi.kt rename to app/src/main/java/com/sopt/now/compose/ProfileScreen.kt diff --git a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt index 61dec2b..b0feb77 100644 --- a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt @@ -40,16 +40,29 @@ class SignUpActivity : ComponentActivity() { super.onCreate(savedInstanceState) setContent { NOWSOPTAndroidTheme { - // A surface container using the 'background' color from the theme Surface( modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background ) { - SignUpUI() + var id by remember { mutableStateOf("") } + var pw by remember { mutableStateOf("") } + var nick by remember { mutableStateOf("") } + var etc by remember { mutableStateOf("") } + + SignUpScreen( + id, + pw, + nick, + etc, + onIdChange = { id = it }, + onPwChange = { pw = it }, + onNickChange = { nick = it }, + onEtcChange = { etc = it }) } } } } + companion object { const val MIN_ID_LENGTH = 6 const val MAX_ID_LENGTH = 10 @@ -59,12 +72,17 @@ class SignUpActivity : ComponentActivity() { } @Composable -fun SignUpUI() { +fun SignUpScreen( + id: String, + pw: String, + nick: String, + etc: String, + onIdChange: (String) -> Unit, + onPwChange: (String) -> Unit, + onNickChange: (String) -> Unit, + onEtcChange: (String) -> Unit +) { val context = LocalContext.current - var id by remember { mutableStateOf("") } - var pw by remember { mutableStateOf("") } - var nick by remember { mutableStateOf("") } - var etc by remember { mutableStateOf("") } Column( modifier = Modifier @@ -84,7 +102,7 @@ fun SignUpUI() { TextField( value = id, label = { Text(stringResource(R.string.tf_label_id)) }, - onValueChange = { id = it }, + onValueChange = onIdChange, placeholder = { Text(stringResource(R.string.tf_ph_id)) }, singleLine = true ) @@ -96,7 +114,7 @@ fun SignUpUI() { TextField( value = pw, label = { Text(stringResource(R.string.tf_label_pw)) }, - onValueChange = { pw = it }, + onValueChange = onPwChange, placeholder = { Text(stringResource(R.string.tf_ph_pw)) }, singleLine = true ) @@ -108,7 +126,7 @@ fun SignUpUI() { TextField( value = nick, label = { Text(stringResource(R.string.tf_label_nick)) }, - onValueChange = { nick = it }, + onValueChange = onNickChange, placeholder = { Text(stringResource(R.string.tf_ph_nick)) }, singleLine = true ) @@ -120,14 +138,14 @@ fun SignUpUI() { TextField( value = etc, label = { Text(stringResource(R.string.tf_label_etc)) }, - onValueChange = { etc = it }, + onValueChange = onEtcChange, placeholder = { Text(stringResource(R.string.tf_ph_etc)) }, singleLine = true ) Spacer(modifier = Modifier.weight(1f)) Button( onClick = { - isSignUpAvailable(context,id,pw,nick,etc) + isSignUpAvailable(context, id, pw, nick, etc) }, modifier = Modifier.fillMaxWidth() ) { @@ -135,7 +153,8 @@ fun SignUpUI() { } } } -fun isSignUpAvailable(context: Context,id: String,pw: String,nick: String,etc: String) { + +fun isSignUpAvailable(context: Context, id: String, pw: String, nick: String, etc: String) { val message = when { id.isEmpty() || pw.isEmpty() || nick.isEmpty() || etc.isEmpty() -> R.string.sign_up_blank_error id.length !in MIN_ID_LENGTH..MAX_ID_LENGTH -> R.string.sign_up_id_error @@ -143,24 +162,35 @@ fun isSignUpAvailable(context: Context,id: String,pw: String,nick: String,etc: S nick.isBlank() || nick.length != nick.trim().length -> R.string.sign_up_nick_error etc.length !in 1..Int.MAX_VALUE -> R.string.sign_up_etc_error else -> { - sendUserInfo(context,id,pw,nick) + sendUserInfo(context, id, pw, nick) R.string.sign_up_success } } Toast.makeText(context, message, Toast.LENGTH_SHORT).show() } -fun sendUserInfo(context: Context,id: String,pw: String,nick:String){ - val intent = Intent(context, LoginActivity::class.java).apply{ + +fun sendUserInfo(context: Context, id: String, pw: String, nick: String) { + val intent = Intent(context, LoginActivity::class.java).apply { putExtra("userId", id) putExtra("userPw", pw) putExtra("userNick", nick) } context.startActivity(intent) } + @Preview(showBackground = true) @Composable -fun GreetingPreview3() { +fun SignUpPreview() { NOWSOPTAndroidTheme { - SignUpUI() + SignUpScreen( + id = "아이디", + pw = "비밀번호", + nick = "닉네임", + etc = "기타 할 말", + onIdChange = {}, + onPwChange = {}, + onNickChange = {}, + onEtcChange = {} + ) } } \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/User.kt b/app/src/main/java/com/sopt/now/compose/User.kt index 3fda0e0..3a7e56a 100644 --- a/app/src/main/java/com/sopt/now/compose/User.kt +++ b/app/src/main/java/com/sopt/now/compose/User.kt @@ -1,7 +1,5 @@ package com.sopt.now.compose -import androidx.compose.ui.graphics.vector.ImageVector - data class User( val profileImage: Int, val name: String, From b906358f80eba101150a7db788dd40cfe1fb8e13 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Wed, 1 May 2024 17:37:05 +0900 Subject: [PATCH 17/17] =?UTF-8?q?del#6/:=20=EC=9E=98=EB=AA=BB=20=EC=98=AC?= =?UTF-8?q?=EB=9D=BC=EA=B0=84=20=ED=8C=8C=EC=9D=BC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/sopt/now/ApiFactory.kt | 23 ------------------- app/src/main/java/com/sopt/now/AuthService.kt | 12 ---------- .../java/com/sopt/now/RequestSignUpDto.kt | 16 ------------- .../java/com/sopt/now/ResponseSignUpDto.kt | 12 ---------- 4 files changed, 63 deletions(-) delete mode 100644 app/src/main/java/com/sopt/now/ApiFactory.kt delete mode 100644 app/src/main/java/com/sopt/now/AuthService.kt delete mode 100644 app/src/main/java/com/sopt/now/RequestSignUpDto.kt delete mode 100644 app/src/main/java/com/sopt/now/ResponseSignUpDto.kt diff --git a/app/src/main/java/com/sopt/now/ApiFactory.kt b/app/src/main/java/com/sopt/now/ApiFactory.kt deleted file mode 100644 index 1e8a177..0000000 --- a/app/src/main/java/com/sopt/now/ApiFactory.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.sopt.now - -import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory -import kotlinx.serialization.json.Json -import okhttp3.MediaType.Companion.toMediaType -import retrofit2.Retrofit - -object ApiFactory { - private const val BASE_URL: String = BuildConfig.AUTH_BASE_URL - - val retrofit: Retrofit by lazy { - Retrofit.Builder() - .baseUrl(BASE_URL) - .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) - .build() - } - - inline fun create(): T = retrofit.create(T::class.java) -} - -object ServicePool { - val authService = ApiFactory.create() -} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/AuthService.kt b/app/src/main/java/com/sopt/now/AuthService.kt deleted file mode 100644 index c08c089..0000000 --- a/app/src/main/java/com/sopt/now/AuthService.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.sopt.now - -import retrofit2.Call -import retrofit2.http.Body -import retrofit2.http.POST - -interface AuthService { - @POST("member/join") //http 메소드 - fun signUp( - @Body request: RequestSignUpDto, - ): Call //비동기->callback -} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/RequestSignUpDto.kt b/app/src/main/java/com/sopt/now/RequestSignUpDto.kt deleted file mode 100644 index 2763e87..0000000 --- a/app/src/main/java/com/sopt/now/RequestSignUpDto.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.sopt.now - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -data class RequestSignUpDto( - @SerialName("authenticationId") - val authenticationId: String, - @SerialName("password") - val password: String, - @SerialName("nickname") - val nickname: String, - @SerialName("phone") - val phone: String, -) diff --git a/app/src/main/java/com/sopt/now/ResponseSignUpDto.kt b/app/src/main/java/com/sopt/now/ResponseSignUpDto.kt deleted file mode 100644 index ce55efe..0000000 --- a/app/src/main/java/com/sopt/now/ResponseSignUpDto.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.sopt.now - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -data class ResponseSignUpDto( - @SerialName("code") - val code: Int, - @SerialName("message") - val message: String, -)