diff --git a/buddy/src/main/java/com/nocapstone/buddyvet/buddy/ui/CompleteRegistrationFragment.kt b/buddy/src/main/java/com/nocapstone/buddyvet/buddy/ui/CompleteRegistrationFragment.kt index f12d351..4a6e7dc 100644 --- a/buddy/src/main/java/com/nocapstone/buddyvet/buddy/ui/CompleteRegistrationFragment.kt +++ b/buddy/src/main/java/com/nocapstone/buddyvet/buddy/ui/CompleteRegistrationFragment.kt @@ -1,12 +1,14 @@ package com.nocapstone.buddyvet.buddy.ui import android.os.Bundle +import android.view.* import androidx.fragment.app.Fragment -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup +import androidx.core.view.MenuHost +import androidx.core.view.MenuProvider import androidx.fragment.app.viewModels +import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope +import androidx.navigation.fragment.findNavController import com.nocapstone.buddyvet.buddy.databinding.FragmentCompleteRegistrationBinding import com.nocapstone.common.util.LoginUtil import dagger.hilt.android.AndroidEntryPoint @@ -35,6 +37,8 @@ class CompleteRegistrationFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + initMenu() + binding.apply { this.viewModel = buddyViewModel this.lifecycleOwner = viewLifecycleOwner @@ -47,6 +51,25 @@ class CompleteRegistrationFragment : Fragment() { } } + private fun initMenu() { + val menuHost: MenuHost = requireActivity() + + menuHost.addMenuProvider(object : MenuProvider { + + override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) { + } + + override fun onMenuItemSelected(menuItem: MenuItem): Boolean { + when (menuItem.itemId) { + android.R.id.home -> { + findNavController().popBackStack() + } + } + return true + } + }, viewLifecycleOwner, Lifecycle.State.RESUMED) + } + override fun onDestroyView() { super.onDestroyView() diff --git a/buddy/src/main/java/com/nocapstone/buddyvet/buddy/ui/InputBuddyInfoFragment.kt b/buddy/src/main/java/com/nocapstone/buddyvet/buddy/ui/InputBuddyInfoFragment.kt index cd85747..84c76d9 100644 --- a/buddy/src/main/java/com/nocapstone/buddyvet/buddy/ui/InputBuddyInfoFragment.kt +++ b/buddy/src/main/java/com/nocapstone/buddyvet/buddy/ui/InputBuddyInfoFragment.kt @@ -2,12 +2,13 @@ package com.nocapstone.buddyvet.buddy.ui import android.os.Bundle import android.util.Log +import android.view.* import androidx.fragment.app.Fragment -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup import android.widget.ArrayAdapter +import androidx.core.view.MenuHost +import androidx.core.view.MenuProvider import androidx.fragment.app.viewModels +import androidx.lifecycle.Lifecycle import androidx.navigation.fragment.findNavController import com.nocapstone.buddyvet.buddy.R import com.nocapstone.buddyvet.buddy.databinding.FragmentInputBuddyInfoBinding @@ -38,6 +39,8 @@ class InputBuddyInfoFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + initMenu() + val neuteredAdapter = ArrayAdapter( requireContext(), list_item, @@ -104,5 +107,24 @@ class InputBuddyInfoFragment : Fragment() { _binding = null } + private fun initMenu() { + val menuHost: MenuHost = requireActivity() + + menuHost.addMenuProvider(object : MenuProvider { + + override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) { + } + + override fun onMenuItemSelected(menuItem: MenuItem): Boolean { + when (menuItem.itemId) { + android.R.id.home -> { + findNavController().popBackStack() + } + } + return true + } + }, viewLifecycleOwner, Lifecycle.State.RESUMED) + } + } \ No newline at end of file diff --git a/buddy/src/main/java/com/nocapstone/buddyvet/buddy/ui/InputBuddyTypeFragment.kt b/buddy/src/main/java/com/nocapstone/buddyvet/buddy/ui/InputBuddyTypeFragment.kt index 2e7b6fd..cb0b360 100644 --- a/buddy/src/main/java/com/nocapstone/buddyvet/buddy/ui/InputBuddyTypeFragment.kt +++ b/buddy/src/main/java/com/nocapstone/buddyvet/buddy/ui/InputBuddyTypeFragment.kt @@ -1,11 +1,12 @@ package com.nocapstone.buddyvet.buddy.ui import android.os.Bundle +import android.view.* import androidx.fragment.app.Fragment -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup +import androidx.core.view.MenuHost +import androidx.core.view.MenuProvider import androidx.fragment.app.viewModels +import androidx.lifecycle.Lifecycle import androidx.navigation.fragment.findNavController import com.nocapstone.buddyvet.buddy.R import com.nocapstone.buddyvet.buddy.databinding.FragmentInputBuddyTypeBinding @@ -27,6 +28,7 @@ class InputBuddyTypeFragment : Fragment() { // Inflate the layout for this fragment _binding = FragmentInputBuddyTypeBinding.inflate(inflater, container, false) + (activity as MainActivityUtil).run { setToolbarTitle("버디 추가") setVisibilityBottomAppbar(View.GONE) @@ -39,6 +41,7 @@ class InputBuddyTypeFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + initMenu() binding.viewModel = buddyViewModel binding.lifecycleOwner = viewLifecycleOwner @@ -62,4 +65,23 @@ class InputBuddyTypeFragment : Fragment() { _binding = null } + private fun initMenu() { + val menuHost: MenuHost = requireActivity() + + menuHost.addMenuProvider(object : MenuProvider { + + override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) { + } + + override fun onMenuItemSelected(menuItem: MenuItem): Boolean { + when (menuItem.itemId) { + android.R.id.home -> { + findNavController().popBackStack() + } + } + return true + } + }, viewLifecycleOwner, Lifecycle.State.RESUMED) + } + } \ No newline at end of file diff --git a/buddy/src/main/res/layout/fragment_input_buddy_info.xml b/buddy/src/main/res/layout/fragment_input_buddy_info.xml index 8d35736..a31a11b 100644 --- a/buddy/src/main/res/layout/fragment_input_buddy_info.xml +++ b/buddy/src/main/res/layout/fragment_input_buddy_info.xml @@ -146,7 +146,7 @@ android:textSize="17sp" />