-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/week04 compose #6
base: develop-compose
Are you sure you want to change the base?
Changes from all commits
74129b2
89b12ac
3e0b41b
7577c5a
701b36c
17a300c
e02334f
2090347
b03535d
712d1ec
3fcf007
f8748de
af1baf3
81346ab
c6468c3
79dd78e
f601c50
15e1426
c277993
5108f8e
ee86bdb
0aa9c07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.sopt.now.compose | ||
|
||
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 <reified T> create(): T = retrofit.create(T::class.java) | ||
} | ||
|
||
object ServicePool { | ||
val authService = ApiFactory.create<AuthService>() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.sopt.now.compose | ||
|
||
import com.sopt.now.compose.data.RequestLogInDto | ||
import com.sopt.now.compose.data.RequestPasswordDto | ||
import com.sopt.now.compose.data.RequestSignUpDto | ||
import com.sopt.now.compose.data.ResponseDto | ||
import com.sopt.now.compose.data.ResponseInfoDto | ||
import retrofit2.Call | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.Header | ||
import retrofit2.http.PATCH | ||
import retrofit2.http.POST | ||
|
||
interface AuthService { | ||
@POST("member/join") | ||
fun signUp( | ||
@Body request: RequestSignUpDto, | ||
): Call<ResponseDto> | ||
|
||
@POST("member/login") | ||
fun logIn( | ||
@Body request: RequestLogInDto, | ||
): Call<ResponseDto> | ||
|
||
@GET("member/info") | ||
fun info(@Header("memberId") memberId: Int): Call<ResponseInfoDto> | ||
|
||
@PATCH("member/password") | ||
fun changePassword( | ||
@Header("memberId") memberId: Int, | ||
@Body request: RequestPasswordDto | ||
): Call<ResponseDto> | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,85 @@ | ||||||||||||||||||||||
package com.sopt.now.compose | ||||||||||||||||||||||
|
||||||||||||||||||||||
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.Icon | ||||||||||||||||||||||
import androidx.compose.material3.NavigationBar | ||||||||||||||||||||||
import androidx.compose.material3.NavigationBarItem | ||||||||||||||||||||||
import androidx.compose.material3.NavigationBarItemDefaults | ||||||||||||||||||||||
import androidx.compose.material3.Text | ||||||||||||||||||||||
import androidx.compose.runtime.Composable | ||||||||||||||||||||||
import androidx.compose.runtime.getValue | ||||||||||||||||||||||
import androidx.compose.ui.Modifier | ||||||||||||||||||||||
import androidx.compose.ui.graphics.Color | ||||||||||||||||||||||
import androidx.compose.ui.graphics.vector.ImageVector | ||||||||||||||||||||||
import androidx.navigation.NavHostController | ||||||||||||||||||||||
import androidx.navigation.compose.currentBackStackEntryAsState | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
@Composable | ||||||||||||||||||||||
fun BottomBar( | ||||||||||||||||||||||
navController: NavHostController, | ||||||||||||||||||||||
modifier: Modifier = Modifier, | ||||||||||||||||||||||
isLoggedIn: Boolean | ||||||||||||||||||||||
) { | ||||||||||||||||||||||
Comment on lines
+22
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kotlin์์๋ ๋ชจ๋ ์ ํ์ ํจ๋ฌ๋ฏธํฐ(Optional Parameter, ๋ํดํธ ๊ฐ์ด ์ฃผ์ด์ง ํจ๋ฌ๋ฏธํฐ)๋ ํ์ ํจ๋ฌ๋ฏธํฐ ๋ค์ ๋ฐฐ์น๋์ด์ผํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ์ปดํฌ์ฆ์์๋ ๋ชจ๋ ์ ํ์ ํจ๋ฌ๋ฏธํฐ ์ ์ผ ์์ Modifier๊ฐ ๋ฐฐ์น๋์ด์ผ ํฉ๋๋ค...๋ผ๊ณ ์ฝ๋ฉ ์ปจ๋ฒค์ ์๋ ์ ํ ์์ต๋๋ค. ํ์๋ ์๋์ง๋ง ๊ณตํต ๋ฃฐ์ ์ง์ผ๋ณด๋ฉด์ ์ฝ๋ ๊ฐ๋ ์ฑ ์ฌ๋ฆฌ๋ ๊ฒ์ ๋์์ด ๋ ์ ์์ ๊ฒ ๊ฐ์์ ๊ณต์ ๋๋ฆฝ๋๋ค.
Suggested change
|
||||||||||||||||||||||
|
||||||||||||||||||||||
val screens = listOf( | ||||||||||||||||||||||
BottomNavItem.Home, BottomNavItem.Search, BottomNavItem.MyPage | ||||||||||||||||||||||
) | ||||||||||||||||||||||
Comment on lines
+28
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (์์ฃผ ์ฌ์ํ ๋ฆฌ๋ทฐ) ์ด ๋ฆฌ์คํธ๋ ์ปดํฌ์ ๋ธ ํจ์ ๊ทธ๋ ค์ง๋ ๋์ ๋จ ํ๋ฒ๋ง ํ ๋น ์ฐ์ฐ์ด ์คํ๋ ๊น์? |
||||||||||||||||||||||
|
||||||||||||||||||||||
if (isLoggedIn) { | ||||||||||||||||||||||
val navBackStackEntry by navController.currentBackStackEntryAsState() | ||||||||||||||||||||||
val currentRoute = navBackStackEntry?.destination?.route | ||||||||||||||||||||||
NavigationBar( | ||||||||||||||||||||||
modifier = modifier, | ||||||||||||||||||||||
containerColor = Color.LightGray, | ||||||||||||||||||||||
) { | ||||||||||||||||||||||
screens.forEach { screen -> | ||||||||||||||||||||||
|
||||||||||||||||||||||
NavigationBarItem( | ||||||||||||||||||||||
label = { | ||||||||||||||||||||||
Text(text = screen.title!!) | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
icon = { | ||||||||||||||||||||||
Icon(imageVector = screen.icon!!, contentDescription = "") | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
selected = currentRoute == screen.route, | ||||||||||||||||||||||
onClick = { | ||||||||||||||||||||||
navController.navigate(screen.route) | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
colors = NavigationBarItemDefaults.colors( | ||||||||||||||||||||||
unselectedTextColor = Color.Gray, selectedTextColor = Color.White | ||||||||||||||||||||||
), | ||||||||||||||||||||||
) | ||||||||||||||||||||||
} | ||||||||||||||||||||||
} | ||||||||||||||||||||||
} | ||||||||||||||||||||||
Comment on lines
+32
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๋ง์ฝ ๋ฐํ ๋ฐ๊ฐ ๋ก๊ทธ์ธ๋ ์ํ ์ด์ธ์๋ ๋ณด์ฌ์ผ ํ๋ค๋ผ๋ ์๊ตฌ์ฌํญ ๋ณ๊ฒฝ์ด ๋ค์ด์ค๋ฉด ์ด๋ป๊ฒ ๋ ๊น์? ๊ทธ๋ฆฌ๊ณ ํน์ ์กฐ๊ฑด์์๋ ๋ณด์ด์ง ์์์ผ ํ๋ค๋ผ๋ ์กฐ๊ฑด์ด ์ถ๊ฐ๋๋ค๋ฉด์? ์ปดํฌ๋ํธ ๋จ์์ ์ด๋ฐ ์ฑ ๋ด ๊ธฐ๋ฅ ์๊ตฌ์ฌํญ๋ค์ ์์์ผ ํ ํ์๊ฐ ์์๊น์? |
||||||||||||||||||||||
|
||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
sealed class BottomNavItem( | ||||||||||||||||||||||
val route: String, | ||||||||||||||||||||||
val title: String? = null, | ||||||||||||||||||||||
val icon: ImageVector? = null | ||||||||||||||||||||||
) { | ||||||||||||||||||||||
data object Home : BottomNavItem( | ||||||||||||||||||||||
route = Routes.Home.route, | ||||||||||||||||||||||
title = "Home", | ||||||||||||||||||||||
icon = Icons.Default.Home | ||||||||||||||||||||||
) | ||||||||||||||||||||||
|
||||||||||||||||||||||
data object Search : BottomNavItem( | ||||||||||||||||||||||
route = Routes.Search.route, | ||||||||||||||||||||||
title = "Search", | ||||||||||||||||||||||
icon = Icons.Default.Search | ||||||||||||||||||||||
) | ||||||||||||||||||||||
|
||||||||||||||||||||||
data object MyPage : BottomNavItem( | ||||||||||||||||||||||
route = Routes.MyPage.route, | ||||||||||||||||||||||
title = "MyPage", | ||||||||||||||||||||||
icon = Icons.Default.Person | ||||||||||||||||||||||
) | ||||||||||||||||||||||
|
||||||||||||||||||||||
} | ||||||||||||||||||||||
Comment on lines
+62
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. enum class๋ก๋ ๋ฐ๊ฟ ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ํด๋น ๊ตฌ์กฐ๋ฅผ sealed๋ก ๋ง๋์ ์ด์ ๊ฐ ์์๊น์? |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,8 @@ | ||||||
package com.sopt.now.compose | ||||||
|
||||||
data class Friend( | ||||||
val profileImageRes: Int, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
๋ฆฌ์์ค ์์ด๋์ ๊ฒฝ์ฐ์๋ ์์ ์ด๋ฐ์์ผ๋ก ์ด๋ ธํ ์ด์ ๋ถ์ด๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค. ์ถ๊ฐ๋ก ํด๋น ์์ดํ ์ด ๋ก์ปฌ ์ด๋ฏธ์ง๊ฐ ์๋ ์ธ๋ถ ์ ์ฅ์์์ ๊ฐ์ ธ์์ผ ํ๋ ์ด๋ฏธ์ง๋ผ๋ฉด ํจ๋ฌ๋ฏธํฐ๊ฐ Int๋ง ๋ฐ์ผ๋ฉด ์๋ ํ ๋ฐ ์ด๋ป๊ฒ ๋์ํ ์ ์์๊น์? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ํ ์ธ๋ถ์์ ๊ฐ์ ธ์์ผ ํ๋ ๊ฒฝ์ฐ๋ ์๊ฐํด๋ณด์ง ๋ชปํ์ต๋๋ค... |
||||||
val name: String, | ||||||
val description: String | ||||||
|
||||||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ค๋ณต์ ์ธ์ ๋๋ค.