Last active
July 26, 2021 10:16
-
-
Save Schabaani/e0b9620b70842f9d96fba1dc7c51af60 to your computer and use it in GitHub Desktop.
See this video: https://www.youtube.com/watch?v=sxtwemW6im0
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
import SwiftUI | |
struct CurvesAndShape: View { | |
var body: some View { | |
Home() | |
} | |
} | |
struct CurvesAndShape_Previews: PreviewProvider { | |
static var previews: some View { | |
CurvesAndShape() | |
} | |
} | |
struct Home: View { | |
@State var color = 0 | |
var body: some View { | |
VStack { | |
ZStack(alignment: .top) { | |
VStack { | |
Image(systemName: "") | |
// .resizable() | |
.frame(height: 200) | |
HStack(spacing: 20) { | |
Button (action: { | |
self.color = 0 | |
}) { | |
VStack(spacing: 8) { | |
ZStack { | |
Circle() | |
.fill(Color.yellow) | |
.frame(width: 20, height: 20) | |
Circle() | |
.stroke(self.color == 0 ? Color.white : Color.clear, lineWidth: 2) | |
.frame(width: 30, height: 30) | |
} | |
Text("Yellow") | |
} | |
} | |
Button (action: { | |
self.color = 1 | |
}) { | |
VStack(spacing: 8) { | |
ZStack { | |
Circle() | |
.fill(Color.orange) | |
.frame(width: 20, height: 20) | |
Circle() | |
.stroke(self.color == 1 ? Color.white : Color.clear, lineWidth: 2) | |
.frame(width: 30, height: 30) | |
} | |
Text("Orange") | |
} | |
} | |
} | |
.padding(.top, 15) | |
.padding(.bottom, 10) | |
} | |
HStack { | |
Button (action: {}) { | |
Image(systemName: "return") | |
.renderingMode(.original) | |
.padding() | |
} | |
.padding(.leading, 10) | |
.padding(.top, 20) | |
Spacer() | |
Button (action: {}) { | |
Image(systemName :"cart") | |
.renderingMode(.original) | |
.padding() | |
} | |
.padding(.horizontal, 10) | |
.padding(.vertical, 20) | |
.background(Color.white) | |
.clipShape(CustomShape(corner: .bottomLeft, radii: 35)) | |
} | |
} | |
.background(self.color == 0 ? Color.yellow : Color.orange) | |
.clipShape(CustomShape(corner: .bottomLeft, radii: 55)) | |
HStack { | |
Text("Melody lamp") | |
.font(.title) | |
.fontWeight(.bold) | |
Spacer() | |
Button (action: {}) { | |
Image(systemName: "heart") | |
.renderingMode(.original) | |
.padding() | |
} | |
.background(self.color == 0 ? Color.yellow : Color.orange) | |
.clipShape(Circle()) | |
.padding(.horizontal, 35) | |
.padding(.top) | |
} | |
.padding(.horizontal) | |
Text("Proin eget cursus augue. Quisque fermentum, lectus nec efficitur lobortis, lectus nisl consectetur enim, a hendrerit neque diam a felis. Vivamus nec vehicula est. Maecenas lacinia pellentesque nunc bibendum efficitur. Curabitur nec varius sem, et molestie magna. Duis rutrum urna quis ultricies bibendum. Donec vestibulum augue eu leo rhoncus, quis aliquet dolor vehicula. Vivamus vehicula tempus elit, vel auctor odio rhoncus in. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.") | |
.multilineTextAlignment(.leading) | |
.foregroundColor(.gray) | |
.padding(.horizontal, 30) | |
.padding(.top, 20) | |
HStack (spacing: 5) { | |
Button (action: {}) { | |
VStack { | |
Text("22 W") | |
.fontWeight(.bold) | |
.foregroundColor(.black) | |
} | |
.padding() | |
} | |
.background(Color.black.opacity(0.06)) | |
.cornerRadius(22) | |
Button (action: {}) { | |
VStack { | |
Text("1.2 M") | |
.fontWeight(.bold) | |
.foregroundColor(.black) | |
} | |
.padding() | |
} | |
.background(Color.black.opacity(0.06)) | |
.cornerRadius(22) | |
Button (action: {}) { | |
VStack { | |
Text("22 CM") | |
.fontWeight(.bold) | |
.foregroundColor(.black) | |
} | |
.padding() | |
} | |
.background(Color.black.opacity(0.06)) | |
.cornerRadius(22) | |
Button (action: {}) { | |
VStack { | |
Text("2 KG") | |
.fontWeight(.bold) | |
.foregroundColor(.black) | |
} | |
.padding() | |
} | |
.background(Color.black.opacity(0.06)) | |
.cornerRadius(22) | |
} | |
.padding(.top, 20) | |
.padding(.bottom, 10) | |
.padding(.horizontal, 3) | |
Spacer(minLength: 0) | |
HStack { | |
Text("$12.45") | |
.foregroundColor(.black) | |
.font(.title) | |
.fontWeight(.bold) | |
.padding(.leading, 35) | |
.padding(.bottom, 20) | |
Spacer() | |
Button (action: {}) { | |
Text("Add To Cart") | |
.foregroundColor(.black) | |
.padding(.vertical, 20) | |
.padding(.horizontal, 35) | |
} | |
.background(self.color == 0 ? Color.yellow : Color.orange) | |
.clipShape(CustomShape(corner: .topLeft, radii: 55)) | |
} | |
} | |
.edgesIgnoringSafeArea(.all) | |
.statusBar(hidden: true) | |
.animation(.default) | |
} | |
} | |
struct CustomShape: Shape { | |
var corner: UIRectCorner | |
var radii: CGFloat | |
func path(in rect: CGRect) -> Path { | |
let path = UIBezierPath(roundedRect: rect, byRoundingCorners: corner, cornerRadii: CGSize(width: radii, height: radii)) | |
return Path(path.cgPath) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment