-
Notifications
You must be signed in to change notification settings - Fork 2
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
[FIX/#208] 투두 생성, 조회 뷰 / 메모 빈칸 대응 수정 #210
Changes from all commits
e195e5d
5050859
09c4a39
c41974d
cc0f3bc
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 |
---|---|---|
|
@@ -19,12 +19,13 @@ class TodoCreateViewModel @Inject constructor( | |
private val todoRepository: TodoRepository, | ||
) : ViewModel() { | ||
|
||
val todo = MutableLiveData("") | ||
private val todo = MutableLiveData("") | ||
private val memo = MutableLiveData("") | ||
Comment on lines
+22
to
+23
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. 어떤경우에 LiveData를 사용하고, 어떤 경우에 StateFlow를 사용하는지 선택 기준이 궁금합니다! 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. 저도 궁금합니다..!! 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. 오 저도 최근에 같은 고민했었습니다😅 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. StateFlow를 사용하는 것을 권장드리긴 합니다만, StateFlow와 같은 경우는 계속해서 상태값을 지니고 있기에 백패킹(_달아주는거)으로 안정성을 보장해주는 것이 꼭 권장되는데, LiveData가 이후에 deprecated된다면 데이터바인딩도 함께 사라질테니, |
||
|
||
val endDate = MutableLiveData("") | ||
val memo = MutableLiveData("") | ||
|
||
private val isTodoAvailable = MutableLiveData(false) | ||
private val isMemoAvailable = MutableLiveData(false) | ||
private val isMemoAvailable = MutableLiveData(true) | ||
val isFinishAvailable = MutableLiveData(false) | ||
|
||
private val _todoCreateState = MutableStateFlow<UiState<Unit>>(UiState.Empty) | ||
|
@@ -43,13 +44,13 @@ class TodoCreateViewModel @Inject constructor( | |
|
||
fun setMemoState(memoText: String, state: EditTextState) { | ||
memo.value = memoText | ||
isMemoAvailable.value = state == EditTextState.SUCCESS | ||
isMemoAvailable.value = state != EditTextState.OVER | ||
checkIsFinishAvailable() | ||
} | ||
|
||
fun checkIsFinishAvailable() { | ||
isFinishAvailable.value = | ||
isTodoAvailable.value == true && isMemoAvailable.value == true && participantModelList.any { it.isSelected } | ||
isTodoAvailable.value == true && isMemoAvailable.value == true && !endDate.value.isNullOrEmpty() && participantModelList.any { it.isSelected } | ||
} | ||
|
||
fun postToCreateTodoFromServer() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,17 @@ import android.content.Intent | |
import android.os.Bundle | ||
import android.view.View | ||
import androidx.activity.viewModels | ||
import androidx.core.view.isVisible | ||
import androidx.lifecycle.flowWithLifecycle | ||
import androidx.lifecycle.lifecycleScope | ||
import com.going.presentation.R | ||
import com.going.presentation.databinding.ActivityTodoDetailBinding | ||
import com.going.presentation.todo.create.TodoCreateActivity | ||
import com.going.ui.base.BaseActivity | ||
import com.going.ui.extension.colorOf | ||
import com.going.ui.extension.drawableOf | ||
import com.going.ui.extension.setOnSingleClickListener | ||
import com.going.ui.extension.stringOf | ||
import com.going.ui.extension.toast | ||
import com.going.ui.state.EnumUiState | ||
import com.going.ui.state.UiState | ||
|
@@ -94,13 +98,21 @@ class TodoDetailActivity : | |
|
||
is UiState.Success -> { | ||
if (isPublic) { | ||
adapter.submitList(state.data) | ||
adapter.submitList(state.data.allocators) | ||
} else { | ||
with(binding) { | ||
rvOurTodoDetailPerson.visibility = View.INVISIBLE | ||
layoutMyTodoCreatePerson.visibility = View.VISIBLE | ||
} | ||
} | ||
if (state.data.memo.isBlank()) { | ||
with(binding) { | ||
etTodoCreateMemo.background = drawableOf(R.drawable.shape_rect_4_gray200_line) | ||
etTodoCreateMemo.text = stringOf(R.string.my_todo_create_tv_memo_hint) | ||
Comment on lines
+108
to
+111
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.
|
||
etTodoCreateMemo.setTextColor(colorOf(R.color.gray_200)) | ||
tvTodoMemoCounter.isVisible = false | ||
} | ||
} | ||
} | ||
|
||
is UiState.Failure -> toast(getString(R.string.server_error)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="25dp" | ||
android:height="24dp" | ||
android:viewportWidth="25" | ||
android:viewportHeight="24"> | ||
<path | ||
android:pathData="M11.765,16.205C12.161,16.633 12.839,16.633 13.235,16.205L17.878,11.179C18.469,10.538 18.015,9.5 17.143,9.5H7.857C6.985,9.5 6.531,10.538 7.122,11.179L11.765,16.205Z" | ||
android:fillColor="#1D1F29"/> | ||
</vector> |
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.
오오 굿굿 깔끔하네욥