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

week6: 6차 필수과제 진행 (compose) #16

Open
wants to merge 1 commit into
base: develop-compose
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -72,6 +72,17 @@ fun SignInScreen(navController: NavController) {
}
}

val isWeekSixthHomeworkFinished = signInViewModel.isWeekSixthHomeworkFinished.observeAsState()
isWeekSixthHomeworkFinished.value?.let {
if (it) {
Toast.makeText(
context,
context.getString(R.string.finish_week_sixth_homework),
Toast.LENGTH_SHORT,
).show()
}
}

Column(modifier = Modifier.padding(24.dp)) {
Text(text = stringResource(id = R.string.sign_in_title))
OutlinedTextField(
Expand All @@ -98,6 +109,7 @@ fun SignInScreen(navController: NavController) {
Button(
onClick = {
signInViewModel.performSignIn(SignInRequest(username, password))
signInViewModel.finishWeekSixthHomework()
},
modifier =
Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class SignInViewModel : ViewModel() {
private val _signInMessage = MutableLiveData<String>()
val signInMessage: LiveData<String> = _signInMessage

private val _isWeekSixthHomeworkFinished = MutableLiveData<Boolean>(false)
val isWeekSixthHomeworkFinished: LiveData<Boolean> = _isWeekSixthHomeworkFinished

fun performSignIn(request: SignInRequest) {
viewModelScope.launch {
runCatching {
Expand All @@ -32,6 +35,10 @@ class SignInViewModel : ViewModel() {
}
}

fun finishWeekSixthHomework() {
_isWeekSixthHomeworkFinished.value = true
}

companion object {
const val SUCCESS_SIGN_IN = "SUCCESS"
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<string name="sign_in_title">로그인</string>
<string name="sign_in_button">로그인</string>
<string name="sign_in_success">로그인에 성공하셨습니다!</string>
<string name="finish_week_sixth_homework">6주차 과제 완료!</string>

<!-- BottomNav -->
<string name="main_home">홈</string>
Expand Down