|
| 1 | +namespace React.Android.Widget |
| 2 | + |
| 3 | +open Android.Content |
| 4 | +open Android.Content.Res |
| 5 | +open Android.Graphics |
| 6 | +open Android.Support.V7.Widget |
| 7 | +open Android.Views |
| 8 | +open Android.Widget |
| 9 | +open React |
| 10 | +open React.Android |
| 11 | +open React.Android.Views |
| 12 | +open System |
| 13 | + |
| 14 | +type IEditTextProps = |
| 15 | + inherit ITextViewProps |
| 16 | + |
| 17 | +type EditTextProps = |
| 18 | + { |
| 19 | + // View Props |
| 20 | + accessibilityLiveRegion: int |
| 21 | + alpha: float32 |
| 22 | + backgroundColor: Color |
| 23 | + backgroundTintMode: PorterDuff.Mode |
| 24 | + clickable: bool |
| 25 | + contentDescription: string |
| 26 | + contextClickable: bool |
| 27 | + elevation: Single |
| 28 | + enabled: bool |
| 29 | + filterTouchesWhenObscured: bool |
| 30 | + focusable: bool |
| 31 | + focusableInTouchMode: bool |
| 32 | + hapticFeedbackEnabled: bool |
| 33 | + horizontalFadingEdgeEnabled: bool |
| 34 | + horizontalScrollBarEnabled: bool |
| 35 | + id: int |
| 36 | + layoutParameters: ViewGroup.LayoutParams |
| 37 | + onClick: Func<unit, unit> |
| 38 | + onCreateContextMenu: Func<IContextMenu, IContextMenuContextMenuInfo, unit> |
| 39 | + onDrag: Func<DragEvent, bool> |
| 40 | + onGenericMotion: Func<MotionEvent, bool> |
| 41 | + onHover: Func<MotionEvent, bool> |
| 42 | + onKey: Func<Keycode, KeyEvent, bool> |
| 43 | + onLongClick: Func<unit, bool> |
| 44 | + onSystemUiVisibilityChange: Func<StatusBarVisibility, unit> |
| 45 | + onTouch: Func<MotionEvent, bool> |
| 46 | + padding: Padding |
| 47 | + pivot: Pivot |
| 48 | + requestFocus: IObservable<unit> |
| 49 | + scrollBarSize: int |
| 50 | + scrollBarStyle: ScrollbarStyles |
| 51 | + selected: bool |
| 52 | + soundEffectsEnabled: bool |
| 53 | + systemUiVisibility: StatusBarVisibility |
| 54 | + textAlignment: TextAlignment |
| 55 | + textDirection: TextDirection |
| 56 | + transitionName: string |
| 57 | + translation: Translation |
| 58 | + verticalFadingEdgeEnabled: bool |
| 59 | + verticalScrollBarEnabled: bool |
| 60 | + verticalScrollbarPosition: ScrollbarPosition |
| 61 | + visibility: ViewStates |
| 62 | + |
| 63 | + // TextView Props |
| 64 | + text: string |
| 65 | + } |
| 66 | + |
| 67 | + interface IEditTextProps with |
| 68 | + // View Props |
| 69 | + member this.AccessibilityLiveRegion = this.accessibilityLiveRegion |
| 70 | + member this.Alpha = this.alpha |
| 71 | + member this.BackgroundColor = this.backgroundColor |
| 72 | + member this.BackgroundTintMode = this.backgroundTintMode |
| 73 | + member this.Clickable = this.clickable |
| 74 | + member this.ContentDescription = this.contentDescription |
| 75 | + member this.ContextClickable = this.contextClickable |
| 76 | + member this.Elevation = this.elevation |
| 77 | + member this.Enabled = this.enabled |
| 78 | + member this.FilterTouchesWhenObscured = this.filterTouchesWhenObscured |
| 79 | + member this.Focusable = this.focusable |
| 80 | + member this.FocusableInTouchMode = this.focusableInTouchMode |
| 81 | + member this.HapticFeedbackEnabled = this.hapticFeedbackEnabled |
| 82 | + member this.HorizontalFadingEdgeEnabled = this.horizontalFadingEdgeEnabled |
| 83 | + member this.HorizontalScrollBarEnabled = this.horizontalScrollBarEnabled |
| 84 | + member this.Id = this.id |
| 85 | + member this.LayoutParameters = this.layoutParameters |
| 86 | + member this.OnClick = this.onClick |
| 87 | + member this.OnCreateContextMenu = this.onCreateContextMenu |
| 88 | + member this.OnDrag = this.onDrag |
| 89 | + member this.OnGenericMotion = this.onGenericMotion |
| 90 | + member this.OnHover = this.onHover |
| 91 | + member this.OnKey = this.onKey |
| 92 | + member this.OnLongClick = this.onLongClick |
| 93 | + member this.OnSystemUiVisibilityChange = this.onSystemUiVisibilityChange |
| 94 | + member this.OnTouch = this.onTouch |
| 95 | + member this.Padding = this.padding |
| 96 | + member this.Pivot = this.pivot |
| 97 | + member this.RequestFocus = this.requestFocus |
| 98 | + member this.ScrollBarSize = this.scrollBarSize |
| 99 | + member this.ScrollBarStyle = this.scrollBarStyle |
| 100 | + member this.Selected = this.selected |
| 101 | + member this.SoundEffectsEnabled = this.soundEffectsEnabled |
| 102 | + member this.SystemUiVisibility = this.systemUiVisibility |
| 103 | + member this.TextAlignment = this.textAlignment |
| 104 | + member this.TextDirection = this.textDirection |
| 105 | + member this.TransitionName = this.transitionName |
| 106 | + member this.Translation = this.translation |
| 107 | + member this.VerticalFadingEdgeEnabled = this.verticalFadingEdgeEnabled |
| 108 | + member this.VerticalScrollBarEnabled = this.verticalScrollBarEnabled |
| 109 | + member this.VerticalScrollbarPosition = this.verticalScrollbarPosition |
| 110 | + member this.Visibility = this.visibility |
| 111 | + |
| 112 | + // TextView Props |
| 113 | + member this.Text = this.text |
| 114 | + |
| 115 | +[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] |
| 116 | +module private EditTextProps = |
| 117 | + let internal defaultProps = { |
| 118 | + // View Props |
| 119 | + accessibilityLiveRegion = TextViewProps.Default.accessibilityLiveRegion |
| 120 | + alpha = TextViewProps.Default.alpha |
| 121 | + backgroundColor = TextViewProps.Default.backgroundColor |
| 122 | + backgroundTintMode = TextViewProps.Default.backgroundTintMode |
| 123 | + clickable = TextViewProps.Default.clickable |
| 124 | + contentDescription = TextViewProps.Default.contentDescription |
| 125 | + contextClickable = TextViewProps.Default.contextClickable |
| 126 | + elevation = TextViewProps.Default.elevation |
| 127 | + enabled = TextViewProps.Default.enabled |
| 128 | + filterTouchesWhenObscured = TextViewProps.Default.filterTouchesWhenObscured |
| 129 | + focusable = TextViewProps.Default.focusable |
| 130 | + focusableInTouchMode = TextViewProps.Default.focusableInTouchMode |
| 131 | + hapticFeedbackEnabled = TextViewProps.Default.hapticFeedbackEnabled |
| 132 | + horizontalFadingEdgeEnabled = TextViewProps.Default.horizontalFadingEdgeEnabled |
| 133 | + horizontalScrollBarEnabled = TextViewProps.Default.horizontalScrollBarEnabled |
| 134 | + id = TextViewProps.Default.id |
| 135 | + layoutParameters = TextViewProps.Default.layoutParameters |
| 136 | + onClick = TextViewProps.Default.onClick |
| 137 | + onCreateContextMenu = TextViewProps.Default.onCreateContextMenu |
| 138 | + onDrag = TextViewProps.Default.onDrag |
| 139 | + onGenericMotion = TextViewProps.Default.onGenericMotion |
| 140 | + onHover = TextViewProps.Default.onHover |
| 141 | + onKey = TextViewProps.Default.onKey |
| 142 | + onLongClick = TextViewProps.Default.onLongClick |
| 143 | + onSystemUiVisibilityChange = TextViewProps.Default.onSystemUiVisibilityChange |
| 144 | + onTouch = TextViewProps.Default.onTouch |
| 145 | + padding = TextViewProps.Default.padding |
| 146 | + pivot = TextViewProps.Default.pivot |
| 147 | + requestFocus = TextViewProps.Default.requestFocus |
| 148 | + scrollBarSize = TextViewProps.Default.scrollBarSize |
| 149 | + scrollBarStyle = TextViewProps.Default.scrollBarStyle |
| 150 | + selected = TextViewProps.Default.selected |
| 151 | + soundEffectsEnabled = TextViewProps.Default.soundEffectsEnabled |
| 152 | + systemUiVisibility = TextViewProps.Default.systemUiVisibility |
| 153 | + textAlignment = TextViewProps.Default.textAlignment |
| 154 | + textDirection = TextViewProps.Default.textDirection |
| 155 | + transitionName = TextViewProps.Default.transitionName |
| 156 | + translation = TextViewProps.Default.translation |
| 157 | + verticalFadingEdgeEnabled = TextViewProps.Default.verticalFadingEdgeEnabled |
| 158 | + verticalScrollBarEnabled = TextViewProps.Default.verticalScrollBarEnabled |
| 159 | + verticalScrollbarPosition = TextViewProps.Default.verticalScrollbarPosition |
| 160 | + visibility = TextViewProps.Default.visibility |
| 161 | + |
| 162 | + // TextView Props |
| 163 | + text = "" |
| 164 | + } |
| 165 | + |
| 166 | +type EditTextProps with |
| 167 | + static member Default = EditTextProps.defaultProps |
| 168 | + |
| 169 | +[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] |
| 170 | +module EditText = |
| 171 | + let private name = typeof<AppCompatEditText>.Name |
| 172 | + |
| 173 | + let setProps (onError: Exception -> unit) (view: EditText) (props: IEditTextProps) = |
| 174 | + // FIXME: hack |
| 175 | + view.SetTextColor Color.Blue |
| 176 | + TextView.setProps onError view props |
| 177 | + |
| 178 | + let private createView (context: Context) (onError: Exception -> unit) = |
| 179 | + let viewProvider () = new AppCompatEditText(context) |
| 180 | + ReactView.createView name viewProvider (setProps onError) |
| 181 | + |
| 182 | + let viewProvider = (name, createView) |
| 183 | + |
| 184 | + let internal reactComponent = ReactComponent.makeLazy (fun (props: EditTextProps) -> ReactNativeElement { |
| 185 | + Name = name |
| 186 | + Props = props |
| 187 | + }) |
0 commit comments