-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Feat/#25 page-paging]: 프로젝트, 개발자 찾기 화면 페이징 숫자 ui 구현
- Loading branch information
Showing
22 changed files
with
344 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 0 additions & 51 deletions
51
feature/projects/src/main/java/com/zucchini/projects/ProjectsFragment.kt
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
feature/projects/src/main/java/com/zucchini/projects/adapter/PageIndicatorAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
), | ||
) | ||
} | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...om/zucchini/projects/DevDetailActivity.kt → ...i/projects/developer/DevDetailActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...a/com/zucchini/projects/MypageFragment.kt → ...ucchini/projects/mypage/MypageFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ucchini/projects/ProjectDetailActivity.kt → ...rojects/projects/ProjectDetailActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
feature/projects/src/main/java/com/zucchini/projects/projects/ProjectsFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ojects/adapter/ProjectDetailDevAdapter.kt → ...ojects/adapter/ProjectDetailDevAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.