diff --git a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase.xcodeproj/project.pbxproj b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase.xcodeproj/project.pbxproj index 1bc780f..55cac0d 100644 --- a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase.xcodeproj/project.pbxproj +++ b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 4FB400D22925CBE3001E7313 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4FB400D12925CBE3001E7313 /* Assets.xcassets */; }; 4FB400D42925CC28001E7313 /* login_bear.riv in Resources */ = {isa = PBXBuildFile; fileRef = 4FB400D32925CC28001E7313 /* login_bear.riv */; }; 4FE33862292BE1DD007BD11E /* RiveChallenge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FE33861292BE1DD007BD11E /* RiveChallenge.swift */; }; + 87B58B2F29340208009E5595 /* UIView + Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 87B58B2E29340208009E5595 /* UIView + Utils.swift */; }; FD5968012908A666002B9C6B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD5968002908A666002B9C6B /* AppDelegate.swift */; }; FD5968032908A666002B9C6B /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD5968022908A666002B9C6B /* SceneDelegate.swift */; }; FD5968052908A666002B9C6B /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD5968042908A666002B9C6B /* HomeViewController.swift */; }; @@ -62,6 +63,7 @@ 4FB400D12925CBE3001E7313 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 4FB400D32925CC28001E7313 /* login_bear.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = login_bear.riv; sourceTree = ""; }; 4FE33861292BE1DD007BD11E /* RiveChallenge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RiveChallenge.swift; sourceTree = ""; }; + 87B58B2E29340208009E5595 /* UIView + Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView + Utils.swift"; sourceTree = ""; }; FD5967FD2908A666002B9C6B /* AnimationsShowcase.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AnimationsShowcase.app; sourceTree = BUILT_PRODUCTS_DIR; }; FD5968002908A666002B9C6B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; FD5968022908A666002B9C6B /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -133,6 +135,14 @@ path = Challenge; sourceTree = ""; }; + 87B58B2D293401F9009E5595 /* Extensions */ = { + isa = PBXGroup; + children = ( + 87B58B2E29340208009E5595 /* UIView + Utils.swift */, + ); + path = Extensions; + sourceTree = ""; + }; FD5967F42908A666002B9C6B = { isa = PBXGroup; children = ( @@ -176,6 +186,7 @@ FD5968392908BEC9002B9C6B /* Showcases */ = { isa = PBXGroup; children = ( + 87B58B2D293401F9009E5595 /* Extensions */, FD5968622909A720002B9C6B /* RiveSection */, FD5968612909A717002B9C6B /* LottieSection */, FD5968582908DAD4002B9C6B /* HeaderSection */, @@ -386,6 +397,7 @@ FD5968442908CF39002B9C6B /* Positioning.swift in Sources */, FD59683D2908C425002B9C6B /* HomeSectionView.swift in Sources */, FD59684C2908CFCA002B9C6B /* Spring.swift in Sources */, + 87B58B2F29340208009E5595 /* UIView + Utils.swift in Sources */, FD5968552908D362002B9C6B /* BaseViewController.swift in Sources */, FD5968642909A740002B9C6B /* LottieBasics.swift in Sources */, FD5968502908D07A002B9C6B /* FirstSectionChallenge.swift in Sources */, @@ -553,22 +565,25 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = 34HR7YPNJ4; + DEVELOPMENT_TEAM = 8GU3CF32ZF; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = AnimationsShowcase/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = br.com.leocoout.AnimationsShowcase; + PRODUCT_BUNDLE_IDENTIFIER = br.com.elsePerez.AnimationsShowcase; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -580,22 +595,25 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = 34HR7YPNJ4; + DEVELOPMENT_TEAM = 8GU3CF32ZF; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = AnimationsShowcase/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = br.com.leocoout.AnimationsShowcase; + PRODUCT_BUNDLE_IDENTIFIER = br.com.elsePerez.AnimationsShowcase; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/bigPlant.imageset/Contents.json b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/bigPlant.imageset/Contents.json new file mode 100644 index 0000000..d62de31 --- /dev/null +++ b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/bigPlant.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "bigPlant.png", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/bigPlant.imageset/bigPlant.png b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/bigPlant.imageset/bigPlant.png new file mode 100644 index 0000000..df8dc3c Binary files /dev/null and b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/bigPlant.imageset/bigPlant.png differ diff --git a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/mediumPlant.imageset/Contents.json b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/mediumPlant.imageset/Contents.json new file mode 100644 index 0000000..fb17127 --- /dev/null +++ b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/mediumPlant.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "mediumPlant.png", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true + } +} diff --git a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/mediumPlant.imageset/mediumPlant.png b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/mediumPlant.imageset/mediumPlant.png new file mode 100644 index 0000000..73afc03 Binary files /dev/null and b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/mediumPlant.imageset/mediumPlant.png differ diff --git a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/smallPlant.imageset/Contents.json b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/smallPlant.imageset/Contents.json new file mode 100644 index 0000000..78ee0b7 --- /dev/null +++ b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/smallPlant.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "smallPlant.png", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true + } +} diff --git a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/smallPlant.imageset/smallPlant.png b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/smallPlant.imageset/smallPlant.png new file mode 100644 index 0000000..a171d58 Binary files /dev/null and b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Assets.xcassets/smallPlant.imageset/smallPlant.png differ diff --git a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/DO NOT CHANGE /BaseViewController.swift b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/DO NOT CHANGE /BaseViewController.swift index b7543b0..51618b5 100644 --- a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/DO NOT CHANGE /BaseViewController.swift +++ b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/DO NOT CHANGE /BaseViewController.swift @@ -16,7 +16,7 @@ class BaseViewController: UIViewController { return view }() - private lazy var actionButton: UIButton = { + lazy var actionButton: UIButton = { var config = UIButton.Configuration.filled() config.baseBackgroundColor = .devpass diff --git a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/Extensions/UIView + Utils.swift b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/Extensions/UIView + Utils.swift new file mode 100644 index 0000000..1df7fcc --- /dev/null +++ b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/Extensions/UIView + Utils.swift @@ -0,0 +1,11 @@ +import UIKit + +extension UIView { + func addSubviews(_ views: [UIView]) { + views.forEach { view in + view.translatesAutoresizingMaskIntoConstraints = false + + addSubview(view) + } + } +} diff --git a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/BezierCurves.swift b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/BezierCurves.swift index a7e082f..39cc102 100644 --- a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/BezierCurves.swift +++ b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/BezierCurves.swift @@ -3,6 +3,23 @@ import UIKit final class BezierCurvesViewController: BaseViewController { override func didTapActionButton() { /// Aplique as animações no objeto `square` + let timeFunc = CAMediaTimingFunction(controlPoints: 0.5, 0, 1, 1) + CATransaction.setAnimationTimingFunction(timeFunc) + UIView.transition(with: square, + duration: 0.5) { + self.actionButton.setTitle("", for: .normal) + self.square.transform = .init(translationX: 100, y: 300) + } completion: { _ in + UIView.animate(withDuration: 0.4, delay: 0) { + self.square.transform = .init(translationX: 150, y: 100) + } completion: { _ in + UIView.animate(withDuration: 0.4, delay: 0) { + self.square.transform = .init(translationX: 0, y: 0) + } completion: { _ in + self.actionButton.setTitle("Animar", for: .normal) + } + } + } } } diff --git a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/Challenge/FirstSectionChallenge.swift b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/Challenge/FirstSectionChallenge.swift index 07ef96a..7ebfcfa 100644 --- a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/Challenge/FirstSectionChallenge.swift +++ b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/Challenge/FirstSectionChallenge.swift @@ -1,6 +1,176 @@ import UIKit -final class FirstSectionChallengeViewController: UIViewController {} +final class FirstSectionChallengeViewController: UIViewController { + let step:Float = 10 + + private lazy var questionLabel: UILabel = { + let label = UILabel() + label.textAlignment = .center + label.font = .systemFont(ofSize: 24) + label.tintColor = .black + label.numberOfLines = 0 + label.lineBreakMode = .byWordWrapping + label.text = "Qual o tamanho do diâmetro do pote?" + label.isHidden = true + return label + }() + + private lazy var baseImageView: UIView = { + let view = UIView(frame: .zero) + view.translatesAutoresizingMaskIntoConstraints = false + return view + }() + + private lazy var plantImageView: UIImageView = { + let imageView = UIImageView(frame: .zero) + imageView.translatesAutoresizingMaskIntoConstraints = false + imageView.image = UIImage(named: "smallPlant") + return imageView + }() + + private lazy var sizePlantSlider: UISlider = { + let slider = UISlider(frame: .zero) + slider.minimumValue = 10 + slider.maximumValue = 40 + slider.isContinuous = true + slider.tintColor = UIColor.green + slider.addTarget(self, action: #selector(self.sliderValueDidChange(_:)), for: .valueChanged) + slider.isHidden = true + return slider + }() + + private lazy var plantSizeLabel: UILabel = { + let label = UILabel() + label.textAlignment = .center + label.font = .systemFont(ofSize: 48) + label.tintColor = .black + label.numberOfLines = 0 + label.lineBreakMode = .byWordWrapping + label.text = "6.0" + return label + }() + + private lazy var sizeLabel: UILabel = { + let label = UILabel() + label.textAlignment = .center + label.font = .systemFont(ofSize: 24) + label.tintColor = .darkGray + label.numberOfLines = 0 + label.lineBreakMode = .byWordWrapping + label.text = "cm" + return label + }() + + private lazy var sizeStackView: UIStackView = { + let stack = UIStackView(arrangedSubviews: [plantSizeLabel, sizeLabel]) + stack.axis = .horizontal + stack.alignment = .center + stack.spacing = 0 + stack.isHidden = true + return stack + }() + + // MARK: - Initialization + override func viewDidLoad() { + super.viewDidLoad() + setup() + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + initialAnimation() + } +} + +extension FirstSectionChallengeViewController { + @objc func sliderValueDidChange(_ sender:UISlider!) { + let plantSize = Double(sizePlantSlider.value) + let sizeString = String(format: "%.1f", plantSize) + plantSizeLabel.text = "\(sizeString)" + animatePlantImage(sizePlant: plantSize) + } + + private func animatePlantImage(sizePlant: Double) { + let isSmallPlant = (10.0..<20.0).contains(sizePlant) + let isMediumPlant = (20.0..<30.0).contains(sizePlant) + + let small = ((sizePlant - 9) / 10) + 1 + let medium = ((sizePlant - 19) / 10) + 2 + let big = ((sizePlant - 29) / 10) + 3 + + UIView.animate(withDuration: 0.5, delay: 0) { + if isSmallPlant { + self.plantImageView.image = UIImage(named: "smallPlant") + self.plantImageView.transform = .init(scaleX: small, y: small) + } else if isMediumPlant { + self.plantImageView.image = UIImage(named: "mediumPlant") + self.plantImageView.transform = .init(scaleX: medium, y: medium) + } else { + self.plantImageView.image = UIImage(named: "bigPlant") + self.plantImageView.transform = .init(scaleX: big, y: big) + } + } + } + + private func initialAnimation() { + UIView.transition(with: self.plantImageView, duration: 1) { + self.plantImageView.transform = .init(scaleX: 8, y: 8) + } completion: { _ in + UIView.animate(withDuration: 1, delay: 0) { + self.plantImageView.transform = .init(scaleX: 1, y: 1) + } completion: { _ in + self.sizeStackView.isHidden = false + self.sizePlantSlider.isHidden = false + self.questionLabel.isHidden = false + self.baseImageView.clipsToBounds = true + self.plantImageView.clipsToBounds = true + } + } + } +} + +// MARK: - ViewConfiguration +extension FirstSectionChallengeViewController: ViewCodable { + func setupSubviews() { + baseImageView.addSubview(plantImageView) + view.addSubviews([questionLabel, + baseImageView, + sizePlantSlider, + sizeStackView]) + } + + func setupConstraints() { + NSLayoutConstraint.activate([ + questionLabel.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 24), + questionLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 24), + questionLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -24), + + baseImageView.topAnchor.constraint(equalTo: questionLabel.bottomAnchor, constant: 24), + baseImageView.centerXAnchor.constraint(equalTo: view.centerXAnchor), + baseImageView.heightAnchor.constraint(equalToConstant: 270), + baseImageView.widthAnchor.constraint(equalToConstant: 270), + + plantImageView.centerYAnchor.constraint(equalTo: baseImageView.centerYAnchor), + plantImageView.centerXAnchor.constraint(equalTo: baseImageView.centerXAnchor), + plantImageView.heightAnchor.constraint(equalToConstant: 80), + plantImageView.widthAnchor.constraint(equalToConstant: 80), + + sizeStackView.topAnchor.constraint(equalTo: baseImageView.bottomAnchor, constant: 24), + sizeStackView.centerXAnchor.constraint(equalTo: view.centerXAnchor), + + sizePlantSlider.topAnchor.constraint(equalTo: sizeStackView.bottomAnchor, constant: 24), + sizePlantSlider.centerXAnchor.constraint(equalTo: view.centerXAnchor), + sizePlantSlider.widthAnchor.constraint(equalToConstant: 300), + sizePlantSlider.heightAnchor.constraint(equalToConstant: 20), + ]) + } + + func setupExtraConfiguration() { + view.backgroundColor = .white + navigationController?.navigationBar.prefersLargeTitles = false + title = "Challenge 🏆" + } +} // MARK: - ShowcaseRow diff --git a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/FadeInFadeOut.swift b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/FadeInFadeOut.swift index e560307..81998e2 100644 --- a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/FadeInFadeOut.swift +++ b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/FadeInFadeOut.swift @@ -3,6 +3,11 @@ import UIKit final class FadeInFadeOutViewController: BaseViewController { override func didTapActionButton() { /// Aplique as animações no objeto `square` + UIView.animate(withDuration: 1, + delay: 0.5, + options: [.repeat, .autoreverse, .curveEaseInOut]) { + self.square.alpha = 0.0 + } } } diff --git a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/Flip.swift b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/Flip.swift index 4b7b354..22c41ba 100644 --- a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/Flip.swift +++ b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/Flip.swift @@ -1,8 +1,27 @@ import UIKit final class FlipViewController: BaseViewController { + private var allReadyTouch = false + + private func topBottomFlip() { + UIView.transition(with: square, duration: 0.5, options: .transitionFlipFromTop, animations: nil) { _ in + UIView.transition(with: self.square, duration: 0.5, options: .transitionFlipFromBottom, animations: nil) { _ in + self.actionButton.isEnabled = true + } + } + } + + private func leftRightFlip() { + UIView.transition(with: square, duration: 0.5, options: .transitionFlipFromLeft, animations: nil) { _ in + UIView.transition(with: self.square, duration: 0.5, options: .transitionFlipFromRight, animations: nil) { _ in + self.topBottomFlip() + } + } + } + override func didTapActionButton() { - /// Aplique as animações no objeto `square` + self.actionButton.isEnabled = false + leftRightFlip() } } diff --git a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/Positioning.swift b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/Positioning.swift index 8009c37..3ec3e76 100644 --- a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/Positioning.swift +++ b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/Positioning.swift @@ -3,6 +3,11 @@ import UIKit final class PositioningViewController: BaseViewController { override func didTapActionButton() { /// Aplique as animações no objeto `square` + UIView.animate(withDuration: 0.5, + delay: 0, + options: [.repeat, .autoreverse]) { + self.square.transform = .init(translationX: 0, y: 200) + } } } diff --git a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/RotationAndScale.swift b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/RotationAndScale.swift index 0e88499..700d60c 100644 --- a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/RotationAndScale.swift +++ b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/RotationAndScale.swift @@ -3,6 +3,12 @@ import UIKit final class RotationAndScaleViewController: BaseViewController { override func didTapActionButton() { /// Aplique as animações no objeto `square` + UIView.animate(withDuration: 0.8, + delay: 0, + options: [.repeat, .autoreverse]) { + self.square.transform = .init(rotationAngle: CGFloat.pi) + self.square.transform = .init(scaleX: 2, y: 2) + } } } diff --git a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/Spring.swift b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/Spring.swift index fca0743..0c9b2dc 100644 --- a/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/Spring.swift +++ b/solutions/devsprint-leonardo-santos-5/matheus-vagner/AnimationsShowcase/Showcases/FirstSection/Spring.swift @@ -3,6 +3,13 @@ import UIKit final class SpringViewController: BaseViewController { override func didTapActionButton() { /// Aplique as animações no objeto `square` + UIView.animate(withDuration: 1, + delay: 0, + usingSpringWithDamping: 0.1, + initialSpringVelocity: 1, + options: [.repeat, .autoreverse]) { + self.square.transform = .init(translationX: 0, y: 100) + } } }