File tree Expand file tree Collapse file tree
AndroidSwiftUICore/Sources/AndroidSwiftUICore/Primitives Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ //
2+ // Overlay.swift
3+ // AndroidSwiftUICore
4+ //
5+ // `.overlay { … }` layers content over a view, sized to the base. Emitted as an
6+ // Overlay node whose first child is the base and second is the overlay; the
7+ // interpreter stacks the overlay at the base's size with the given alignment.
8+ //
9+
10+ public struct _OverlayView < Base: View , Overlay: View > : View {
11+ internal let base : Base
12+ internal let overlay : Overlay
13+ internal let alignment : Alignment
14+ public typealias Body = Never
15+ }
16+
17+ extension _OverlayView : PrimitiveView {
18+ public func _render( in context: ResolveContext ) -> RenderNode {
19+ RenderNode (
20+ type: " Overlay " ,
21+ id: context. path,
22+ props: [
23+ " horizontal " : . string( alignment. horizontal. rawValue) ,
24+ " vertical " : . string( alignment. vertical. rawValue) ,
25+ ] ,
26+ children: [
27+ Evaluator . resolve ( base, context. descending ( " base " ) ) ,
28+ Evaluator . resolve ( overlay, context. descending ( " overlay " ) ) ,
29+ ]
30+ )
31+ }
32+ }
33+
34+ public extension View {
35+ func overlay< V: View > (
36+ alignment: Alignment = . center,
37+ @ViewBuilder content: ( ) -> V
38+ ) -> _OverlayView < Self , V > {
39+ _OverlayView ( base: self , overlay: content ( ) , alignment: alignment)
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments