Skip to content

Commit 70e5485

Browse files
committed
#48 [ui] 진행중 뷰모델 로직
1 parent a9ae44d commit 70e5485

File tree

3 files changed

+86
-3
lines changed

3 files changed

+86
-3
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<activity
2121
android:name=".ui.main.MainActivity"
2222
android:exported="false"
23-
android:screenOrientation="portrait" />
23+
android:screenOrientation="portrait"></activity>
2424

2525
<activity
2626
android:name=".ui.onboarding.OnboardingActivity"
@@ -44,12 +44,17 @@
4444
</activity>
4545

4646
<activity
47-
android:name=".ui.dailyroutine.dailyroutineadd.DailyRoutineAddActivity"
47+
android:name=".ui.happyroutine.addlist.HappyAddListActivity"
48+
android:exported="false"
49+
android:screenOrientation="portrait"></activity>
50+
51+
<activity
52+
android:name=".ui.happyroutine.adddetail.HappyDetailActivity"
4853
android:exported="false"
4954
android:screenOrientation="portrait" />
5055

5156
<activity
52-
android:name=".ui.happyroutine.addlist.HappyAddListActivity"
57+
android:name=".ui.dailyroutine.dailyroutineadd.DailyRoutineAddActivity"
5358
android:exported="false"
5459
android:screenOrientation="portrait" />
5560

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.sopetit.softie.domain.entity
2+
3+
import androidx.annotation.DrawableRes
4+
5+
data class HappyProgress(
6+
val routineId: Int,
7+
@DrawableRes val imageUrl: Int,
8+
val title: String,
9+
val content: String,
10+
val detailTitle: String,
11+
val detailContent: String,
12+
val detailTime: String,
13+
val detailPlace: String
14+
)

app/src/main/java/com/sopetit/softie/ui/happyroutine/progress/HappyProgressFragment.kt

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,77 @@ package com.sopetit.softie.ui.happyroutine.progress
22

33
import android.os.Bundle
44
import android.view.View
5+
import androidx.fragment.app.activityViewModels
56
import com.sopetit.softie.R
67
import com.sopetit.softie.databinding.FragmentHappyProgressBinding
8+
import com.sopetit.softie.domain.entity.HappyProgress
9+
import com.sopetit.softie.ui.main.home.HomeFragment
710
import com.sopetit.softie.util.binding.BindingFragment
811

912
class HappyProgressFragment :
1013
BindingFragment<FragmentHappyProgressBinding>(R.layout.fragment_happy_progress) {
14+
1115
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
1216
super.onViewCreated(view, savedInstanceState)
17+
18+
val viewModel: HappyProgressViewModel by activityViewModels()
19+
val happyProgress = viewModel.mockHappyProgress
20+
21+
setCardBinding(happyProgress)
22+
setCardEnter()
23+
setEditEnter()
24+
setClearEnter()
25+
}
26+
27+
private fun setCardBinding(happyProgress: HappyProgress) {
28+
with(binding) {
29+
tvHappyProgressSubtitle.text = happyProgress.title
30+
ivHappyProgressCardFront.setImageResource(happyProgress.imageUrl)
31+
tvHappyProgressCardFrontTitle.text = happyProgress.content
32+
tvHappyProgressCardBackTitle.text = happyProgress.detailTitle
33+
tvHappyProgressCardBackContent.text = happyProgress.detailContent
34+
tvHappyProgressCardBackTime.text = happyProgress.detailTime
35+
tvHappyProgressCardBackPlace.text = happyProgress.detailPlace
36+
}
37+
}
38+
39+
private fun setCardEnter() {
40+
with(binding) {
41+
clHappyProgressCardFront.setOnClickListener {
42+
setCardFlip(clHappyProgressCardFront, clHappyProgressCardBack)
43+
}
44+
clHappyProgressCardBack.setOnClickListener {
45+
setCardFlip(clHappyProgressCardBack, clHappyProgressCardFront)
46+
}
47+
}
48+
}
49+
50+
private fun setEditEnter() {
51+
binding.tvHappyProgressEdit.setOnClickListener {
52+
val homeFragment = HomeFragment()
53+
requireActivity().supportFragmentManager.beginTransaction()
54+
.replace(R.id.fcv_main, homeFragment)
55+
.commit()
56+
}
57+
}
58+
59+
private fun setCardFlip(viewFront: View, viewToBack: View) {
60+
val isVisible = viewFront.visibility == View.VISIBLE
61+
if (isVisible) {
62+
viewFront.visibility = View.INVISIBLE
63+
viewToBack.visibility = View.VISIBLE
64+
} else {
65+
viewFront.visibility = View.VISIBLE
66+
viewToBack.visibility = View.INVISIBLE
67+
}
68+
}
69+
70+
private fun setClearEnter() {
71+
binding.btnHappyProgressClear.setOnClickListener {
72+
val homeFragment = HomeFragment()
73+
requireActivity().supportFragmentManager.beginTransaction()
74+
.replace(R.id.fcv_main, homeFragment)
75+
.commit()
76+
}
1377
}
1478
}

0 commit comments

Comments
 (0)