Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -62,6 +63,7 @@
4FB400D12925CBE3001E7313 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4FB400D32925CC28001E7313 /* login_bear.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = login_bear.riv; sourceTree = "<group>"; };
4FE33861292BE1DD007BD11E /* RiveChallenge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RiveChallenge.swift; sourceTree = "<group>"; };
87B58B2E29340208009E5595 /* UIView + Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView + Utils.swift"; sourceTree = "<group>"; };
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 = "<group>"; };
FD5968022908A666002B9C6B /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -133,6 +135,14 @@
path = Challenge;
sourceTree = "<group>";
};
87B58B2D293401F9009E5595 /* Extensions */ = {
isa = PBXGroup;
children = (
87B58B2E29340208009E5595 /* UIView + Utils.swift */,
);
path = Extensions;
sourceTree = "<group>";
};
FD5967F42908A666002B9C6B = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -176,6 +186,7 @@
FD5968392908BEC9002B9C6B /* Showcases */ = {
isa = PBXGroup;
children = (
87B58B2D293401F9009E5595 /* Extensions */,
FD5968622909A720002B9C6B /* RiveSection */,
FD5968612909A717002B9C6B /* LottieSection */,
FD5968582908DAD4002B9C6B /* HeaderSection */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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";
Expand All @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "bigPlant.png",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "mediumPlant.png",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "smallPlant.png",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import UIKit

extension UIView {
func addSubviews(_ views: [UIView]) {
views.forEach { view in
view.translatesAutoresizingMaskIntoConstraints = false

addSubview(view)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down
Loading