OneScript

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>
  )
}
参数类型说明
isPresentedboolean是否显示。
onDismiss() => void用户关闭时调用,需在其中把 isPresented 设为 false。
contentViewChild弹出的内容。

How is this guide?

最后更新于