mirror of
https://github.com/hanzoai/dev-desktop.git
synced 2026-11-20 23:08:14 +00:00
123 lines
4.1 KiB
Swift
123 lines
4.1 KiB
Swift
import ExpoModulesCore
|
|
|
|
public class HanzoReviewDiffModule: Module {
|
|
public func definition() -> ModuleDefinition {
|
|
Name("HanzoReviewDiffSurface")
|
|
|
|
View(HanzoReviewDiffView.self) {
|
|
Prop("contentInsetTop") { (view: HanzoReviewDiffView, value: Double) in
|
|
view.setContentInsetTop(CGFloat(value))
|
|
}
|
|
|
|
Prop("contentInsetBottom") { (view: HanzoReviewDiffView, value: Double) in
|
|
view.setContentInsetBottom(CGFloat(value))
|
|
}
|
|
|
|
Prop("tokensResetKey") { (view: HanzoReviewDiffView, tokensResetKey: String) in
|
|
view.setTokensResetKey(tokensResetKey)
|
|
}
|
|
|
|
Prop("contentResetKey") { (view: HanzoReviewDiffView, contentResetKey: String) in
|
|
view.setContentResetKey(contentResetKey)
|
|
}
|
|
|
|
Prop("collapsedFileIdsJson") { (view: HanzoReviewDiffView, collapsedFileIdsJson: String) in
|
|
view.setCollapsedFileIdsJson(collapsedFileIdsJson)
|
|
}
|
|
|
|
Prop("viewedFileIdsJson") { (view: HanzoReviewDiffView, viewedFileIdsJson: String) in
|
|
view.setViewedFileIdsJson(viewedFileIdsJson)
|
|
}
|
|
|
|
Prop("selectedRowIdsJson") { (view: HanzoReviewDiffView, selectedRowIdsJson: String) in
|
|
view.setSelectedRowIdsJson(selectedRowIdsJson)
|
|
}
|
|
|
|
Prop("collapsedCommentIdsJson") { (view: HanzoReviewDiffView, collapsedCommentIdsJson: String) in
|
|
view.setCollapsedCommentIdsJson(collapsedCommentIdsJson)
|
|
}
|
|
|
|
Prop("appearanceScheme") { (view: HanzoReviewDiffView, appearanceScheme: String) in
|
|
view.setAppearanceScheme(appearanceScheme)
|
|
}
|
|
|
|
Prop("themeJson") { (view: HanzoReviewDiffView, themeJson: String) in
|
|
view.setThemeJson(themeJson)
|
|
}
|
|
|
|
Prop("styleJson") { (view: HanzoReviewDiffView, styleJson: String) in
|
|
view.setStyleJson(styleJson)
|
|
}
|
|
|
|
Prop("rowHeight") { (view: HanzoReviewDiffView, rowHeight: Double) in
|
|
view.setRowHeight(CGFloat(rowHeight))
|
|
}
|
|
|
|
Prop("contentWidth") { (view: HanzoReviewDiffView, contentWidth: Double) in
|
|
view.setContentWidth(CGFloat(contentWidth))
|
|
}
|
|
|
|
Prop("initialRowIndex") { (view: HanzoReviewDiffView, initialRowIndex: Double) in
|
|
view.setInitialRowIndex(initialRowIndex)
|
|
}
|
|
|
|
Prop("initialFileId") { (view: HanzoReviewDiffView, fileId: String) in
|
|
view.setInitialFileId(fileId)
|
|
}
|
|
|
|
Prop("scrollEnabled") { (view: HanzoReviewDiffView, enabled: Bool) in
|
|
view.setScrollEnabled(enabled)
|
|
}
|
|
|
|
Prop("bounces") { (view: HanzoReviewDiffView, bounces: Bool) in
|
|
view.setBounces(bounces)
|
|
}
|
|
|
|
Prop("refreshEnabled") { (view: HanzoReviewDiffView, enabled: Bool) in
|
|
view.setRefreshEnabled(enabled)
|
|
}
|
|
|
|
Prop("refreshing") { (view: HanzoReviewDiffView, refreshing: Bool) in
|
|
view.setRefreshing(refreshing)
|
|
}
|
|
|
|
Events(
|
|
"onDebug",
|
|
"onVisibleFileChange",
|
|
"onToggleFile",
|
|
"onToggleViewedFile",
|
|
"onPressLine",
|
|
"onToggleComment",
|
|
"onPressNotice",
|
|
"onPullToRefresh"
|
|
)
|
|
|
|
AsyncFunction("scrollToFile") { (view: HanzoReviewDiffView, fileId: String, animated: Bool) in
|
|
view.scrollToFile(fileId, animated: animated)
|
|
}
|
|
|
|
AsyncFunction("scrollToTop") { (view: HanzoReviewDiffView, animated: Bool) in
|
|
view.scrollToTop(animated: animated)
|
|
}
|
|
|
|
// Large, frequently changing JSON values cannot be regular Fabric props. Expo's
|
|
// prop adapter compares strings on the main thread before invoking a setter, which
|
|
// makes a syntax-token patch capable of blocking a frame by itself.
|
|
AsyncFunction("setRowsJson") { (view: HanzoReviewDiffView, rowsJson: String, contentResetKey: String) in
|
|
view.setContentResetKey(contentResetKey)
|
|
view.setRowsJson(rowsJson)
|
|
}
|
|
|
|
AsyncFunction("setTokensJson") { (view: HanzoReviewDiffView, tokensJson: String) in
|
|
view.setTokensJson(tokensJson)
|
|
}
|
|
|
|
AsyncFunction("setTokensPatchJson") { (view: HanzoReviewDiffView, tokensPatchJson: String, promise: Promise) in
|
|
view.setTokensPatchJson(tokensPatchJson) { accepted in
|
|
promise.resolve(accepted)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|