Skip to content

Commit

Permalink
Merge pull request #76 from TeamFILL-IN/feature/#75
Browse files Browse the repository at this point in the history
[feature/#75] FilmRoll 화면에서 사진 클릭 시 사진 다이얼로그 제대로 뜰 수 있게 수정
  • Loading branch information
l2hyunwoo authored Feb 20, 2022
2 parents 6ed0708 + 55d7f40 commit b138049
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ data class CategoryPhoto(
val photoId: Int,
val imageUrl: String,
val filmId: Int,
val fileName: String,
val filmName: String,
val likeCount: Int,
val isLiked: Boolean,
val isGaro: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import android.view.ViewGroup
import android.view.WindowManager
import androidx.fragment.app.DialogFragment
import com.bumptech.glide.Glide
import com.teamfillin.fillin.R
import com.teamfillin.fillin.core.intent.stringArgs
import com.teamfillin.fillin.databinding.FragmentPhotoDialogBinding
import dagger.hilt.android.AndroidEntryPoint

Expand All @@ -15,29 +17,42 @@ class PhotoDialogFragment : DialogFragment() {
private var _binding: FragmentPhotoDialogBinding? = null
private val binding: FragmentPhotoDialogBinding
get() = requireNotNull(_binding)
private val photoUrl by stringArgs()
private val profileUrl by stringArgs()
private val filmName by stringArgs()
private val userName by stringArgs()

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentPhotoDialogBinding.inflate(layoutInflater, container, false)

binding.btnClose.setOnClickListener {
dismiss()
}
binding.heart.setOnClickListener {
binding.number.text = (
binding.number.text.toString()
.toInt() + (if (!binding.heart.isSelected) 1 else -1)
).toString()
binding.heart.isSelected = !binding.heart.isSelected
}
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val photoUrl = arguments?.getString("photoUrl")
Glide.with(requireActivity()).load(photoUrl).into(binding.ivPhoto)
super.onViewCreated(view, savedInstanceState)
// TODO by Nunu 좋아요 기능 원복
// binding.heart.setOnClickListener {
// binding.number.text = (
// binding.number.text.toString()
// .toInt() + (if (!binding.heart.isSelected) 1 else -1)
// ).toString()
// binding.heart.isSelected = !binding.heart.isSelected
// }
Glide.with(requireContext())
.load(photoUrl)
.into(binding.ivPhoto)
Glide.with(requireContext())
.load(profileUrl)
.circleCrop()
.placeholder(R.drawable.ic_basic_profile)
.into(binding.ivProfile)
with(binding) {
btnClose.setOnClickListener { dismiss() }
tvName.text = userName
tvFilmname.text = filmName
}
}

//휴대폰 크기 맞춰 자동 조절 다이얼로그
Expand All @@ -53,4 +68,17 @@ class PhotoDialogFragment : DialogFragment() {
super.onDestroyView()
_binding = null
}

companion object {
@JvmStatic
fun newInstance(photoUrl: String, profileUrl: String, filmName: String, userName: String) =
PhotoDialogFragment().apply {
arguments = Bundle().apply {
putString("photoUrl", photoUrl)
putString("profileUrl", profileUrl)
putString("filmName", filmName)
putString("userName", userName)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ class CurationAdapter(
binding.root.setOnClickListener {
listener.onClick(input.data)
}
binding.btnLike.setOnSingleClickListener {
binding.btnLike.isSelected = !binding.btnLike.isSelected
}
// TODO by Nunu 좋아요 기능 원복
// binding.btnLike.setOnSingleClickListener {
// binding.btnLike.isSelected = !binding.btnLike.isSelected
// }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@ package com.teamfillin.fillin.presentation.filmroll

import android.app.Activity
import android.content.Intent
import android.graphics.Rect
import android.os.Bundle
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import androidx.paging.PagingData
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.tabs.TabLayout
import com.teamfillin.fillin.R
import com.teamfillin.fillin.core.base.BindingActivity
import com.teamfillin.fillin.core.content.receive
import com.teamfillin.fillin.core.view.setOnSingleClickListener
import com.teamfillin.fillin.data.service.FilmRollService
import com.teamfillin.fillin.databinding.ActivityFilmRollBinding
import com.teamfillin.fillin.presentation.filmroll.add.AddPhotoActivity
import com.teamfillin.fillin.design.dp
import com.teamfillin.fillin.presentation.category.FilmRollCategoryActivity
import com.teamfillin.fillin.presentation.dialog.PhotoDialogFragment
import com.teamfillin.fillin.presentation.filmroll.add.AddCompleteDialog
import com.teamfillin.fillin.presentation.filmroll.add.AddPhotoActivity
import com.teamfillin.fillin.presentation.map.SpaceDecoration
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collectLatest
Expand All @@ -33,12 +36,9 @@ class FilmRollActivity : BindingActivity<ActivityFilmRollBinding>(R.layout.activ
lateinit var service: FilmRollService
private val viewModel by viewModels<FilmRollViewModel>()
private val filmRollPagingAdapter = FilmRollPagingAdapter {
val dialog = PhotoDialogFragment()
val bundle = Bundle().apply { putString("photoUrl", it.imageUrl) }
dialog.apply {
arguments = bundle
show(supportFragmentManager, "dialog")
}
val dialog =
PhotoDialogFragment.newInstance(it.imageUrl, it.userImageUrl, it.filmName, it.nickname)
dialog.show(supportFragmentManager, "dialog")
}
private lateinit var curationAdapter: CurationAdapter
private val addPhotoLauncher =
Expand Down Expand Up @@ -72,14 +72,27 @@ class FilmRollActivity : BindingActivity<ActivityFilmRollBinding>(R.layout.activ
private fun addCurationList() {
service.getCuration().receive({
curationAdapter = CurationAdapter(it.data.curation) {
val dialog = PhotoDialogFragment()
val bundle = Bundle().apply { putString("photoUrl", it.imageUrl) }
dialog.apply {
arguments = bundle
show(supportFragmentManager, "dialog")
}
val dialog = PhotoDialogFragment.newInstance(
photoUrl = it.imageUrl,
profileUrl = it.userImageUrl,
filmName = it.filmName,
userName = it.nickname
)
dialog.show(supportFragmentManager, "dialog")
}
binding.rvCuration.adapter = curationAdapter
binding.rvCuration.addItemDecoration(object : RecyclerView.ItemDecoration() {
override fun getItemOffsets(
outRect: Rect,
itemPosition: Int,
parent: RecyclerView
) {
with(outRect) {
left = if (itemPosition == 0) 16.dp else 8.dp
right = 8.dp
}
}
})
curationAdapter.submitList(it.data.photos)
}, {
Timber.d("Error $it")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ class FilmRollAdapter :
Glide.with(binding.root)
.load(film.image)
.into(binding.ivItemFilmroll)
binding.btnLike.setOnSingleClickListener {
binding.btnLike.isSelected = !binding.btnLike.isSelected
}
// TODO 좋아요 기능 복원
// binding.btnLike.setOnSingleClickListener {
// binding.btnLike.isSelected = !binding.btnLike.isSelected
// }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ class FilmRollPagingAdapter(
binding.root.setOnSingleClickListener {
itemClickListener.onClick(film)
}
binding.btnLike.setOnSingleClickListener {
binding.btnLike.isSelected = !binding.btnLike.isSelected
}
// TODO by Nunu 좋아요 기능 복원
// binding.btnLike.setOnSingleClickListener {
// binding.btnLike.isSelected = !binding.btnLike.isSelected
// }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class HomeActivity : BindingActivity<ActivityHomeBinding>(R.layout.activity_home
}
}
markerLocationEvent()
activityNaverMap?.setOnMapClickListener { pointF, latLng ->
activityNaverMap?.setOnMapClickListener { _, _ ->
val intent = Intent(this, StudioMapActivity::class.java)
startActivity(intent)
}
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_film_roll.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
android:id="@+id/rv_curation"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_marginStart="15dp"
android:layout_marginTop="12dp"
android:orientation="horizontal"
android:overScrollMode="never"
Expand Down
62 changes: 31 additions & 31 deletions app/src/main/res/layout/fragment_photo_dialog.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout 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"
Expand Down Expand Up @@ -131,36 +130,37 @@
android:layout_height="0dp"
android:layout_weight="1" />

<LinearLayout
android:id="@+id/li_like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="10dp"
android:background="@drawable/linearline"
android:visibility="visible">

<ImageView
android:id="@+id/heart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:backgroundTint="@color/dark_grey_3"
android:src="@drawable/heartbutton" />

<TextView
android:id="@+id/number"
style="@style/Body2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:text="22"
android:textColor="@color/grey_2" />

</LinearLayout>
<!-- <LinearLayout-->
<!-- android:id="@+id/li_like"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="center"-->
<!-- android:layout_marginRight="10dp"-->
<!-- android:background="@drawable/linearline"-->
<!-- android:src="@drawable/unlike"-->
<!-- android:visibility="visible">-->

<!-- <ImageView-->
<!-- android:id="@+id/heart"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="center"-->
<!-- android:layout_marginLeft="10dp"-->
<!-- android:backgroundTint="@color/dark_grey_3"-->
<!-- android:src="@drawable/heartbutton" />-->

<!-- <TextView-->
<!-- android:id="@+id/number"-->
<!-- style="@style/Body2"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="center"-->
<!-- android:layout_marginLeft="5dp"-->
<!-- android:layout_marginRight="10dp"-->
<!-- android:text="22"-->
<!-- android:textColor="@color/grey_2" />-->

<!-- </LinearLayout>-->

</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
22 changes: 11 additions & 11 deletions app/src/main/res/layout/item_curation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="160dp"
android:layout_height="120dp">
android:layout_height="match_parent">

<ImageView
android:id="@+id/iv_curation"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:paddingHorizontal="5dp"
android:scaleType="centerInside"
android:scaleType="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<ImageButton
android:id="@+id/btn_like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@android:color/transparent"
android:scaleType="center"
android:src="@drawable/likebutton"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<!-- <ImageButton-->
<!-- android:id="@+id/btn_like"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:backgroundTint="@android:color/transparent"-->
<!-- android:scaleType="center"-->
<!-- android:src="@drawable/likebutton"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent" />-->
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_curation_first.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="103dp"
android:layout_height="118dp"
android:layout_height="match_parent"
android:background="@drawable/ic_curation_cover"
android:paddingHorizontal="5dp">

Expand Down
20 changes: 10 additions & 10 deletions app/src/main/res/layout/item_film_roll.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/shape_kakao_background" />

<ImageButton
android:id="@+id/btn_like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:backgroundTint="@android:color/transparent"
android:src="@drawable/likebutton"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<!-- <ImageButton-->
<!-- android:id="@+id/btn_like"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginEnd="8dp"-->
<!-- android:layout_marginBottom="8dp"-->
<!-- android:backgroundTint="@android:color/transparent"-->
<!-- android:src="@drawable/likebutton"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent" />-->

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ dependencies {
implementation(platform(ThirdPartyDependencies.okHttpBom))
implementation(ThirdPartyDependencies.okHttp)
implementation(ThirdPartyDependencies.retrofit)
implementation(ThirdPartyDependencies.timber)

// Test Dependency
testImplementation(TestDependencies.jUnit)
Expand Down
Loading

0 comments on commit b138049

Please sign in to comment.