Skip to content

Commit

Permalink
[FEAT] 이전 진행한 회고 기반 화면 전환 기능 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
amourxyoung committed Jul 19, 2023
1 parent 4137d1e commit de6088b
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,18 @@ interface WriteReviewRepository {
memberId: Int,
projectId: Int,
requestReviewTIL: RequestReviewTILDto,
// requestReviewTIL: TIL,
): Result<ResponseSaveReviewDto>

suspend fun upload5F(
memberId: Int,
projectId: Int,
requestReview5F: RequestReview5FDto,
// reviewTemplateId: Int,
// fact: String,
// feeling: String,
// finding: String,
// feedback: String,
// actionPlan: String,
): Result<ResponseSaveReviewDto>

suspend fun uploadAAR(
memberId: Int,
projectId: Int,
requestReviewAAR: RequestReviewAARDto,

// reviewTemplateId: Int,
// initialGoal: String,
// result: String,
// difference: String,
// persistence: String,
// actionPlan: String,
): Result<ResponseSaveReviewDto>

suspend fun getPreviousTemplate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,20 @@ class PersonalDashboardFragment :

private fun clickBottomBtn() {
binding.clPersonalBottomBtn.setOnClickListener {
activity?.let {
val intent = Intent(context, WriteRetrospectiveActivity::class.java)
startActivity(intent)
when (viewModel.previousReviewType.value) {
1 -> activity?.let { // TIL
val intent = Intent(context, WriteRetrospectiveActivity::class.java)
startActivity(intent)
}
2 -> activity?.let { // 5F
val intent = Intent(context, WriteRetrospectiveActivity::class.java)
startActivity(intent)
}
3 -> activity?.let {
// AAR
val intent = Intent(context, WriteRetrospectiveActivity::class.java)
startActivity(intent)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.lifecycle.viewModelScope
import com.puzzling.puzzlingaos.domain.entity.ActionPlan
import com.puzzling.puzzlingaos.domain.entity.MyPuzzleBoard
import com.puzzling.puzzlingaos.domain.repository.MyBoardRepository
import com.puzzling.puzzlingaos.domain.repository.WriteReviewRepository
import com.puzzling.puzzlingaos.util.UserInfo
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
Expand All @@ -17,6 +18,7 @@ import javax.inject.Inject
@HiltViewModel
class PersonalDashboardViewModel @Inject constructor(
private val repository: MyBoardRepository,
private val writeReviewRepository: WriteReviewRepository,
) : ViewModel() {
private val _myNickname = MutableLiveData<String>()
val myNickname: LiveData<String> get() = _myNickname
Expand Down Expand Up @@ -44,6 +46,10 @@ class PersonalDashboardViewModel @Inject constructor(
val actionPlanList: LiveData<List<ActionPlan>>
get() = _actionPlanList

private val _previousReviewType = MutableLiveData<Int>()
val previousReviewType: LiveData<Int>
get() = _previousReviewType

private val _isSuccess = MutableLiveData(false)
val isSuccess: LiveData<Boolean> get() = _isSuccess

Expand All @@ -52,6 +58,7 @@ class PersonalDashboardViewModel @Inject constructor(
getMyPuzzleData()
getActionPlan()
getMyPuzzleBoard()
getPreviousTemplate()
}

private fun getMyPuzzleData() = viewModelScope.launch {
Expand Down Expand Up @@ -101,16 +108,15 @@ class PersonalDashboardViewModel @Inject constructor(
}
}

// val actionPlanList: List<ActionPlan> =
// listOf(
// ActionPlan("여기에는 글이 계속 작성되다가 작성되다가 작성되다가 작성되다가 이쯤 되면 끊기게 돼...", "7월 3일"),
// ActionPlan("여기에는 글이 계속 작성되다가 작성되다가 작성되다가 작성되다가 이쯤 되면 끊기게 돼...", "7월 4일"),
// ActionPlan("여기에는 글이 계속 작성되다가 작성되다가 작성되다가 작성되다가 이쯤 되면 끊기게 돼...", "7월 5일"),
// ActionPlan("여기에는 글이 계속 작성되다가 작성되다가 작성되다가 작성되다가 이쯤 되면 끊기게 돼...", "7월 6일"),
// ActionPlan("여기에는 글이 계속 작성되다가 작성되다가 작성되다가 작성되다가 이쯤 되면 끊기게 돼...", "7월 7일"),
// )

val _bottomButtonText = MutableLiveData<String>()
val bottomButtonText: String
get() = _bottomButtonText.value ?: "회고 작성일이 아니에요"
private fun getPreviousTemplate() {
viewModelScope.launch {
writeReviewRepository.getPreviousTemplate(UserInfo.MEMBER_ID, UserInfo.PROJECT_ID)
.onSuccess { response ->
_previousReviewType.value = response.data.previousTemplateId
Log.d("write", "getPreviousTemplate() success:: ${_previousReviewType.value}")
}.onFailure {
Log.d("write", "getPreviousTemplate() Fail:: $it")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class WriteReviewViewModel @Inject constructor(
val selectedReviewType: LiveData<String>
get() = _selectedReviewType

private val _reviewTypeText = MutableLiveData<String>()
val reviewTypeText: LiveData<String>
get() = _reviewTypeText

private val _selectedChipText = MutableLiveData<String>()
val selectedChipText: LiveData<String>
get() = _selectedChipText
Expand All @@ -85,6 +89,10 @@ class WriteReviewViewModel @Inject constructor(
val templateIdList: LiveData<List<Int>>
get() = _templateIdList

private val _previousReviewType = MutableLiveData<Int>()
val previousReviewType: LiveData<Int>
get() = _previousReviewType

fun setSelectedChipText(chipText: String) {
_selectedChipText.value = chipText
}
Expand Down Expand Up @@ -154,6 +162,7 @@ class WriteReviewViewModel @Inject constructor(

init {
getReviewType()
getPreviousTemplate()
}

fun setSelectedReviewTypeText(reviewType: String) {
Expand All @@ -163,30 +172,6 @@ class WriteReviewViewModel @Inject constructor(
_isReviewTypeSelected.value = true
}

private fun getReviewType() {
viewModelScope.launch {
repository.getReviewType().onSuccess { response ->
_reviewTypeList.value = response
val reviewTypes: List<ReviewType> =
_reviewTypeList.value!!
Log.d("write", "getReviewType() success:: $response")
_reviewNameList.value = reviewTypes.map {
it.reviewTemplateName
}
_reviewDescList.value = reviewTypes.map {
it.reviewTemplateMeaning
}
_templateIdList.value = reviewTypes.map {
it.reviewTemplateId
}
Log.d("write", "_reviewName success:: ${_reviewNameList.value}")
Log.d("write", "_reviewDesc success:: ${_reviewDescList.value}")
}.onFailure {
Log.d("write", "getReviewType() Fail:: $it")
}
}
}

fun getTIL(): TIL {
return TIL(
reviewTemplateId = 1,
Expand Down Expand Up @@ -288,6 +273,47 @@ class WriteReviewViewModel @Inject constructor(
}
}

private fun getReviewType() {
viewModelScope.launch {
repository.getReviewType().onSuccess { response ->
_reviewTypeList.value = response
val reviewTypes: List<ReviewType> =
_reviewTypeList.value!!
Log.d("write", "getReviewType() success:: $response")
_reviewNameList.value = reviewTypes.map {
it.reviewTemplateName
}
_reviewDescList.value = reviewTypes.map {
it.reviewTemplateMeaning
}
_templateIdList.value = reviewTypes.map {
it.reviewTemplateId
}
Log.d("write", "_reviewName success:: ${_reviewNameList.value}")
Log.d("write", "_reviewDesc success:: ${_reviewDescList.value}")
}.onFailure {
Log.d("write", "getReviewType() Fail:: $it")
}
}
}

private fun getPreviousTemplate() {
viewModelScope.launch {
repository.getPreviousTemplate(UserInfo.MEMBER_ID, UserInfo.PROJECT_ID)
.onSuccess { response ->
_previousReviewType.value = response.data.previousTemplateId
when (_previousReviewType.value) {
1 -> _reviewTypeText.value = "TIL"
2 -> _reviewTypeText.value = "5F"
3 -> _reviewTypeText.value = "AAR"
}
Log.d("write", "getPreviousTemplate() success:: ${_previousReviewType.value}")
}.onFailure {
Log.d("write", "getPreviousTemplate() Fail:: $it")
}
}
}

companion object {
const val WRITE_REGEX =
"^[ㄱ-ㅎㅏ-ㅣ가-힣a-zA-Z0-9 \\\\\\\\s!@#\$%^&*()-_=+\\\\[{\\\\]}\\\\|;:'\",.<>/?]*\$"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_write_retrospective.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
android:layout_marginStart="18dp"
android:layout_marginEnd="2dp"
android:includeFontPadding="false"
android:text="@string/tv_write_chip"
android:text="@{vm.reviewTypeText}"
android:textAppearance="@style/Kor.Body1.Bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0"
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/layout/fragment_write_aar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
android:hint="placeholder 위치, 텍스트박스는 기본 사이즈입니다. 양 옆 마진 16px을 가진 텍스트박스가 존재합니다. "
android:scrollbars="vertical"
android:selectAllOnFocus="false"
android:text="@={vm.question5f1}" />
android:text="@={vm.aarQuestion1}" />
</com.google.android.material.textfield.TextInputLayout>


Expand Down Expand Up @@ -117,7 +117,7 @@
android:hint="placeholder 위치, 텍스트박스는 기본 사이즈입니다. 양 옆 마진 16px을 가진 텍스트박스가 존재합니다. "
android:scrollbars="vertical"
android:selectAllOnFocus="false"
android:text="@={vm.question5f2}" />
android:text="@={vm.aarQuestion2}" />
</com.google.android.material.textfield.TextInputLayout>

<TextView
Expand Down Expand Up @@ -169,7 +169,7 @@
android:hint="placeholder 위치, 텍스트박스는 기본 사이즈입니다. 양 옆 마진 16px을 가진 텍스트박스가 존재합니다. "
android:scrollbars="vertical"
android:selectAllOnFocus="false"
android:text="@={vm.question5f3}" />
android:text="@={vm.aarQuestion3}" />
</com.google.android.material.textfield.TextInputLayout>

<TextView
Expand Down Expand Up @@ -222,7 +222,7 @@
android:hint="placeholder 위치, 텍스트박스는 기본 사이즈입니다. 양 옆 마진 16px을 가진 텍스트박스가 존재합니다. "
android:scrollbars="vertical"
android:selectAllOnFocus="false"
android:text="@={vm.question5f4}" />
android:text="@={vm.aarQuestion4}" />
</com.google.android.material.textfield.TextInputLayout>

<TextView
Expand Down Expand Up @@ -276,7 +276,7 @@
android:hint="placeholder 위치, 텍스트박스는 기본 사이즈입니다. 양 옆 마진 16px을 가진 텍스트박스가 존재합니다. "
android:scrollbars="vertical"
android:selectAllOnFocus="false"
android:text="@={vm.question5f5}" />
android:text="@={vm.aarQuestion5}" />
</com.google.android.material.textfield.TextInputLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
Expand Down

0 comments on commit de6088b

Please sign in to comment.