├── .gitignore ├── Animations ├── CreditCardFlip │ └── CreditCardFlip.swift ├── DNALoading │ └── DNALoading.swift ├── DarkmodeToggle │ └── DarkmodeToggle.swift ├── Download Button │ └── DownloadButton.swift ├── HalfpipeLoading │ └── HalfpipeLoadingView.swift ├── HeartButton │ └── HeartButton.swift ├── LikeButton │ └── LikeButton.swift ├── LoadingScreen │ └── LoadingScreen.swift ├── Menu │ └── MenuView.swift ├── ParticlesEmitter │ └── ParticlesEmitter.swift ├── Radar │ └── Radar.swift ├── RecordRipple │ └── RecordRipple.swift ├── Reddit │ ├── Reddit.swift │ └── RedditView.swift ├── Search │ └── Search.swift ├── Share Button │ ├── ShareButton.swift │ ├── ShareItems.swift │ └── Sticker.swift ├── ShareTwitter │ ├── Twitter.swift │ └── TwitterView.swift ├── Slider │ ├── Slider.swift │ └── SliderView.swift ├── StarRating │ ├── SliderController.swift │ ├── StarRating.swift │ └── Stars.swift ├── StickerToggle │ ├── Buttons.swift │ └── StickerToggle.swift ├── TabBar │ ├── Bar.swift │ ├── TabBar.swift │ └── TabItem.swift └── Wifi │ └── Wifi.swift ├── Gifs ├── .DS_Store ├── CreditCardFlip.gif ├── DNALoading.gif ├── DownloadButton.gif ├── HeartButton.gif ├── LikeButton.gif ├── LoadingScreen.gif ├── Menu.gif ├── Radar.gif ├── RecordRipple.gif ├── ShareButton.gif ├── Slider.gif ├── StarRating.gif ├── TabBar.gif ├── ToggleButton.gif ├── Wifi.gif ├── appleLock.gif ├── darkmode.gif ├── halfpipe.gif ├── reddit.gif ├── search.gif └── twitter.gif └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | 3 | * 4 | 5 | !InstaPosts/Animations/* 6 | !.gitignore 7 | !Gifs/* 8 | 9 | -------------------------------------------------------------------------------- /Animations/CreditCardFlip/CreditCardFlip.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CreditCard.swift 3 | // InstaPosts 4 | // 5 | // Created by InnAppsCoding on 10/06/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct CreditCardFlip: View { 12 | @State private var animating = false 13 | @State private var isImageFlipped = false 14 | @State private var rotation: Double = 0 15 | 16 | var body: some View { 17 | ZStack { 18 | if isImageFlipped { 19 | Image("credit-card-back") 20 | .scaleEffect(0.6) 21 | .rotation3DEffect(.degrees(180), axis: (x: 0, y: 1, z: 0)) 22 | } else { 23 | Image("credit-card-front") 24 | .scaleEffect(0.6) 25 | } 26 | } 27 | .rotation3DEffect(.degrees(rotation), axis: (x: 0, y: 1, z: 0)) 28 | .onTapGesture { 29 | withAnimation(Animation.linear(duration: 0.3)) { 30 | self.animating.toggle() 31 | } 32 | } 33 | .onAppear { 34 | Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true) { _ in 35 | if self.animating { 36 | withAnimation(Animation.linear(duration: 0.01)) { 37 | self.rotation += 3 38 | } 39 | if self.rotation == 90 || self.rotation == 270 { 40 | self.isImageFlipped.toggle() 41 | } else if self.rotation == 360 || self.rotation == 180 { 42 | self.animating = false 43 | } 44 | 45 | if self.rotation == 360 { 46 | self.rotation = 0 47 | } 48 | } 49 | } 50 | } 51 | } 52 | } 53 | 54 | struct CreditCardFlip_Previews: PreviewProvider { 55 | static var previews: some View { 56 | CreditCardFlip() 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Animations/DNALoading/DNALoading.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DNALoading.swift 3 | // InstagramAnimation 4 | // 5 | // Created by InnAppsCoding on 14/08/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | let firstC = Color(UIColor(red: 0.57, green: 0.92, blue: 0.94, alpha: 1.00)) 12 | let secondC = Color(UIColor(red: 0.50, green: 0.50, blue: 0.87, alpha: 1.00)) 13 | let firstC1 = Color(UIColor(red: 0.92, green: 0.69, blue: 0.81, alpha: 1.00)) 14 | let secondC2 = Color(UIColor(red: 0.40, green: 0.31, blue: 0.69, alpha: 1.00)) 15 | 16 | struct DNALoading: View { 17 | 18 | @State private var top: Bool = false 19 | 20 | var body: some View { 21 | HStack(spacing: self.spacing) { 22 | ForEach(0..> { 108 | get { (AnimatablePair(height, AnimatablePair(left.animatableData, right.animatableData))) } 109 | set { 110 | height = newValue.first 111 | right.animatableData = newValue.second.first 112 | left.animatableData = newValue.second.second 113 | } 114 | } 115 | 116 | func path(in rect: CGRect) -> Path { 117 | var path = Path() 118 | 119 | path.move(to: CGPoint(x: rect.midX, y: height)) 120 | path.addLine(to: CGPoint(x: rect.midX, y: rect.maxY)) 121 | 122 | path.move(to: left) 123 | path.addLine(to: CGPoint(x: rect.midX, y: rect.maxY)) 124 | 125 | path.addLine(to: right) 126 | 127 | return path 128 | } 129 | } 130 | 131 | struct FillCircle: Shape { 132 | var endAngle: Double 133 | 134 | var animatableData: Double { 135 | get { endAngle } 136 | set { endAngle = newValue } 137 | } 138 | 139 | func path(in rect: CGRect) -> Path { 140 | var path = Path() 141 | 142 | path.move(to: CGPoint(x: rect.midX, y: rect.midY)) 143 | path.addArc(center: CGPoint(x: rect.midX, y: rect.midY), radius: rect.height/2, startAngle: .degrees(endAngle - 90), endAngle: .degrees(-90), clockwise: true) 144 | 145 | return path 146 | } 147 | } 148 | 149 | -------------------------------------------------------------------------------- /Animations/HalfpipeLoading/HalfpipeLoadingView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HalfpipeLoadingView.swift 3 | // Animations 4 | // 5 | // Created by Inncoder on 13/08/2020. 6 | // Copyright © 2020 Inncoder AS. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct HalfpipeLoadingView: View { 12 | 13 | @State private var ballTrim1: CGFloat = 0 14 | @State private var ballTrim2: CGFloat = 0 15 | 16 | @State private var trailTrim1: CGFloat = 0 17 | @State private var trailTrim2: CGFloat = 0 18 | 19 | @State private var rightSide = true 20 | 21 | var body: some View { 22 | ZStack { 23 | Circle() 24 | .stroke(lineWidth: 15) 25 | .foregroundColor(.gray) 26 | .frame(width: capsuleSize / 2, height: capsuleSize / 2) 27 | ZStack { 28 | Circle() 29 | .stroke(lineWidth: 15) 30 | .frame(width: capsuleSize / 2, height: capsuleSize / 2) 31 | .opacity(0) 32 | Capsule() 33 | .trim(from: trailTrim1, to: trailTrim2) 34 | .stroke(ballColor, style: StrokeStyle(lineWidth: lineWidth, lineCap: .round)) 35 | .rotationEffect(.degrees(-90)) 36 | .frame(width: capsuleSize, height: capsuleSize / 2) 37 | .offset(x: 0, y: -capsuleSize / 4) 38 | } 39 | .mask(Circle().trim(from: 0, to: 0.5).stroke(Color.gray, style: StrokeStyle(lineWidth: lineWidth, lineCap: .round))) 40 | Capsule() 41 | .trim(from: ballTrim1, to: ballTrim2) 42 | .stroke(ballColor, style: StrokeStyle(lineWidth: lineWidth, lineCap: .round)) 43 | 44 | .rotationEffect(.degrees(-90)) 45 | .frame(width: capsuleSize, height: capsuleSize / 2) 46 | .offset(x: 0, y: -capsuleSize / 4) 47 | 48 | } 49 | .onAppear() { 50 | self.startAnimating() 51 | } 52 | } 53 | 54 | 55 | // MARK: - Drawing constants 56 | let capsuleSize: CGFloat = 300 57 | let lineWidth: CGFloat = 15 58 | let time: Double = 1.5 59 | let ballColor = AngularGradient(gradient: Gradient(colors: [.blue, .green]), center: .center) 60 | 61 | let trimRight: CGFloat = 0.20 62 | let trimLeft: CGFloat = 0.80 63 | 64 | 65 | // MARK: - Functions 66 | 67 | func setupRight() { 68 | self.ballTrim1 = trimRight 69 | self.ballTrim2 = trimRight + 0.001 70 | 71 | self.trailTrim1 = trimRight 72 | self.trailTrim2 = trimRight + 0.001 73 | } 74 | func setupLeft() { 75 | self.ballTrim1 = trimLeft 76 | self.ballTrim2 = trimLeft + 0.001 77 | 78 | self.trailTrim1 = trimLeft 79 | self.trailTrim2 = trimLeft + 0.001 80 | } 81 | 82 | func startAnimating() { 83 | Timer.scheduledTimer(withTimeInterval: self.time, repeats: true) { _ in 84 | if self.rightSide { 85 | self.setupRight() 86 | withAnimation(Animation.easeInOut(duration: self.time)) { 87 | self.ballTrim1 = self.trimLeft 88 | self.ballTrim2 = self.trimLeft + 0.001 89 | } 90 | withAnimation(Animation.easeInOut(duration: self.time)) { 91 | self.trailTrim2 = self.trimLeft 92 | } 93 | DispatchQueue.main.asyncAfter(deadline: .now() + self.time / 4) { 94 | withAnimation(Animation.easeInOut(duration: self.time - (self.time * 0.40))) { 95 | self.trailTrim1 = self.trimLeft 96 | } 97 | } 98 | } else { 99 | self.setupLeft() 100 | withAnimation(Animation.easeInOut(duration: self.time)) { 101 | self.ballTrim1 = self.trimRight 102 | self.ballTrim2 = self.trimRight + 0.001 103 | } 104 | withAnimation(Animation.easeInOut(duration: self.time)) { 105 | self.trailTrim1 = self.trimRight 106 | } 107 | DispatchQueue.main.asyncAfter(deadline: .now() + self.time / 4) { 108 | withAnimation(Animation.easeInOut(duration: self.time - (self.time * 0.40))) { 109 | self.trailTrim2 = self.trimRight 110 | } 111 | } 112 | } 113 | self.rightSide.toggle() 114 | } 115 | } 116 | } 117 | 118 | struct HalfpipeLoadingView_Previews: PreviewProvider { 119 | static var previews: some View { 120 | HalfpipeLoadingView() 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /Animations/HeartButton/HeartButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HeartButton.swift 3 | // InstaPosts 4 | // 5 | // Created by InnAppsCoding on 22/06/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct HeartButton: View { 12 | @State private var lifetime: Float = 0 13 | @State private var ringScale: CGFloat = 0 14 | @State private var ringOpacity: Double = 1 15 | @State private var imageScale: CGFloat = 1 16 | @State private var color = Color.gray 17 | var body: some View { 18 | ZStack { 19 | 20 | Circle() 21 | .stroke(Color.gray, lineWidth: 8) 22 | .frame(width: 200, height: 200) 23 | .opacity(self.ringOpacity) 24 | .scaleEffect(self.ringScale) 25 | 26 | ParticlesEmitter { 27 | EmitterCell() 28 | .content(.image((UIImage(systemName: "heart.fill")?.withTintColor(.red, renderingMode: .alwaysOriginal))!)) 29 | .lifetime(self.lifetime) 30 | .birthRate(100) 31 | .velocity(100) 32 | .scale(0.3) 33 | .alphaSpeed(-0.2) 34 | .scaleSpeed(-0.1) 35 | .emissionRange(.pi * 2) 36 | .yAcceleration(-30) 37 | .color(UIColor.red) 38 | } 39 | .emitterSize(CGSize(width: 1, height: 1)) 40 | .emitterShape(.circle) 41 | .frame(width: 1, height: 1) 42 | 43 | Rectangle() 44 | .frame(width: 100, height: 80) 45 | .foregroundColor(color) 46 | .mask( 47 | Image(systemName: "heart.fill") 48 | .resizable() 49 | ) 50 | .scaleEffect(self.imageScale) 51 | } 52 | .onTapGesture { 53 | self.ringOpacity = 1 54 | self.ringScale = 0 55 | withAnimation(Animation.linear(duration: 0.3)) { 56 | self.imageScale = 0.6 57 | } 58 | 59 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { 60 | withAnimation(Animation.linear(duration: 0.3)) { 61 | self.ringScale = 1 62 | self.imageScale = 1 63 | self.ringOpacity = 0 64 | self.lifetime = 1 65 | self.color = .red 66 | } 67 | } 68 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) { 69 | withAnimation { 70 | self.lifetime = 0 71 | } 72 | } 73 | } 74 | } 75 | } 76 | 77 | struct HeartButton_Previews: PreviewProvider { 78 | static var previews: some View { 79 | HeartButton() 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Animations/LikeButton/LikeButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LikeButton.swift 3 | // InstaPosts 4 | // 5 | // Created by InnAppsCoding on 21/06/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct LikeButton: View { 12 | 13 | @State private var ringScale: CGFloat = 0 14 | @State private var ringOpacity: Double = 1 15 | @State private var imageScale: CGFloat = 1 16 | @State private var imageRotation: Double = 0 17 | @State private var orbOffset: Double = 0 18 | @State private var ordScale: CGFloat = 0 19 | @State private var color = Color.gray 20 | 21 | var body: some View { 22 | ZStack { 23 | 24 | ForEach(0..<8) { 25 | Circle() 26 | .foregroundColor(Color(UIColor(red: 0.00, green: 0.00, blue: 1.0, alpha: 1.00))) 27 | .frame(width: ($0.isMultiple(of: 2) ? 15 : 5), height: ($0.isMultiple(of: 2) ? 15 : 5)) 28 | .scaleEffect(self.ordScale) 29 | .opacity($0.isMultiple(of: 2) ? 1 : 0.5) 30 | .offset(CGSize(width: 0, height: ($0.isMultiple(of: 2) ? self.orbOffset : self.orbOffset/1.2))) 31 | .rotationEffect(.degrees(Double(($0 * 45)))) 32 | } 33 | 34 | Circle() 35 | .stroke(Color.gray, lineWidth: 8) 36 | .frame(width: 100, height: 100) 37 | .opacity(self.ringOpacity) 38 | .scaleEffect(self.ringScale) 39 | 40 | Rectangle() 41 | .frame(width: 50, height: 50) 42 | .foregroundColor(color) 43 | .mask( 44 | Image("like") 45 | .resizable() 46 | ) 47 | .scaleEffect(self.imageScale) 48 | .rotationEffect(.degrees(self.imageRotation)) 49 | } 50 | .onTapGesture { 51 | self.orbOffset = 0 52 | self.ringOpacity = 1 53 | self.ringScale = 0 54 | withAnimation(Animation.linear(duration: 0.3)) { 55 | self.imageScale = 0.6 56 | self.imageRotation = -30 57 | } 58 | 59 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { 60 | withAnimation(Animation.linear(duration: 0.6)) { 61 | self.orbOffset = -50 62 | } 63 | withAnimation(Animation.linear(duration: 0.3)) { 64 | self.color = Color.blue 65 | self.ordScale = 1 66 | self.ringScale = 1 67 | self.imageScale = 1 68 | self.ringOpacity = 0 69 | self.imageRotation = 0 70 | } 71 | } 72 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) { 73 | withAnimation(Animation.linear(duration: 0.3)) { 74 | self.ordScale = 0 75 | } 76 | } 77 | } 78 | } 79 | } 80 | 81 | struct LikeButton_Previews: PreviewProvider { 82 | static var previews: some View { 83 | LikeButton() 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Animations/LoadingScreen/LoadingScreen.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoadingScreen.swift 3 | // InstaPosts 4 | // 5 | // Created by InnAppsCoding on 28/07/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct LoadingScreen: View { 12 | 13 | let darkGradient = Gradient(colors: [Color(UIColor(red: 0.192, green: 0.212, blue: 0.329, alpha: 1.000)), Color(UIColor(red: 0.565, green: 0.608, blue: 0.667, alpha: 1.000))]) 14 | 15 | @State private var ball1Pos: CGFloat = -75 16 | @State private var ball2Pos: CGFloat = 0 17 | @State private var ball3Pos: CGFloat = 75 18 | @State private var ball4Pos: CGFloat = 150 19 | 20 | var body: some View { 21 | ZStack { 22 | Color.offWhite 23 | .edgesIgnoringSafeArea(.all) 24 | 25 | Capsule() 26 | .foregroundColor(.offWhite) 27 | .frame(width: 190, height: 470) 28 | .shadow(color: Color.black.opacity(0.2), radius: 10, x: 10, y: 10) 29 | .shadow(color: Color.white.opacity(0.7), radius: 10, x: -5, y: -5) 30 | 31 | ZStack{ 32 | Capsule() 33 | .stroke(Color.offWhite, lineWidth: 10) 34 | .shadow(color: Color.black.opacity(0.2), radius: 10, x: 10, y: 10) 35 | .clipShape( 36 | Capsule() 37 | ) 38 | .shadow(color: Color.white.opacity(0.7), radius: 2, x: -2, y: -2) 39 | .clipShape( 40 | Capsule() 41 | ) 42 | .frame(width: 150, height: 430) 43 | } 44 | .mask(Capsule().frame(width: 150, height: 430)) 45 | 46 | Circle() 47 | .fill(LinearGradient(gradient: darkGradient, startPoint: .leading, endPoint: .trailing)) 48 | .frame(width: 30, height: 30) 49 | .offset(x: 0, y: ball1Pos) 50 | 51 | Circle() 52 | .fill(LinearGradient(gradient: darkGradient, startPoint: .leading, endPoint: .trailing)) 53 | .frame(width: 30, height: 30) 54 | .offset(x: 0, y: ball2Pos) 55 | 56 | Circle() 57 | .fill(LinearGradient(gradient: darkGradient, startPoint: .leading, endPoint: .trailing)) 58 | .frame(width: 30, height: 30) 59 | .offset(x: 0, y: ball3Pos) 60 | 61 | Circle() 62 | .fill(LinearGradient(gradient: darkGradient, startPoint: .leading, endPoint: .trailing)) 63 | .frame(width: 30, height: 30) 64 | .offset(x: 0, y: ball4Pos) 65 | 66 | Ball() 67 | 68 | } 69 | .onAppear { 70 | self.animate() 71 | Timer.scheduledTimer(withTimeInterval: 4, repeats: true) { _ in 72 | self.animate() 73 | } 74 | } 75 | } 76 | func animate() { 77 | withAnimation(Animation.linear(duration: 0.5)) { 78 | self.ball1Pos = -150 79 | } 80 | withAnimation(Animation.easeInOut(duration: 0.5).delay(0.5)) { 81 | self.ball2Pos = -75 82 | } 83 | withAnimation(Animation.easeInOut(duration: 0.5).delay(1.0)) { 84 | self.ball3Pos = 0 85 | } 86 | withAnimation(Animation.easeInOut(duration: 0.5).delay(1.5)) { 87 | self.ball4Pos = 75 88 | } 89 | DispatchQueue.main.asyncAfter(wallDeadline: .now() + 2.0) { 90 | withAnimation(Animation.easeInOut(duration: 0.5)) { 91 | self.ball4Pos = 150 92 | } 93 | withAnimation(Animation.easeInOut(duration: 0.5).delay(0.5)) { 94 | self.ball3Pos = 75 95 | } 96 | withAnimation(Animation.easeInOut(duration: 0.5).delay(1.0)) { 97 | self.ball2Pos = 0 98 | } 99 | withAnimation(Animation.easeInOut(duration: 0.5).delay(1.5)) { 100 | self.ball1Pos = -75 101 | } 102 | } 103 | } 104 | } 105 | 106 | struct LoadingScreen_Previews: PreviewProvider { 107 | static var previews: some View { 108 | LoadingScreen() 109 | } 110 | } 111 | 112 | struct Ball: View { 113 | let lightGradient = Gradient(colors: [Color(UIColor(red: 0.01, green: 0.67, blue: 0.69, alpha: 1.00)), 114 | Color(UIColor(red: 0.00, green: 0.80, blue: 0.67, alpha: 1.00))]) 115 | @State private var flag = false 116 | 117 | var body: some View { 118 | ZStack { 119 | Circle() 120 | .fill(LinearGradient(gradient: lightGradient, startPoint: .leading, endPoint: .trailing)) 121 | .frame(width: 30, height: 30).offset(x: -15, y: -15) 122 | .modifier(Follow(pct: self.flag ? 1 : 0, path: BallPath.createPath(in: CGRect(x: 0, y: 0, width: 100, height: 300)))) 123 | .offset(x: -35, y: -135) 124 | .onAppear { 125 | withAnimation(Animation.linear(duration: 4.0).repeatForever(autoreverses: false)) { 126 | self.flag.toggle() 127 | } 128 | } 129 | } 130 | } 131 | } 132 | 133 | struct Follow: GeometryEffect { 134 | var pct: CGFloat = 0 135 | let path: Path 136 | 137 | var animatableData: CGFloat { 138 | get { return pct } 139 | set { pct = newValue } 140 | } 141 | 142 | func effectValue(size: CGSize) -> ProjectionTransform { 143 | let pt = percentPoint(pct) 144 | return ProjectionTransform(CGAffineTransform(translationX: pt.x, y: pt.y)) 145 | } 146 | 147 | func percentPoint(_ percent: CGFloat) -> CGPoint { 148 | 149 | let pct = percent > 1 ? 0 : (percent < 0 ? 1 : percent) 150 | 151 | let f = pct > 0.999 ? CGFloat(1-0.001) : pct 152 | let t = pct > 0.999 ? CGFloat(1) : pct + 0.001 153 | let tp = path.trimmedPath(from: f, to: t) 154 | 155 | return CGPoint(x: tp.boundingRect.midX, y: tp.boundingRect.midY) 156 | } 157 | } 158 | 159 | struct BallPath: Shape { 160 | func path(in rect: CGRect) -> Path { 161 | return BallPath.createPath(in: rect) 162 | } 163 | 164 | static func createPath(in rect: CGRect) -> Path { 165 | 166 | let heightFactor = rect.size.height/8 167 | let midX = rect.midX 168 | 169 | var path = Path() 170 | 171 | path.move(to: CGPoint(x: midX, y: rect.minY)) 172 | 173 | path.addArc(center: CGPoint(x: midX, y: heightFactor), radius: heightFactor, startAngle: .degrees(-90), endAngle: .degrees(90), clockwise: false) 174 | 175 | path.addArc(center: CGPoint(x: midX, y: heightFactor*3), radius: heightFactor, startAngle: .degrees(-90), endAngle: .degrees(90), clockwise: true) 176 | 177 | path.addArc(center: CGPoint(x: midX, y: heightFactor*5), radius: heightFactor, startAngle: .degrees(-90), endAngle: .degrees(90), clockwise: false) 178 | 179 | path.addArc(center: CGPoint(x: midX, y: heightFactor*7), radius: heightFactor, startAngle: .degrees(-90), endAngle: .degrees(90), clockwise: true) 180 | 181 | 182 | path.addArc(center: CGPoint(x: midX, y: heightFactor*7), radius: heightFactor, startAngle: .degrees(90), endAngle: .degrees(-90), clockwise: true) 183 | 184 | path.addArc(center: CGPoint(x: midX, y: heightFactor*5), radius: heightFactor, startAngle: .degrees(90), endAngle: .degrees(-90), clockwise: false) 185 | 186 | path.addArc(center: CGPoint(x: midX, y: heightFactor*3), radius: heightFactor, startAngle: .degrees(90), endAngle: .degrees(-90), clockwise: true) 187 | 188 | path.addArc(center: CGPoint(x: midX, y: heightFactor), radius: heightFactor, startAngle: .degrees(90), endAngle: .degrees(-90), clockwise: false) 189 | 190 | return path 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /Animations/Menu/MenuView.swift: -------------------------------------------------------------------------------- 1 | //// 2 | //// Menu.swift 3 | //// InstaPosts 4 | //// 5 | //// Created by InnAppsCoding on 18/06/2020. 6 | //// Copyright © 2020 InnAppsCoding. All rights reserved 7 | //// 8 | // 9 | //import SwiftUI 10 | // 11 | //// Remember to add PureSwiftUI to your project for this to work https://github.com/CodeSlicing/pure-swift-ui 12 | //import PureSwiftUI 13 | // 14 | //struct MenuView: View { 15 | // 16 | // @State private var animate = false 17 | // @State private var rotation: Double = 0 18 | // @State private var trim: CGFloat = 0 19 | // 20 | // var body: some View { 21 | // ZStack { 22 | // Circle() 23 | // .foregroundColor(.white) 24 | // ZStack { 25 | // Circle() 26 | // .trim(from: 0, to: trim) 27 | // .stroke(lineWidth: 4) 28 | // .rotate(.degrees(rotation - 90.0)) 29 | // Menu(animate: animate) 30 | // .stroke(Color.black, style: StrokeStyle(lineWidth: 20, lineCap: .round)) 31 | // .frame(100) 32 | // } 33 | // .rotate(.degrees(rotation)) 34 | // } 35 | // .frame(250) 36 | // .onTapGesture { 37 | // withAnimation(Animation.linear(duration: 0.5)) { 38 | // if self.animate { 39 | // self.rotation = 0 40 | // self.trim = 0 41 | // } else { 42 | // self.rotation = 180 43 | // self.trim = 1 44 | // } 45 | // self.animate.toggle() 46 | // } 47 | // } 48 | // } 49 | //} 50 | // 51 | //struct MenuView_Previews: PreviewProvider { 52 | // static var previews: some View { 53 | // MenuView() 54 | // } 55 | //} 56 | // 57 | //struct Menu: Shape { 58 | // private let layoutConfig = LayoutGuideConfig.grid(columns: 2, rows: 2) 59 | // private var factor: Double 60 | // 61 | // init(animate: Bool = true) { 62 | // self.factor = animate ? 1 : 0 63 | // } 64 | // 65 | // var animatableData: Double { 66 | // get { factor } 67 | // set { factor = newValue } 68 | // } 69 | // 70 | // func path(in rect: CGRect) -> Path { 71 | // var path = Path() 72 | // 73 | // var g = layoutConfig.layout(in: rect) 74 | // 75 | // path.move(g[0, 0]) 76 | // path.line(g[2, 0].to(g[2, 2], factor)) 77 | // 78 | // path.move(g[0, 1].to(g[1, 1], factor)) 79 | // path.line(g[2, 1].to(g[1, 1], factor)) 80 | // 81 | // path.move(g[0, 2]) 82 | // path.line(g[2, 2].to(g[2, 0], factor)) 83 | // 84 | // return path 85 | // } 86 | //} 87 | // 88 | -------------------------------------------------------------------------------- /Animations/ParticlesEmitter/ParticlesEmitter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ParticlesEmitter.swift 3 | // SwiftUI-Particles 4 | // 5 | // Created by Arthur Guibert on 28/10/2019. 6 | // Copyright © 2019 Arthur Guibert. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | import UIKit 11 | 12 | 13 | /// Class that wraps the CAEmitterCell in a class compatible with SwiftUI 14 | public struct ParticlesEmitter: UIViewRepresentable { 15 | var center: CGPoint = .zero 16 | var emitterSize: CGSize = .init(width: 1, height: 1) 17 | var shape: CAEmitterLayerEmitterShape = .line 18 | var cells: [CAEmitterCell] = [] 19 | 20 | public func updateUIView(_ uiView: InternalParticlesView, context: UIViewRepresentableContext) { 21 | uiView.emit(from: center, 22 | size: emitterSize, 23 | shape: shape, 24 | cells: cells) 25 | } 26 | 27 | public func makeUIView(context: Context) -> InternalParticlesView { 28 | let view = InternalParticlesView() 29 | view.emit(from: center, 30 | size: emitterSize, 31 | shape: shape, 32 | cells: cells) 33 | return view 34 | } 35 | } 36 | 37 | extension ParticlesEmitter { 38 | func emitterSize(_ size: CGSize) -> Self { 39 | return ParticlesEmitter(center: self.center, emitterSize: size, shape: shape, cells: self.cells) 40 | } 41 | 42 | func emitterPosition(_ position: CGPoint) -> Self { 43 | return ParticlesEmitter(center: position, emitterSize: self.emitterSize, shape: shape, cells: self.cells) 44 | } 45 | 46 | func emitterShape(_ shape: CAEmitterLayerEmitterShape) -> Self { 47 | return ParticlesEmitter(center: self.center, emitterSize: self.emitterSize, shape: shape, cells: self.cells) 48 | } 49 | } 50 | 51 | 52 | /// The container view class for the particles, as the project is using a CAEmitterLayer 53 | public final class InternalParticlesView: UIView { 54 | private var particleEmitter: CAEmitterLayer? 55 | 56 | /// Function that adds the emitter cells to the layer 57 | /// - Parameter center: center of the emitter 58 | /// - Parameter size: size of the emitter 59 | /// - Parameter cells: all the CAEmitterCell 60 | func emit(from center: CGPoint, size: CGSize, shape: CAEmitterLayerEmitterShape, cells: [CAEmitterCell]) { 61 | if particleEmitter == nil { 62 | particleEmitter = CAEmitterLayer() 63 | layer.addSublayer(particleEmitter!) 64 | } 65 | 66 | particleEmitter?.emitterPosition = center 67 | particleEmitter?.emitterShape = shape 68 | particleEmitter?.emitterSize = size 69 | particleEmitter?.emitterCells = cells 70 | } 71 | } 72 | 73 | @_functionBuilder 74 | struct EmitterCellBuilder { 75 | static func buildBlock(_ cells: CAEmitterCell...) -> [CAEmitterCell] { 76 | Array(cells) 77 | } 78 | } 79 | 80 | extension ParticlesEmitter { 81 | init(@EmitterCellBuilder _ content: () -> [CAEmitterCell]) { 82 | self.init(cells: content()) 83 | } 84 | 85 | init(@EmitterCellBuilder _ content: () -> CAEmitterCell) { 86 | self.init(cells: [content()]) 87 | } 88 | } 89 | 90 | class EmitterCell: CAEmitterCell { 91 | override init() { 92 | super.init() 93 | } 94 | 95 | required init?(coder: NSCoder) { 96 | super.init(coder: coder) 97 | } 98 | 99 | func copyEmitter() -> EmitterCell { 100 | return super.copy() as! EmitterCell 101 | } 102 | } 103 | 104 | 105 | extension EmitterCell { 106 | /// Content for the emitter cell, it is either an image, or a circle. 107 | /// NB: It could easily be extended for other shapes. 108 | public enum Content { 109 | case image(UIImage) 110 | case circle(CGFloat) 111 | } 112 | 113 | @inlinable func content(_ content: Content) -> Self { 114 | self.contents = content.image.cgImage 115 | return self 116 | } 117 | 118 | @inlinable func birthRate(_ birthRate: Float) -> Self { 119 | self.birthRate = birthRate 120 | return self 121 | } 122 | 123 | @inlinable func lifetime(_ lifetime: Float) -> Self { 124 | self.lifetime = lifetime 125 | return self 126 | } 127 | 128 | @inlinable func scale(_ scale: CGFloat) -> Self { 129 | self.scale = scale 130 | return self 131 | } 132 | 133 | @inlinable func scaleRange(_ scaleRange: CGFloat) -> Self { 134 | self.scaleRange = scaleRange 135 | return self 136 | } 137 | 138 | @inlinable func scaleSpeed(_ scaleSpeed: CGFloat) -> Self { 139 | self.scaleSpeed = scaleSpeed 140 | return self 141 | } 142 | 143 | @inlinable func velocity(_ velocity: CGFloat) -> Self { 144 | self.velocity = velocity 145 | return self 146 | } 147 | 148 | @inlinable func velocityRange(_ velocityRange: CGFloat) -> Self { 149 | self.velocityRange = velocityRange 150 | return self 151 | } 152 | 153 | @inlinable func emissionLongitude(_ emissionLongitude: CGFloat) -> Self { 154 | self.emissionLongitude = emissionLongitude 155 | return self 156 | } 157 | 158 | @inlinable func emissionLatitude(_ emissionLatitude: CGFloat) -> Self { 159 | self.emissionLatitude = emissionLatitude 160 | return self 161 | } 162 | 163 | @inlinable func emissionRange(_ emissionRange: CGFloat) -> Self { 164 | self.emissionRange = emissionRange 165 | return self 166 | } 167 | 168 | @inlinable func spin(_ spin: CGFloat) -> Self { 169 | self.spin = spin 170 | return self 171 | } 172 | 173 | @inlinable func spinRange(_ spinRange: CGFloat) -> Self { 174 | self.spinRange = spinRange 175 | return self 176 | } 177 | 178 | @inlinable func color(_ color: UIColor) -> Self { 179 | self.color = color.cgColor 180 | return self 181 | } 182 | 183 | @inlinable func xAcceleration(_ xAcceleration: CGFloat) -> Self { 184 | self.xAcceleration = xAcceleration 185 | return self 186 | } 187 | 188 | @inlinable func yAcceleration(_ yAcceleration: CGFloat) -> Self { 189 | self.yAcceleration = yAcceleration 190 | return self 191 | } 192 | 193 | @inlinable func zAcceleration(_ zAcceleration: CGFloat) -> Self { 194 | self.zAcceleration = zAcceleration 195 | return self 196 | } 197 | 198 | @inlinable func alphaSpeed(_ alphaSpeed: Float) -> Self { 199 | self.alphaSpeed = alphaSpeed 200 | return self 201 | } 202 | 203 | @inlinable func alphaRange(_ alphaRange: Float) -> Self { 204 | self.alphaRange = alphaRange 205 | return self 206 | } 207 | } 208 | 209 | fileprivate extension EmitterCell.Content { 210 | var image: UIImage { 211 | switch self { 212 | case let .image(image): 213 | return image 214 | case let .circle(radius): 215 | let size = CGSize(width: radius * 2, height: radius * 2) 216 | return UIGraphicsImageRenderer(size: size).image { context in 217 | context.cgContext.setFillColor(UIColor.white.cgColor) 218 | context.cgContext.addPath(CGPath(ellipseIn: CGRect(origin: .zero, size: size), transform: nil)) 219 | context.cgContext.fillPath() 220 | } 221 | } 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /Animations/Radar/Radar.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Radar.swift 3 | // Animations 4 | // 5 | // Created by Inncoder on 25/08/2020. 6 | // Copyright © 2020 Inncoder. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct Marker: Identifiable, Hashable { 12 | var id: Int 13 | var offet: CGFloat 14 | var degrees: Double 15 | } 16 | 17 | struct Radar: View { 18 | @State private var rotation: Double = 0 19 | @State private var opasity: Double = 1 20 | 21 | private var markers: [Marker] = [] 22 | private var scannerTailColor: AngularGradient = AngularGradient( 23 | gradient: Gradient(colors: [Color.blue]), 24 | center: .center 25 | ) 26 | 27 | init() { 28 | self.markers = randomMarkersList() 29 | self.scannerTailColor = AngularGradient( 30 | gradient: Gradient(colors: [color.opacity(0), color.opacity(1)]), 31 | center: .center 32 | ) 33 | } 34 | 35 | var body: some View { 36 | ZStack { 37 | Color.offWhite.edgesIgnoringSafeArea(.all) 38 | Circle() 39 | .fill(Color.offWhite) 40 | .frame(width: self.scannerSize, height: self.scannerSize) 41 | .shadow(color: Color.black.opacity(0.2), radius: 10, x: 10, y: 10) 42 | .shadow(color: Color.white.opacity(0.7), radius: 10, x: -5, y: -5) 43 | // Markers 44 | ForEach(markers, id: \.self) { m in 45 | Circle() 46 | .opacity(self.opasity) 47 | .animation( 48 | Animation 49 | .linear(duration: self.scannerSpeed) 50 | .repeatForever(autoreverses: false) 51 | .delay((self.scannerSpeed / 360) * (90 + m.degrees)) 52 | ) 53 | .frame(width: self.markerSize, height: self.markerSize) 54 | .foregroundColor(self.color) 55 | .offset(x: m.offet, y: 0) 56 | .rotationEffect(.degrees(m.degrees)) 57 | .blur(radius: 2) 58 | } 59 | // Scanner tail 60 | Circle() 61 | .trim(from: 0, to: 0.375) 62 | .stroke(lineWidth: self.scannerSize / 2) 63 | .fill(scannerTailColor) 64 | .frame(width: self.scannerSize / 2, height: self.scannerSize / 2) 65 | .rotationEffect(.degrees(135 + self.rotation)) 66 | 67 | // Scanner line 68 | Rectangle() 69 | .frame(width: 4, height: (self.scannerSize / 2)) 70 | .offset(x: 0, y: -self.scannerSize / 4) 71 | .rotationEffect(.degrees(self.rotation)) 72 | .foregroundColor(self.color) 73 | 74 | // Scanner middle point 75 | Circle() 76 | .frame(width: self.middlePointSize, height: self.middlePointSize) 77 | .foregroundColor(self.color) 78 | } 79 | .onAppear { 80 | self.opasity = 0 81 | withAnimation(Animation.linear(duration: self.scannerSpeed).repeatForever(autoreverses: false)) { 82 | self.rotation = 360 83 | } 84 | } 85 | } 86 | 87 | func randomMarkersList() -> [Marker] { 88 | var markers = [Marker]() 89 | 90 | for i in 0..= (-Int((self.height/2) + self.curveHeight)) { 54 | if self.animate { 55 | withAnimation(Animation.linear(duration: 0.03)) { 56 | self.offsetY -= 1 57 | } 58 | } 59 | } 60 | } 61 | } 62 | } 63 | } 64 | 65 | struct Fluid: Shape { 66 | var time: CGFloat 67 | let width: CGFloat 68 | let height: CGFloat 69 | let curveHeight: CGFloat 70 | let curveLength: CGFloat 71 | 72 | func path(in rect: CGRect) -> Path { 73 | return ( 74 | Path { path in 75 | path.move(to: CGPoint(x: width, y: height*2)) 76 | path.addLine(to: CGPoint(x: 0, y: height*2)) 77 | for i in stride(from: 0, to: CGFloat(rect.width), by: 1) { 78 | path.addLine(to: CGPoint(x: i, y: sin(((i / rect.height) + time) * curveLength * .pi) * curveHeight + rect.midY)) 79 | } 80 | path.addLine(to: CGPoint(x: width, y: height*2)) 81 | } 82 | ) 83 | } 84 | } 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Animations/Reddit/RedditView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RedditView.swift 3 | // InstaPosts 4 | // 5 | // Created by InnAppsCoding on 21/06/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | 12 | struct RedditView: View { 13 | let gradient = LinearGradient(gradient: Gradient(colors: [.yellow, .red]), startPoint: .top, endPoint: .bottom) 14 | var body: some View { 15 | Reddit(width: 250, 16 | height: 250, 17 | curveHeight: 10, 18 | curveLength: 1.5, 19 | speed: 0.4, 20 | color: gradient 21 | ) 22 | .shadow(color: .gray, radius: 2, x: 3, y: 3) 23 | } 24 | } 25 | 26 | struct RedditView_Previews: PreviewProvider { 27 | static var previews: some View { 28 | RedditView() 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Animations/Search/Search.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Search.swift 3 | // Animations 4 | // 5 | // Created by Inncoder on 14/09/2020. 6 | // Copyright © 2020 Inncoder AS. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct Search: View { 12 | 13 | @State private var searching = false 14 | @State private var searchText = "" 15 | 16 | @State private var trimTo: CGFloat = 0 17 | @State private var lineOffset: CGFloat = 0 18 | @State private var rotation: Double = 0 19 | @State private var xRotation: Double = 0 20 | @State private var opacity: Double = 0 21 | 22 | 23 | var body: some View { 24 | HStack { 25 | ZStack { 26 | TextField("", text: $searchText, onEditingChanged: { _ in 27 | self.animateToX() 28 | }) 29 | .frame(width: textFieldSize, height: size) 30 | Capsule() 31 | .stroke(lineWidth: strokeWidth) 32 | .frame(width: textFieldSize + 20, height: size + 10) 33 | } 34 | .padding() 35 | ZStack { 36 | Circle() 37 | .stroke(lineWidth: strokeWidth) 38 | .frame(width: size, height: size) 39 | Circle() 40 | .trim(from: 0, to: trimTo) 41 | .stroke(lineWidth: size / 2) 42 | .frame(width: size / 2, height: size / 2) 43 | .rotationEffect(.degrees(45)) 44 | 45 | Capsule() 46 | .frame(width: size / 2, height: strokeWidth) 47 | .offset(x: size / 4, y: 0) 48 | .offset(x: lineOffset, y: 0) 49 | .rotationEffect(.degrees(rotation)) 50 | 51 | ZStack { 52 | Capsule() 53 | .rotationEffect(.degrees(-xRotation)) 54 | Capsule() 55 | .rotationEffect(.degrees(xRotation)) 56 | } 57 | .frame(width: size / 2, height: strokeWidth / 2) 58 | .foregroundColor(.white) 59 | .opacity(opacity) 60 | } 61 | .onTapGesture { 62 | self.searchText = "" 63 | self.animateToSearch() 64 | } 65 | } 66 | .onAppear { 67 | self.lineOffset = self.size / 2 68 | self.rotation = 45 69 | } 70 | } 71 | 72 | // MARK: - Drawing constants 73 | let size: CGFloat = 30 74 | let textFieldSize: CGFloat = 150 75 | let strokeWidth: CGFloat = 5 76 | let animationDuration: Double = 0.6 77 | 78 | // MARK: - Functions 79 | func animateToX() { 80 | if !self.searching { 81 | withAnimation(Animation.linear(duration: self.animationDuration / 3)) { 82 | self.lineOffset = 0 83 | } 84 | DispatchQueue.main.asyncAfter(deadline: .now() + self.animationDuration / 3 * 2) { 85 | withAnimation(Animation.linear(duration: self.animationDuration / 3)) { 86 | self.rotation = 360 87 | self.trimTo = 1 88 | } 89 | } 90 | DispatchQueue.main.asyncAfter(deadline: .now() + (self.animationDuration / 3) * 3) { 91 | withAnimation(Animation.linear(duration: self.animationDuration / 3)) { 92 | self.opacity = 1 93 | self.xRotation = 45 94 | } 95 | } 96 | self.searching = true 97 | } 98 | } 99 | 100 | func animateToSearch() { 101 | if self.searching { 102 | withAnimation(Animation.linear(duration: self.animationDuration / 3)) { 103 | self.opacity = 0 104 | self.xRotation = 0 105 | 106 | } 107 | DispatchQueue.main.asyncAfter(deadline: .now() + self.animationDuration / 3) { 108 | withAnimation(Animation.linear(duration: self.animationDuration / 3)) { 109 | self.rotation = 45 110 | self.trimTo = 0 111 | } 112 | } 113 | DispatchQueue.main.asyncAfter(deadline: .now() + (self.animationDuration / 3) * 2) { 114 | withAnimation(Animation.linear(duration: self.animationDuration / 3)) { 115 | self.lineOffset = self.size / 2 116 | } 117 | } 118 | } 119 | self.searching = false 120 | } 121 | } 122 | 123 | struct Search_Previews: PreviewProvider { 124 | static var previews: some View { 125 | Search() 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /Animations/Share Button/ShareButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ShareButton.swift 3 | // InstagramAnimation 4 | // 5 | // Created by InnAppsCoding on 11/06/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct ShareButton: View { 12 | 13 | @State private var o1: CGFloat = 0 14 | @State private var o2: CGFloat = 300 15 | @State private var o3: CGFloat = 0 16 | 17 | @State private var shared = false 18 | @State private var text = "Share!" 19 | 20 | var body: some View { 21 | ZStack { 22 | ZStack { 23 | // ShareItems(shared: $shared, 24 | // text: $text, 25 | // o1: $o1, 26 | // o2: $o2, 27 | // o3: $o3) 28 | Sticker(shared: $shared, 29 | text: $text, 30 | o1: $o1, 31 | o2: $o2, 32 | o3: $o3) 33 | } 34 | .frame(width: 300, height: 100) 35 | } 36 | } 37 | } 38 | 39 | struct ShareButton_Previews: PreviewProvider { 40 | static var previews: some View { 41 | ShareButton() 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Animations/Share Button/ShareItems.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ShareItems.swift 3 | // InstaPosts 4 | // 5 | // Created by InnAppsCoding on 11/06/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct ShareItems: View { 12 | 13 | @Binding var shared: Bool 14 | @Binding var text: String 15 | @Binding var o1: CGFloat 16 | @Binding var o2: CGFloat 17 | @Binding var o3: CGFloat 18 | 19 | @State private var b1Tapped = false 20 | 21 | var body: some View { 22 | ZStack { 23 | 24 | Capsule() 25 | .stroke(Color.gray, lineWidth: 4) 26 | .blur(radius: 5) 27 | .frame(width: 300, height: 100) 28 | .offset(x: 2, y: 3) 29 | .clipShape(Capsule()) 30 | 31 | HStack { 32 | Spacer() 33 | 34 | Button(action: { 35 | self.share() 36 | }) { 37 | ZStack { 38 | RoundedRectangle(cornerRadius: 10) 39 | .frame(width: 50, height: 50) 40 | .foregroundColor(.white) 41 | .shadow(color: .gray, radius: 5, x: 2, y: 3) 42 | Image("twitter") 43 | .resizable() 44 | .frame(width: 40, height: 40) 45 | } 46 | } 47 | .buttonStyle(PlainButtonStyle()) 48 | 49 | Spacer() 50 | 51 | Button(action: { 52 | self.share() 53 | }) { 54 | ZStack { 55 | RoundedRectangle(cornerRadius: 10) 56 | .foregroundColor(.white) 57 | .frame(width: 50, height: 50) 58 | .shadow(color: .gray, radius: 5, x: 2, y: 3) 59 | Image("facebook") 60 | .resizable() 61 | .frame(width: 55, height: 40) 62 | } 63 | } 64 | .buttonStyle(PlainButtonStyle()) 65 | 66 | Spacer() 67 | 68 | Button(action: { 69 | self.share() 70 | }) { 71 | ZStack { 72 | RoundedRectangle(cornerRadius: 10) 73 | .foregroundColor(.white) 74 | .frame(width: 50, height: 50) 75 | .shadow(color: .gray, radius: 5, x: 2, y: 3) 76 | Image("instagram") 77 | .resizable() 78 | .frame(width: 40, height: 40) 79 | } 80 | } 81 | .buttonStyle(PlainButtonStyle()) 82 | 83 | Spacer() 84 | } 85 | } 86 | } 87 | func share() { 88 | self.shared = false 89 | self.text = "Thank You!" 90 | withAnimation(Animation.linear(duration: 1)) { 91 | self.o1 = 0 92 | self.o2 = 300 93 | self.o3 = 0 94 | } 95 | } 96 | } 97 | 98 | -------------------------------------------------------------------------------- /Animations/Share Button/Sticker.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Sticker.swift 3 | // InstaPosts 4 | // 5 | // Created by InnAppsCoding on 11/06/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct Sticker: View { 12 | 13 | @Binding var shared: Bool 14 | @Binding var text: String 15 | @Binding var o1: CGFloat 16 | @Binding var o2: CGFloat 17 | @Binding var o3: CGFloat 18 | 19 | let gradient = LinearGradient( 20 | gradient: Gradient(colors: [ 21 | Color(UIColor(red: 0.00, green: 0.62, blue: 1.00, alpha: 1.00)), 22 | Color(UIColor(red: 0.35, green: 0.75, blue: 1.00, alpha: 1.00)) 23 | ]), 24 | startPoint: .leading, 25 | endPoint: .trailing 26 | ) 27 | 28 | var body: some View { 29 | ZStack { 30 | if !shared { 31 | ZStack { 32 | Capsule() 33 | .fill(gradient) 34 | .frame(width: 300, height: 100) 35 | .offset(x: 0, y: 0) 36 | .mask(Capsule()) 37 | Text(text) 38 | .font(.largeTitle) 39 | } 40 | .mask(Rectangle().offset(x: o1, y: 0)) 41 | 42 | .onTapGesture { 43 | withAnimation(Animation.linear(duration: 1)) { 44 | withAnimation(Animation.linear(duration: 1.5)) { 45 | self.o1 = -290 46 | self.o2 = 10 47 | self.o3 = -290 48 | } 49 | } 50 | DispatchQueue.main.asyncAfter(deadline: .now() + 1) { 51 | self.shared = true 52 | } 53 | } 54 | } 55 | ZStack { 56 | Capsule() 57 | .foregroundColor(.gray) 58 | .frame(width: 300, height: 100) 59 | .offset(x: o2, y: 0) 60 | } 61 | .mask(Rectangle()) 62 | .offset(x: o3, y: 0) 63 | } 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /Animations/ShareTwitter/Twitter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Fluid.swift 3 | // InstaPosts 4 | // 5 | // Created by InnAppsCoding on 16/06/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct Twitter: View { 12 | 13 | @State var width: CGFloat 14 | @State var height: CGFloat 15 | @State var curveHeight: CGFloat = 0 16 | @State var curveLength: CGFloat 17 | @State var speed: Double 18 | @State var color: Color 19 | 20 | @State private var time: Double = 0 21 | @State private var offsetY = 0 22 | @State private var animate = false 23 | 24 | var body: some View { 25 | VStack { 26 | ZStack { 27 | Rectangle() 28 | .frame(width: width, height: height) 29 | ZStack { 30 | Fluid(time: CGFloat(time*1.2), width: width, height: height, curveHeight: curveHeight, curveLength: curveLength) 31 | .fill(color) 32 | .frame(width: width, height: height) 33 | Fluid(time: CGFloat(time), width: width, height: height, curveHeight: curveHeight, curveLength: curveLength) 34 | .fill(color) 35 | .opacity(0.5) 36 | .frame(width: width, height: height) 37 | } 38 | .offset(x: 0, y: CGFloat(self.offsetY)) 39 | } 40 | .mask( 41 | Image("twitter") 42 | .resizable() 43 | .frame(width: width, height: height) 44 | ) 45 | } 46 | .onTapGesture { 47 | self.animate.toggle() 48 | } 49 | .onAppear { 50 | self.offsetY = Int((self.height/2) + self.curveHeight) 51 | Timer.scheduledTimer(withTimeInterval: 0.02, repeats: true) { _ in 52 | self.time += 0.01 53 | if self.offsetY >= (-Int((self.height/2) + self.curveHeight)) { 54 | if self.animate { 55 | withAnimation(Animation.linear(duration: 0.03)) { 56 | self.offsetY -= 1 57 | } 58 | } 59 | } 60 | } 61 | } 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /Animations/ShareTwitter/TwitterView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TwitterView.swift 3 | // InstaPosts 4 | // 5 | // Created by InnAppsCoding on 16/06/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct TwitterView: View { 12 | var body: some View { 13 | Twitter(width: 250, 14 | height: 250, 15 | curveHeight: 10, 16 | curveLength: 1.5, 17 | speed: 1, 18 | color: Color(UIColor(red: 0.35, green: 0.80, blue: 0.93, alpha: 1.00)) 19 | ) 20 | } 21 | } 22 | 23 | struct TwitterView_Previews: PreviewProvider { 24 | static var previews: some View { 25 | TwitterView() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Animations/Slider/Slider.swift: -------------------------------------------------------------------------------- 1 | //// 2 | //// Slider.swift 3 | //// InstaPosts 4 | //// 5 | //// Created by InnAppsCoding on 19/06/2020. 6 | //// Copyright © 2020 InnAppsCoding. All rights reserved. 7 | //// 8 | // 9 | //import SwiftUI 10 | //import PureSwiftUI 11 | // 12 | //struct Slider: View { 13 | // @State var percentage: Float = 50 14 | // @State var width: CGFloat 15 | // var body: some View { 16 | // ZStack(alignment: .center) { 17 | // Capsule() 18 | // .foregroundColor(.blue) 19 | // .frame(width: width < 100 ? 100 : width, height: 50) 20 | // SliderBase(percentage: $percentage) 21 | // .frame(width: width < 100 ? 100-65 : width-65, height: 50) 22 | // } 23 | // } 24 | //} 25 | // 26 | //struct SliderBase: View { 27 | // @Binding var percentage: Float 28 | // @State private var animated = false 29 | // 30 | // var body: some View { 31 | // GeometryReader { geometry in 32 | // ZStack(alignment: .leading) { 33 | // Rectangle() 34 | // .foregroundColor(.blue) 35 | // SliderTop(animate: self.$animated, percentage: self.$percentage) 36 | // .offset((geometry.size.width * CGFloat(self.percentage / 100)-25), self.animated ? -55 : 0) 37 | // } 38 | // .gesture(DragGesture(minimumDistance: 0) 39 | // .onEnded({ _ in 40 | // withAnimation() { 41 | // self.animated = false 42 | // } 43 | // }) 44 | // .onChanged({ value in 45 | // withAnimation(Animation.spring(response: 0.5, dampingFraction: 0.8, blendDuration: 0.9)) { 46 | // self.animated = true 47 | // } 48 | // self.percentage = min(max(0, Float(value.location.x / (geometry.size.width) * 100)), 100) 49 | // })) 50 | // 51 | // } 52 | // } 53 | //} 54 | // 55 | //struct SliderTop: View { 56 | // @Binding var animate: Bool 57 | // @Binding var percentage: Float 58 | // 59 | // var body: some View { 60 | // ZStack { 61 | // Trapezoid(animate: animate) 62 | // .foregroundColor(.blue) 63 | // .frame(width: 35, height: 15) 64 | // .offset(0, 25) 65 | // Circle() 66 | // .foregroundColor(.blue) 67 | // .frame(50) 68 | // Circle() 69 | // .foregroundColor(.white) 70 | // .frame(40) 71 | // Text("\(Int(percentage))") 72 | // .foregroundColor(.black) 73 | // } 74 | // } 75 | //} 76 | // 77 | //struct Trapezoid: Shape { 78 | // private let layoutGrid = LayoutGuideConfig.grid(columns: 4, rows: 4) 79 | // private var factor: Double 80 | // 81 | // init(animate: Bool = true) { 82 | // self.factor = animate ? 0 : 1 83 | // } 84 | // 85 | // var animatableData: Double { 86 | // get { 87 | // factor 88 | // } 89 | // set { 90 | // factor = newValue 91 | // } 92 | // } 93 | // 94 | // func path(in rect: CGRect) -> Path { 95 | // var g = layoutGrid.layout(in: rect) 96 | // var path = Path() 97 | // path.move(g[0, 4].to(g[2, 0], factor)) 98 | // path.addQuadCurve(to: g[0, 0].to(g[2, 0], factor), control: g[1, 2].to(g[2, 0], factor)) 99 | // path.addLine(to: g[4, 0].to(g[2, 0], factor)) 100 | // path.addQuadCurve(to: g[4, 4].to(g[2, 0], factor), control: g[3, 2].to(g[2, 0], factor)) 101 | // return path 102 | // } 103 | //} 104 | -------------------------------------------------------------------------------- /Animations/Slider/SliderView.swift: -------------------------------------------------------------------------------- 1 | //// 2 | //// SliderView.swift 3 | //// InstaPosts 4 | //// 5 | //// Created by InnAppsCoding on 19/06/2020. 6 | //// Copyright © 2020 InnAppsCoding. All rights reserved. 7 | //// 8 | // 9 | //import SwiftUI 10 | // 11 | //struct SliderView: View { 12 | // @State var percentage: Float = 50 13 | // 14 | // var body: some View { 15 | // Slider(width: 250) 16 | // } 17 | //} 18 | // 19 | //struct SliderView_Previews: PreviewProvider { 20 | // static var previews: some View { 21 | // SliderView() 22 | // } 23 | //} 24 | -------------------------------------------------------------------------------- /Animations/StarRating/SliderController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SliderView.swift 3 | // InstaPosts 4 | // 5 | // Created by InnAppsCoding on 22/06/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct SliderController: View { 12 | 13 | @Binding var percentage: Float 14 | @Binding var lifetime: Float 15 | 16 | var body: some View { 17 | GeometryReader { geometry in 18 | ZStack(alignment: .leading) { 19 | Rectangle() 20 | .foregroundColor(Color(.darkGray)) 21 | Rectangle() 22 | .foregroundColor(.yellow) 23 | .frame(width: geometry.size.width * CGFloat(self.percentage / 100)) 24 | } 25 | .cornerRadius(12) 26 | .gesture(DragGesture(minimumDistance: 0) 27 | .onEnded({ _ in 28 | withAnimation() { 29 | self.lifetime = 1 30 | } 31 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { 32 | withAnimation { 33 | self.lifetime = 0 34 | } 35 | } 36 | 37 | }) 38 | .onChanged({ value in 39 | self.percentage = min(max(0, Float(value.location.x / geometry.size.width * 100)), 100) 40 | })) 41 | } 42 | } 43 | } 44 | 45 | struct SliderController_Previews: PreviewProvider { 46 | static var previews: some View { 47 | SliderController(percentage: .constant(50), lifetime: .constant(0)) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Animations/StarRating/StarRating.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StarRating.swift 3 | // InstaPosts 4 | // 5 | // Created by InnAppsCoding on 22/06/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct StarRating: View { 12 | 13 | @State private var percentage: Float = 50 14 | @State private var lifetime: Float = 0 15 | var body: some View { 16 | ZStack { 17 | ParticlesEmitter { 18 | EmitterCell() 19 | .content(.image(UIImage(systemName: "star")!)) 20 | .lifetime(self.lifetime) 21 | .birthRate(100) 22 | .velocity(100) 23 | .scale(0.3) 24 | .alphaSpeed(-0.2) 25 | .scaleSpeed(-0.1) 26 | .emissionRange(.pi * 2) 27 | .yAcceleration(-30) 28 | .color(UIColor.yellow) 29 | } 30 | .emitterSize(CGSize(width: 1, height: 1)) 31 | .emitterShape(.circle) 32 | .frame(width: 1, height: 1) 33 | .offset(x: (2.4 * CGFloat(self.percentage))-120, y: 0) 34 | 35 | SliderController(percentage: $percentage, lifetime: $lifetime) 36 | .mask(Stars()) 37 | .frame(width: 240, height: 40) 38 | } 39 | } 40 | } 41 | 42 | struct StarRating_Previews: PreviewProvider { 43 | static var previews: some View { 44 | StarRating() 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Animations/StarRating/Stars.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Stars.swift 3 | // InstaPosts 4 | // 5 | // Created by InnAppsCoding on 22/06/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct Stars: View { 12 | var body: some View { 13 | HStack(spacing: 2) { 14 | ForEach(1..<6) { _ in 15 | Image(systemName: "star.fill") 16 | .resizable() 17 | } 18 | } 19 | } 20 | } 21 | 22 | struct Stars_Previews: PreviewProvider { 23 | static var previews: some View { 24 | Stars() 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Animations/StickerToggle/Buttons.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Buttons.swift 3 | // Animations 4 | // 5 | // Created by Inncoder on 31/08/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct ButtonOn: View { 12 | 13 | @State var size: CGFloat 14 | 15 | var body: some View { 16 | ZStack { 17 | Circle() 18 | .foregroundColor(Color(red: 0.67, green: 0.81, blue: 1.00)) 19 | .frame(width: size / 2, height: size / 2) 20 | Image(systemName: "sun.max.fill") 21 | .resizable() 22 | .foregroundColor(.yellow) 23 | .frame(width: size / 4, height: size / 4) 24 | Image(systemName: "cloud.fill") 25 | .resizable() 26 | .foregroundColor(.white) 27 | .frame(width: size / 6, height: size / 8) 28 | .offset(x: size / 10, y: size / 10) 29 | } 30 | } 31 | } 32 | 33 | struct Buttons_Previews: PreviewProvider { 34 | static var previews: some View { 35 | ButtonOn(size: 150) 36 | } 37 | } 38 | 39 | struct ButtonOff: View { 40 | 41 | @State var size: CGFloat 42 | 43 | var body: some View { 44 | ZStack { 45 | Circle() 46 | .foregroundColor(.black) 47 | .frame(width: size / 2, height: size / 2) 48 | Image(systemName: "moon.fill") 49 | .resizable() 50 | .foregroundColor(.white) 51 | .frame(width: size / 4, height: size / 4) 52 | Image(systemName: "star.fill") 53 | .resizable() 54 | .foregroundColor(.yellow) 55 | .frame(width: size / 20, height: size / 20) 56 | .offset(x: size / 6, y: 0) 57 | Image(systemName: "star.fill") 58 | .resizable() 59 | .foregroundColor(.yellow) 60 | .frame(width: size / 20, height: size / 20) 61 | .offset(x: size / 15, y: -size / 8) 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Animations/StickerToggle/StickerToggle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StickerToggle.swift 3 | // Animations 4 | // 5 | // Created by Inncoder on 26/08/2020. 6 | // Copyright © 2020 Inncoder AS. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct StickerToggle: View { 12 | let darkBackground = Color(red: 0.189, green: 0.187, blue: 0.256) 13 | 14 | @State private var offsetGray: CGFloat = 0 15 | @State private var offsetGreen: CGFloat = 0 16 | 17 | @State private var offsetRect: CGFloat = 0 18 | 19 | @State private var darkmode = false 20 | @State private var toggled = false 21 | @State private var animating = false 22 | 23 | var body: some View { 24 | ZStack { 25 | if darkmode { 26 | darkBackground.edgesIgnoringSafeArea(.all) 27 | } else { 28 | Color.white.edgesIgnoringSafeArea(.all) 29 | } 30 | 31 | Capsule() 32 | .frame(width: toggleSize + buttonPadding, height: (toggleSize / 2) + buttonPadding) 33 | .foregroundColor(.gray) 34 | ZStack { 35 | Rectangle() 36 | .frame(width: toggleSize, height: toggleSize / 2) 37 | .opacity(0) 38 | if toggled { 39 | ButtonOff(size: toggleSize) 40 | .offset(x: offsetGray, y: 0) 41 | ButtonOn(size: toggleSize) 42 | .offset(x: offsetGreen, y: 0) 43 | } else { 44 | ButtonOn(size: toggleSize) 45 | .offset(x: offsetGreen, y: 0) 46 | ButtonOff(size: toggleSize) 47 | .offset(x: offsetGray, y: 0) 48 | } 49 | } 50 | .mask(Rectangle().offset(x: self.offsetRect, y: 0)) 51 | .offset(x: -self.toggleSize / 4, y: 0) 52 | } 53 | .onAppear { 54 | self.offsetGreen = 0 55 | self.offsetGray = -self.toggleSize / 2 56 | self.offsetRect = self.toggleSize / 4 57 | } 58 | .onTapGesture { 59 | if !self.animating { 60 | withAnimation { 61 | self.darkmode.toggle() 62 | } 63 | self.animating = true 64 | if self.toggled { 65 | self.offsetGreen = self.toggleSize 66 | self.offsetGray = self.toggleSize / 2 67 | self.offsetRect = self.toggleSize / 4 68 | withAnimation(Animation.easeIn) { 69 | self.offsetGreen = 0 70 | self.offsetRect = -self.toggleSize / 4 71 | } 72 | } else { 73 | self.offsetGreen = 0 74 | self.offsetGray = -self.toggleSize / 2 75 | self.offsetRect = self.toggleSize / 4 76 | withAnimation(Animation.easeIn) { 77 | self.offsetGray = self.toggleSize / 2 78 | self.offsetRect = self.toggleSize * 0.75 79 | } 80 | } 81 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { 82 | self.toggled.toggle() 83 | self.animating = false 84 | } 85 | } 86 | } 87 | .preferredColorScheme(self.darkmode ? .dark : .light) 88 | } 89 | 90 | // MARK: - Drawing constants 91 | 92 | let toggleSize: CGFloat = 120 93 | let buttonPadding: CGFloat = 10 94 | let toggleSwitchSize: CGFloat = 75 95 | } 96 | 97 | struct StickerToggle_Previews: PreviewProvider { 98 | static var previews: some View { 99 | StickerToggle() 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Animations/TabBar/Bar.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TabBar.swift 3 | // InstaPosts 4 | // 5 | // Created by InnAppsCoding on 02/08/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct Bar: Shape { 12 | var tab: CGFloat 13 | 14 | var animatableData: Double { 15 | get { return Double(tab) } 16 | set { tab = CGFloat(newValue) } 17 | } 18 | 19 | func path(in rect: CGRect) -> Path { 20 | 21 | var path = Path() 22 | 23 | let widthFactor = rect.maxX/(CGFloat(TabItems.shared.items.count) + 1) 24 | let widthFactorTimesCount = (rect.maxX/(CGFloat(TabItems.shared.items.count) + 1)) * tab 25 | 26 | path.move(to: CGPoint(x: rect.minX, y: rect.minY)) 27 | path.addLine(to: CGPoint(x: rect.minX, y: rect.maxY)) 28 | path.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY)) 29 | path.addLine(to: CGPoint(x: rect.maxX, y: rect.minY)) 30 | path.addLine(to: CGPoint(x: widthFactorTimesCount + widthFactor, y: rect.minY)) 31 | path.addCurve(to: CGPoint(x: widthFactorTimesCount, y: rect.midY), 32 | control1: CGPoint(x: widthFactorTimesCount + 40, y: rect.minY), 33 | control2: CGPoint(x: widthFactorTimesCount + 40, y: rect.minY + 50)) 34 | path.addCurve(to: CGPoint(x: widthFactorTimesCount - widthFactor, y: rect.minY), 35 | control1: CGPoint(x: widthFactorTimesCount - 40, y: rect.minY + 50), 36 | control2: CGPoint(x: widthFactorTimesCount - 40, y: rect.minY)) 37 | path.addLine(to: CGPoint(x: rect.maxX - widthFactorTimesCount, y: rect.minY)) 38 | return path 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Animations/TabBar/TabBar.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TabBar.swift 3 | // InstaPosts 4 | // 5 | // Created by InnAppsCoding on 02/08/2020. 6 | // Copyright © 2020 InnAppsCoding. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct TabBar: View { 12 | let darkBackground = UIColor(red: 0.189, green: 0.187, blue: 0.256, alpha: 1.0) 13 | 14 | @ObservedObject var tabItems = TabItems.shared 15 | 16 | @State private var circleSize: CGFloat = 50 17 | @State private var iconeSize: CGFloat = 30 18 | 19 | var body: some View { 20 | ZStack { 21 | Color(darkBackground) 22 | .edgesIgnoringSafeArea(.all) 23 | VStack { 24 | Spacer() 25 | ZStack { 26 | Bar(tab: tabItems.selectedTabIndex) 27 | .foregroundColor(.white) 28 | .frame(width: UIScreen.main.bounds.width, height: 100) 29 | HStack(spacing: (UIScreen.main.bounds.width - (CGFloat(TabItems.shared.items.count + 1) * self.circleSize)) / (CGFloat(TabItems.shared.items.count) + 1)) { 30 | ForEach(0.. Bool { 25 | lhs.id <= rhs.id 26 | } 27 | } 28 | 29 | class TabItems: ObservableObject { 30 | static let shared = TabItems() 31 | 32 | @Published var items: [TabItem] = [ 33 | TabItem(imageName: "house.fill", offset: -40), 34 | TabItem(imageName: "magnifyingglass"), 35 | TabItem(imageName: "plus.app"), 36 | TabItem(imageName: "heart"), 37 | TabItem(imageName: "person.fill"), 38 | ] 39 | 40 | @Published var selectedTabIndex: CGFloat = 1 41 | 42 | func select(_ index: Int) { 43 | let tabItem = items[index] 44 | 45 | tabItem.opacity = 0 46 | tabItem.offset = 30 47 | 48 | withAnimation(Animation.easeInOut) { 49 | selectedTabIndex = CGFloat(index + 1) 50 | for i in 0..