Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] 회고 작성뷰 detail 구현 #30

Merged
merged 17 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ android {

defaultConfig {
applicationId "com.puzzling.puzzlingaos"
minSdk 24
minSdk 26
targetSdk 33
versionCode 1
versionName "1.0"
Expand Down
24 changes: 15 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@
android:supportsRtl="true"
android:theme="@style/Theme.PuzzlingAOS"
tools:targetApi="31">

<activity
android:name=".presentation.home.team.TeamPuzzleBoardActivity"
android:exported="false" />
<activity
android:name=".presentation.home.personal.MyPuzzleBoardActivity"
android:exported="false" />
<activity
android:name=".presentation.writeRetrospective.WriteRetrospectiveActivity"
android:exported="true"
android:windowSoftInputMode="adjustPan"/>
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".presentation.main.MainActivity"
android:exported="true"
Expand All @@ -28,17 +33,18 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".presentation.invitationCode.InvitationCodeActivity"
android:windowSoftInputMode="adjustPan"
android:exported="true"/>
<activity
android:name=".presentation.invitationCode.InvitationCodeActivity"
android:exported="true"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".presentation.register.RegisterActivity"
android:windowSoftInputMode="adjustPan"
android:exported="true" />
android:exported="true"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".presentation.team.currentSituation.TeamCurrentSituationFragment"
android:windowSoftInputMode="adjustPan"
android:exported="true" />
android:exported="true"
android:windowSoftInputMode="adjustPan" />
</application>

</manifest>
22 changes: 22 additions & 0 deletions app/src/main/java/com/puzzling/puzzlingaos/base/BindingAdapter.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
package com.puzzling.puzzlingaos.base

import android.graphics.Color
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.widget.AppCompatRadioButton
import androidx.databinding.BindingAdapter
import coil.load
import com.puzzling.puzzlingaos.R

@BindingAdapter("image")
fun ImageView.setImage(imageUrl: String) {
this.load(imageUrl)
}

@BindingAdapter("spanTextColor")
fun setTextColor(view: TextView, inputText: String?) {
val isConditionMet = inputText == "Your Condition"
view.setTextColor(if (isConditionMet) Color.BLUE else Color.BLACK)
}
// TODO span color 이용해서 텍스트 컬러 처리

@BindingAdapter("app:checkedReviewType")
fun setCheckedReviewType(radioButton: AppCompatRadioButton, reviewType: String) {
val checkedId = when (reviewType) {
"TIL" -> R.id.rbtn_choose_first
"5F" -> R.id.rbtn_choose_second
"AAR" -> R.id.rbtn_choose_third
else -> R.id.rbtn_choose_first
}
radioButton.isChecked = radioButton.id == checkedId
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ data class ActionPlan(
@SerialName("actionPlanContent")
val actionPlanContent: String,
@SerialName("actionPlanDate")
val actionPlanDate: String,
val actionPlanDate: String?,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.puzzling.puzzlingaos.domain.entity

import androidx.annotation.DrawableRes

data class PuzzleBoard(
val date: String,
@DrawableRes val boardImage: Int,
)
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
package com.puzzling.puzzlingaos.presentation.home

import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.fragment.app.commit
import com.google.android.material.tabs.TabLayout
import com.puzzling.puzzlingaos.R
import com.puzzling.puzzlingaos.base.BaseFragment
import com.puzzling.puzzlingaos.databinding.FragmentHomeBinding
import com.puzzling.puzzlingaos.presentation.home.personal.PersonalDashboardFragment
import com.puzzling.puzzlingaos.presentation.home.team.TeamDashboardFragment
import com.puzzling.puzzlingaos.presentation.main.HomeChooseProjectFragment

class HomeFragment :
BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {
private val viewModel by activityViewModels<HomeViewModel>()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.vm = viewModel
initTabItem()
showProjectBottomSheet()
clickTabItem()
showPopupMessage()
handleSelectedProject()
}

private fun initTabItem() {
Expand Down Expand Up @@ -47,4 +56,27 @@ class HomeFragment :
}
})
}

private fun showProjectBottomSheet() {
binding.clHomeProjectMain.setOnClickListener {
val chooseProjectFragment = HomeChooseProjectFragment()
chooseProjectFragment.show(parentFragmentManager, "show")
}
}

private fun showPopupMessage() {
binding.btnHomeNotification.setOnClickListener {
val isCardVisible = binding.cvHomePopup.isVisible
binding.cvHomePopup.isVisible = !isCardVisible
}
}

private fun handleSelectedProject() {
viewModel.isProjectNameSelected.observe(viewLifecycleOwner) {
Log.d("home", "isProjectSelected: ${viewModel.isProjectNameSelected.value}")
val projectName = viewModel.selectedProjectName.value
binding.tvHomeProjectName.text = projectName.toString()
Log.d("home", "tvHomeProjectName: ${binding.tvHomeProjectName.text}")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.puzzling.puzzlingaos.presentation.home

import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.puzzling.puzzlingaos.data.model.response.ResponseMyPageProjectDto

class HomeViewModel : ViewModel() {

val projectItemList = mutableListOf<ResponseMyPageProjectDto>(
ResponseMyPageProjectDto("Piickle", "2023-07-03", 2),
ResponseMyPageProjectDto("HARA", "2023-07-28", 3),
ResponseMyPageProjectDto("낫투두", "2023-07-12", 4),
ResponseMyPageProjectDto("PEEKABOOK", "2023-07-20", 5),
ResponseMyPageProjectDto("ZOOC", "2023-06-25", 9),
)

private val _reviewCycleList = MutableLiveData<List<String>>()
val reviewCycleList: List<String>
get() = requireNotNull(_reviewCycleList.value)

private val _reviewCycleText = MutableLiveData<String>()
val reviewCycleText: String
get() = requireNotNull("")

private val _isCardVisible = MutableLiveData(false)
val isCardVisible: LiveData<Boolean>
get() = _isCardVisible

var selectedProject: ResponseMyPageProjectDto? = null

private val _projectItemSelected = MutableLiveData<Boolean>()
val projectItemSelected: LiveData<Boolean>
get() = _projectItemSelected

private val _isProjectNameSelected = MutableLiveData(false)
val isProjectNameSelected: LiveData<Boolean>
get() = _isProjectNameSelected

private val _selectedProjectName = MutableLiveData("PUZZLING")
val selectedProjectName: LiveData<String>
get() = _selectedProjectName

init {
_reviewCycleList.value = listOf("월", "수", "금")
_reviewCycleText.value = _reviewCycleList.value?.joinToString(separator = ",")
}

fun setSelectedProjectText(projectName: String) {
_selectedProjectName.value = projectName
Log.d("home", "_selectedProjectName.value :: ${_selectedProjectName.value}")
_isProjectNameSelected.value = true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.puzzling.puzzlingaos.presentation.home.personal

import android.os.Bundle
import androidx.activity.viewModels
import androidx.fragment.app.viewModels
import com.puzzling.puzzlingaos.R
import com.puzzling.puzzlingaos.base.BaseActivity
import com.puzzling.puzzlingaos.databinding.ActivityMyPuzzleBoardBinding

class MyPuzzleBoardActivity :
BaseActivity<ActivityMyPuzzleBoardBinding>(R.layout.activity_my_puzzle_board) {
private val viewModel by viewModels<MyPuzzleBoardViewModel>()
private var _myPuzzleBoardAdapter: MyPuzzleBoardAdapter? = null
private val myPuzzleBoardAdapter
get() = requireNotNull(_myPuzzleBoardAdapter) { "adapter is null !!" }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setMyPuzzleBoardAdapter()
}

private fun setMyPuzzleBoardAdapter() {
_myPuzzleBoardAdapter = MyPuzzleBoardAdapter()
_myPuzzleBoardAdapter?.submitList(viewModel.puzzleBoardList)
binding.rcvMypuzzleBoard.also {
it.adapter = _myPuzzleBoardAdapter
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.puzzling.puzzlingaos.presentation.home.personal

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.puzzling.puzzlingaos.databinding.ItemMypuzzleBoardBinding
import com.puzzling.puzzlingaos.domain.entity.PuzzleBoard
import com.puzzling.puzzlingaos.util.ItemDiffCallback
import com.puzzling.puzzlingaos.util.loadImage

class MyPuzzleBoardAdapter : ListAdapter<PuzzleBoard, MyPuzzleBoardAdapter.MyPuzzleBoardViewHolder>(
ItemDiffCallback<PuzzleBoard>(
onContentsTheSame = { old, new -> old == new },
onItemsTheSame = { old, new -> old == new },
),
) {
class MyPuzzleBoardViewHolder(private val binding: ItemMypuzzleBoardBinding) :
RecyclerView.ViewHolder(binding.root) {
fun onBind(data: PuzzleBoard) = with(binding) {
tvMypuzzleDate.text = data.date
ivMyuzzleBoard.loadImage(binding.root.context.getDrawable(data.boardImage))
}
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyPuzzleBoardViewHolder {
val binding =
ItemMypuzzleBoardBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return MyPuzzleBoardViewHolder(binding)
}

override fun onBindViewHolder(holder: MyPuzzleBoardViewHolder, position: Int) {
holder.onBind(
getItem(position) as PuzzleBoard,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.puzzling.puzzlingaos.presentation.home.personal

import androidx.lifecycle.ViewModel
import com.puzzling.puzzlingaos.R
import com.puzzling.puzzlingaos.domain.entity.PuzzleBoard

class MyPuzzleBoardViewModel : ViewModel() {
val puzzleBoardList = listOf<PuzzleBoard>(
PuzzleBoard("2023.07.03. ~ 2023.07.18.", R.drawable.img_myboard1),
PuzzleBoard("2023.06.14. ~ 2023.06.29.", R.drawable.img_myboard2),
PuzzleBoard("2023.05.04. ~ 2023.06.12.", R.drawable.img_myboard3),
PuzzleBoard("2023.05.04. ~ 2023.06.12.", R.drawable.img_myboard4),

)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class PersonalDashboardFragment :
super.onViewCreated(view, savedInstanceState)
setActionPlanAdapter()
clickBottomBtn()
clickMyPuzzleBoardBtn()
clickPuzzlePiece()
}

private fun setActionPlanAdapter() {
Expand All @@ -39,4 +41,21 @@ class PersonalDashboardFragment :
}
}
}

private fun clickMyPuzzleBoardBtn() {
binding.clPersonalTopBackground.setOnClickListener {
activity?.let {
val intent = Intent(context, MyPuzzleBoardActivity::class.java)
startActivity(intent)
}
}
}

private fun clickPuzzlePiece() {
with(binding) {
// TODO 각 퍼즐 조각 클릭 -> 각 날짜의 회고 상세조회로 넘어가는 로직 추가
clPersonalMain1.setOnClickListener {
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.puzzling.puzzlingaos.presentation.home.personal

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.puzzling.puzzlingaos.domain.entity.ActionPlan

Expand All @@ -12,4 +13,8 @@ class PersonalDashboardViewModel : ViewModel() {
ActionPlan("여기에는 글이 계속 작성되다가 작성되다가 작성되다가 작성되다가 이쯤 되면 끊기게 돼...", "7월 6일"),
ActionPlan("여기에는 글이 계속 작성되다가 작성되다가 작성되다가 작성되다가 이쯤 되면 끊기게 돼...", "7월 7일"),
)

val _bottomButtonText = MutableLiveData<String>()
val bottomButtonText: String
get() = _bottomButtonText.value ?: "회고 작성일이 아니에요"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ package com.puzzling.puzzlingaos.presentation.home.team

import androidx.lifecycle.ViewModel

class TeamDashBoardViewModel : ViewModel() {
// test
}
class TeamDashBoardViewModel : ViewModel()
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.puzzling.puzzlingaos.presentation.home.team

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.fragment.app.viewModels
Expand All @@ -13,5 +14,15 @@ class TeamDashboardFragment :

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

private fun clickTeamPuzzleBoardBtn() {
binding.clTeamTopBackground.setOnClickListener {
activity?.let {
val intent = Intent(context, TeamPuzzleBoardActivity::class.java)
startActivity(intent)
}
}
}
}
Loading
Loading