-
Notifications
You must be signed in to change notification settings - Fork 8
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: 빈 프래그먼트 추가 (FestivalList, TicketList, MyPage) * feat: 바텀네비게이션 menu * feat: HomeActivity 바텀네비게이션 구현 * refactor: 확장함수 제거 * chore: 문자열 리소스 주석 추가 * fix: onDestroyView에서 binding null 처리
- Loading branch information
Showing
15 changed files
with
273 additions
and
5 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
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
59 changes: 59 additions & 0 deletions
59
android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/HomeActivity.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,59 @@ | ||
package com.festago.festago.presentation.ui.home | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.fragment.app.Fragment | ||
import com.festago.festago.R | ||
import com.festago.festago.databinding.ActivityHomeBinding | ||
import com.festago.festago.presentation.ui.home.festivallist.FestivalListFragment | ||
import com.festago.festago.presentation.ui.home.mypage.MyPageFragment | ||
import com.festago.festago.presentation.ui.home.ticketlist.TicketListFragment | ||
|
||
class HomeActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
val binding = ActivityHomeBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
binding.bnvHome.setOnItemSelectedListener { | ||
when (getItemType(it.itemId)) { | ||
HomeItemType.FESTIVAL_LIST -> changeFragment<FestivalListFragment>() | ||
HomeItemType.TICKET_LIST -> changeFragment<TicketListFragment>() | ||
HomeItemType.MY_PAGE -> changeFragment<MyPageFragment>() | ||
} | ||
true | ||
} | ||
|
||
changeFragment<FestivalListFragment>() | ||
} | ||
|
||
private fun getItemType(menuItemId: Int): HomeItemType { | ||
return when (menuItemId) { | ||
R.id.item_festival -> HomeItemType.FESTIVAL_LIST | ||
R.id.item_mypage -> HomeItemType.MY_PAGE | ||
R.id.item_ticket -> HomeItemType.TICKET_LIST | ||
else -> throw IllegalArgumentException("menu item id not found") | ||
} | ||
} | ||
|
||
private inline fun <reified T : Fragment> changeFragment() { | ||
val tag = T::class.java.name | ||
val fragmentTransaction = supportFragmentManager.beginTransaction() | ||
|
||
supportFragmentManager.fragments.forEach { fragment -> | ||
fragmentTransaction.hide(fragment) | ||
} | ||
|
||
var targetFragment = supportFragmentManager.findFragmentByTag(tag) | ||
|
||
if (targetFragment == null) { | ||
targetFragment = T::class.java.newInstance() | ||
fragmentTransaction.add(R.id.fcv_home_container, targetFragment, tag) | ||
} else { | ||
fragmentTransaction.show(targetFragment) | ||
} | ||
|
||
fragmentTransaction.commit() | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/HomeItemType.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,7 @@ | ||
package com.festago.festago.presentation.ui.home | ||
|
||
enum class HomeItemType { | ||
FESTIVAL_LIST, | ||
TICKET_LIST, | ||
MY_PAGE, | ||
} |
29 changes: 29 additions & 0 deletions
29
...c/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListFragment.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,29 @@ | ||
package com.festago.festago.presentation.ui.home.festivallist | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import com.festago.festago.R | ||
import com.festago.festago.databinding.FragmentFestivalListBinding | ||
|
||
class FestivalListFragment : Fragment(R.layout.fragment_festival_list) { | ||
|
||
private var _binding: FragmentFestivalListBinding? = null | ||
private val binding get() = _binding!! | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle?, | ||
): View { | ||
_binding = FragmentFestivalListBinding.inflate(inflater) | ||
return binding.root | ||
} | ||
|
||
override fun onDestroyView() { | ||
_binding = null | ||
super.onDestroyView() | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...stago/app/src/main/java/com/festago/festago/presentation/ui/home/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.festago.festago.presentation.ui.home.mypage | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import com.festago.festago.R | ||
import com.festago.festago.databinding.FragmentMyPageBinding | ||
|
||
class MyPageFragment : Fragment(R.layout.fragment_my_page) { | ||
|
||
private var _binding: FragmentMyPageBinding? = null | ||
private val binding get() = _binding!! | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle?, | ||
): View { | ||
_binding = FragmentMyPageBinding.inflate(inflater) | ||
return binding.root | ||
} | ||
|
||
override fun onDestroyView() { | ||
_binding = null | ||
super.onDestroyView() | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...p/src/main/java/com/festago/festago/presentation/ui/home/ticketlist/TicketListFragment.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,29 @@ | ||
package com.festago.festago.presentation.ui.home.ticketlist | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import com.festago.festago.R | ||
import com.festago.festago.databinding.FragmentTicketListBinding | ||
|
||
class TicketListFragment : Fragment(R.layout.fragment_ticket_list) { | ||
|
||
private var _binding: FragmentTicketListBinding? = null | ||
private val binding get() = _binding!! | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle?, | ||
): View { | ||
_binding = FragmentTicketListBinding.inflate(inflater) | ||
return binding.root | ||
} | ||
|
||
override fun onDestroyView() { | ||
_binding = null | ||
super.onDestroyView() | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
android/festago/app/src/main/res/drawable/ic_bottom_navigation_festival.xml
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,5 @@ | ||
<vector android:height="24dp" android:tint="#FFFFFF" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M13,5.7l0,-1.7l3,0l-1,-1.49l1,-1.51l-5,0l0,4.7l-9,6.3l0,10l7,0l0,-5l3.03,-2l2.97,2l0,5l7,0l0,-10z"/> | ||
</vector> |
5 changes: 5 additions & 0 deletions
5
android/festago/app/src/main/res/drawable/ic_bottom_navigation_user.xml
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,5 @@ | ||
<vector android:height="24dp" android:tint="#FFFFFF" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/> | ||
</vector> |
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,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout> | ||
|
||
<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" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".presentation.ui.home.HomeActivity"> | ||
|
||
<androidx.fragment.app.FragmentContainerView | ||
android:id="@+id/fcv_home_container" | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
app:layout_constraintBottom_toTopOf="@id/bnv_home" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<com.google.android.material.bottomnavigation.BottomNavigationView | ||
android:id="@+id/bnv_home" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:labelVisibilityMode="unlabeled" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:menu="@menu/menu_bottom_navigation" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
16 changes: 16 additions & 0 deletions
16
android/festago/app/src/main/res/layout/fragment_festival_list.xml
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,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout> | ||
|
||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".presentation.ui.home.festivallist.FestivalListFragment"> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:text="Festival List Fragment" /> | ||
|
||
</FrameLayout> | ||
</layout> |
16 changes: 16 additions & 0 deletions
16
android/festago/app/src/main/res/layout/fragment_my_page.xml
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,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout> | ||
|
||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".presentation.ui.home.mypage.MyPageFragment"> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:text="My Page Fragment" /> | ||
|
||
</FrameLayout> | ||
</layout> |
16 changes: 16 additions & 0 deletions
16
android/festago/app/src/main/res/layout/fragment_ticket_list.xml
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,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout> | ||
|
||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".presentation.ui.home.ticketlist.TicketListFragment"> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:text="Ticket List Fragment" /> | ||
|
||
</FrameLayout> | ||
</layout> |
21 changes: 21 additions & 0 deletions
21
android/festago/app/src/main/res/menu/menu_bottom_navigation.xml
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,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item | ||
android:id="@+id/item_festival" | ||
android:enabled="true" | ||
android:icon="@drawable/ic_bottom_navigation_festival" | ||
android:iconTint="@color/md_theme_light_secondary" | ||
android:title="@string/home_bottom_navigation_festival" /> | ||
<item | ||
android:id="@+id/item_ticket" | ||
android:enabled="true" | ||
android:icon="@drawable/ic_festago_logo_foreground" | ||
android:iconTint="@color/md_theme_light_secondary" | ||
android:title="@string/home_bottom_navigation_ticket" /> | ||
<item | ||
android:id="@+id/item_mypage" | ||
android:enabled="true" | ||
android:icon="@drawable/ic_bottom_navigation_user" | ||
android:iconTint="@color/md_theme_light_secondary" | ||
android:title="@string/home_bottom_navigation_user" /> | ||
</menu> |
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