-
Notifications
You must be signed in to change notification settings - Fork 25
/
Text.purs
69 lines (58 loc) · 1.89 KB
/
Text.purs
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
-- | See [Text](https://facebook.github.io/react-native/docs/text.html)
module ReactNative.Components.Text (
TextProps, textElem, text', text_, text
, texts', texts, texts_
, EllipsizeMode, ellipsizeMode
) where
import React (ReactElement)
import ReactNative.Unsafe.ApplyProps (unsafeApplyProps)
import ReactNative.Events (LayoutEvent, TouchEvent, EventHandler)
import ReactNative.PropTypes (Prop)
import ReactNative.Styles (Styles)
import ReactNative.Unsafe.Components (textU)
import Unsafe.Coerce (unsafeCoerce)
type TextProps eff = {
style :: Styles
, key :: String
, testID :: String
, numberOfLines :: Int
, accessible :: Boolean
, onLayout :: EventHandler eff LayoutEvent
, onPress :: EventHandler eff TouchEvent
, onLongPress :: EventHandler eff TouchEvent
, selectable :: Boolean
, ellipsizeMode :: EllipsizeMode
, ios:: Prop {
adjustsFontSizeToFit :: Boolean
, allowFontScaling :: Boolean
, minimumFontScale :: Number
, suppressHilighting :: Boolean
}
}
textElem :: String -> ReactElement
textElem = unsafeCoerce
text' :: forall eff. Prop (TextProps eff) -> String -> ReactElement
text' p s = textU (unsafeApplyProps {} p) [textElem s]
text :: Styles -> String -> ReactElement
text style s = textU {style} [textElem s]
text_ :: String -> ReactElement
text_ s = textU {} [textElem s]
texts :: Styles -> Array ReactElement -> ReactElement
texts style = textU {style}
texts_ :: Array ReactElement -> ReactElement
texts_ = textU {}
texts' :: forall eff. Prop (TextProps eff) -> Array ReactElement -> ReactElement
texts' p = textU (unsafeApplyProps {} p)
newtype EllipsizeMode = EllipsizeMode String
ellipsizeMode :: {
head :: EllipsizeMode
, middle :: EllipsizeMode
, tail :: EllipsizeMode
, clip :: EllipsizeMode
}
ellipsizeMode = {
head: EllipsizeMode "head"
, middle: EllipsizeMode "middle"
, tail: EllipsizeMode "tail"
, clip: EllipsizeMode "clip"
}