| 1 | import ExpoModulesCore |
| 2 | |
| 3 | public class T3ReviewDiffModule: Module { |
| 4 | public func definition() -> ModuleDefinition { |
| 5 | Name("T3ReviewDiffSurface") |
| 6 | |
| 7 | View(T3ReviewDiffView.self) { |
| 8 | Prop("contentInsetTop") { (view: T3ReviewDiffView, value: Double) in |
| 9 | view.setContentInsetTop(CGFloat(value)) |
| 10 | } |
| 11 | |
| 12 | Prop("contentInsetBottom") { (view: T3ReviewDiffView, value: Double) in |
| 13 | view.setContentInsetBottom(CGFloat(value)) |
| 14 | } |
| 15 | |
| 16 | Prop("tokensResetKey") { (view: T3ReviewDiffView, tokensResetKey: String) in |
| 17 | view.setTokensResetKey(tokensResetKey) |
| 18 | } |
| 19 | |
| 20 | Prop("contentResetKey") { (view: T3ReviewDiffView, contentResetKey: String) in |
| 21 | view.setContentResetKey(contentResetKey) |
| 22 | } |
| 23 | |
| 24 | Prop("collapsedFileIdsJson") { (view: T3ReviewDiffView, collapsedFileIdsJson: String) in |
| 25 | view.setCollapsedFileIdsJson(collapsedFileIdsJson) |
| 26 | } |
| 27 | |
| 28 | Prop("viewedFileIdsJson") { (view: T3ReviewDiffView, viewedFileIdsJson: String) in |
| 29 | view.setViewedFileIdsJson(viewedFileIdsJson) |
| 30 | } |
| 31 | |
| 32 | Prop("selectedRowIdsJson") { (view: T3ReviewDiffView, selectedRowIdsJson: String) in |
| 33 | view.setSelectedRowIdsJson(selectedRowIdsJson) |
| 34 | } |
| 35 | |
| 36 | Prop("collapsedCommentIdsJson") { (view: T3ReviewDiffView, collapsedCommentIdsJson: String) in |
| 37 | view.setCollapsedCommentIdsJson(collapsedCommentIdsJson) |
| 38 | } |
| 39 | |
| 40 | Prop("appearanceScheme") { (view: T3ReviewDiffView, appearanceScheme: String) in |
| 41 | view.setAppearanceScheme(appearanceScheme) |
| 42 | } |
| 43 | |
| 44 | Prop("themeJson") { (view: T3ReviewDiffView, themeJson: String) in |
| 45 | view.setThemeJson(themeJson) |
| 46 | } |
| 47 | |
| 48 | Prop("styleJson") { (view: T3ReviewDiffView, styleJson: String) in |
| 49 | view.setStyleJson(styleJson) |
| 50 | } |
| 51 | |
| 52 | Prop("rowHeight") { (view: T3ReviewDiffView, rowHeight: Double) in |
| 53 | view.setRowHeight(CGFloat(rowHeight)) |
| 54 | } |
| 55 | |
| 56 | Prop("contentWidth") { (view: T3ReviewDiffView, contentWidth: Double) in |
| 57 | view.setContentWidth(CGFloat(contentWidth)) |
| 58 | } |
| 59 | |
| 60 | Prop("initialRowIndex") { (view: T3ReviewDiffView, initialRowIndex: Double) in |
| 61 | view.setInitialRowIndex(initialRowIndex) |
| 62 | } |
| 63 | |
| 64 | Prop("scrollEnabled") { (view: T3ReviewDiffView, enabled: Bool) in |
| 65 | view.setScrollEnabled(enabled) |
| 66 | } |
| 67 | |
| 68 | Prop("bounces") { (view: T3ReviewDiffView, bounces: Bool) in |
| 69 | view.setBounces(bounces) |
| 70 | } |
| 71 | |
| 72 | Prop("refreshEnabled") { (view: T3ReviewDiffView, enabled: Bool) in |
| 73 | view.setRefreshEnabled(enabled) |
| 74 | } |
| 75 | |
| 76 | Prop("refreshing") { (view: T3ReviewDiffView, refreshing: Bool) in |
| 77 | view.setRefreshing(refreshing) |
| 78 | } |
| 79 | |
| 80 | Events( |
| 81 | "onDebug", |
| 82 | "onVisibleFileChange", |
| 83 | "onToggleFile", |
| 84 | "onToggleViewedFile", |
| 85 | "onPressLine", |
| 86 | "onToggleComment", |
| 87 | "onPullToRefresh" |
| 88 | ) |
| 89 | |
| 90 | AsyncFunction("scrollToFile") { (view: T3ReviewDiffView, fileId: String, animated: Bool) in |
| 91 | view.scrollToFile(fileId, animated: animated) |
| 92 | } |
| 93 | |
| 94 | AsyncFunction("scrollToTop") { (view: T3ReviewDiffView, animated: Bool) in |
| 95 | view.scrollToTop(animated: animated) |
| 96 | } |
| 97 | |
| 98 | // Large, frequently changing JSON values cannot be regular Fabric props. Expo's |
| 99 | // prop adapter compares strings on the main thread before invoking a setter, which |
| 100 | // makes a syntax-token patch capable of blocking a frame by itself. |
| 101 | AsyncFunction("setRowsJson") { (view: T3ReviewDiffView, rowsJson: String) in |
| 102 | view.setRowsJson(rowsJson) |
| 103 | } |
| 104 | |
| 105 | AsyncFunction("setTokensJson") { (view: T3ReviewDiffView, tokensJson: String) in |
| 106 | view.setTokensJson(tokensJson) |
| 107 | } |
| 108 | |
| 109 | AsyncFunction("setTokensPatchJson") { (view: T3ReviewDiffView, tokensPatchJson: String) in |
| 110 | view.setTokensPatchJson(tokensPatchJson) |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | } |