Skip to content

Commit

Permalink
Merge pull request #15 from Keyneez/feature/#3-infomain-layout
Browse files Browse the repository at this point in the history
[UI/#3] 홈(infomain) / 뷰페이저 뷰 구현
  • Loading branch information
etama123 authored Jan 2, 2023
2 parents b7cf99e + 1cb3097 commit 804173e
Show file tree
Hide file tree
Showing 14 changed files with 339 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,35 @@ package com.lab.keyneez.presentation.main.home

import android.os.Bundle
import android.view.View
import com.google.android.material.tabs.TabLayoutMediator
import com.lab.keyneez.R
import com.lab.keyneez.databinding.FragmentHomeBinding
import com.lab.keyneez.presentation.main.home.adapter.HomeVPFragmentAdapter
import com.lab.keyneez.util.binding.BindingFragment

class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home) {

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

initHomeViewPagerAdapter()
}

private fun initHomeViewPagerAdapter() {
val viewPager = binding.vpHome
val tabLayout = binding.tabHome

val homeTabTitles = listOf<String>(
getString(R.string.home_recommend),
getString(R.string.home_popular),
getString(R.string.home_new)
)

viewPager.adapter = HomeVPFragmentAdapter(parentFragmentManager, lifecycle)

TabLayoutMediator(tabLayout, viewPager) { tab, position ->
tab.text = homeTabTitles[position]
}.attach()
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.lab.keyneez.presentation.main.home

import android.os.Bundle
import android.view.View
import com.lab.keyneez.R
import com.lab.keyneez.databinding.FragmentHomeNewBinding
import com.lab.keyneez.util.binding.BindingFragment

class NewInfoFragment : BindingFragment<FragmentHomeNewBinding>(R.layout.fragment_home_new) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}

companion object {
fun newInstance(): NewInfoFragment {
return NewInfoFragment()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.lab.keyneez.presentation.main.home

import android.os.Bundle
import android.view.View
import com.lab.keyneez.R
import com.lab.keyneez.databinding.FragmentHomePopularBinding
import com.lab.keyneez.util.binding.BindingFragment

class PopularInfoFragment :
BindingFragment<FragmentHomePopularBinding>(R.layout.fragment_home_popular) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}

companion object {
fun newInstance(): PopularInfoFragment {
return PopularInfoFragment()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.lab.keyneez.presentation.main.home

import android.os.Bundle
import android.view.View
import com.lab.keyneez.R
import com.lab.keyneez.databinding.FragmentHomeRecommendBinding
import com.lab.keyneez.util.binding.BindingFragment

class RecommendInfoFragment :
BindingFragment<FragmentHomeRecommendBinding>(R.layout.fragment_home_recommend) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}

companion object {
fun newInstance(): RecommendInfoFragment {
return RecommendInfoFragment()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.lab.keyneez.presentation.main.home.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.lab.keyneez.presentation.main.home.NewInfoFragment
import com.lab.keyneez.presentation.main.home.PopularInfoFragment
import com.lab.keyneez.presentation.main.home.RecommendInfoFragment

class HomeVPFragmentAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle) :
FragmentStateAdapter(fragmentManager, lifecycle) {
override fun getItemCount(): Int {
return 3
}

override fun createFragment(position: Int): Fragment {
when (position) {
0 -> return RecommendInfoFragment()
1 -> return PopularInfoFragment()
2 -> return NewInfoFragment()
}
return RecommendInfoFragment()
}
}
Binary file added app/src/main/res/drawable/haedal.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/ic_home_search.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:pathData="M0,0h32v32h-32z"
android:fillColor="#ffffff"/>
<path
android:pathData="M26.533,27.967L17.767,19.2C17.1,19.778 16.322,20.228 15.433,20.55C14.544,20.872 13.6,21.034 12.6,21.034C10.2,21.034 8.167,20.2 6.5,18.534C4.833,16.867 4,14.856 4,12.5C4,10.145 4.833,8.133 6.5,6.467C8.167,4.8 10.189,3.967 12.567,3.967C14.922,3.967 16.928,4.8 18.583,6.467C20.239,8.133 21.067,10.145 21.067,12.5C21.067,13.456 20.911,14.378 20.6,15.267C20.289,16.156 19.822,16.989 19.2,17.767L28,26.5L26.533,27.967ZM12.567,19.034C14.367,19.034 15.9,18.395 17.167,17.117C18.433,15.839 19.067,14.3 19.067,12.5C19.067,10.7 18.433,9.161 17.167,7.883C15.9,6.606 14.367,5.967 12.567,5.967C10.744,5.967 9.194,6.606 7.917,7.883C6.639,9.161 6,10.7 6,12.5C6,14.3 6.639,15.839 7.917,17.117C9.194,18.395 10.744,19.034 12.567,19.034Z"
android:fillColor="#000000"/>
</vector>
30 changes: 30 additions & 0 deletions app/src/main/res/drawable/img_home_logo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="80dp"
android:height="30dp"
android:viewportWidth="80"
android:viewportHeight="30">
<path
android:pathData="M6.312,18.711L4.084,21.04V24.698H1.475V10.395H4.084V17.73L11.03,10.395H13.961L8.059,16.79L14.322,24.698H11.271L6.312,18.711Z"
android:fillColor="#000000"/>
<path
android:pathData="M24.059,19.304C24.059,19.481 24.046,19.733 24.019,20.06H15.608C15.755,20.863 16.137,21.503 16.753,21.98C17.382,22.443 18.158,22.675 19.081,22.675C20.259,22.675 21.229,22.28 21.992,21.49L23.337,23.063C22.855,23.649 22.246,24.092 21.51,24.391C20.774,24.691 19.944,24.841 19.021,24.841C17.843,24.841 16.806,24.602 15.909,24.126C15.013,23.649 14.317,22.988 13.822,22.144C13.34,21.285 13.099,20.318 13.099,19.242C13.099,18.18 13.333,17.226 13.802,16.382C14.283,15.524 14.946,14.856 15.789,14.379C16.632,13.903 17.582,13.664 18.639,13.664C19.683,13.664 20.613,13.903 21.43,14.379C22.259,14.842 22.902,15.503 23.357,16.361C23.825,17.206 24.059,18.187 24.059,19.304ZM18.639,15.708C17.837,15.708 17.154,15.953 16.592,16.443C16.043,16.92 15.709,17.56 15.588,18.364H21.671C21.563,17.574 21.236,16.933 20.687,16.443C20.138,15.953 19.456,15.708 18.639,15.708Z"
android:fillColor="#000000"/>
<path
android:pathData="M34.905,13.787L29.887,25.576C29.419,26.761 28.85,27.592 28.181,28.069C27.511,28.559 26.702,28.805 25.752,28.805C25.216,28.805 24.688,28.716 24.166,28.539C23.644,28.362 23.216,28.117 22.881,27.803L23.885,25.924C24.126,26.155 24.407,26.339 24.728,26.475C25.063,26.612 25.397,26.68 25.732,26.68C26.173,26.68 26.535,26.564 26.816,26.332C27.11,26.101 27.378,25.712 27.619,25.168L27.799,24.739L23.122,13.787H25.732L29.104,21.858L32.497,13.787H34.905Z"
android:fillColor="#000000"/>
<path
android:pathData="M41.151,13.664C42.503,13.664 43.587,14.066 44.403,14.87C45.219,15.673 45.627,16.865 45.627,18.445V24.698H43.118V18.772C43.118,17.819 42.897,17.104 42.456,16.627C42.014,16.136 41.385,15.891 40.569,15.891C39.645,15.891 38.916,16.177 38.381,16.75C37.845,17.308 37.578,18.118 37.578,19.181V24.698H35.069V13.787H37.457V15.197C37.872,14.693 38.394,14.311 39.023,14.052C39.652,13.794 40.361,13.664 41.151,13.664Z"
android:fillColor="#000000"/>
<path
android:pathData="M57.482,19.304C57.482,19.481 57.469,19.733 57.442,20.06H49.031C49.179,20.863 49.56,21.503 50.176,21.98C50.805,22.443 51.581,22.675 52.504,22.675C53.682,22.675 54.652,22.28 55.415,21.49L56.76,23.063C56.278,23.649 55.669,24.092 54.933,24.391C54.197,24.691 53.367,24.841 52.444,24.841C51.266,24.841 50.229,24.602 49.333,24.126C48.436,23.649 47.74,22.988 47.245,22.144C46.763,21.285 46.522,20.318 46.522,19.242C46.522,18.18 46.756,17.226 47.225,16.382C47.707,15.524 48.369,14.856 49.212,14.379C50.055,13.903 51.005,13.664 52.063,13.664C53.106,13.664 54.036,13.903 54.853,14.379C55.683,14.842 56.325,15.503 56.78,16.361C57.248,17.206 57.482,18.187 57.482,19.304ZM52.063,15.708C51.26,15.708 50.577,15.953 50.015,16.443C49.466,16.92 49.132,17.56 49.011,18.364H55.094C54.987,17.574 54.659,16.933 54.11,16.443C53.561,15.953 52.879,15.708 52.063,15.708Z"
android:fillColor="#000000"/>
<path
android:pathData="M68.966,19.304C68.966,19.481 68.953,19.733 68.926,20.06H60.515C60.662,20.863 61.044,21.503 61.659,21.98C62.288,22.443 63.064,22.675 63.988,22.675C65.166,22.675 66.136,22.28 66.899,21.49L68.244,23.063C67.762,23.649 67.153,24.092 66.417,24.391C65.681,24.691 64.851,24.841 63.928,24.841C62.75,24.841 61.713,24.602 60.816,24.126C59.92,23.649 59.224,22.988 58.729,22.144C58.247,21.285 58.006,20.318 58.006,19.242C58.006,18.18 58.24,17.226 58.708,16.382C59.19,15.524 59.853,14.856 60.696,14.379C61.539,13.903 62.489,13.664 63.546,13.664C64.59,13.664 65.52,13.903 66.337,14.379C67.166,14.842 67.809,15.503 68.264,16.361C68.732,17.206 68.966,18.187 68.966,19.304ZM63.546,15.708C62.743,15.708 62.061,15.953 61.499,16.443C60.95,16.92 60.616,17.56 60.495,18.364H66.577C66.47,17.574 66.143,16.933 65.594,16.443C65.045,15.953 64.363,15.708 63.546,15.708Z"
android:fillColor="#000000"/>
<path
android:pathData="M78.646,22.654V24.698H69.392V23.084L75.273,15.83H69.512V13.787H78.485V15.401L72.583,22.654H78.646Z"
android:fillColor="#000000"/>
<path
android:pathData="M29.868,1.798C30.079,1.515 30.475,1.46 30.753,1.674L35.316,5.198C35.594,5.413 35.648,5.816 35.438,6.099L30.213,13.108C30.002,13.391 29.606,13.447 29.328,13.232L24.765,9.708C24.487,9.493 24.432,9.09 24.643,8.807L29.868,1.798Z"
android:fillColor="#2CC9ED"/>
</vector>
75 changes: 67 additions & 8 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>
<layout 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">

<data>

</data>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".presentation.main.home.HomeFragment">

<!-- TODO: Update blank fragment layout -->
<TextView
<ImageView
android:id="@+id/tv_home_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginVertical="13dp"
android:layout_marginStart="24dp"
android:src="@drawable/img_home_logo"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<ImageButton
android:id="@+id/btn_home_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="215dp"
android:background="@color/white"
android:padding="13dp"
android:src="@drawable/ic_home_search"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/tv_home_logo"
app:layout_constraintTop_toTopOf="parent" />

<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_home"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="115dp"
android:layout_marginTop="10dp"
app:layout_constraintTop_toBottomOf="@id/tv_home_logo"
app:tabIndicatorColor="@color/gray900"
app:tabIndicatorHeight="3dp"
app:tabSelectedTextColor="@color/gray900"
app:tabTextColor="@color/gray400">

<com.google.android.material.tabs.TabItem
android:id="@+id/tabitem_recommend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/home_recommend" />

<com.google.android.material.tabs.TabItem
android:id="@+id/tabitem_popular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/home_popular" />

<com.google.android.material.tabs.TabItem
android:id="@+id/tabitem_new"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/home_new" />
</com.google.android.material.tabs.TabLayout>

<androidx.viewpager2.widget.ViewPager2
android:id="@+id/vp_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tab_home" />

</androidx.constraintlayout.widget.ConstraintLayout>

</FrameLayout>
</layout>
26 changes: 26 additions & 0 deletions app/src/main/res/layout/fragment_home_new.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>

<data>

</data>

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layout_home_new"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/tv_new"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/home_new"
android:textSize="30dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
25 changes: 25 additions & 0 deletions app/src/main/res/layout/fragment_home_popular.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>

<data>

</data>

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layout_home_popular"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/tv_popular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/home_popular"
android:textSize="30dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
26 changes: 26 additions & 0 deletions app/src/main/res/layout/fragment_home_recommend.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>

<data>

</data>

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layout_home_recommend"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/tv_recommend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/home_recommend"
android:textSize="30dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
41 changes: 41 additions & 0 deletions app/src/main/res/layout/item_infomain.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/layout_home_rv"
android:background="@color/white"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginTop="16dp">
<ImageView
android:id="@+id/img_infomain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/haedal"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>

<TextView
android:id="@+id/tv_infomain_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="28sp"
android:text="@string/infomain_title"
android:layout_marginTop="72dp"
android:paddingHorizontal="21dp"
app:layout_constraintTop_toBottomOf="@id/img_infomain"
app:layout_constraintLeft_toLeftOf="parent" />

<TextView
android:id="@+id/tv_infomain_sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text="@string/infomain_sub"
android:paddingHorizontal="21dp"
android:layout_marginBottom="34dp"
app:layout_constraintTop_toBottomOf="@id/tv_infomain_title"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>
8 changes: 6 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
<string name="verification_description">학생증 또는 청소년증을\n준비해주세요.</string>
<string name="verification_sub_description">청소년 인증을 위해 학생증/청소년증\n촬영이 필요해요.</string>

<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
//home
<string name="home_recommend">추천</string>
<string name="home_popular">인기</string>
<string name="home_new">최신</string>
<string name="infomain_title">청소년 영화관 할인</string>
<string name="infomain_sub">영화보면서 팝콘 어때요</string>
</resources>

0 comments on commit 804173e

Please sign in to comment.