diff --git a/SwiftUIPlayground.xcodeproj/project.xcworkspace/xcuserdata/tahatesser.xcuserdatad/UserInterfaceState.xcuserstate b/SwiftUIPlayground.xcodeproj/project.xcworkspace/xcuserdata/tahatesser.xcuserdatad/UserInterfaceState.xcuserstate index a0eb44d..256fffe 100644 Binary files a/SwiftUIPlayground.xcodeproj/project.xcworkspace/xcuserdata/tahatesser.xcuserdatad/UserInterfaceState.xcuserstate and b/SwiftUIPlayground.xcodeproj/project.xcworkspace/xcuserdata/tahatesser.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/SwiftUIPlayground/Assets.xcassets/Joker.imageset/Contents.json b/SwiftUIPlayground/Assets.xcassets/Joker.imageset/Contents.json new file mode 100644 index 0000000..0cf0c44 --- /dev/null +++ b/SwiftUIPlayground/Assets.xcassets/Joker.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "Joker.jpg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SwiftUIPlayground/Assets.xcassets/Joker.imageset/Joker.jpg b/SwiftUIPlayground/Assets.xcassets/Joker.imageset/Joker.jpg new file mode 100644 index 0000000..ce00e02 Binary files /dev/null and b/SwiftUIPlayground/Assets.xcassets/Joker.imageset/Joker.jpg differ diff --git a/SwiftUIPlayground/Assets.xcassets/Red_Deck.imageset/Contents.json b/SwiftUIPlayground/Assets.xcassets/Red_Deck.imageset/Contents.json new file mode 100644 index 0000000..d187d8e --- /dev/null +++ b/SwiftUIPlayground/Assets.xcassets/Red_Deck.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "Red_Deck.jpg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SwiftUIPlayground/Assets.xcassets/Red_Deck.imageset/Red_Deck.jpg b/SwiftUIPlayground/Assets.xcassets/Red_Deck.imageset/Red_Deck.jpg new file mode 100644 index 0000000..6dedffd Binary files /dev/null and b/SwiftUIPlayground/Assets.xcassets/Red_Deck.imageset/Red_Deck.jpg differ diff --git a/SwiftUIPlayground/Samples.swift b/SwiftUIPlayground/Samples.swift index 4d349e7..73f619c 100644 --- a/SwiftUIPlayground/Samples.swift +++ b/SwiftUIPlayground/Samples.swift @@ -179,6 +179,7 @@ public let samples: [String: AnyView] = [ title: "View", samples: [ "Color Brightess": AnyView(ColorBrightnessSample()), + "Flipper Animation": AnyView(FlipperAnimationSample()), ] )), "NumbersDataBasicValues": AnyView(SamplesList( @@ -186,5 +187,5 @@ public let samples: [String: AnyView] = [ [ "NumberFormatter": AnyView(NumberFormatterSample()), ] - )) + )), ] diff --git a/SwiftUIPlayground/Samples/NumbersDataBasicValues/NumberFormatterSample.swift b/SwiftUIPlayground/Samples/NumbersDataBasicValues/NumberFormatterSample.swift index 9e3dc95..bb7fcf2 100644 --- a/SwiftUIPlayground/Samples/NumbersDataBasicValues/NumberFormatterSample.swift +++ b/SwiftUIPlayground/Samples/NumbersDataBasicValues/NumberFormatterSample.swift @@ -13,7 +13,7 @@ struct NumberFormatterSample: View { .font(.system(size: 80, weight: .bold)) .padding() } - + private func formatNumberAsWords(_ number: Int) -> String { let numberFormatter = NumberFormatter() numberFormatter.numberStyle = .spellOut diff --git a/SwiftUIPlayground/Samples/View/FlipperAnimationSample.swift b/SwiftUIPlayground/Samples/View/FlipperAnimationSample.swift new file mode 100644 index 0000000..40186a5 --- /dev/null +++ b/SwiftUIPlayground/Samples/View/FlipperAnimationSample.swift @@ -0,0 +1,41 @@ +// +// FlipperAnimationSample.swift +// SwiftUIPlayground +// +// Created by Taha Tesser on 05.01.2025. +// + +import SwiftUI + +struct FlipperAnimationSample: View { + @State private var timer: Timer? + @State private var flipped: Bool = false + + var body: some View { + ZStack { + Image(.joker) + .rotation3DEffect(.degrees(flipped ? -180 : 0), axis: (x: 1.0, y: 0.0, z: 0.0)) + .opacity(flipped ? 0 : 1) + + Image(.redDeck) + .rotation3DEffect(.degrees(flipped ? 0 : 180), axis: (x: 1.0, y: 0.0, z: 0.0)) + .opacity(flipped ? 1 : 0) + } + .onAppear { + timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { _ in + + withAnimation(.spring(response: 0.6, dampingFraction: 0.7, blendDuration: 0.2)) { + flipped.toggle() + } + } + } + .onDisappear { + timer?.invalidate() + timer = nil + } + } +} + +#Preview { + FlipperAnimationSample() +}