about summary refs log tree commit diff
path: root/modules/bottom-sheet/ios/BottomSheetModule.swift
blob: 579608e75bf44262e104202a5de11ef9f7571840 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import ExpoModulesCore

public class BottomSheetModule: Module {
  public func definition() -> ModuleDefinition {
    Name("BottomSheet")

    AsyncFunction("dismissAll") {
      SheetManager.shared.dismissAll()
    }

    View(SheetView.self) {
      Events([
        "onAttemptDismiss",
        "onSnapPointChange",
        "onStateChange"
      ])

      AsyncFunction("dismiss") { (view: SheetView) in
        view.dismiss()
      }

      AsyncFunction("updateLayout") { (view: SheetView) in
        view.updateLayout()
      }

      Prop("cornerRadius") { (view: SheetView, prop: Float) in
        view.cornerRadius = CGFloat(prop)
      }

      Prop("minHeight") { (view: SheetView, prop: Double) in
        view.minHeight = prop
      }

      Prop("maxHeight") { (view: SheetView, prop: Double) in
        view.maxHeight = prop
      }

      Prop("preventDismiss") { (view: SheetView, prop: Bool) in
        view.preventDismiss = prop
      }

      Prop("preventExpansion") { (view: SheetView, prop: Bool) in
        view.preventExpansion = prop
      }
    }
  }
}