I am using a BottomSheetDialogFragment class with Navigation Architecture component. I am following the Single activity pattern and therefore i have only one activity and several fragments. Below is my code.
BottomSheetDialogFragment.kt
class LogoBottomSheetFragment : BottomSheetDialogFragment() {
private var _binding: FragmentBottomSheetAccountLogoBinding? = null
private val binding get() = _binding!!
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentBottomSheetAccountLogoBinding.inflate(inflater, container, false)
return binding.root
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
And this is how i open the dialog in my navigation.xml from my main fragment:
<dialog
android:id="@+id/logoBottomSheetFragment"
android:name="com.th3pl4gu3.locky.ui.main.add.account.LogoBottomSheetFragment"
android:label="LogoBottomSheetFragment"
tools:layout="@layout/fragment_bottom_sheet_account_logo" />
Now i want to pass data FROM the bottom sheet to the main fragment.
Is there a proper way to do this? Can someone please help me.
Thank you.