Skip to content

Commit

Permalink
VStack and ZStack
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuowei committed Jun 7, 2019
1 parent 88b97af commit 5f3044d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
32 changes: 32 additions & 0 deletions marina.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,38 @@ struct HStack<Content> : View, MarinaHStackAccess where Content: View {
}
}

protocol MarinaVStackAccess : MarinaViewContentAccessor {
}

struct VStack<Content> : View, MarinaVStackAccess where Content: View {
var body:Never {
fatalError("VStack has no body")
}
var content:Content
init(@ViewBuilder content: () -> Content) {
self.content = content()
}
func getContent() -> Any {
return content
}
}

protocol MarinaZStackAccess : MarinaViewContentAccessor {
}

struct ZStack<Content> : View, MarinaHStackAccess where Content: View {
var body:Never {
fatalError("ZStack has no body")
}
var content:Content
init(@ViewBuilder content: () -> Content) {
self.content = content()
}
func getContent() -> Any {
return content
}
}

struct MarinaDemo : View {
var body: some View {
HStack {
Expand Down
10 changes: 10 additions & 0 deletions marina_html.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ func render(view: Any, emitter: DOMEmitter) {
let v = view as! MarinaHStackAccess
render(view: v.getContent(), emitter: emitter)
emitter.close("div")
case "VStack":
emitter.emit("div", ["class": "marina-vstack"])
let v = view as! MarinaVStackAccess
render(view: v.getContent(), emitter: emitter)
emitter.close("div")
case "ZStack":
emitter.emit("div", ["class": "marina-zstack"])
let v = view as! MarinaZStackAccess
render(view: v.getContent(), emitter: emitter)
emitter.close("div")
case "Text":
emitter.emit("div", ["class": "marina-text"])
let v = view as! MarinaTextAccess
Expand Down

0 comments on commit 5f3044d

Please sign in to comment.