Skip to content

Commit

Permalink
#48 [ui] 진행중 뷰모델 로직
Browse files Browse the repository at this point in the history
  • Loading branch information
pump9918 committed Jan 14, 2024
1 parent a9ae44d commit 70e5485
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<activity
android:name=".ui.main.MainActivity"
android:exported="false"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"></activity>

<activity
android:name=".ui.onboarding.OnboardingActivity"
Expand All @@ -44,12 +44,17 @@
</activity>

<activity
android:name=".ui.dailyroutine.dailyroutineadd.DailyRoutineAddActivity"
android:name=".ui.happyroutine.addlist.HappyAddListActivity"
android:exported="false"
android:screenOrientation="portrait"></activity>

<activity
android:name=".ui.happyroutine.adddetail.HappyDetailActivity"
android:exported="false"
android:screenOrientation="portrait" />

<activity
android:name=".ui.happyroutine.addlist.HappyAddListActivity"
android:name=".ui.dailyroutine.dailyroutineadd.DailyRoutineAddActivity"
android:exported="false"
android:screenOrientation="portrait" />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.sopetit.softie.domain.entity

import androidx.annotation.DrawableRes

data class HappyProgress(
val routineId: Int,
@DrawableRes val imageUrl: Int,
val title: String,
val content: String,
val detailTitle: String,
val detailContent: String,
val detailTime: String,
val detailPlace: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,77 @@ package com.sopetit.softie.ui.happyroutine.progress

import android.os.Bundle
import android.view.View
import androidx.fragment.app.activityViewModels
import com.sopetit.softie.R
import com.sopetit.softie.databinding.FragmentHappyProgressBinding
import com.sopetit.softie.domain.entity.HappyProgress
import com.sopetit.softie.ui.main.home.HomeFragment
import com.sopetit.softie.util.binding.BindingFragment

class HappyProgressFragment :
BindingFragment<FragmentHappyProgressBinding>(R.layout.fragment_happy_progress) {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

val viewModel: HappyProgressViewModel by activityViewModels()
val happyProgress = viewModel.mockHappyProgress

setCardBinding(happyProgress)
setCardEnter()
setEditEnter()
setClearEnter()
}

private fun setCardBinding(happyProgress: HappyProgress) {
with(binding) {
tvHappyProgressSubtitle.text = happyProgress.title
ivHappyProgressCardFront.setImageResource(happyProgress.imageUrl)
tvHappyProgressCardFrontTitle.text = happyProgress.content
tvHappyProgressCardBackTitle.text = happyProgress.detailTitle
tvHappyProgressCardBackContent.text = happyProgress.detailContent
tvHappyProgressCardBackTime.text = happyProgress.detailTime
tvHappyProgressCardBackPlace.text = happyProgress.detailPlace
}
}

private fun setCardEnter() {
with(binding) {
clHappyProgressCardFront.setOnClickListener {
setCardFlip(clHappyProgressCardFront, clHappyProgressCardBack)
}
clHappyProgressCardBack.setOnClickListener {
setCardFlip(clHappyProgressCardBack, clHappyProgressCardFront)
}
}
}

private fun setEditEnter() {
binding.tvHappyProgressEdit.setOnClickListener {
val homeFragment = HomeFragment()
requireActivity().supportFragmentManager.beginTransaction()
.replace(R.id.fcv_main, homeFragment)
.commit()
}
}

private fun setCardFlip(viewFront: View, viewToBack: View) {
val isVisible = viewFront.visibility == View.VISIBLE
if (isVisible) {
viewFront.visibility = View.INVISIBLE
viewToBack.visibility = View.VISIBLE
} else {
viewFront.visibility = View.VISIBLE
viewToBack.visibility = View.INVISIBLE
}
}

private fun setClearEnter() {
binding.btnHappyProgressClear.setOnClickListener {
val homeFragment = HomeFragment()
requireActivity().supportFragmentManager.beginTransaction()
.replace(R.id.fcv_main, homeFragment)
.commit()
}
}
}

0 comments on commit 70e5485

Please sign in to comment.