This project is to research what we can do to take advantage of using SwiftUI as a replacement for UIKit being the iOS native framework used by React Native to render user interfaces. Especially, it would make it possible to use React Native on other Apple platforms such as macOS, watchOS, tvOS and iOS widgets.
- Applying layout metrics calculated by Yoga from provided position-related styles
- Other styles
-
backgroundColor -
color -
opacity -
borderLeft(borderLeftWidthandborderLeftColor)
-
- Styles excluding these inherited from
View-
fontSize -
fontWeight -
fontStyle(onlyitalicso far) -
textAlign(nojustifysupport)
-
- Props
-
numberOfLinesprop -
ellipsizeModeprop-
head -
center -
tail -
clip(no such equivalent in SwiftUI, but it can be implemented the other way)
-
-
- React Native's button heavily depends on Touchables relying on responder events that might be tricky to reimplement, so we have our own
Buttoncomponent instead. - Events
-
onPress -
onActiveStateChange
-
- Styles inherited from
View - Props
-
placeholder -
value - partially
multiline, read more below
-
- Events
-
onChange -
onFocus -
onBlur -
onEndEditing
-
- SwiftUI's
TextFielddoesn't provide much functionalities yet. Under the hood it still usesUITextFieldfromUIKitso hopefully it will be improved soon. So far it isn't yet possible to:- Focus/blur on demand
- Change tappable area — the default area is very narrow and doesn't include given padding
- Get cursor position
- Read text selection
- For multiline input we can use
TextEditorhowever it doesn't meet our requirements even more as it doesn't support any events and placeholder text.
- Props
-
value - partially
trackColor(onlyfalsestate is supported by SwiftUI yet)
-
- Events
-
onChange
-
- A lot of properties known from
UIScrollVieware missing in SwiftUI, so we have our ownScrollViewcomponent. - There is no convenient way to get
onScrollevent other than just adding drag gesture. - Scroll to specified point within the view is not provided yet. However, as it let us scroll to a subview with specified ID, we can omit this limitation by rendering empty points filling the entire axis with an ID being its (X,Y) position which is how
scrollTocommand is implemented. - Props
-
axesthat takesvertical/horizontal/bothas an argument. -
showsIndicators— as opposed toUIScrollView, for 2-directional scroll views, we cannot specify different arguments for specific axis.
-
- Commands
scrollTo(options: { y: number, animated: boolean })— works only for vertical scrolls, as it would be a significant performance hit in the current implementation to support both axes.
- Implemented only for network assets.
- Only
sourceproperty is supported. Accepts the same value types asImagefrom React Native.
Animates changes to all animatable values within this view (including its subviews).
- Props
-
type(easeIn,easeOut,easeInOut,linear) -
duration(in seconds)
-
Adds a shadow with given radius, offsetX, offsetY, opacity and color to children views.
Masks children views using the alpha channel of the views provided by shape prop.
SVG-like shape components. Shapes are not managed by Yoga which means they have their own layouting mechanism (configurable with alignment, offsetX and offsetY props) that makes them positioned absolutely to the parent view.
As opposed to SVG, our shapes can contain children.
Common shape props: fill, alignment, offsetX, offsetY, stroke, strokeWidth, strokeLineCap, strokeLineJoin, strokeDashes, strokeDashPhase.
Additional props: width, height
Additional props: radius