-
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
[refactor] AddSubjectScreen 코드정리 #83
base: develop
Are you sure you want to change the base?
Changes from all commits
48aa341
9b04063
5ff4294
5bfe051
363f9fd
52bde75
83cdc9b
aec7848
8498f5b
6e8195f
d74ba24
2e8922c
0899663
1768cdf
57147aa
a9ffe76
a106e16
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 |
---|---|---|
|
@@ -111,7 +111,7 @@ class MainNavigator( | |
inclusive = true | ||
} | ||
launchSingleTop = true | ||
} | ||
}, | ||
) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,42 +10,41 @@ class AddSubjectContract { | |
data class AddSubjectState( | ||
val subjectName: String = "", | ||
val isTextFieldFocused: Boolean = false, | ||
val isButtonEnable: Boolean = false, | ||
val subjectTextFieldState: BbangZipTextFieldInputState = BbangZipTextFieldInputState.Default, | ||
val isButtonEnabled: Boolean = false, | ||
val subjectTextFieldInputState: BbangZipTextFieldInputState = BbangZipTextFieldInputState.Default, | ||
) : BaseContract.State, Parcelable { | ||
override fun toParcelable(): Parcelable = this | ||
} | ||
|
||
sealed interface AddSubjectEvent : BaseContract.Event { | ||
data class OnFocusTextField(val isTextFieldFocused: Boolean) : AddSubjectEvent | ||
data class OnTextFieldFocus(val isTextFieldFocused: Boolean) : AddSubjectEvent | ||
|
||
data class OnChangeSubjectName(val subjectName: String) : AddSubjectEvent | ||
data class OnSubjectNameChange(val subjectName: String) : AddSubjectEvent | ||
|
||
data object OnClickBackBtn : AddSubjectEvent | ||
data object OnAddBtnClick : AddSubjectEvent | ||
|
||
data object OnClickAddBtn : AddSubjectEvent | ||
data object OnBackIconClick : AddSubjectEvent | ||
|
||
data object OnClickDeleteBtn : AddSubjectEvent | ||
data object OnTextFieldDeleteIconClick : AddSubjectEvent | ||
} | ||
|
||
sealed interface AddSubjectReduce : BaseContract.Reduce { | ||
data class UpdateSubjectName(val subjectName: String) : AddSubjectReduce | ||
|
||
data object UpdateIsButtonEnabled : AddSubjectReduce | ||
|
||
data object UpdateSubjectInputState : AddSubjectReduce | ||
|
||
data class UpdateSubjectName(val subjectName: String) : AddSubjectReduce | ||
|
||
data class UpdateIsTextFieldFocused(val isTextFieldFocused: Boolean) : AddSubjectReduce | ||
|
||
data object ResetSubjectName : AddSubjectReduce | ||
} | ||
|
||
sealed interface AddSubjectSideEffect : BaseContract.SideEffect { | ||
data object NavigateSubjectDetail : AddSubjectSideEffect | ||
|
||
// 공부 추가 완료! 미룬이 탈출이 코앞이에요 | ||
data class ShowSnackBar(val message: String) : AddSubjectSideEffect | ||
data object NavigateToSubject : AddSubjectSideEffect | ||
|
||
data object NavigateToBack : AddSubjectSideEffect | ||
|
||
data class ShowSuccessAddSubjectSnackBar(val message: String) : AddSubjectSideEffect | ||
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. p5 : 저희가 snackBar 함수를 사용할때 동일한 snackBar함수를 사용합니다. 특정 이유가 아니라면 ShowSnackBar함수 네이밍을 바꿀 필요가 없지않을까요? 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. p5 |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package org.android.bbangzip.presentation.ui.subject.addsubject | ||
|
||
import android.app.Activity | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
|
@@ -9,55 +10,57 @@ import androidx.compose.foundation.layout.padding | |
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.toArgb | ||
import androidx.compose.ui.platform.LocalFocusManager | ||
import androidx.compose.ui.platform.LocalView | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import org.android.bbangzip.R | ||
import org.android.bbangzip.presentation.component.button.BbangZipButton | ||
import org.android.bbangzip.presentation.component.textfield.BbangZipBasicTextField | ||
import org.android.bbangzip.presentation.component.topbar.BbangZipBaseTopBar | ||
import org.android.bbangzip.presentation.model.BbangZipTextFieldInputState | ||
import org.android.bbangzip.presentation.type.BbangZipButtonSize | ||
import org.android.bbangzip.presentation.type.BbangZipButtonType | ||
import org.android.bbangzip.presentation.util.modifier.addFocusCleaner | ||
import org.android.bbangzip.ui.theme.BbangZipTheme | ||
|
||
private const val TEXT_FIELD_MAX_CHARACTER = 10 | ||
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. p3 : 이 상수를 screen이 아닌 어디에 적을지 고민해보면 좋을 것 같습니다 |
||
|
||
@Composable | ||
fun AddSubjectScreen( | ||
subjectName: String = "", | ||
isButtonEnable: Boolean = false, | ||
isTextFieldFocused: Boolean = false, | ||
textFieldInputState: BbangZipTextFieldInputState = BbangZipTextFieldInputState.Default, | ||
onSubjectNameChanged: (String) -> Unit = {}, | ||
onTextFieldFocusChanged: (Boolean) -> Unit = {}, | ||
onAddBtnClicked: () -> Unit = {}, | ||
onDeleteBtnClicked: () -> Unit = {}, | ||
onBackButtonClicked: () -> Unit = {} | ||
state: AddSubjectContract.AddSubjectState, | ||
onSubjectNameChange: (String) -> Unit = {}, | ||
onTextFieldFocusChange: (Boolean) -> Unit = {}, | ||
onAddBtnClick: () -> Unit = {}, | ||
onTextFieldDeleteIconClick: () -> Unit = {}, | ||
onBackIconClick: () -> Unit = {}, | ||
) { | ||
(LocalView.current.context as Activity).window.statusBarColor = BbangZipTheme.colors.backgroundNormal_FFFFFF.toArgb() | ||
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. p5 : route가 아닌 screen에 선언하는 이유는 무엇인가요? |
||
|
||
val focusManager = LocalFocusManager.current | ||
|
||
Column( | ||
modifier = | ||
Modifier | ||
.fillMaxSize() | ||
.addFocusCleaner(focusManager = focusManager), | ||
Modifier | ||
.fillMaxSize() | ||
.addFocusCleaner(focusManager = focusManager), | ||
) { | ||
BbangZipBaseTopBar( | ||
title = "과목 추가하기", | ||
title = stringResource(R.string.add_subject_title), | ||
leadingIcon = R.drawable.ic_chevronleft_thick_small_24, | ||
onLeadingIconClick = onBackButtonClicked | ||
onLeadingIconClick = onBackIconClick, | ||
) | ||
|
||
Column( | ||
modifier = | ||
Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 20.dp) | ||
.padding(top = 48.dp, bottom = 20.dp), | ||
Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 20.dp) | ||
.padding(top = 48.dp, bottom = 20.dp), | ||
) { | ||
Text( | ||
text = "과목명", | ||
text = stringResource(R.string.add_subject_textfield_label), | ||
style = BbangZipTheme.typography.headline1Bold, | ||
color = BbangZipTheme.colors.labelNormal_282119, | ||
) | ||
|
@@ -68,13 +71,13 @@ fun AddSubjectScreen( | |
leadingIcon = R.drawable.ic_book_default_24, | ||
placeholder = R.string.modify_subject_name_placeholder, | ||
guideline = R.string.modify_subject_name_guideline, | ||
value = subjectName, | ||
value = state.subjectName, | ||
modifier = Modifier.fillMaxWidth(), | ||
bbangZipTextFieldInputState = textFieldInputState, | ||
onValueChange = onSubjectNameChanged, | ||
onFocusChange = onTextFieldFocusChanged, | ||
onDeleteButtonClick = onDeleteBtnClicked, | ||
maxCharacter = 10, | ||
bbangZipTextFieldInputState = state.subjectTextFieldInputState, | ||
onValueChange = onSubjectNameChange, | ||
onFocusChange = onTextFieldFocusChange, | ||
onDeleteButtonClick = onTextFieldDeleteIconClick, | ||
maxCharacter = TEXT_FIELD_MAX_CHARACTER, | ||
focusManager = focusManager, | ||
) | ||
|
||
|
@@ -84,11 +87,11 @@ fun AddSubjectScreen( | |
bbangZipButtonSize = BbangZipButtonSize.Large, | ||
bbangZipButtonType = BbangZipButtonType.Solid, | ||
onClick = { | ||
onAddBtnClicked() | ||
onAddBtnClick() | ||
}, | ||
modifier = Modifier.fillMaxWidth(), | ||
label = stringResource(R.string.btn_add_label), | ||
isEnable = isButtonEnable, | ||
isEnable = state.isButtonEnabled, | ||
) | ||
} | ||
} | ||
|
@@ -98,7 +101,6 @@ fun AddSubjectScreen( | |
@Composable | ||
private fun AddSubjectScreenPreview() { | ||
AddSubjectScreen( | ||
"Preview", | ||
false, | ||
state = AddSubjectContract.AddSubjectState(), | ||
) | ||
} |
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.
p5 : 디테일 와캬퍄