本文へ移動

UIコンポーネント ​

実装ステータス: runtime discoveryが正本です。現在のHostは通常のstack/grid/form/list/controlに加え、EmptyView、If、GeometryReader、Canvas、ForEach、SearchField、Searchable、ReorderList、SwipeActions、ContextMenu、ContentUnavailableView、MediaImage、NavigationTitle、Toolbar、Map、WebView、VideoPlayer、AudioPlayer、CameraPreview、BarcodeScanner、ARViewを実装しています。

input componentは、two-way updateのためstate.profile.name、state.enabled、global.search.queryのような明示的props.bind pathを使います。nested state/global pathは実行可能なv1 behaviorです。bind値の変更後、change eventからactionを呼び出せます。

ForEachはprops.itemsにstate arrayを指す通常のApsule interpolation(例: state.items expression)、props.itemにiteration alias(default item)、props.keyにstable object key(default id)を使います。子孫はitem.contentのようにalias fieldをinterpolateできます。repeated content内のtap actionはiteration scope objectを最初の引数として受け取るため、各row用にstatic JSONへIDを複製しなくても選択itemを特定できます。

TextEditorはTextFieldのmultiline版です。同じprops.bind state bindingを使い、minimum editor heightとしてprops.minHeightを受け取ります。

TextField、SecureField、TextEditor、SearchFieldはkeyboardType、autocapitalization、autocorrection、submitLabelなどのnative input hintを受け取ります。Sheetはdetents(medium、large、fraction:<0-1>、height:<points>)、dragIndicator、interactiveDismissDisabledに対応します。

Pickerはprops.optionsに{ "label": "...", "value": "..." } object arrayを使い、string valueをbindします。DatePickerはISO-8601 stringをbindし、既存numeric Unix timestampも受け付けます。props.dateOnly: trueでdateのみに制限します。ColorPickerは#RRGGBBまたは#RRGGBBAA stringをbindします。Sheet、Alert、ConfirmationDialog、DisclosureGroupはboolean props.bindを使います。Alertはoptional confirm eventを呼び出せます。NavigationLinkはprops.routeを使って同じruntime/stateを保持したままproject routeを読み込みます。

LazyVGridはprops.columns、LazyHGridはprops.rowsを使い、両方ともprops.spacingとprops.itemSpacingを受け取ります。TabViewはstring selectionをbindし、各direct childからtabTitle、tabSystemName、optional tabValueを読みます。props.hideTabBar: trueではnative tab selectionを保ちながらtab barを隠せます。ConfirmationDialogはdirect Button childをnative actionとして描画し、props.roleのdestructiveとcancelを尊重します。ShareLinkはprops.urlまたはstring props.valueを受け取ります。

shape componentはprops.color、props.width、props.heightを受け取ります。optional props.widthBinding/props.heightBindingは通常のstate interpolationからnumeric valueを解決できます。指定された場合はstatic width/heightを上書きしつつ、older Host向けbackward-compatible fallbackとしてstatic valueも残します。RoundedRectangleはprops.cornerRadiusにも対応します。Image/MediaImageはpackaged assetまたはProject-sandbox media pathを解決できます。Mapはinitial regionとmarker/polyline collectionを受け取り、regionChange/mapTapをemitします。WebViewはprops.urlを受け取り、navigate/error/messageをemitし、host.webViewからcontrolできます。VideoPlayerとAudioPlayerはProject-sandboxまたはHTTP media URLを解決します。CameraPreviewはnative preview surfaceで、capture自体はhost.cameraからimperativeに行います。

v1の目標はSwiftUI APIをすべてmirrorすることではありません。native appearanceを維持しながら、一般的な小規模appを幅広く作るためのbuilding blockを揃えることです。

SwiftUI coverageをpercentageで評価することに大きな意味はありません。SwiftUIにはlayout、scene、graphics、accessibility、gesture、framework integration、platform-specific featureまで非常に広いAPI surfaceがあるためです。Apsuleでは代わりに広いapp-type coverageを目標にします。

Layout ​

Type用途
VStackchildを縦方向に並べる。
HStackchildを横方向に並べる。
ZStackchildを重ねて配置する。
Spaceralignmentに使える可変empty space。
Dividernative separator。
ScrollViewcontentを縦/横にscrollする。
LazyVStack大きな縦stackを効率的に描画する。
LazyHStack大きな横stackを効率的に描画する。
LazyVGrid縦方向へflowする効率的なgrid。
LazyHGrid横方向へflowする効率的なgrid。
GeometryReader必要な場合にavailable geometry/sizeへ反応する。多用しない。
Canvasline/rectangle/ellipse/text/polyline command arrayを描画し、drag coordinateを受け取る。
Ifprops.conditionがtruthyなら最初のchild、そうでなければoptionalな2番目のchildを描画する。

Textとlabel ​

Type用途
Texttextを描画する。
Labelnative icon + textの組み合わせ。

Inputとcontrol ​

Type用途
Buttonactionを実行する。
TextField通常のtext input。
TextEditormultiline text input。
SecureFieldsensitive inputを隠して入力する。
SearchFieldcompactなsearch-style text input。
Searchablechild contentへnative search UIを適用する。
Toggleboolean on/off input。
Slidernumeric range input。
Picker選択肢から選ぶ。
DatePickerdate/time input。
ColorPickercolor input。
Menuaction/optionのcompact menu。

Data/content ​

Type用途
Imagelocal/system image。
AsyncImageURLから読み込むremote image。
ProgressViewloading indicatorまたはprogress。
Gaugenative gauge/measurement visualization。
Listnative structured list。
ReorderListbound state/global arrayを使うnative editable list。
ForEachcollection itemごとにUIを繰り返す。
Section関連row/contentをgroup化する。
Formnative form/settings風structure。
DisclosureGroupcontentをexpand/collapseする。
SwipeActionscontentへnative leading/trailing swipe actionを追加する。
ContextMenucontentへnative context menuを追加する。
MediaImageProject assetまたはProject sandboxのimageを表示する。
VideoPlayerAVPlayer-backed native video playback。
AudioPlayercompactなAVPlayer-backed audio playback。
ContentUnavailableViewnative empty/error-state presentation。
Type用途
NavigationStacknative navigation container。routeはproject levelで定義したまま。
NavigationLink必要な場合のdeclarative route trigger。
NavigationTitleroute-local native navigation titleを設定する。
Toolbarproject-controlled native toolbar itemを追加する。
TabViewmain tab-based application navigation。
Sheetmodal sheetを表示する。
Alertnative alert。
ConfirmationDialognative action/confirmation dialog。
LinkURLを開く。
ShareLinknative share entry point。

Shapeとgraphics ​

Type用途
Rectanglerectangle shape。
RoundedRectanglerounded rectangle shape。
Circlecircle shape。
Capsulecapsule/pill shape。

Native framework-backed UI ​

Type用途
MapMapKit-backed native map UI。
WebViewWebKit-backed web content surface。Apsule全体のrendererではなく明示的component。
CameraPreviewCamera permissionがある場合のlive native camera preview。
BarcodeScannerAVCaptureMetadataOutput backed live QR/barcode scanner。scan eventでpayload/symbologyをemitする。
ARViewoptional plane detectionを備えた基本RealityKit/ARKit world-tracking surface。

Liquid Glass ​

Liquid Glassはspecial component typeを増やすのではなく、主にstyle/modifierとして表現します。たとえば通常のButtonが対応するglass styleをopt-inできます。

Hostは対応glass propertyを、Host SDK/OSで利用可能なnative SwiftUI APIへmappingします。未対応effectはweb/CSS effectで黙って近似せず、runtime validationで報告しなければなりません。

今後のUI候補 ​

Chart、rich-text editor、高度なcustom layout protocol、accessibility-specialized component、domain-specific Health/Home UIは、独立したv1 componentではありません。generic UI surfaceで十分な場合、それらのdata/OS integrationはProject JavaScriptから引き続き利用できます。