Skip to content
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/#6] 1주차 심화과제 (Compose) #8

Open
wants to merge 16 commits into
base: develop-compose
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions app/build.gradle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c: 이제 버전 카탈로그의 사용도 고민해보시면 좋을듯?

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.devtools.ksp'
id 'dagger.hilt.android.plugin'
}

android {
Expand Down Expand Up @@ -50,24 +52,36 @@ dependencies {
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0'
implementation 'androidx.activity:activity-compose:1.8.2'

// Compose BOM
implementation platform('androidx.compose:compose-bom:2024.03.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
implementation 'androidx.compose.ui:ui-graphics-android:1.6.8'
implementation 'androidx.compose.ui:ui-test-android:1.6.8'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation platform('androidx.compose:compose-bom:2024.03.00')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'

// Debugging and Testing
debugImplementation 'androidx.compose.ui:ui-tooling'
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
androidTestImplementation platform('androidx.compose:compose-bom:2024.03.00')

// Navigation
implementation 'androidx.navigation:navigation-compose:2.7.7'

// Serialization
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0'

// Hilt (Dependency Injection)
implementation 'com.google.dagger:hilt-android:2.49'
ksp 'com.google.dagger:hilt-compiler:2.49'
implementation 'androidx.hilt:hilt-navigation-compose:1.2.0'

// Testing
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
Comment on lines +80 to +83
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c: 위에도 테스팅 범주가 있고 아래도 있네요?


implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
}
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools">

<application
android:name=".NOWSoptApp"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
Expand All @@ -15,6 +16,7 @@
<activity
android:name=".presentation.ui.main.MainActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize"
android:label="@string/app_name"
android:theme="@style/Theme.NOWSOPTAndroid"
android:screenOrientation="portrait">
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/java/com/sopt/now/compose/NOWSoptApp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.sopt.now.compose

import android.app.Application
import android.content.Context
import androidx.appcompat.app.AppCompatDelegate
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class NOWSoptApp : Application() {
override fun onCreate() {
super.onCreate()
appContext = applicationContext
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
}

companion object {
lateinit var appContext: Context
private set
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.sopt.now.compose.presentation.ui.auth.component
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand All @@ -11,15 +12,19 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.unit.dp
Expand All @@ -28,25 +33,31 @@ import com.sopt.now.compose.ui.theme.CustomTheme

@Composable
fun AuthTextField(
value: TextFieldValue,
onValueChange: (TextFieldValue) -> Unit,
value: String,
onValueChange: (String) -> Unit,
modifier: Modifier = Modifier,
isFocused: Boolean,
onFocusChanged: (Boolean) -> Unit,
onRemove: () -> Unit,
hint: String,
visualTransformation: VisualTransformation = VisualTransformation.None
visualTransformation: VisualTransformation = VisualTransformation.None,
focusRequester: FocusRequester = FocusRequester(),
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
keyboardActions: KeyboardActions = KeyboardActions.Default,
) {
Box(modifier = modifier) {
BasicTextField(
value = value,
onValueChange = onValueChange,
modifier = Modifier
.fillMaxWidth()
.focusRequester(focusRequester)
.onFocusChanged { focusState ->
onFocusChanged(focusState.isFocused)
},
textStyle = TextStyle(color = CustomTheme.colors.gray01),
keyboardOptions = keyboardOptions,
keyboardActions = keyboardActions,
singleLine = true,
visualTransformation = visualTransformation,
cursorBrush = SolidColor(CustomTheme.colors.gray01),
Expand All @@ -60,8 +71,10 @@ fun AuthTextField(
.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
) {
Box {
if (value.text.isEmpty()) {
Box(
modifier = Modifier.weight(1f)
) {
if (value.isEmpty()) {
Text(
text = hint,
style = CustomTheme.typography.body1Medium,
Expand All @@ -70,15 +83,17 @@ fun AuthTextField(
}
innerTextField()
}
Spacer(modifier = Modifier.weight(1f))
Image(
painter = painterResource(id = R.drawable.ic_textfield_clear),
contentDescription = null,
modifier = Modifier
.padding(end = 6.dp)
.clickable { onRemove() }
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() },
onClick = onRemove
)
)

}
Spacer(modifier = Modifier.height(4.dp))
Box(
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,51 +1,26 @@
package com.sopt.now.compose.presentation.ui.auth.navigation

import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavType
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import com.sopt.now.compose.presentation.ui.auth.screen.AuthViewModel
import com.sopt.now.compose.presentation.ui.auth.screen.SignInRoute
import com.sopt.now.compose.presentation.ui.auth.screen.SignUpRoute
import com.sopt.now.compose.presentation.ui.home.navigation.HomeNavigator
import com.sopt.now.compose.presentation.ui.home.screen.HomeRoute

fun NavGraphBuilder.authNavGraph(
authNavigator: AuthNavigator,
homeNavigator: HomeNavigator
authViewModel: AuthViewModel
) {
composable(
route = "signIn/{id}/{password}/{nickname}/{phoneNumber}",
arguments = listOf(
navArgument("id") { type = NavType.StringType },
navArgument("password") { type = NavType.StringType },
navArgument("nickname") { type = NavType.StringType },
navArgument("phoneNumber") { type = NavType.StringType }
composable(route = "signIn") {
SignInRoute(
authNavigator = authNavigator,
authViewModel = authViewModel
)
) { backStackEntry ->
val id = backStackEntry.arguments?.getString("id") ?: ""
val password = backStackEntry.arguments?.getString("password") ?: ""
val nickname = backStackEntry.arguments?.getString("nickname") ?: ""
val phoneNumber = backStackEntry.arguments?.getString("phoneNumber") ?: ""
SignInRoute(authNavigator, id, password, nickname, phoneNumber)
}

composable(route = "signUp") {
SignUpRoute(authNavigator)
}

composable(
route = "home/{id}/{password}/{nickname}/{phoneNumber}",
arguments = listOf(
navArgument("id") { type = NavType.StringType },
navArgument("password") { type = NavType.StringType },
navArgument("nickname") { type = NavType.StringType },
navArgument("phoneNumber") { type = NavType.StringType }
SignUpRoute(
authNavigator = authNavigator,
authViewModel = authViewModel
)
) { backStackEntry ->
val id = backStackEntry.arguments?.getString("id") ?: ""
val password = backStackEntry.arguments?.getString("password") ?: ""
val nickname = backStackEntry.arguments?.getString("nickname") ?: ""
val phoneNumber = backStackEntry.arguments?.getString("phoneNumber") ?: ""
HomeRoute(homeNavigator, id, password, nickname, phoneNumber)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import androidx.navigation.NavController
class AuthNavigator(
private val navController: NavController
) {
fun navigateToSignIn(id: String, password: String, nickname: String, phoneNumber: String) {
navController.navigate("signIn/$id/$password/$nickname/$phoneNumber")
fun navigateToSignIn() {
navController.navigate("signIn")
}

fun navigateToSignUp() {
navController.navigate("signUp")
}

fun navigateToHome(id: String, password: String, nickname: String, phoneNumber: String) {
fun navigateToHome(id: String?, password: String?, nickname: String?, phoneNumber: String?) {
navController.navigate("home/$id/$password/$nickname/$phoneNumber")
}
Comment on lines +16 to 18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c: data class를 활용한 네비게이션의 활용도 배워보시면 좋을듯!


Expand Down
Loading