Skip to content

Commit

Permalink
Merge pull request #27 from SSU-Plector/feat/#25-page-paging
Browse files Browse the repository at this point in the history
[Feat/#25 page-paging]: 프로젝트, 개발자 찾기 화면 페이징 숫자 ui 구현
  • Loading branch information
kangyuri1114 authored Apr 20, 2024
2 parents dc7b65c + 14a1f46 commit 7b9033a
Show file tree
Hide file tree
Showing 22 changed files with 344 additions and 83 deletions.
4 changes: 2 additions & 2 deletions feature/projects/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:exported="false" />
<activity
android:name="com.zucchini.projects.ProjectDetailActivity"
android:name="com.zucchini.projects.projects.ProjectDetailActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
Expand All @@ -18,7 +18,7 @@
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
<activity
android:name="com.zucchini.projects.DevDetailActivity"
android:name="com.zucchini.projects.developer.DevDetailActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.zucchini.projects.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.zucchini.feature.projects.databinding.ItemPageIndicatorBinding

class PageIndicatorAdapter(private val context: Context, private val totalPage: Int) :
RecyclerView.Adapter<PageIndicatorAdapter.PageIndicatorViewHolder>() {
private var currentPage = 0

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

override fun onBindViewHolder(holder: PageIndicatorViewHolder, position: Int) {
holder.bind(position)
}

override fun getItemCount(): Int = totalPage

fun setCurrentPage(page: Int) {
currentPage = page
notifyDataSetChanged()
}

inner class PageIndicatorViewHolder(private val binding: ItemPageIndicatorBinding) :
RecyclerView.ViewHolder(binding.root) {

fun bind(position: Int) {
binding.pageNumber.text = (position + 1).toString()

binding.pageNumber.setOnClickListener {
currentPage = position
notifyDataSetChanged()
}
if (position == currentPage) {
binding.pageNumber.setTextColor(
ContextCompat.getColor(
context,
com.zucchini.core.designsystem.R.color.olive_black,
),
)
} else {
binding.pageNumber.setTextColor(
ContextCompat.getColor(
context,
com.zucchini.core.designsystem.R.color.gray1,
),
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.zucchini.projects
package com.zucchini.projects.developer

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import com.zucchini.feature.projects.databinding.ActivityDevDetailBinding
import com.zucchini.projects.adapter.DevDetailProjectAdapter
import com.zucchini.projects.developer.adapter.DevDetailProjectAdapter
import com.zucchini.projects.dummy.DevProjectsDummy

class DevDetailActivity : AppCompatActivity() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
package com.zucchini.projects
package com.zucchini.projects.developer

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.zucchini.feature.projects.databinding.FragmentDevInfoBinding
import com.zucchini.projects.adapter.DeveloperInfoAdapter
import com.zucchini.projects.adapter.PageIndicatorAdapter
import com.zucchini.projects.developer.adapter.DeveloperInfoAdapter
import com.zucchini.projects.dummy.DeveloperInfoDummy

class DevInfoFragment : Fragment() {
private var _binding: FragmentDevInfoBinding? = null
private val binding: FragmentDevInfoBinding get() = _binding!!

private lateinit var developerInfoAdapter: DeveloperInfoAdapter
private lateinit var pageIndicatorAdapter: PageIndicatorAdapter

private val totalPage = 4

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand All @@ -22,17 +29,25 @@ class DevInfoFragment : Fragment() {
_binding = FragmentDevInfoBinding.inflate(inflater, container, false)

initDeveloperAdapter()
initPageIndicator()

return binding.root
}

private fun initDeveloperAdapter() {
val developerInfoAdapter = DeveloperInfoAdapter()
developerInfoAdapter = DeveloperInfoAdapter()
binding.rvDevinfo.adapter = developerInfoAdapter
binding.rvDevinfo.layoutManager = GridLayoutManager(context, 2)
developerInfoAdapter.submitList(DeveloperInfoDummy.developerInfoList)
}

private fun initPageIndicator() {
pageIndicatorAdapter = PageIndicatorAdapter(requireContext(), totalPage)
binding.rvPageIndicator.adapter = pageIndicatorAdapter
binding.rvPageIndicator.layoutManager =
LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.zucchini.projects.adapter
package com.zucchini.projects.developer.adapter

import android.content.Intent
import android.view.LayoutInflater
Expand All @@ -9,8 +9,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.zucchini.domain.model.DevDetailProjectInfo
import com.zucchini.feature.projects.R
import com.zucchini.feature.projects.databinding.ItemDevDetailProjectsBinding
import com.zucchini.projects.DevDetailActivity
import com.zucchini.projects.ProjectDetailActivity
import com.zucchini.projects.projects.ProjectDetailActivity
import com.zucchini.view.ItemDiffCallback

class DevDetailProjectAdapter :
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.zucchini.projects.adapter
package com.zucchini.projects.developer.adapter

import android.content.Intent
import android.view.LayoutInflater
Expand All @@ -9,7 +9,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.zucchini.domain.model.DeveloperInfo
import com.zucchini.feature.projects.R
import com.zucchini.feature.projects.databinding.ItemDeveloperBinding
import com.zucchini.projects.DevDetailActivity
import com.zucchini.projects.developer.DevDetailActivity
import com.zucchini.view.ItemDiffCallback

class DeveloperInfoAdapter :
Expand All @@ -32,6 +32,7 @@ class DeveloperInfoAdapter :
override fun onBindViewHolder(holder: DeveloperInfoViewHolder, position: Int) {
holder.bind(getItem(position))
}
override fun getItemCount(): Int = 8

inner class DeveloperInfoViewHolder(private val binding: ItemDeveloperBinding) :
RecyclerView.ViewHolder(binding.root) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.zucchini.projects
package com.zucchini.projects.mypage

import android.content.Intent
import android.net.Uri
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.zucchini.projects
package com.zucchini.projects.projects

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.GridLayoutManager
import com.zucchini.feature.projects.databinding.ActivityProjectDetailBinding
import com.zucchini.projects.adapter.ProjectDetailDevAdapter
import com.zucchini.projects.projects.adapter.ProjectDetailDevAdapter
import com.zucchini.projects.dummy.ProjectDetailDevDummy

class ProjectDetailActivity : AppCompatActivity() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package com.zucchini.projects.projects

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import com.zucchini.domain.model.Keyword
import com.zucchini.domain.model.KeywordList
import com.zucchini.feature.projects.databinding.FragmentProjectsBinding
import com.zucchini.projects.adapter.PageIndicatorAdapter
import com.zucchini.projects.dummy.ProjectDummyList
import com.zucchini.projects.projects.adapter.ProjectsAdapter
import com.zucchini.projects.projects.adapter.SearchKeywordAdapter

class ProjectsFragment : Fragment() {
private var _binding: FragmentProjectsBinding? = null
private val binding: FragmentProjectsBinding get() = _binding!!

private lateinit var pageIndicatorAdapter: PageIndicatorAdapter

private val totalPage = 4
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View {
_binding = FragmentProjectsBinding.inflate(inflater, container, false)

initKeywordAdapter()
initProjectsAdapter()
initPageIndicator()
setSortingKeyword()
return binding.root
}

private fun initProjectsAdapter() {
val projectsAdapter = ProjectsAdapter()
binding.rvProjects.layoutManager = LinearLayoutManager(context)
binding.rvProjects.adapter = projectsAdapter
projectsAdapter.submitList(ProjectDummyList.projectDummyList)
}

private fun initKeywordAdapter() {
val searchKeywordAdapter = SearchKeywordAdapter()
binding.rvSearchKeyword.layoutManager =
LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
binding.rvSearchKeyword.adapter = searchKeywordAdapter
searchKeywordAdapter.submitList(KeywordList.searchKeyword.map { Keyword(it) })
}

private fun initPageIndicator() {
pageIndicatorAdapter = PageIndicatorAdapter(requireContext(), totalPage)
binding.rvPageIndicator.adapter = pageIndicatorAdapter
binding.rvPageIndicator.layoutManager =
LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
}

private fun setSortingKeyword() {
binding.tvSortRecent.setOnClickListener {
binding.tvSortRecent.setTextColor(
ContextCompat.getColor(
requireContext(),
com.zucchini.core.designsystem.R.color.olive_black,
),
)
binding.tvSortHighCheck.setTextColor(
ContextCompat.getColor(
requireContext(),
com.zucchini.core.designsystem.R.color.gray1,
),
)
binding.tvSortLowCheck.setTextColor(
ContextCompat.getColor(
requireContext(),
com.zucchini.core.designsystem.R.color.gray1,
),
)
}
binding.tvSortHighCheck.setOnClickListener {
binding.tvSortRecent.setTextColor(
ContextCompat.getColor(
requireContext(),
com.zucchini.core.designsystem.R.color.gray1,
),
)
binding.tvSortHighCheck.setTextColor(
ContextCompat.getColor(
requireContext(),
com.zucchini.core.designsystem.R.color.olive_black,
),
)
binding.tvSortLowCheck.setTextColor(
ContextCompat.getColor(
requireContext(),
com.zucchini.core.designsystem.R.color.gray1,
),
)
}
binding.tvSortLowCheck.setOnClickListener {
binding.tvSortRecent.setTextColor(
ContextCompat.getColor(
requireContext(),
com.zucchini.core.designsystem.R.color.gray1,
),
)
binding.tvSortHighCheck.setTextColor(
ContextCompat.getColor(
requireContext(),
com.zucchini.core.designsystem.R.color.gray1,
),
)
binding.tvSortLowCheck.setTextColor(
ContextCompat.getColor(
requireContext(),
com.zucchini.core.designsystem.R.color.olive_black,
),
)
}
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.zucchini.projects.adapter
package com.zucchini.projects.projects.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
Expand Down
Loading

0 comments on commit 7b9033a

Please sign in to comment.