Skip to content

Instantly share code, notes, and snippets.

⚡️
Get shit done!

Christian Aranda WildStudio

⚡️
Get shit done!
Block or report user

Report or block WildStudio

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:3c9eadc4c26d169d5d6aee14604379a9
import SwiftUI
struct ContentView : View {
var body: some View {
Text("Hello World")
}
}
View gist:547bffa9562b1e97eb93580a3b2bd3bb
// Instantiate a new UIWindow with the size of our phone screen and assign it to the window property
let window = UIWindow(frame: UIScreen.main.bounds)
// Instantiate a UIHostingController which is a ViewController but it is capable of holding the new SwiftUI View.
window.rootViewController = UIHostingController(rootView: ContentView())
self.window = window
// Make the window key and visible. This is telling it is the active window.
window.makeKeyAndVisible()
View gist:252e87e7a1e806c68439f9adb20da36e
struct LoginView: View {
@State var username: String = ""
@State var password: String = ""
@State var authenticationDidFail: Bool = false
var body: some View {
VStack {
View gist:3ebb7ed6e7d3ff2a7d3d572aea994146
struct LoginView: View {
@State var username: String = ""
@State var password: String = ""
@State var authenticationDidFail: Bool = false
var body: some View {
}
@WildStudio
WildStudio / Map Operation
Created Jul 5, 2019
Combine: Map Operation
View Map Operation
let _ = Just(5)
.map { $0 * 10 ) }.sink { receivedValue in
// sink is a subscriber that terminates the pipeline
print("The result is \(receivedValue)")
}
@WildStudio
WildStudio / Subscribe
Created Jul 5, 2019
Combine: Subscribe
View Subscribe
let label = UILabel()
let labelSubscriber = Subscribers.Assign(object: label, keyPath: \.text)
publisher.subscribe(labelSubscriber)
@WildStudio
WildStudio / Creating a Publisher
Created Jul 5, 2019
Combine: Creating a Publisher
View Creating a Publisher
import Combine
extension Notification.Name {
static let upadateLabel = Notification.Name("updateLabel")
}
struct Data {
let title: String
}
@WildStudio
WildStudio / Cancellable Publisher
Created Jul 5, 2019
Combine: Cancellable Publisher
View Cancellable Publisher
let cancellablePublisher = somePublisher.sink { data in
// do something
}
cancellablePublisher.cancel()
@WildStudio
WildStudio / UIViewPropertyAnimator
Created May 30, 2019
Adding spring animation with UIViewPropertyAnimator
View UIViewPropertyAnimator
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,
View UISpringTimingParameters
UISpringTimingParameters(mass: CGFloat, stiffness: CGFloat, damping: CGFloat, initialVelocity: CGVector)
You can’t perform that action at this time.