Skip to content
This repository was archived by the owner on Apr 19, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/ReactNative/Components/Button.purs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@ import ReactNative.Unsafe.ApplyProps (unsafeApplyProps)
import ReactNative.Unsafe.Components (buttonU)
import Prelude

type ButtonProps r = {
onPress :: EventHandler TouchEvent
, title :: String --TODO: check this
| r
}

type ButtonPropsO = (
accessibilityLabel :: String
, color :: Color
, disabled :: Boolean
, onPress :: EventHandler TouchEvent
, title :: String
, testID :: String
, ios :: {
hasTVPreferredFocus :: Boolean --TODO: Apple Tv only
}
)

-- | Create a button with the given `title` and `onPress` handler
Expand All @@ -28,5 +36,5 @@ button_ :: String -> ReactElement
button_ title = buttonU {title}

-- | Create a button with the given props and `title`
button' :: forall o. Optional o ButtonPropsO => {|o} -> ReactElement
button' :: forall o. Optional o ButtonPropsO => ButtonProps o -> ReactElement
button' = buttonU <<< unsafeApplyProps
76 changes: 76 additions & 0 deletions src/ReactNative/Components/DrawerLayoutAndroid.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
module ReactNative.Components.DrawerLayoutAndroid (
DrawerPosition,
KeyboardDismissMode,
DrawerLockMode,
drawerPosition,
keyboardDismissMode,
drawerLockMode
)
where

import Prelude
import ReactNative.Optional (class Optional)
import React (ReactElement)
import ReactNative.Components.View (ViewPropsEx)
import ReactNative.Events (UnitEventHandler)
import ReactNative.PropTypes.Color (Color)
import ReactNative.Unsafe.ApplyProps (unsafeApplyProps)
import ReactNative.Unsafe.Components (drawerLayoutAndroidU)


type DrawerLayoutAndroid r = {
renderNavigationView :: UnitEventHandler
| r
}

type DrawerLayoutAndroidO = ViewPropsEx (
onDrawerClose :: UnitEventHandler
, drawerPosition :: DrawerPosition
, drawerWidth :: Number
, keyboardDismissMode :: KeyboardDismissMode
, drawerLockMode :: DrawerLockMode
, onDrawerOpen :: UnitEventHandler
, onDrawerSlide :: UnitEventHandler
-- , onDrawerStateChanged :: Function --TODO: need to do this
, drawerBackgroundColor :: Color
, statusBarBackgroundColor :: Color
) () ()


drawerLayoutAndroid :: forall o
. Optional o DrawerLayoutAndroidO
=> DrawerLayoutAndroid o -> Array ReactElement -> ReactElement
drawerLayoutAndroid = drawerLayoutAndroidU <<< unsafeApplyProps

newtype DrawerPosition = DrawerPosition String
drawerPosition :: {
"DrawerConsts.DrawerPosition.Left" :: DrawerPosition
, "DrawerConsts.DrawerPosition.Right" :: DrawerPosition
}
drawerPosition = {
"DrawerConsts.DrawerPosition.Left": DrawerPosition "DrawerConsts.DrawerPosition.Left"
, "DrawerConsts.DrawerPosition.Right": DrawerPosition "DrawerConsts.DrawerPosition.Right"
}

newtype KeyboardDismissMode = KeyboardDismissMode String
keyboardDismissMode :: {
none :: KeyboardDismissMode
, onDrag :: KeyboardDismissMode
}
keyboardDismissMode = {
none: KeyboardDismissMode "none"
, onDrag: KeyboardDismissMode "onDrag"
}

newtype DrawerLockMode = DrawerLockMode String
drawerLockMode :: {
unlocked :: DrawerLockMode
, lockedClosed :: DrawerLockMode
, lockedOpen :: DrawerLockMode
}
drawerLockMode = {
unlocked: DrawerLockMode "unlocked"
, lockedClosed: DrawerLockMode "lockedClosed"
, lockedOpen: DrawerLockMode "lockedCpen"
}

57 changes: 57 additions & 0 deletions src/ReactNative/Components/FlatList.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module ReactNative.Components.FlatList (
flatList
)
where

import Prelude

import React (ReactElement)
import ReactNative.Components.ScrollView (ScrollViewPropsEx)
import ReactNative.Optional (class Optional)
import ReactNative.Unsafe.ApplyProps (unsafeApplyProps)
import ReactNative.Unsafe.Components (flatListU)
import Type.Data.Boolean (kind Boolean)


type FlatListProps r = {
-- renderItem :: Function
"data" :: Array String --TODO: check this
| r
}

type FlatListPropsO = ScrollViewPropsEx (
-- props :: VirtualizedList --TODO: change that
-- , ItemSeparatorComponent :: Component
-- , ListEmptyComponent :: component, function, element
-- , ListFooterComponent :: component, function, element
-- , ListHeaderComponent :: component, function, element
-- , columnWrapperStyle :: style object
-- , extraData :: any
-- getItemLayout :: Function
horizontal :: Boolean
, initialNumToRender :: Number
, initialScrollIndex :: Number
, inverted :: Boolean
-- , keyExtractor :: Function
, numColumns :: Number
-- , onEndReached :: Function
, onEndReachedThreshold :: Number
-- , onRefresh :: Function
-- , onViewableItemsChanged :: Function
, legacyImplementation :: Boolean
, refreshing :: Boolean
, removeClippedSubviews :: Boolean
-- , viewabilityConfig :: ViewabilityConfig
-- , viewabilityConfigCallbackPairs :: array of ViewabilityConfigCallbackPair
, android :: {
progressViewOffset :: Number
}
)
-- (
-- progressViewOffset :: Number
-- ) ()

flatList :: forall o
. Optional o FlatListPropsO
=> FlatListProps o -> Array ReactElement -> ReactElement
flatList = flatListU <<< unsafeApplyProps
14 changes: 6 additions & 8 deletions src/ReactNative/Components/Image.purs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ import ReactNative.Styles (ResizeMode, Styles)
import ReactNative.Unsafe.ApplyProps (unsafeApplyProps)
import ReactNative.Unsafe.Components (imageU)

type ImageProps r = {
source :: ImageSource
| r
}

type ImagePropsO = BaseProps (
style :: Styles
, onError :: UnitEventHandler
Expand All @@ -27,15 +22,18 @@ type ImagePropsO = BaseProps (
, onLoadEnd :: UnitEventHandler
, onLoadStart :: UnitEventHandler
, resizeMode :: ResizeMode
, loadingIndicatorSource :: Array ImageSource --TODO: Number
, source :: ImageSource --TODO: check this
, android :: {
resizeMethod :: ResizeMethod
, fadeDuration :: Number
}
, ios :: {
accessibilityLabel :: String
, accessible :: Boolean
, blurRadius :: Number
, capInsets :: {top::Number, left::Number, bottom::Number, right::Number}
, defaultSource :: ImageSource
, defaultSource :: ImageSource --TODO: check this
, onPartialLoad :: UnitEventHandler
, onProgress :: EventHandler ImageProgressEvent
}
Expand All @@ -52,7 +50,7 @@ backgroundImage style source = imageU {style, source}
-- | Background images are simply normal images with children overalayed ontop
backgroundImage' :: forall o
. Optional o ImagePropsO
=> ImageProps o -> Array ReactElement -> ReactElement
=> {|o} -> Array ReactElement -> ReactElement
backgroundImage' = imageU <<< unsafeApplyProps

-- | Create an Image from source only
Expand All @@ -66,7 +64,7 @@ image style source = imageU {style, source} []
-- | Create an Image with props and source
image' :: forall o
. Optional o ImagePropsO
=> ImageProps o -> ReactElement
=> {|o} -> ReactElement
image' p = imageU (unsafeApplyProps p) []

newtype ResizeMethod = ResizeMethod String
Expand Down
24 changes: 24 additions & 0 deletions src/ReactNative/Components/ImageBackground.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module ReactNative.Components.ImageBackground (
imageBackground
) where

import Prelude

import React (ReactElement)
import ReactNative.Optional (class Optional)
import ReactNative.Styles (Styles)
import ReactNative.Unsafe.ApplyProps (unsafeApplyProps)
import ReactNative.Unsafe.Components (imageBackgroundU)


type ImageBackgroundO = ( style :: Styles )
-- , style :: view styles
-- , imageStyle :: image styles
-- , imageRef :: Ref
-- ) () ()


imageBackground :: forall o
. Optional o ImageBackgroundO
=> {|o} -> Array ReactElement -> ReactElement
imageBackground = imageBackgroundU <<< unsafeApplyProps
24 changes: 24 additions & 0 deletions src/ReactNative/Components/InputAccessoryView.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module ReactNative.Components.InputAccessoryView (
inputAccessoryView
)
where

import Prelude

import React (ReactElement)
import ReactNative.Optional (class Optional)
import ReactNative.PropTypes.Color (Color)
import ReactNative.Styles (Styles)
import ReactNative.Unsafe.ApplyProps (unsafeApplyProps)
import ReactNative.Unsafe.Components (inputAccessoryViewU)

type InputAccessoryViewO =
( backgroundColor :: Color
, nativeID :: String
, style :: Styles
)

inputAccessoryView :: forall o
. Optional o InputAccessoryViewO
=> {|o} -> Array ReactElement -> ReactElement
inputAccessoryView = inputAccessoryViewU <<< unsafeApplyProps
41 changes: 41 additions & 0 deletions src/ReactNative/Components/KeyboardAvoidingView.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module ReactNative.Components.KeyboardAvoidingView (
BehaviorType, behaviorType, keyboardAvoidingView
)
where

import Prelude

import React (ReactElement)
import ReactNative.Components.View (ViewPropsEx)
import ReactNative.Optional (class Optional)
import ReactNative.Styles (Styles)
import ReactNative.Unsafe.ApplyProps (unsafeApplyProps)
import ReactNative.Unsafe.Components (keyboardAvoidingViewU)
import Type.Data.Boolean (kind Boolean)

type KeyboardAvoidingViewPropsO = ViewPropsEx (
keyboardVerticalOffset :: Number
, behavior :: BehaviorType
-- , contentContainerStyle :: View.style
, enabled :: Boolean
) () ()


keyboardAvoidingView :: forall o
. Optional o KeyboardAvoidingViewPropsO
=> {|o} -> Array ReactElement -> ReactElement
keyboardAvoidingView = keyboardAvoidingViewU <<< unsafeApplyProps


newtype BehaviorType = BehaviorType String
behaviorType :: {
height :: BehaviorType
, position :: BehaviorType
, padding :: BehaviorType
}
behaviorType = {
height: BehaviorType "height"
, position: BehaviorType "position"
, padding: BehaviorType "padding"
}

15 changes: 9 additions & 6 deletions src/ReactNative/Components/ListView.purs
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,28 @@ foreign import unsafeMerge :: forall a b c. a -> b -> c
type SectionId = String
type RowId = String

type ListViewProps a section blob r = {
type ListViewProps a section blob r = { --TODO: Fully check this component
dataSource :: ListViewDataSource' blob a section
, initialListSize :: Int
, onEndReachedThreshold :: Int
, pageSize :: Int
, renderRow :: RowRenderer a
, renderScrollComponent :: forall props. props -> ReactElement
, scrollRenderAheadDistance :: Int
, stickyHeaderIndices :: Array Number
| r
}

type ListViewPropsO section = ScrollViewPropsEx (
enableEmptySections :: Boolean
, initialListSize :: Int
, onChangeVisibleRows :: EventHandler2 RowMap RowMap
, onEndReached :: EventHandler (Nullable ScrollEvent)
, onEndReachedThreshold :: Int
, pageSize :: Int
, renderFooter :: Unit -> ReactElement
, renderHeader :: Unit -> ReactElement
, renderScrollComponent :: forall props. props -> ReactElement
, renderSectionHeader :: SectionRenderer section
, renderSeparator :: Fn3 SectionId RowId Boolean ReactElement
, scrollRenderAheadDistance :: Int
, removeClippedSubviews :: Boolean
, stickySectionHeadersEnabled :: Boolean
)

-- | Create a list view with a data source and a simple row rendering function
Expand Down
17 changes: 17 additions & 0 deletions src/ReactNative/Components/MaskedViewIOS.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module ReactNative.Components.MaskedViewIOS (
maskedViewIOS'
)
where

import Prelude

import React (ReactElement)
import ReactNative.Components.View (ViewPropsEx)
import ReactNative.Unsafe.ApplyProps (unsafeApplyProps)
import ReactNative.Unsafe.Components (maskedViewIOSU)

type MaskedViewIOS = ViewPropsEx () () () --(-- maskElement :: element
--) () ()

maskedViewIOS' :: {|MaskedViewIOS} -> Array ReactElement -> ReactElement
maskedViewIOS' = maskedViewIOSU <<< unsafeApplyProps
24 changes: 24 additions & 0 deletions src/ReactNative/Components/PickerIOS.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module ReactNative.Components.PickerIOS (
pickerIOS
)
where

import Prelude

import React (ReactElement)
import ReactNative.Optional (class Optional)
import ReactNative.Components.View (ViewPropsEx)
import ReactNative.Events (UnitEventHandler)
import ReactNative.Unsafe.ApplyProps (unsafeApplyProps)
import ReactNative.Unsafe.Components (pickerIOSU)

type PickerIOSO = ViewPropsEx (
-- itemStyle :: text styles
onValueChange :: UnitEventHandler
-- , selectedValue :: any
) () ()

pickerIOS :: forall o
. Optional o PickerIOSO
=> {|o} -> Array ReactElement -> ReactElement
pickerIOS = pickerIOSU <<< unsafeApplyProps
Loading