expo-ui-swift-ui
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseThe instructions in this skill apply to SDK 55 only. For other SDK versions, refer to the Expo UI SwiftUI docs for that version for the most accurate information.
本技能中的说明仅适用于SDK 55。对于其他SDK版本,请参考对应版本的Expo UI SwiftUI文档以获取最准确的信息。
Installation
Installation
bash
npx expo install @expo/uiA native rebuild is required after installation ().
npx expo run:iosbash
npx expo install @expo/ui安装后需要进行原生重建()。
npx expo run:iosInstructions
Instructions
- Expo UI's API mirrors SwiftUI's API. Use SwiftUI knowledge to decide which components or modifiers to use.
- Components are imported from , modifiers from
@expo/ui/swift-ui.@expo/ui/swift-ui/modifiers - When about to use a component, fetch its docs to confirm the API - https://docs.expo.dev/versions/v55.0.0/sdk/ui/swift-ui/{component-name}/index.md
- When unsure about a modifier's API, refer to the docs - https://docs.expo.dev/versions/v55.0.0/sdk/ui/swift-ui/modifiers/index.md
- Every SwiftUI tree must be wrapped in .
Host - is specifically for embedding RN components inside a SwiftUI tree. Example:
RNHostView
jsx
import { Host, VStack, RNHostView } from "@expo-ui/swift-ui";
import { Pressable } from "react-native";
<Host matchContents>
<VStack>
<RNHostView matchContents>
// Here, `Pressable` is an RN component so it is wrapped in `RNHostView`.
<Pressable />
</RNHostView>
</VStack>
</Host>;- If a required modifier or View is missing in Expo UI, it can be extended via a local Expo module. See: https://docs.expo.dev/guides/expo-ui-swift-ui/extending/index.md. Confirm with the user before extending.
- Expo UI的API镜像了SwiftUI的API。可以利用SwiftUI知识来决定使用哪些组件或修饰符。
- 组件从导入,修饰符从
@expo/ui/swift-ui导入。@expo/ui/swift-ui/modifiers - 使用组件前,请查阅其文档以确认API - https://docs.expo.dev/versions/v55.0.0/sdk/ui/swift-ui/{component-name}/index.md
- 不确定修饰符的API时,请参考文档 - https://docs.expo.dev/versions/v55.0.0/sdk/ui/swift-ui/modifiers/index.md
- 每个SwiftUI树都必须用包裹。
Host - 专门用于在SwiftUI树中嵌入RN组件。示例:
RNHostView
jsx
import { Host, VStack, RNHostView } from "@expo-ui/swift-ui";
import { Pressable } from "react-native";
<Host matchContents>
<VStack>
<RNHostView matchContents>
// Here, `Pressable` is an RN component so it is wrapped in `RNHostView`.
<Pressable />
</RNHostView>
</VStack>
</Host>;- 如果Expo UI中缺少所需的修饰符或视图,可以通过本地Expo模块进行扩展。请参阅:https://docs.expo.dev/guides/expo-ui-swift-ui/extending/index.md。扩展前请与用户确认。