Files
bsky-social-app/modules/expo-selectable-text/ios/ExpoProTextModule.swift
T
2024-01-11 00:38:47 -08:00

27 lines
715 B
Swift

import ExpoModulesCore
public class ExpoProTextModule: Module {
public func definition() -> ModuleDefinition {
Name("ExpoProText")
View(ExpoProTextView.self) {
Events("onTextPress", "onTextLongPress")
Prop("segments") { (view: ExpoProTextView, prop: String) in
// Convert the JSON to segments
if let data = prop.data(using: .utf8) {
print("yes")
if let segments = try? JSONDecoder().decode(TextSegments.self, from: data) {
print("yes2")
view.segments = segments.segments
}
}
}
Prop("selectable") { (view: ExpoProTextView, prop: Bool) in
view.textView.isSelectable = prop
}
}
}
}