Skip to content

Commit

Permalink
[Feat/#109] 답변 저장 버튼 UT 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
ss99x2002 committed Aug 30, 2023
1 parent af76b1c commit 8c2c693
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@ class AnswerActivity : BindingActivity<ActivityAnswerBinding>(R.layout.activity_
binding.clickListener = this
binding.vm = viewModel
setIntentResponse()
setClickBtnSave()
}

override fun onClick(view: View?) {
when (view?.id) {
R.id.iv_qna_back -> showBackDialog()
R.id.iv_check -> {
setCheckStatus()
}
}
}

private fun setCheckStatus() {
if (!viewModel.answer.value.isNullOrBlank()) {
showConfirmDialog()
private fun setClickBtnSave() {
with(binding) {
viewModel.answer.observe(this@AnswerActivity) {
btnSave.isEnabled = !it.isNullOrBlank()
}
btnSave.setOnClickListener {
showConfirmDialog()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class AnswerViewModel : ViewModel() {
section.value = intent.getStringExtra("section")
}

fun setBundleArgument(bundle:Bundle) : Bundle{
fun setBundleArgument(bundle: Bundle): Bundle {
bundle.apply {
putString("question",question.value)
putString("question", question.value)
putString("topic", topic.value)
putString("section", section.value)
putString("answer", answer.value)
Expand Down
22 changes: 18 additions & 4 deletions app/src/main/res/layout/activity_answer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:titleText ="@{vm.section}"
app:visibleCheck="@{true}" />
app:titleText="@{vm.section}"
app:visibleCheck="@{false}" />

<TextView
android:id="@+id/tv_topic"
Expand All @@ -55,8 +55,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="19dp"
android:text="@{vm.question}"
android:gravity="center"
android:text="@{vm.question}"
android:textColor="@color/umbba_black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down Expand Up @@ -92,8 +92,8 @@
android:layout_height="wrap_content"
android:gravity="left"
android:hint="@string/answer_edittext_hint"
android:minHeight="172dp"
android:maxLength="100"
android:minHeight="172dp"
android:text="@={vm.answer}"
android:textAppearance="@style/AndroidBody1_2Regular16"
android:textColorHint="@color/grey_800"
Expand All @@ -104,5 +104,19 @@

</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_save"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginHorizontal="24dp"
android:layout_marginBottom="24dp"
android:background="@drawable/sel_btn_next"
android:enabled="false"
android:stateListAnimator="@null"
android:text="저장하기"
android:textAppearance="@style/AndroidBody1_1SemiBold16"
android:textColor="@color/umbba_white"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

0 comments on commit 8c2c693

Please sign in to comment.