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
extension CaseIterable where Self: Equatable & RawRepresentable { | |
var allCases: AllCases { Self.allCases } | |
func next() -> Self { | |
let index = allCases.firstIndex(of: self)! | |
let next = allCases.index(after: index) | |
guard next != allCases.endIndex else { return allCases[index] } | |
return allCases[next] | |
} | |
func previous() -> Self { |
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 WheelView: View { | |
// Circle Radius | |
@State var radius : Double = 150 | |
// Direction of swipe | |
@State var direction = Direction.left | |
// index of the number at the bottom of the circle | |
@State var chosenIndex = 0 | |
// degree of circle and hue | |
@Binding var degree : Double | |
// @State var degree = 90.0 |
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 ContentView: View { | |
@State var degree = 0.0 | |
var body: some View { | |
ZStack { | |
LinearGradient(colors: [.blue.opacity(0.7),.purple.opacity(0.7)], startPoint: .topLeading, endPoint: .bottomTrailing).ignoresSafeArea() | |
Color.black.opacity(0.8).ignoresSafeArea() | |
MyView(degree: $degree).modifier(InteractiveView()) | |
.frame(width: 300, height: 300) | |
} | |
} |
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 InteractiveView : ViewModifier { | |
@State var degree = 0.0 | |
@State var xAxis : CGFloat = 0 | |
@State var yAxis : CGFloat = 0 | |
func body(content: Content) -> some View { | |
GeometryReader { geo in | |
let gesture = DragGesture() | |
.onChanged { value in | |
degree = 0 |
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 ContentView: View { | |
var body: some View { | |
ZStack { | |
LinearGradient(colors: [.blue.opacity(0.7),.purple.opacity(0.7)], startPoint: .topLeading, endPoint: .bottomTrailing).ignoresSafeArea() | |
Color.black.opacity(0.8).ignoresSafeArea() | |
InteractiveView() | |
} | |
} | |
} |
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 InteractiveView : View { | |
@State var degree = 0.0 | |
@State var xAxis : CGFloat = 0 | |
@State var yAxis : CGFloat = 0 | |
var body: some View { | |
GeometryReader { geo in | |
let gesture = DragGesture() | |
.onChanged { value in | |
degree = 0 |
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 MyView : View { | |
@Binding var degree : Double | |
var body: some View { | |
ZStack { | |
RoundedRectangle(cornerRadius: 15).stroke(LinearGradient(colors: [.blue,.purple], startPoint: .topLeading, endPoint: .bottomTrailing),lineWidth: 10) | |
RoundedRectangle(cornerRadius: 15).fill(.white) | |
RoundedRectangle(cornerRadius: 15).fill(LinearGradient(colors: [.blue.opacity(0.95),.purple.opacity(0.95)], startPoint: .topLeading, endPoint: .bottomTrailing)) |
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 LikesModifier: ViewModifier { | |
@State var time = 0.0 | |
let duration = 2.0 | |
func body(content: Content) -> some View { | |
ZStack { | |
ForEach(0..<2) { _ in | |
content | |
.foregroundColor(.white) | |
.modifier(LikesGeometryEffect(time: time)) |
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 ContentView: View { | |
//MARK: Variables | |
@State var backDegree = 0.0 | |
@State var frontDegree = -90.0 | |
@State var isFlipped = false | |
let width : CGFloat = 200 | |
let height : CGFloat = 250 | |
let durationAndDelay : CGFloat = 0.3 | |
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 CardBack : View { | |
let width : CGFloat | |
let height : CGFloat | |
@Binding var degree : Double | |
var body: some View { | |
ZStack { | |
RoundedRectangle(cornerRadius: 20) | |
.stroke(.blue.opacity(0.7), lineWidth: 3) | |
.frame(width: width, height: height) |