-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2deb84
commit aba0e0c
Showing
9 changed files
with
259 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:pathData="M12,12m-12,0a12,12 0,1 1,24 0a12,12 0,1 1,-24 0" | ||
android:fillColor="#2C2F33"/> | ||
<path | ||
android:pathData="M8,16L16,8" | ||
android:strokeWidth="2.3" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#63666A" | ||
android:strokeLineCap="round"/> | ||
<path | ||
android:pathData="M8,8L16,16" | ||
android:strokeWidth="2.3" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#63666A" | ||
android:strokeLineCap="round"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
feature/mypage/src/main/java/com/teamwiney/mypage/account/MyPageModifyNicknameScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
package com.teamwiney.mypage.account | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.layout.statusBarsPadding | ||
import androidx.compose.foundation.text.KeyboardActions | ||
import androidx.compose.foundation.text.KeyboardOptions | ||
import androidx.compose.material.Text | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.text.input.KeyboardType | ||
import androidx.compose.ui.unit.dp | ||
import androidx.lifecycle.compose.collectAsStateWithLifecycle | ||
import com.teamwiney.core.common.WineyAppState | ||
import com.teamwiney.core.design.R | ||
import com.teamwiney.mypage.MyPageContract | ||
import com.teamwiney.mypage.MyPageContract.Companion.NEW_NICKNAME_MAX_LENGTH | ||
import com.teamwiney.mypage.MyPageViewModel | ||
import com.teamwiney.ui.components.HeightSpacer | ||
import com.teamwiney.ui.components.TopBar | ||
import com.teamwiney.ui.components.WButton | ||
import com.teamwiney.ui.components.WTextField | ||
import com.teamwiney.ui.theme.WineyTheme | ||
import kotlinx.coroutines.flow.collectLatest | ||
|
||
@Composable | ||
fun MyPageModifyNicknameScreen( | ||
appState: WineyAppState, | ||
viewModel: MyPageViewModel | ||
) { | ||
val uiState by viewModel.uiState.collectAsStateWithLifecycle() | ||
val effectFlow = viewModel.effect | ||
val keyboardController = LocalSoftwareKeyboardController.current | ||
|
||
LaunchedEffect(true) { | ||
effectFlow.collectLatest { effect -> | ||
when (effect) { | ||
is MyPageContract.Effect.NavigateTo -> { | ||
appState.navigate(effect.destination, effect.navOptions) | ||
} | ||
|
||
is MyPageContract.Effect.ShowSnackBar -> { | ||
appState.showSnackbar(effect.message) | ||
} | ||
|
||
else -> { } | ||
} | ||
} | ||
} | ||
|
||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.statusBarsPadding() | ||
.background(WineyTheme.colors.background_1) | ||
) { | ||
TopBar { | ||
appState.navController.navigateUp() | ||
} | ||
Column( | ||
modifier = Modifier.padding(horizontal = 24.dp) | ||
) { | ||
Text( | ||
text = "닉네임을 변경해주세요", | ||
style = WineyTheme.typography.title1.copy( | ||
color = WineyTheme.colors.gray_50 | ||
) | ||
) | ||
HeightSpacer(height = 14.dp) | ||
Text( | ||
text = "언제든지 다시 바꿀 수 있어요!", | ||
style = WineyTheme.typography.bodyM2.copy( | ||
color = WineyTheme.colors.gray_700 | ||
) | ||
) | ||
HeightSpacer(height = 30.dp) | ||
Text( | ||
text = if (uiState.newNicknameErrorState) "최대 9자로 입력해주세요." else "닉네임", | ||
color = if (uiState.newNicknameErrorState) WineyTheme.colors.error else WineyTheme.colors.gray_600, | ||
style = if (uiState.newNicknameErrorState) WineyTheme.typography.bodyM2 else WineyTheme.typography.bodyB2 | ||
) | ||
HeightSpacer(10.dp) | ||
WTextField( | ||
value = uiState.newNickname, | ||
onValueChanged = { | ||
viewModel.updateNewNickname(it) | ||
}, | ||
trailingIcon = { | ||
Icon( | ||
modifier = Modifier.size(24.dp).clickable { | ||
viewModel.updateNewNickname("") | ||
}, | ||
painter = painterResource(id = R.drawable.ic_textfield_delete), | ||
contentDescription = "IC_TEXT_DELETE", | ||
tint = Color.Unspecified | ||
) | ||
}, | ||
placeholderText = "${NEW_NICKNAME_MAX_LENGTH}자리 입력", | ||
maxLength = NEW_NICKNAME_MAX_LENGTH, | ||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text), | ||
keyboardActions = KeyboardActions( | ||
onDone = { | ||
keyboardController?.hide() | ||
viewModel.modifyNickname() | ||
} | ||
), | ||
onErrorState = uiState.newNicknameErrorState | ||
) | ||
Spacer(modifier = Modifier.weight(1f)) | ||
WButton( | ||
text = "변경", | ||
onClick = { | ||
keyboardController?.hide() | ||
viewModel.modifyNickname() | ||
}, | ||
enabled = uiState.newNickname.isNotEmpty(), | ||
modifier = Modifier.padding(bottom = 30.dp) | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters