跳到正文

Popover

从组合式 SwiftUI 触发器显示原生 SwiftUI 浮窗。

#导入

从 github.com/egoist/quickgui/go/ui 导入 ui。

import (
	"github.com/egoist/quickgui/go/ui"
)

#用法

func SwiftUiPopoverExample() *native.Node {
	open, setOpen := ui.CreateSignal(false)
	return ui.SwiftUI.Host(
		ui.SwiftUIHostProps{MatchContents: true},
		func() *native.Node {
			return ui.SwiftUI.Popover.Root(
				ui.SwiftUIPopoverProps{
					IsPresented:         open,
					OnIsPresentedChange: setOpen,
				},
				func() *native.Node {
					return ui.Fragment([]*native.Node{ui.SwiftUI.Popover.Trigger(ui.SwiftUIPopoverTriggerProps{Render: func() *native.Node { return ui.SwiftUI.Button(ui.SwiftUIButtonProps{Label: "Account"}) }}),
						ui.SwiftUI.Popover.Content(
							ui.SwiftUIPopoverContentProps{},
							func() *native.Node {
								return ui.SwiftUI.QuickGUIHostView(
									ui.SwiftUIQuickGUIHostViewProps{Width: 240, Height: 120},
									"Account settings",
								)
							},
						)})
				},
			)
		},
	)
}

#结构

  • ui.SwiftUI.Popover.Trigger
  • ui.SwiftUI.Popover.Content

#API 参考

展开条目查看说明和完整签名。短横线表示声明中未记录默认值。

SwiftUIPopover.Root

查看源码
ui.SwiftUIPopover.Root(props SwiftUIPopoverProps, children ...any) *native.Node
TestIDany—

Stable identifier for native automation and tests.

any
查看源码
Modifiersany—

Ordered SwiftUI view modifiers applied to the hosted control.

any
查看源码
Reffunc(*native.Node)—

Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.

func(*native.Node)
查看源码
ChildrenComponent—

Content mounted inside the component. Compound child callbacks run after the parent context exists.

Component
查看源码
IsPresentedany—

Controlled native SwiftUI popover presentation state.

any
查看源码
OnIsPresentedChangefunc(bool)—

Reports native SwiftUI popover presentation changes.

func(bool)
查看源码
AttachmentAnchorstring—

Anchor point on the composed SwiftUI trigger.

string
查看源码
ArrowEdgestring—

Preferred edge for the native SwiftUI popover arrow.

string
查看源码

SwiftUIPopover.Trigger

查看源码
ui.SwiftUIPopover.Trigger(props SwiftUIPopoverTriggerProps) *native.Node
RenderComponent—

Callback that constructs the content for this part.

Component
查看源码
OnPressfunc(*native.Event)—

Runs when the native SwiftUI button is activated.

func(*native.Event)
查看源码
Reffunc(*native.Node)—

Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.

func(*native.Node)
查看源码

SwiftUIPopover.Content

查看源码
ui.SwiftUIPopover.Content(props SwiftUIPopoverContentProps, children ...any) *native.Node
ChildrenComponent—

Content mounted inside the component. Compound child callbacks run after the parent context exists.

Component
查看源码
Reffunc(*native.Node)—

Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.

func(*native.Node)
查看源码