-
-
Save anupamchugh/3028ced1b21fd20ecb9f222246edf66f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct LineView: View { | |
var data: [(Double)] | |
var title: String? | |
var price: String? | |
public init(data: [Double], | |
title: String? = nil, | |
price: String? = nil) { | |
self.data = data | |
self.title = title | |
self.price = price | |
} | |
public var body: some View { | |
GeometryReader{ geometry in | |
VStack(alignment: .leading, spacing: 8) { | |
Group{ | |
if (self.title != nil){ | |
Text(self.title!) | |
.font(.title) | |
} | |
if (self.price != nil){ | |
Text(self.price!) | |
.font(.body) | |
.offset(x: 5, y: 0) | |
} | |
}.offset(x: 0, y: 0) | |
ZStack{ | |
GeometryReader{ reader in | |
Line(data: self.data, | |
frame: .constant(CGRect(x: 0, y: 0, width: reader.frame(in: .local).width , height: reader.frame(in: .local).height)), | |
minDataValue: .constant(nil), | |
maxDataValue: .constant(nil) | |
) | |
.offset(x: 0, y: 0) | |
} | |
.frame(width: geometry.frame(in: .local).size.width, height: 200) | |
.offset(x: 0, y: -100) | |
} | |
.frame(width: geometry.frame(in: .local).size.width, height: 200) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment