Skip to content

Add Android BridgeViewProvider for React Native view overrides#32

Open
asikora-sf wants to merge 7 commits intosalesforce:devfrom
asikora-sf:stack/viewprovider/03-android-viewprovider-bridge
Open

Add Android BridgeViewProvider for React Native view overrides#32
asikora-sf wants to merge 7 commits intosalesforce:devfrom
asikora-sf:stack/viewprovider/03-android-viewprovider-bridge

Conversation

@asikora-sf
Copy link
Contributor

Summary

  • Creates BridgeViewProvider.kt implementing AgentforceViewProvider interface
  • canHandle(definition:) checks against pre-registered component type strings from JS
  • GetView() renders a ReactRootView inside a Compose AndroidView
  • Adds registerViewProvider / clearViewProvider React methods to AgentforceModule
  • Passes the view provider to AgentforceConfiguration.Builder when registered

Stack

PR 3/6 in the viewprovider stack. Depends on PR #30, #31.

Test plan

  • Android build compiles with new BridgeViewProvider
  • registerViewProvider accepts componentTypes + reactComponentName
  • clearViewProvider resets registration
  • Without registration, configuration builder skips setViewProvider (no behavior change)

Replace componentTypes[] + reactComponentName with a componentMap
Record<string, string> so each SDK component type maps to its own
React Native component name.
Bridges the native SDK view customization to React Native via RCTRootView.
- BridgeViewProvider: canHandle() checks pre-registered types, view() renders RCTRootView in SwiftUI
- registerViewProvider/clearViewProvider native methods exposed to JS
- ViewProvider passed to AgentforceClient init when registered
Replace Set<String> + single reactComponentName with a [String: String]
dictionary mapping each component definition to its own React component.
canHandle() checks map keys, view() looks up the component name per type.
@asikora-sf asikora-sf force-pushed the stack/viewprovider/03-android-viewprovider-bridge branch from bd47ecd to add211f Compare March 5, 2026 22:30
RCTRootView embedded in UIViewRepresentable was getting zero size
because SwiftUI had no sizing information. Set sizeFlexibility and
implement sizeThatFits so the React content measures correctly.
Bridges the native SDK view customization to React Native via ReactRootView.
- BridgeViewProvider: canHandle() checks pre-registered types, GetView() renders ReactRootView in Compose
- registerViewProvider/clearViewProvider React methods exposed to JS
- ViewProvider passed to AgentforceConfiguration builder when registered
Change BridgeViewProvider from N:1 (multiple types → one component) to
1:1 mapping (each type → its own React component name). The register()
method now accepts a Map<String, String> and GetView() looks up the
per-type component name from the map.

Also update registerViewProvider in AgentforceModule to read componentMap
from the ReadableMap instead of componentTypes array + reactComponentName.
@asikora-sf asikora-sf force-pushed the stack/viewprovider/03-android-viewprovider-bridge branch from add211f to 47ed555 Compare March 5, 2026 23:25
@asikora-sf
Copy link
Contributor Author

@CCX-Wu I had to do some sizing work in the second PR for intrinsic sizing on iOS, may need some Android work as well if there's similar issues.

Copy link
Contributor

@CCX-Wu CCX-Wu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants