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

비밀번호 초기화 로직 변경 #375

Merged
merged 28 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
91826cb
refactor: 비번 찾기 화면들 별도 디렉토리로 분리
JuTaK97 Oct 25, 2024
70515b3
feat: 비번 재설정 메인 화면 얼개 잡기
JuTaK97 Oct 25, 2024
f875bb9
feat: Step 1 - 아이디 입력 화면
JuTaK97 Oct 25, 2024
fc0f385
feat: Step 2 - 전체 이메일 입력 화면
JuTaK97 Oct 25, 2024
bd97c07
feat: AnimatedContent 사용하도록 변경
JuTaK97 Oct 25, 2024
0eb4bca
fix: Step 2 - 스텝 3에서 이전으로 돌아왔을 때 입력값 유지되게 하기
JuTaK97 Oct 25, 2024
9079d58
fix: Dialog 에서 확인만 보일 수 있게 하기
JuTaK97 Oct 25, 2024
b653b8e
feat: Step 3 - 코드 인증 화면
JuTaK97 Oct 26, 2024
2a5633f
feat: Step 4 - 새 비밀번호 입력 화면
JuTaK97 Oct 26, 2024
e000eb6
chore: 필요 없는 코드 제거
JuTaK97 Oct 26, 2024
6bcfd73
fix: EditText 에서 입력값 없는데 포커스 되면 힌트 사라지는 것 수정
JuTaK97 Oct 26, 2024
cd0378f
feat: 기존 EditText 에서 String 대신 TextFieldValue 사용도록만 바뀐 컴포넌트 추가
JuTaK97 Oct 26, 2024
ae33c2d
feat: Step 1 - 아이디 입력 화면 개선
JuTaK97 Oct 26, 2024
db75146
feat: Step 2 - 전체 이메일 입력 화면 개선
JuTaK97 Oct 26, 2024
9f229d1
feat: Step 3 - 코드 인증 화면 개선
JuTaK97 Oct 26, 2024
9344573
feat: Step 4 - 새 비밀번호 입력 화면 개선
JuTaK97 Oct 26, 2024
ffa3f52
feat: 비번 리셋 API 변경
JuTaK97 Oct 26, 2024
d709082
feat: 기타 사용성 추가 개선
JuTaK97 Oct 26, 2024
2a4dab0
feat: 페이지 변경
JuTaK97 Oct 26, 2024
bae4b71
feat: 디자인 세부사항 반영 (안 읽어도 됨)
JuTaK97 Oct 26, 2024
f84ea20
feat: 탑바 디자인대로 변경
JuTaK97 Oct 26, 2024
b36691d
feat: imePadding 을 AnimatedContent 밖으로 이동
JuTaK97 Oct 26, 2024
664c385
chore: lint
JuTaK97 Oct 26, 2024
30466c8
feat: 디자인 스펙 반영
JuTaK97 Oct 26, 2024
58e632d
chore: 로딩 인디케이터 제거
JuTaK97 Oct 26, 2024
b26a307
chore: 불필요한 LocalSoftwareKeyboardController 제거
JuTaK97 Oct 26, 2024
889b285
refactor: 하위 페이지에 uiState 만 넘기기
JuTaK97 Oct 26, 2024
6e09073
Merge branch 'develop' into jutak/password-reset-refactor
JuTaK97 Oct 30, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.wafflestudio.snutt2.ui.SNUTTColors
import com.wafflestudio.snutt2.ui.SNUTTTypography

Expand All @@ -46,6 +47,8 @@ fun EditText(
value: String,
onValueChange: (String) -> Unit,
hint: String? = null,
hintTextColor: Color = SNUTTColors.EditTextHint,
hintTextStyle: TextStyle = SNUTTTypography.body1.copy(fontSize = 15.sp),
underlineEnabled: Boolean = true,
underlineColor: Color = SNUTTColors.Gray200,
underlineColorFocused: Color = SNUTTColors.Black900,
Expand Down Expand Up @@ -86,11 +89,11 @@ fun EditText(
modifier = Modifier.weight(1f),
) {
it()
if (value.isEmpty() && isFocused.not()) { // FIXME: lectureDetail 에서는 focus 되어 있어도 empty이면 hint 가 나와야 한다.
if (value.isEmpty()) {
hint?.let {
Text(
text = it,
style = textStyle.copy(color = SNUTTColors.Gray200),
style = hintTextStyle.copy(color = hintTextColor),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package com.wafflestudio.snutt2.components.compose

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
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.foundation.text.selection.LocalTextSelectionColors
import androidx.compose.foundation.text.selection.TextSelectionColors
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.wafflestudio.snutt2.ui.SNUTTColors
import com.wafflestudio.snutt2.ui.SNUTTTypography

@Composable
fun EditTextFieldValue(
modifier: Modifier = Modifier,
leadingIcon: @Composable (() -> Unit) = {},
trailingIcon: @Composable (() -> Unit) = {},
keyboardOptions: KeyboardOptions = KeyboardOptions(),
keyboardActions: KeyboardActions = KeyboardActions(),
singleLine: Boolean = false,
enabled: Boolean = true,
visualTransformation: VisualTransformation = VisualTransformation.None,
value: TextFieldValue,
onValueChange: (TextFieldValue) -> Unit,
hint: String? = null,
hintTextColor: Color = SNUTTColors.EditTextHint,
hintTextStyle: TextStyle = SNUTTTypography.body1.copy(fontSize = 15.sp),
underlineEnabled: Boolean = true,
underlineColor: Color = SNUTTColors.Gray200,
underlineColorFocused: Color = SNUTTColors.Black900,
underlineWidth: Dp = 1.dp,
clearFocusFlag: Boolean = false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

혹시 얘는 무슨 용도로 있는거야?
clearFocusFlag 값이 바뀌는 부분을 못찾았어...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

그거 EditText 에는 있을걸? 그 SearchPage 상단 EditText에서 x표시 누를때 포커스 해제 용도

textStyle: TextStyle = SNUTTTypography.subtitle1.copy(color = SNUTTColors.Black900),
) {
val focusManager = LocalFocusManager.current
LaunchedEffect(clearFocusFlag) {
if (clearFocusFlag) focusManager.clearFocus()
}

var isFocused by remember { mutableStateOf(false) }
val customTextSelectionColors = TextSelectionColors(
handleColor = SNUTTColors.Black900,
backgroundColor = SNUTTColors.Black300,
)
CompositionLocalProvider(
LocalTextSelectionColors provides customTextSelectionColors,
) {
BasicTextField(
modifier = modifier
.onFocusChanged { isFocused = it.isFocused },
keyboardOptions = keyboardOptions,
keyboardActions = keyboardActions,
value = value,
textStyle = textStyle,
enabled = enabled,
onValueChange = onValueChange,
singleLine = singleLine,
visualTransformation = visualTransformation,
cursorBrush = SolidColor(SNUTTColors.Black900),
decorationBox = {
Column {
Row(modifier = Modifier.fillMaxWidth()) {
leadingIcon()
Box(
modifier = Modifier.weight(1f),
) {
it()
if (value.text.isEmpty()) {
hint?.let {
Text(
text = it,
style = hintTextStyle.copy(color = hintTextColor),
)
}
}
}
trailingIcon()
}

if (underlineEnabled) {
Box(
modifier = Modifier
.padding(top = 8.dp)
.background(if (isFocused) underlineColorFocused else underlineColor)
.fillMaxWidth()
.height(underlineWidth),
)
}
}
},
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.wafflestudio.snutt2.components.compose

import androidx.compose.animation.AnimatedContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.wafflestudio.snutt2.ui.SNUTTColors
import com.wafflestudio.snutt2.ui.SNUTTTypography

@Composable
fun IOSStyleTopBar(
modifier: Modifier = Modifier,
Comment on lines +23 to +25
Copy link
Collaborator

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋㅋ 이름도 이렇게 지은 김에
ios 화면 보니까 topbar 싹 가운데 정렬이던데
CenterAlignedTopAppBar 써보는거 어때?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

머터리얼 쓰기 싫어

Copy link
Collaborator

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋㅋㅋ

title: String,
backButtonText: String,
onBack: () -> Unit,
) {
Box(
modifier = modifier
.fillMaxWidth()
.background(color = SNUTTColors.White900)
.height(40.dp)
.drawWithCache {
onDrawWithContent {
drawLine(
color = SNUTTColors.EditTextHint,
start = Offset(0f, this.size.height), end = Offset(this.size.width, this.size.height),
strokeWidth = 0.5.dp.toPx(),
)
drawContent()
}
}
.padding(horizontal = 5.dp),
contentAlignment = Alignment.CenterStart,
) {
Row(
modifier = Modifier.clicks(1000L) { onBack() },
verticalAlignment = Alignment.CenterVertically,
) {
ArrowBackIcon(
colorFilter = ColorFilter.tint(SNUTTColors.Black900),
)
AnimatedContent(backButtonText, label = "") {
Text(
text = it,
style = SNUTTTypography.button,
)
}
}
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Text(
text = title,
style = SNUTTTypography.h3,
)
}
}
}

@Preview
@Composable
fun IOSStyleTopBarPreview() {
IOSStyleTopBar(
title = "비밀번호 재설정",
backButtonText = "로그인",
) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ fun CustomDialog(
}
}
}
} ?: positiveButtonText?.let {
Row(modifier = Modifier.padding(vertical = 20.dp, horizontal = 30.dp)) {
Box(modifier = Modifier.weight(1f))
Box(modifier = Modifier.clicks { onConfirm() }) {
Text(text = positiveButtonText, style = SNUTTTypography.body1)
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.wafflestudio.snutt2.components.compose
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -22,8 +23,8 @@ fun WebViewStyleButton(
Box(
modifier = modifier
.clicks { if (enabled) onClick() }
.background(if (enabled) enabledColor else disabledColor)
.height(60.dp),
.background(shape = RoundedCornerShape(6.dp), color = if (enabled) enabledColor else disabledColor)
.height(47.dp),
contentAlignment = Alignment.Center,
) {
content()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ interface UserRepository {

suspend fun verifyPwResetCode(id: String, code: String)

suspend fun resetPassword(id: String, password: String)
suspend fun resetPassword(id: String, password: String, code: String)

suspend fun sendCodeToEmail(email: String)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ class UserRepositoryImpl @Inject constructor(
)
}

override suspend fun resetPassword(id: String, password: String) {
override suspend fun resetPassword(id: String, password: String, code: String) {
api._postResetPassword(
PostResetPasswordParams(id, password),
PostResetPasswordParams(id, password, code),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,6 @@ object SNUTTStringUtils {
append("(${quota - freshmanQuota})")
}
}.toString()

fun String.isValidPassword(): Boolean = Regex("^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{6,20}$").matches(this)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ import com.squareup.moshi.JsonClass
data class PostResetPasswordParams(
@Json(name = "user_id") val id: String,
@Json(name = "password") val password: String,
@Json(name = "code") val code: String,
)
4 changes: 4 additions & 0 deletions app/src/main/java/com/wafflestudio/snutt2/ui/Colors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ object SNUTTColors {

val VacancyRed = Color(0xffed6c58)

val EditTextLabel = Color(0xff8a898e)
val EditTextHint = Color(0xffc4c4c4)
val EditTextUnderline = Color(0xffdcdcde)

val Colors.VacancyBlue @Composable get() = if (isLight) Color(0xff446cc2) else Color(0xff7aaaf3)
val VacancyBlue @Composable get() = MaterialTheme.colors.VacancyBlue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import com.wafflestudio.snutt2.views.logged_in.table_lectures.LecturesOfTablePag
import com.wafflestudio.snutt2.views.logged_in.vacancy_noti.VacancyPage
import com.wafflestudio.snutt2.views.logged_in.vacancy_noti.VacancyViewModel
import com.wafflestudio.snutt2.views.logged_out.*
import com.wafflestudio.snutt2.views.logged_out.reset_password.ResetPasswordPage
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import javax.inject.Inject
Expand Down Expand Up @@ -348,7 +349,7 @@ class RootActivity : AppCompatActivity() {
}

composable2(NavigationDestination.FindPassword) {
FindPasswordPage()
ResetPasswordPage()
}

composable2(NavigationDestination.EmailVerification) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ class UserViewModel @Inject constructor(
userRepository.verifyPwResetCode(id, code)
}

suspend fun resetPassword(id: String, password: String) {
userRepository.resetPassword(id, password)
suspend fun resetPassword(id: String, password: String, code: String) {
userRepository.resetPassword(id, password, code)
}

suspend fun sendCodeToEmail(email: String) {
Expand Down
Loading
Loading