57 lines · 1.8 KB · Swift
RawDownload
import ExpoModulesCoreimport Security public final class T3NativeControlsModule: Module {  public func definition() -> ModuleDefinition {    Name("T3NativeControls")     Function("getShowcasePairingUrl") {      let arguments = ProcessInfo.processInfo.arguments      guard        let flagIndex = arguments.firstIndex(of: "--showcasePairingUrl"),        arguments.indices.contains(flagIndex + 1)      else {        return nil as String?      }      return arguments[flagIndex + 1]    }     Function("getShowcaseScene") { () -> String? in      let scenePath = NSHomeDirectory() + "/Library/Caches/T3ShowcaseScene"      if let storedScene = try? String(contentsOfFile: scenePath, encoding: .utf8)        .trimmingCharacters(in: .whitespacesAndNewlines), !storedScene.isEmpty {        return storedScene      }      let arguments = ProcessInfo.processInfo.arguments      guard        let flagIndex = arguments.firstIndex(of: "--showcaseScene"),        arguments.indices.contains(flagIndex + 1)      else {        return nil as String?      }      return arguments[flagIndex + 1]    }     Function("prepareShowcaseCapture") {      for itemClass in [kSecClassGenericPassword, kSecClassInternetPassword] {        SecItemDelete([kSecClass as String: itemClass] as CFDictionary)      }    }     Function("markShowcaseReady") { (scene: String) in      let readyPath = NSHomeDirectory() + "/Library/Caches/T3ShowcaseReadyScene"      try? scene.write(toFile: readyPath, atomically: true, encoding: .utf8)    }     View(T3HeaderButtonView.self) {      Prop("label") { (view: T3HeaderButtonView, label: String) in        view.setLabel(label)      }      Prop("systemImage") { (view: T3HeaderButtonView, systemImage: String) in        view.setSystemImage(systemImage)      }       Events("onTriggered")    }  }}