Syntrofic UI

Button

按钮 · 主要、次要、危险等动作层级,加载、禁用、图标与键盘按压

接入

TypeScript
import { SNativeButton } from '@syntrofic/ui-native'

Native 安装与配置

Vue
<script setup lang="ts">
import { SNativeButton } from '@syntrofic/ui-native'
import { ref } from 'vue'

const saved = ref(false)
</script>

<template>
  <SNativeButton :label="saved ? '已保存' : '保存'" @tap="saved = true" />
</template>

使用说明

操作层级、禁用、加载时文字让位、指示器进退场

对话框

v-model:open 管理打开状态。triggerLabel 提供默认入口,自定义入口可以使用 #trigger,也可以调用组件的 show(returnFocus)。内容和底部操作插槽接收 close(reason),closed 在原生窗口关闭后返回原因。

对话框用原生模态窗口阻断背景交互。正文支持滚动,标题和底部操作保留在各自的布局行。入场时面板轻微收拢并显现,关闭时先过渡再释放原生窗口。打开后可用 initialFocus 选定初始焦点,关闭后恢复触发入口。点按外部、Android 返回键和从标题区向下拖动均可独立配置。

<SNativeDialog triggerLabel="归档项目" title="归档项目?" description="归档后可恢复。">
  <template #footer="{ close }">
    <SNativeButton label="取消" variant="secondary" size="sm" @tap="close('cancel')" />
    <SNativeButton label="确认归档" variant="danger" size="sm" @tap="close('confirm')" />
  </template>
</SNativeDialog>

底部面板

v-model:open 管理打开状态,v-model:detent 管理停靠索引。组件引用提供 present(index, returnFocus)、resize(index)、dismiss(reason) 和 dismissStack()。设置 name 后可通过 getNativeBottomSheet(name) 从另一个入口取得同一组方法。

<SNativeBottomSheet title="交付素材" triggerLabel="选择素材" :detents="['peek', 0.48, 0.86]">
  <SNativeListGroup :items="assets" separators />
  <template #footer="{ resize, dismiss }">
    <SNativeButton label="展开" size="sm" variant="ghost" @tap="resize(2)" />
    <SNativeButton label="确认" size="sm" @tap="dismiss('confirm')" />
  </template>
</SNativeBottomSheet>

设备预览

在 Native 示例应用中打开 编号 088 的 SNativeButton 场景。运行 iOS 或 Android 示例。