Skip to content

Commit

Permalink
[FEAT] BottomSheet 프래그먼트 전환 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
alschlee committed Aug 5, 2023
1 parent bc61e2d commit 59e00e7
Show file tree
Hide file tree
Showing 28 changed files with 602 additions and 10 deletions.
17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 48 additions & 1 deletion app/src/main/java/com/example/allforkids_aos/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,57 @@ package com.example.allforkids_aos

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.example.allforkids_aos.fragments.MainFragment
import com.example.allforkids_aos.fragments.SearchFragment
import com.example.allforkids_aos.fragments.MapFragment
import com.example.allforkids_aos.fragments.CommunityFragment
import com.example.allforkids_aos.fragments.SettingFragment

class MainActivity : AppCompatActivity() {
private val mainFragment = MainFragment()
private val searchFragment = SearchFragment()
private val mapFragment = MapFragment()
private val communityFragment = CommunityFragment()
private val settingFragment = SettingFragment()

private lateinit var bottomNavigationView: BottomNavigationView

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

bottomNavigationView = findViewById(R.id.bottomNavigationView)

// MainFragment로 시작
replaceFragment(mainFragment)

bottomNavigationView.setOnItemSelectedListener { menuItem ->
when (menuItem.itemId) {
R.id.tapMain -> {
replaceFragment(mainFragment)
}
R.id.tapSearch -> {
replaceFragment(searchFragment)
}
R.id.tapMap -> {
replaceFragment(mapFragment)
}
R.id.tapCommunity -> {
replaceFragment(communityFragment)
}
R.id.tapSetting -> {
replaceFragment(settingFragment)
}
}
true
}
}

private fun replaceFragment(fragment: Fragment) {
supportFragmentManager.beginTransaction()
.replace(R.id.fragmentContainer, fragment)
.commit()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.example.allforkids_aos.fragments

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.example.allforkids_aos.R

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"

/**
* A simple [Fragment] subclass.
* Use the [CommunityFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class CommunityFragment : Fragment() {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
param1 = it.getString(ARG_PARAM1)
param2 = it.getString(ARG_PARAM2)
}
}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_community, container, false)
}

companion object {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment CommunityFragment.
*/
// TODO: Rename and change types and number of parameters
@JvmStatic
fun newInstance(param1: String, param2: String) =
CommunityFragment().apply {
arguments = Bundle().apply {
putString(ARG_PARAM1, param1)
putString(ARG_PARAM2, param2)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.allforkids_aos.fragments

import androidx.fragment.app.Fragment
import com.example.allforkids_aos.R


class MainFragment : Fragment(R.layout.fragment_main) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.example.allforkids_aos.fragments

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.example.allforkids_aos.R

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"

/**
* A simple [Fragment] subclass.
* Use the [MapFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class MapFragment : Fragment() {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
param1 = it.getString(ARG_PARAM1)
param2 = it.getString(ARG_PARAM2)
}
}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_map, container, false)
}

companion object {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment MapFragment.
*/
// TODO: Rename and change types and number of parameters
@JvmStatic
fun newInstance(param1: String, param2: String) =
MapFragment().apply {
arguments = Bundle().apply {
putString(ARG_PARAM1, param1)
putString(ARG_PARAM2, param2)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.example.allforkids_aos.fragments

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.example.allforkids_aos.R

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"

/**
* A simple [Fragment] subclass.
* Use the [SearchFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class SearchFragment : Fragment() {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
param1 = it.getString(ARG_PARAM1)
param2 = it.getString(ARG_PARAM2)
}
}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_search, container, false)
}

companion object {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment SearchFragment.
*/
// TODO: Rename and change types and number of parameters
@JvmStatic
fun newInstance(param1: String, param2: String) =
SearchFragment().apply {
arguments = Bundle().apply {
putString(ARG_PARAM1, param1)
putString(ARG_PARAM2, param2)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.example.allforkids_aos.fragments

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.example.allforkids_aos.R

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"

/**
* A simple [Fragment] subclass.
* Use the [SettingFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class SettingFragment : Fragment() {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
param1 = it.getString(ARG_PARAM1)
param2 = it.getString(ARG_PARAM2)
}
}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_setting, container, false)
}

companion object {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment SettingFragment.
*/
// TODO: Rename and change types and number of parameters
@JvmStatic
fun newInstance(param1: String, param2: String) =
SettingFragment().apply {
arguments = Bundle().apply {
putString(ARG_PARAM1, param1)
putString(ARG_PARAM2, param2)
}
}
}
}
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/icon_community.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="30dp"
android:height="30dp"
android:viewportWidth="30"
android:viewportHeight="30">
<group>
<clip-path
android:pathData="M0,0h30v30h-30z"/>
<path
android:pathData="M15,26.25V23.594L21.625,16.969L24.281,19.625L17.656,26.25H15ZM3.75,20V17.5H12.5V20H3.75ZM25.156,18.75L22.5,16.094L23.406,15.188C23.635,14.958 23.927,14.844 24.281,14.844C24.635,14.844 24.927,14.958 25.156,15.188L26.063,16.094C26.292,16.323 26.406,16.615 26.406,16.969C26.406,17.323 26.292,17.615 26.063,17.844L25.156,18.75ZM3.75,15V12.5H17.5V15H3.75ZM3.75,10V7.5H17.5V10H3.75Z"
android:fillColor="#1C1B1F"/>
</group>
</vector>
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/icon_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="30dp"
android:height="30dp"
android:viewportWidth="30"
android:viewportHeight="30">
<group>
<clip-path
android:pathData="M0,0h30v30h-30z"/>
<path
android:pathData="M5,26.25V14.531L2.75,16.25L1.25,14.25L5,11.375V7.5H7.5V9.469L15,3.75L28.75,14.25L27.25,16.219L25,14.531V26.25H5ZM7.5,23.75H13.75V18.75H16.25V23.75H22.5V12.625L15,6.906L7.5,12.625V23.75ZM5,6.25C5,5.208 5.365,4.323 6.094,3.594C6.823,2.865 7.708,2.5 8.75,2.5C9.104,2.5 9.401,2.38 9.641,2.141C9.88,1.901 10,1.604 10,1.25H12.5C12.5,2.292 12.135,3.177 11.406,3.906C10.677,4.635 9.792,5 8.75,5C8.396,5 8.099,5.12 7.859,5.359C7.62,5.599 7.5,5.896 7.5,6.25H5Z"
android:fillColor="#1C1B1F"/>
</group>
</vector>
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/icon_map.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="30dp"
android:height="30dp"
android:viewportWidth="30"
android:viewportHeight="30">
<group>
<clip-path
android:pathData="M0,0h30v30h-30z"/>
<path
android:pathData="M15,27.5C12.792,27.5 10.99,27.151 9.594,26.453C8.198,25.755 7.5,24.854 7.5,23.75C7.5,23.021 7.802,22.385 8.406,21.844C9.01,21.302 9.844,20.875 10.906,20.563L11.625,22.938C11.271,23.042 10.948,23.172 10.656,23.328C10.365,23.484 10.167,23.625 10.063,23.75C10.333,24.083 10.958,24.375 11.938,24.625C12.917,24.875 13.938,25 15,25C16.063,25 17.088,24.875 18.078,24.625C19.068,24.375 19.698,24.083 19.969,23.75C19.865,23.625 19.667,23.484 19.375,23.328C19.083,23.172 18.76,23.042 18.406,22.938L19.125,20.563C20.188,20.875 21.016,21.302 21.609,21.844C22.203,22.385 22.5,23.021 22.5,23.75C22.5,24.854 21.802,25.755 20.406,26.453C19.01,27.151 17.208,27.5 15,27.5ZM15,19.156C15.375,18.469 15.771,17.838 16.188,17.266C16.604,16.693 17.01,16.146 17.406,15.625C18.177,14.625 18.792,13.724 19.25,12.922C19.708,12.12 19.938,11.125 19.938,9.938C19.938,8.563 19.458,7.396 18.5,6.438C17.542,5.479 16.375,5 15,5C13.625,5 12.458,5.479 11.5,6.438C10.542,7.396 10.063,8.563 10.063,9.938C10.063,11.125 10.292,12.12 10.75,12.922C11.208,13.724 11.823,14.625 12.594,15.625C12.99,16.146 13.396,16.693 13.813,17.266C14.229,17.838 14.625,18.469 15,19.156ZM15,23.75C14.771,23.75 14.563,23.682 14.375,23.547C14.188,23.412 14.052,23.229 13.969,23C13.49,21.521 12.885,20.281 12.156,19.281C11.427,18.281 10.719,17.323 10.031,16.406C9.365,15.49 8.786,14.542 8.297,13.563C7.807,12.583 7.563,11.375 7.563,9.938C7.563,7.854 8.281,6.094 9.719,4.656C11.156,3.219 12.917,2.5 15,2.5C17.083,2.5 18.844,3.219 20.281,4.656C21.719,6.094 22.438,7.854 22.438,9.938C22.438,11.375 22.198,12.583 21.719,13.563C21.24,14.542 20.656,15.49 19.969,16.406C19.302,17.323 18.599,18.281 17.859,19.281C17.12,20.281 16.51,21.521 16.031,23C15.948,23.229 15.813,23.412 15.625,23.547C15.438,23.682 15.229,23.75 15,23.75ZM15,12.594C15.729,12.594 16.354,12.333 16.875,11.813C17.396,11.292 17.656,10.667 17.656,9.938C17.656,9.208 17.396,8.583 16.875,8.063C16.354,7.542 15.729,7.281 15,7.281C14.271,7.281 13.646,7.542 13.125,8.063C12.604,8.583 12.344,9.208 12.344,9.938C12.344,10.667 12.604,11.292 13.125,11.813C13.646,12.333 14.271,12.594 15,12.594Z"
android:fillColor="#1C1B1F"/>
</group>
</vector>
Loading

0 comments on commit 59e00e7

Please sign in to comment.