-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20a1b4d
commit 95a3077
Showing
12 changed files
with
94 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 26 additions & 6 deletions
32
android/src/main/java/com/commandbarmodule/HelpHubViewManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,43 @@ | ||
package com.commandbarmodule | ||
|
||
import com.commandbar.android.CommandBarOptions | ||
import com.commandbar.android.HelpHubWebView | ||
import com.facebook.react.bridge.Arguments | ||
import com.facebook.react.bridge.Callback | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.bridge.ReadableMap | ||
import com.facebook.react.bridge.WritableMap | ||
import com.facebook.react.modules.core.DeviceEventManagerModule | ||
import com.facebook.react.uimanager.ReactStylesDiffMap | ||
import com.facebook.react.uimanager.SimpleViewManager | ||
import com.facebook.react.uimanager.ThemedReactContext | ||
import com.commandbar.android.HelpHubWebView | ||
import com.facebook.react.uimanager.ViewManager | ||
import com.facebook.react.uimanager.annotations.ReactProp | ||
|
||
class HelpHubViewManager(reactContext: ReactApplicationContext) : SimpleViewManager<HelpHubWebView>() { | ||
|
||
class HelpHubViewManager(var reactContext: ReactApplicationContext) : SimpleViewManager<HelpHubWebView>() { | ||
private lateinit var commandBarOptions: CommandBarOptions | ||
|
||
override fun getName(): String { | ||
return "HelpHubView" | ||
} | ||
|
||
@ReactProp(name = "orgId") | ||
fun setOrgId(view: HelpHubWebView, orgId: String) { | ||
view.setOrgId(orgId) | ||
@ReactProp(name = "options") | ||
fun setOptions(view: HelpHubWebView, options: ReadableMap) { | ||
this.commandBarOptions = CommandBarOptions(dictionary = options.toHashMap()) | ||
view.setOptions(this.commandBarOptions) | ||
view.setFallbackActionCallback { this.handleFallbackAction(it) } | ||
} | ||
|
||
fun handleFallbackAction(action: Map<String, Any>) { | ||
val payload: WritableMap = Arguments.makeNativeMap(action) | ||
|
||
this.reactContext | ||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java) | ||
.emit("onFallbackAction", payload) | ||
} | ||
|
||
override fun createViewInstance(reactContext: ThemedReactContext): HelpHubWebView { | ||
return HelpHubWebView(reactContext, null) | ||
return HelpHubWebView(reactContext) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import Foundation | ||
import WebKit | ||
import CommandBarIOS | ||
|
||
@objc(RNCommandBar) | ||
class RNCommandBar : NSObject { | ||
@objc | ||
func openHelpHub(_ orgId: NSString, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) -> Void { | ||
CommandBar.openHelpHub(orgId: orgId as String, resolve: nil, reject: nil) | ||
func openHelpHub(_ options: NSDictionary, onFallBackAction fallbackAction: RCTResponseSenderBlock? = nil) -> Void { | ||
let options = CommandBarOptions(dictionary: options as! [String : Any]) | ||
let commandbar = CommandBar(options: options) | ||
commandbar.openHelpHub(resolve: nil, reject: nil) | ||
resolve(true) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#import <React/RCTBridgeModule.h> | ||
#import <React/RCTViewManager.h> | ||
#import <React/RCTEventEmitter.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters