Skip to content

Commit

Permalink
Merge pull request #10 from NOW-SOPT-APP4-KREAM/init-single-activity-…
Browse files Browse the repository at this point in the history
…architecture

[init] Jetpack Navigation 세팅
  • Loading branch information
Hyobeen-Park authored May 16, 2024
2 parents 38a28ba + 8d3b962 commit d5c33a1
Show file tree
Hide file tree
Showing 20 changed files with 415 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".presentation.ui.dummy.DummyActivity"
android:name=".presentation.ui.main.MainActivity"
android:exported="true"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.sopt.kream.presentation.ui.main

import android.os.Bundle
import android.view.View
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import org.sopt.kream.R
import org.sopt.kream.databinding.ActivityMainBinding
import org.sopt.kream.util.base.BindingActivity

class MainActivity : BindingActivity<ActivityMainBinding>({ ActivityMainBinding.inflate(it) }) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

initBottomNavigation()
}

private fun initBottomNavigation() {
val navController = (supportFragmentManager.findFragmentById(R.id.fcv_main) as NavHostFragment).navController
binding.bnvMain.setupWithNavController(navController)

setBottomNavigationVisibility(navController)
}

private fun setBottomNavigationVisibility(navController: NavController) {
navController.addOnDestinationChangedListener { _, destination, _ ->
binding.apply {
if (destination.id in
listOf(
R.id.recommend_fragment,
R.id.release_fragment,
)
) {
bnvMain.visibility = View.VISIBLE
viewMain.visibility = View.VISIBLE
} else {
bnvMain.visibility = View.GONE
viewMain.visibility = View.GONE
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.sopt.kream.presentation.ui.main.home.recommend

import android.os.Bundle
import android.view.View
import androidx.navigation.fragment.findNavController
import org.sopt.kream.R
import org.sopt.kream.databinding.FragmentRecommendBinding
import org.sopt.kream.util.base.BindingFragment

class RecommendFragment : BindingFragment<FragmentRecommendBinding>({ FragmentRecommendBinding.inflate(it) }) {
override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)

initBtnProductDetail()
}

private fun initBtnProductDetail() {
binding.btnToProductDetail.setOnClickListener {
findNavController().navigate(R.id.product_detail_fragment)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.sopt.kream.presentation.ui.main.home.release

import android.os.Bundle
import android.view.View
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import org.sopt.kream.databinding.FragmentReleaseBinding
import org.sopt.kream.util.base.BindingFragment

class ReleaseFragment : BindingFragment<FragmentReleaseBinding>({ FragmentReleaseBinding.inflate(it) }) {
override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)
binding.cvRelease.setContent {
releaseScreen()
}
}

@Composable
fun releaseScreen() {
Text(text = "Release")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.sopt.kream.presentation.ui.productdetail

import org.sopt.kream.databinding.FragmentProductDetailBinding
import org.sopt.kream.util.base.BindingFragment

class ProductDetailFragment : BindingFragment<FragmentProductDetailBinding>({ FragmentProductDetailBinding.inflate(it) })
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.sopt.kream.presentation.ui.search

import org.sopt.kream.databinding.FragmentSearchBinding
import org.sopt.kream.util.base.BindingFragment

class SearchFragment : BindingFragment<FragmentSearchBinding>({ FragmentSearchBinding.inflate(it) })
5 changes: 5 additions & 0 deletions app/src/main/res/color/selector_main_bnv_item_text_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/black02" android:state_selected="true"/>
<item android:color="@color/black06" android:state_selected="false"/>
</selector>
18 changes: 18 additions & 0 deletions app/src/main/res/drawable/ic_bnv_home.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="28dp"
android:height="28dp"
android:viewportWidth="28"
android:viewportHeight="28">
<path
android:pathData="M5,24V10.883L14,4L23,10.883V24H5ZM11.5,19V20H16.5V19H11.5Z"
android:fillColor="#222222"
android:fillType="evenOdd"/>
<group>
<clip-path
android:pathData="M5,24V10.883L14,4L23,10.883V24H5ZM11.5,19V20H16.5V19H11.5Z"
android:fillType="evenOdd"/>
<path
android:pathData="M5,10.883L4.393,10.089L4,10.389V10.883H5ZM5,24H4V25H5V24ZM14,4L14.608,3.206L14,2.741L13.392,3.206L14,4ZM23,10.883H24V10.389L23.608,10.089L23,10.883ZM23,24V25H24V24H23ZM11.5,20H10.5V21H11.5V20ZM11.5,19V18H10.5V19H11.5ZM16.5,20V21H17.5V20H16.5ZM16.5,19H17.5V18H16.5V19ZM4,10.883V24H6V10.883H4ZM13.392,3.206L4.393,10.089L5.607,11.677L14.608,4.794L13.392,3.206ZM23.608,10.089L14.608,3.206L13.392,4.794L22.392,11.677L23.608,10.089ZM24,24V10.883H22V24H24ZM5,25H23V23H5V25ZM12.5,20V19H10.5V20H12.5ZM16.5,19H11.5V21H16.5V19ZM15.5,19V20H17.5V19H15.5ZM11.5,20H16.5V18H11.5V20Z"
android:fillColor="#222222"/>
</group>
</vector>
16 changes: 16 additions & 0 deletions app/src/main/res/drawable/ic_bnv_my.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="28dp"
android:height="28dp"
android:viewportWidth="28"
android:viewportHeight="28">
<path
android:pathData="M13.583,10.249m-4.167,0a4.167,4.167 0,1 1,8.333 0a4.167,4.167 0,1 1,-8.333 0"
android:strokeWidth="0.833333"
android:fillColor="#00000000"
android:strokeColor="#222222"/>
<path
android:pathData="M4.56,24.417L6.81,16.917H21.19L23.44,24.417H4.56Z"
android:strokeWidth="0.833333"
android:fillColor="#00000000"
android:strokeColor="#222222"/>
</vector>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/ic_bnv_saved.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="28dp"
android:height="28dp"
android:viewportWidth="28"
android:viewportHeight="28">
<path
android:pathData="M21.083,5.25H6.917V22.333L14,16.917L21.083,22.333V5.25Z"
android:strokeWidth="0.833333"
android:fillColor="#00000000"
android:strokeColor="#222222"/>
</vector>
23 changes: 23 additions & 0 deletions app/src/main/res/drawable/ic_bnv_shop.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="28dp"
android:height="28dp"
android:viewportWidth="28"
android:viewportHeight="28">
<path
android:pathData="M17.058,12.693m-7.875,0a7.875,7.875 0,1 1,15.75 0a7.875,7.875 0,1 1,-15.75 0"
android:strokeWidth="0.874999"
android:fillColor="#00000000"
android:strokeColor="#222222"/>
<path
android:pathData="M22.744,18.818L27.119,23.193"
android:strokeWidth="0.874999"
android:fillColor="#00000000"
android:strokeColor="#222222"
android:strokeLineCap="square"/>
<path
android:pathData="M2.182,8.318H7.432M2.182,13.568H5.682M2.182,18.818H7.432"
android:strokeWidth="0.874999"
android:fillColor="#00000000"
android:strokeColor="#222222"
android:strokeLineCap="square"/>
</vector>
20 changes: 20 additions & 0 deletions app/src/main/res/drawable/ic_bnv_style.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="28dp"
android:height="28dp"
android:viewportWidth="28"
android:viewportHeight="28">
<path
android:pathData="M4.375,4.375h19.25v19.25h-19.25z"
android:strokeWidth="0.916667"
android:fillColor="#00000000"
android:strokeColor="#222222"/>
<path
android:pathData="M7.584,16.292H20.417M7.584,19.042H17.667"
android:strokeWidth="0.916667"
android:fillColor="#00000000"
android:strokeColor="#222222"/>
<path
android:pathData="M9.875,9.121C9.249,8.409 8.171,8.289 7.4,8.867C6.59,9.474 6.426,10.623 7.034,11.433L9.814,13.945C9.849,13.976 9.902,13.976 9.937,13.945L12.717,11.433C13.325,10.623 13.16,9.474 12.35,8.867C11.58,8.289 10.501,8.409 9.875,9.121Z"
android:fillColor="#222222"
android:fillType="evenOdd"/>
</vector>
46 changes: 46 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.fragment.app.FragmentContainerView
android:id="@+id/fcv_main"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/view_main"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/nav_graph" />

<View
android:id="@+id/view_main"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/gray06"
app:layout_constraintBottom_toTopOf="@id/bnv_main"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bnv_main"
android:layout_width="0dp"
android:layout_height="55dp"
android:background="@color/white"
app:itemActiveIndicatorStyle="@android:color/transparent"
app:itemIconSize="28dp"
app:itemPaddingBottom="9dp"
app:itemPaddingTop="9dp"
app:itemTextAppearanceActive="@style/TextAppearance.Kream.Body8.SemiBold"
app:itemTextAppearanceInactive="@style/TextAppearance.Kream.Body8.SemiBold"
app:itemTextColor="@color/selector_main_bnv_item_text_color"
app:labelVisibilityMode="labeled"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/menu_bnv" />

</androidx.constraintlayout.widget.ConstraintLayout>
18 changes: 18 additions & 0 deletions app/src/main/res/layout/fragment_product_detail.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<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.productdetail.ProductDetailFragment">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Product Detail"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
27 changes: 27 additions & 0 deletions app/src/main/res/layout/fragment_recommend.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<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.main.home.recommend.RecommendFragment">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Recommend"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/btn_to_product_detail"
android:layout_width="0dp"
android:layout_height="100dp"
android:text="Product Detail"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
18 changes: 18 additions & 0 deletions app/src/main/res/layout/fragment_release.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<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.main.home.release.ReleaseFragment">

<androidx.compose.ui.platform.ComposeView
android:id="@+id/cv_release"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
18 changes: 18 additions & 0 deletions app/src/main/res/layout/fragment_search.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<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.search.SearchFragment">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
27 changes: 27 additions & 0 deletions app/src/main/res/menu/menu_bnv.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/item_bnv_home"
android:icon="@drawable/ic_bnv_home"
android:title="@string/bnv_home" />
<item
android:id="@+id/item_bnv_style"
android:icon="@drawable/ic_bnv_style"
android:enabled="false"
android:title="@string/bnv_style"/>
<item
android:id="@+id/item_bnv_shop"
android:icon="@drawable/ic_bnv_shop"
android:enabled="false"
android:title="@string/bnv_shop"/>
<item
android:id="@+id/item_bnv_saved"
android:icon="@drawable/ic_bnv_saved"
android:enabled="false"
android:title="@string/bnv_saved"/>
<item
android:id="@+id/item_bnv_my"
android:icon="@drawable/ic_bnv_my"
android:enabled="false"
android:title="@string/bnv_my"/>
</menu>
Loading

0 comments on commit d5c33a1

Please sign in to comment.