Skip to content

Commit

Permalink
Implement a few more views used in landmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuowei committed Jun 7, 2019
1 parent 5f3044d commit b46343b
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
1 change: 1 addition & 0 deletions mainstock/main.swift
@@ -0,0 +1 @@
print("hello")
70 changes: 69 additions & 1 deletion marina.swift
Expand Up @@ -26,6 +26,10 @@ protocol MarinaViewContentAccessor {
protocol MarinaTextAccess: MarinaViewContentAccessor {
}

struct Color {
static let primary = Color()
}

struct Text : View, MarinaTextAccess {
var content:String
var body:Never {
Expand All @@ -37,6 +41,9 @@ struct Text : View, MarinaTextAccess {
func getContent() -> Any {
return content
}
func color(_ color: Color?) -> Text {
return self
}
}

protocol MarinaTupleViewAccess: MarinaViewContentAccessor {
Expand Down Expand Up @@ -125,12 +132,17 @@ struct HStack<Content> : View, MarinaHStackAccess where Content: View {
protocol MarinaVStackAccess : MarinaViewContentAccessor {
}

struct HorizontalAlignment {
static let center = HorizontalAlignment()
static let leading = HorizontalAlignment()
}

struct VStack<Content> : View, MarinaVStackAccess where Content: View {
var body:Never {
fatalError("VStack has no body")
}
var content:Content
init(@ViewBuilder content: () -> Content) {
init(alignment: HorizontalAlignment = .center, @ViewBuilder content: () -> Content) {
self.content = content()
}
func getContent() -> Any {
Expand All @@ -154,6 +166,62 @@ struct ZStack<Content> : View, MarinaHStackAccess where Content: View {
}
}

protocol MarinaScrollViewAccess: MarinaViewContentAccessor {
}

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

protocol Identifiable {
associatedtype ID: Hashable
associatedtype IdentifiedValue = Self
}

struct ForEach<Data, Content> : View where Data : RandomAccessCollection, Content : View, Data.Element : Identifiable {
var body:Never {
fatalError("ForEach has no body")
}
var data: Data
var content: (Data.Element.IdentifiedValue) -> Content
init(_ data: Data, content: @escaping (Data.Element.IdentifiedValue) -> Content) {
self.data = data
self.content = content
}
}

struct NavigationButton<Label, Destination> : View where Label : View, Destination : View {
var body:Never {
fatalError("NavigationButton has no body")
}
init(destination: Destination, isDetail: Bool = true, onTrigger: @escaping () -> Bool = { true }, label: () -> Label) {
}
}

enum RenderingMode {
case automatic
}

struct Image: View {
var body:Never {
fatalError("Image has no body")
}
init(url: String, label: Text) {
}
func renderingMode(_ renderingMode: RenderingMode) -> Image {
return self
}
}

struct MarinaDemo : View {
var body: some View {
HStack {
Expand Down
9 changes: 9 additions & 0 deletions stockDemo.sh
@@ -0,0 +1,9 @@
#!/bin/sh
set -e
export DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer
SWIFTFLAGS="-sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.0.sdk -target x86_64-apple-ios13.0-simulator"
subdir="WorkingWithUIControls_StartingPoint/Landmarks/Landmarks"
swiftc $SWIFTFLAGS -o marina mainstock/main.swift marina.swift marina_html.swift \
$subdir/CategoryRow.swift $subdir/Home.swift $subdir/LandmarkDetail.swift \
$subdir/models/* $@
./run.sh

0 comments on commit b46343b

Please sign in to comment.