❗ ❗ This project is new and has not reached a stable release yet. Working to complete all features soon! ❗ ❗
SwiftUI is awesome. So is React Native! This library aims to leverage some of the best SwiftUI features in React Native applications.
Run yarn build
to generate a dist/
folder, then run yarn watch
while developing.
Install the package in your React Native project:
yarn add swiftui-react-native
If you intend on using any of the navigation components, you will need to install these as well:
yarn add react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view
Then run,
cd ios && pod install && cd ..
Note: These views are based off of React Navigation components https://reactnavigation.org/docs/getting-started/.
Another Note: If you run into any error messages regarding RNGesutureHandler, try restarting the bundler and re-running yarn ios
. Trying to fix this ASAP!
Import the components you need like this:
import { VStack, Text, Button } from 'swiftui-react-native';
And display them like this:
return (
<VStack
aligment='leading'
background={UIColor.systemGray6}
padding={{ leading: 30 }}
cornerRadius={20}
>
<Text font='title'>Some cool text</Text>
<Button action={doSomething}>
<Text>Click the cool button</Text>
</Button>
</VStack>
);
vs. SwiftUI…
var body: some View {
VStack(alignment: .leading) {
Text("Some cool text").font(.title)
Button(action: doSomething) {
Text("Click the cool button")
}
}.background(Color(UIColor.systemGray6))
.cornerRadius(20)
.padding(.leading, 30)
}
examples/
)Author: andrew-levy
Source Code: https://github.com/andrew-levy/swiftui-react-native
#react-native #react #mobile-apps