UI弹出呈现
sheet
从底部弹出一张卡片。
sheet(options) 在 isPresented 为 true 时从底部弹出 content,用户可以下滑关闭。受控规则见概览。
import {
Button, List, Modifier, NavigationStack, Text, ToolbarItem, useState,
} from "onescript/views"
function Inbox() {
const [shown, setShown] = useState(false)
return (
<Button
action={() => setShown(true)}
modifier={Modifier.sheet({
isPresented: shown,
onDismiss: () => setShown(false),
content: (
<NavigationStack>
<List modifier={Modifier
.navigationTitle("筛选")
.presentationDetents(["medium", "large"])
.toolbar(
<ToolbarItem placement="confirmationAction">
<Button action={() => setShown(false)}>完成</Button>
</ToolbarItem>
)}>
<Text>仅显示未读</Text>
</List>
</NavigationStack>
),
})}
>
筛选
</Button>
)
}| 参数 | 类型 | 说明 |
|---|---|---|
isPresented | boolean | 是否显示。 |
onDismiss | () => void | 用户关闭时调用,需在其中把 isPresented 设为 false。 |
content | ViewChild | 弹出的内容。 |
- 内容需要标题栏或工具栏时,请用
NavigationStack包裹。 - 在内容中的视图上使用
presentationDetents、presentationDragIndicator、presentationContentInteraction、presentationBackgroundInteraction和interactiveDismissDisabled调整 sheet。
How is this guide?
最后更新于