This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct LoginView: View { | |
@State var username: String = "" | |
@State var password: String = "" | |
@State var authenticationDidFail: Bool = false | |
var body: some View { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let _ = Just(5) | |
.map { $0 * 10 ) }.sink { receivedValue in | |
// sink is a subscriber that terminates the pipeline | |
print("The result is \(receivedValue)") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let label = UILabel() | |
let labelSubscriber = Subscribers.Assign(object: label, keyPath: \.text) | |
publisher.subscribe(labelSubscriber) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Combine | |
extension Notification.Name { | |
static let upadateLabel = Notification.Name("updateLabel") | |
} | |
struct Data { | |
let title: String | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let cancellablePublisher = somePublisher.sink { data in | |
// do something | |
} | |
cancellablePublisher.cancel() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { | |
guard let toViewController = transitionContext | |
.viewController(forKey: .to) as? DetailViewController else { return } | |
let animator = UIViewPropertyAnimator(duration: Constant.duration, dampingRatio: 0.82) | |
let container = transitionContext.containerView | |
container.addSubview(toViewController.view) | |
let offscreenY = toViewController.view.bounds.height - toViewController.view.frame.minY + 20 | |
toViewController.positionContainer(left: 20.0, | |
right: 20.0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UISpringTimingParameters(mass: CGFloat, stiffness: CGFloat, damping: CGFloat, initialVelocity: CGVector) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UISpringTimingParameters(mass: CGFloat, stiffness: CGFloat, damping: CGFloat, initialVelocity: CGVector) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { | |
guard let toViewController = transitionContext | |
.viewController(forKey: .to) as? DetailViewController else { return } | |
let container = transitionContext.containerView | |
container.addSubview(toViewController.view) | |
toViewController.positionContainer(left: 20.0, | |
right: 20.0, | |
top: selectedCardFrame.origin.y + 20.0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func onTapButton(_ sender: Any) { | |
presentAnimationController.selectedCardFrame = imageView.frame | |
self.performSegue(withIdentifier: "showDetail", sender: nil) | |
} |