@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
swift 122 lines 4.03 KB
Raw
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("initialFileId") { (view: T3ReviewDiffView, fileId: String) in
65 view.setInitialFileId(fileId)
66 }
67
68 Prop("scrollEnabled") { (view: T3ReviewDiffView, enabled: Bool) in
69 view.setScrollEnabled(enabled)
70 }
71
72 Prop("bounces") { (view: T3ReviewDiffView, bounces: Bool) in
73 view.setBounces(bounces)
74 }
75
76 Prop("refreshEnabled") { (view: T3ReviewDiffView, enabled: Bool) in
77 view.setRefreshEnabled(enabled)
78 }
79
80 Prop("refreshing") { (view: T3ReviewDiffView, refreshing: Bool) in
81 view.setRefreshing(refreshing)
82 }
83
84 Events(
85 "onDebug",
86 "onVisibleFileChange",
87 "onToggleFile",
88 "onToggleViewedFile",
89 "onPressLine",
90 "onToggleComment",
91 "onPressNotice",
92 "onPullToRefresh"
93 )
94
95 AsyncFunction("scrollToFile") { (view: T3ReviewDiffView, fileId: String, animated: Bool) in
96 view.scrollToFile(fileId, animated: animated)
97 }
98
99 AsyncFunction("scrollToTop") { (view: T3ReviewDiffView, animated: Bool) in
100 view.scrollToTop(animated: animated)
101 }
102
103 // Large, frequently changing JSON values cannot be regular Fabric props. Expo's
104 // prop adapter compares strings on the main thread before invoking a setter, which
105 // makes a syntax-token patch capable of blocking a frame by itself.
106 AsyncFunction("setRowsJson") { (view: T3ReviewDiffView, rowsJson: String, contentResetKey: String) in
107 view.setContentResetKey(contentResetKey)
108 view.setRowsJson(rowsJson)
109 }
110
111 AsyncFunction("setTokensJson") { (view: T3ReviewDiffView, tokensJson: String) in
112 view.setTokensJson(tokensJson)
113 }
114
115 AsyncFunction("setTokensPatchJson") { (view: T3ReviewDiffView, tokensPatchJson: String, promise: Promise) in
116 view.setTokensPatchJson(tokensPatchJson) { accepted in
117 promise.resolve(accepted)
118 }
119 }
120 }
121 }
122 }