Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.android.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- We fixed an issue where TextInput-based fields like the TextBox and TextArea would not receive focus on Android devices via touch.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/react_native_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,24 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.viewModels
import com.mendix.developerapp.MendixBaseFragment
import com.mendix.developerapp.R
import com.mendix.developerapp.loading.ProjectLoaderViewModel
import com.mendix.developerapp.ui.theme.MyApplicationTheme
import com.mendix.developerapp.utilities.GlobalTouchEventListener
import org.devio.rn.splashscreen.SplashScreen

open class MendixProjectFragmentBase : MendixBaseFragment(), GlobalTouchEventListener {
private lateinit var composeView: ComposeView
protected val viewModel: ProjectLoaderViewModel by viewModels()

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

composeView.setContent {
MyApplicationTheme {
MendixProjectScreen(viewModel)
}
}
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = super.onCreateView(inflater, container, savedInstanceState)
val rootView = inflater.inflate(R.layout.fragment_mendix_project_traditional, container, false)
val reactNativeContainer = rootView.findViewById<FrameLayout>(R.id.react_native_container)
val reactRootView = super.onCreateView(inflater, container, savedInstanceState)

viewModel.status.observe(viewLifecycleOwner) {
if (it === ProjectLoaderViewModel.STATUS_SUCCESS) {
Expand All @@ -42,22 +32,13 @@ open class MendixProjectFragmentBase : MendixBaseFragment(), GlobalTouchEventLis
}
}

/**
* Why aren't we just attaching to ReactRootView directly? ReactRootView is fairly special.
* Layouting is actually handled by the UIManagerModule, which means whatever child is added out of React Native's context
* to the ReactRootView is basically ignored and gets no layout call nor parameters.
*/
val frameLayout = FrameLayout(requireContext())
frameLayout.layoutParams = FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
reactNativeContainer.addView(reactRootView,
FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
)
frameLayout.addView(view)

viewModel.setRNFrameLayout(frameLayout)

return ComposeView(requireContext()).also {
composeView = it
}
return rootView
}
}
}