-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6 mypage_fragment/설정 화면 : 3 작성한 리뷰 화면
- 내가 작성한 리뷰가 없는 경우의 화면 구현
- Loading branch information
Showing
4 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
app/src/main/java/com/ftw/hometerview/ui/writtenreview/nonreview/NonReviewFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.ftw.hometerview.ui.writtenreview.nonreview | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.databinding.DataBindingUtil | ||
import androidx.lifecycle.Lifecycle | ||
import androidx.lifecycle.lifecycleScope | ||
import androidx.lifecycle.repeatOnLifecycle | ||
import com.ftw.hometerview.R | ||
import com.ftw.hometerview.databinding.FragmentNonReviewBinding | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
@AndroidEntryPoint | ||
class NonReviewFragment : Fragment() { | ||
|
||
companion object { | ||
fun newInstance(): NonReviewFragment { | ||
return NonReviewFragment() | ||
} | ||
} | ||
|
||
private var _binding: FragmentNonReviewBinding? = null | ||
private val binding get() = _binding!! | ||
|
||
@Inject | ||
lateinit var viewModel: NonReviewViewModel | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
_binding = DataBindingUtil.inflate<FragmentNonReviewBinding?>( | ||
inflater, | ||
R.layout.fragment_non_review, | ||
container, | ||
false | ||
).apply { | ||
viewModel = this@NonReviewFragment.viewModel | ||
} | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
observeEvent() | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
|
||
private fun observeEvent() { | ||
lifecycleScope.launch { | ||
repeatOnLifecycle(Lifecycle.State.STARTED) { | ||
viewModel.event.collect { event -> | ||
when (event) { | ||
NonReviewViewModel.Event.None -> {} | ||
NonReviewViewModel.Event.onClickWriteReview -> { | ||
// ㄹㅣ뷰 작성 화면으로 이동 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/ftw/hometerview/ui/writtenreview/nonreview/NonReviewViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.ftw.hometerview.ui.writtenreview.nonreview | ||
|
||
import kotlinx.coroutines.flow.* | ||
|
||
class NonReviewViewModel() { | ||
|
||
sealed class Event { | ||
object None : Event() | ||
object onClickWriteReview : Event() | ||
} | ||
|
||
private val _event: MutableStateFlow<Event> = MutableStateFlow(Event.None) | ||
val event: StateFlow<Event> = _event.asStateFlow() | ||
|
||
fun onClickWriteReview() { | ||
_event.value = Event.onClickWriteReview | ||
_event.value = Event.None | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
> | ||
|
||
<data> | ||
<variable | ||
name="viewModel" | ||
type="com.ftw.hometerview.ui.writtenreview.nonreview.NonReviewViewModel" | ||
/> | ||
</data> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
> | ||
|
||
<TextView | ||
android:id="@+id/non_review_text" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:fontFamily="@font/pretendard_regular" | ||
android:text="작성한 집터뷰가 없어요" | ||
android:textColor="@color/gray_600" | ||
android:layout_marginBottom="@dimen/dp_size_32" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="작성한 집터뷰가 없어요" | ||
/> | ||
|
||
<com.ftw.hometerview.design.MainButton | ||
android:id="@+id/write_review_button" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="집터뷰 작성하기" | ||
android:onClick="@{() -> viewModel.onClickWriteReview()}" | ||
android:layout_marginTop="@dimen/dp_size_16" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/non_review_text" | ||
/> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |