Skip to content

Commit

Permalink
[AN/USER] 홈화면 가로모드 지원 및 페스티벌 화면 다양한 화면 크기 반영 (#545) (#546) (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
re4rk authored Oct 17, 2023
1 parent 660e80c commit 28cfb77
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.festago.festago.presentation.ui.home.ticketlist.TicketListFragment
import com.festago.festago.presentation.ui.signin.SignInActivity
import com.festago.festago.presentation.util.repeatOnStarted
import com.festago.festago.presentation.util.requestNotificationPermission
import com.google.android.material.navigation.NavigationBarView
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
Expand All @@ -26,19 +27,25 @@ class HomeActivity : AppCompatActivity() {

private val vm: HomeViewModel by viewModels()

private val resultLauncher: ActivityResultLauncher<Intent> by lazy {
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == SignInActivity.RESULT_NOT_SIGN_IN) {
binding.bnvHome.selectedItemId = R.id.item_festival
}
}
}
private lateinit var resultLauncher: ActivityResultLauncher<Intent>

private val navigationBarView by lazy { binding.nvHome as NavigationBarView }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
initBinding()
initView()
initObserve()
initResultLauncher()
}

private fun initResultLauncher() {
resultLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == SignInActivity.RESULT_NOT_SIGN_IN) {
navigationBarView.selectedItemId = R.id.item_festival
}
}
initNotificationPermission()
}

Expand All @@ -47,13 +54,13 @@ class HomeActivity : AppCompatActivity() {
}

private fun initView() {
binding.bnvHome.setOnItemSelectedListener {
navigationBarView.setOnItemSelectedListener {
vm.selectItem(getItemType(it.itemId))
true
}

binding.fabTicket.setOnClickListener {
binding.bnvHome.selectedItemId = R.id.item_ticket
navigationBarView.selectedItemId = R.id.item_ticket
}

changeFragment<FestivalListFragment>()
Expand Down Expand Up @@ -81,13 +88,13 @@ class HomeActivity : AppCompatActivity() {

private fun initNotificationPermission() {
val requestPermissionLauncher = registerForActivityResult(
ActivityResultContracts.RequestPermission()
ActivityResultContracts.RequestPermission(),
) { isGranted: Boolean ->
if (!isGranted) {
Toast.makeText(
this,
getString(R.string.home_notification_permission_denied),
Toast.LENGTH_SHORT
Toast.LENGTH_SHORT,
).show()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.GridLayoutManager
import com.festago.festago.R
import com.festago.festago.databinding.FragmentFestivalListBinding
import com.festago.festago.presentation.ui.home.ticketlist.TicketListFragment
Expand Down Expand Up @@ -52,9 +53,23 @@ class FestivalListFragment : Fragment(R.layout.fragment_festival_list) {
}
}

private val Int.dp: Int get() = (this / resources.displayMetrics.density).toInt()

private fun initView() {
adapter = FestivalListAdapter()
binding.rvFestivalList.adapter = adapter

binding.rvFestivalList.layoutManager.apply {
if (this is GridLayoutManager) {
val spanSize = (resources.displayMetrics.widthPixels.dp / 160)
spanCount = when {
spanSize < 2 -> 2
spanSize > 4 -> 4
else -> spanSize
}
}
}

vm.loadFestivals()

binding.srlFestivalList.setOnRefreshListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
android:fillType="evenOdd"/>
<path
android:pathData="M180,360C279.41,360 360,279.41 360,180C360,80.59 279.41,0 180,0C80.59,0 0,80.59 0,180C0,279.41 80.59,360 180,360Z"
android:fillColor="#3A73D2"/>
android:fillColor="?attr/colorOnSurface"/>
</group>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/seed" android:state_selected="true" />
<item android:color="@color/seed" android:state_checked="true" />
<item android:color="@color/md_theme_light_outline" android:state_checked="false" />
<item android:color="?attr/colorSurfaceBright" android:state_checked="false" />
</selector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/seed" android:state_selected="true" />
<item android:color="@color/seed" android:state_checked="true" />
<item android:color="?attr/colorSurfaceInverse" android:state_checked="false" />
</selector>
53 changes: 53 additions & 0 deletions android/festago/app/src/main/res/layout-land/activity_home.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<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">

<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".presentation.ui.home.HomeActivity">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.google.android.material.navigationrail.NavigationRailView
android:id="@+id/nvHome"
android:layout_width="68dp"
android:layout_height="match_parent"
android:background="?attr/colorSurfaceBright"
app:itemActiveIndicatorStyle="@color/zxing_transparent"
app:itemIconSize="40dp"
app:itemIconTint="@drawable/menu_selector_color_inverse"
app:itemMinHeight="96dp"
app:labelVisibilityMode="unlabeled"
app:menu="@menu/menu_bottom_navigation"
app:menuGravity="center" />

<androidx.fragment.app.FragmentContainerView
android:id="@+id/fcv_home_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>


<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabTicket"
style="@style/Widget.MaterialComponents.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/transparent"
android:backgroundTint="@drawable/menu_selector_color"
android:src="@drawable/ic_festago_coupon"
app:borderWidth="1dp"
app:fabSize="mini"
app:layout_anchor="@id/nvHome"
app:layout_anchorGravity="center"
app:maxImageSize="48dp"
app:menu="@menu/menu_bottom_navigation"
app:tint="@null" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
11 changes: 6 additions & 5 deletions android/festago/app/src/main/res/layout/activity_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:backgroundTint="?attr/colorSurfaceBright"
app:backgroundTint="?attr/colorSurface"
app:contentInsetStart="0dp"
app:fabAlignmentMode="center">


<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bnvHome"
android:id="@+id/nvHome"
android:layout_width="match_parent"
android:layout_height="68dp"
android:background="#00000000"
app:itemActiveIndicatorStyle="@color/zxing_transparent"
app:itemIconSize="40dp"
app:itemIconTint="@drawable/menu_selector_color"
app:itemIconTint="@drawable/menu_selector_color_inverse"
app:labelVisibilityMode="unlabeled"
app:menu="@menu/menu_bottom_navigation" />
</com.google.android.material.bottomappbar.BottomAppBar>
Expand All @@ -42,12 +43,12 @@
style="@style/Widget.MaterialComponents.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:backgroundTint="@drawable/menu_selector_color"
android:src="@drawable/ic_festago_coupon"
app:borderWidth="1dp"
app:fabCustomSize="72dp"
app:tint="@color/white"
app:layout_anchor="@id/baNavigation"
app:maxImageSize="72dp" />
app:maxImageSize="72dp"
app:tint="@null" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>

0 comments on commit 28cfb77

Please sign in to comment.