Skip to content

Instantly share code, notes, and snippets.

View abadikaka's full-sized avatar
🎯
Focusing

Michael Abadi Santoso abadikaka

🎯
Focusing
View GitHub Profile
@abadikaka
abadikaka / BuilderBlock.swift
Last active May 13, 2020 14:11
Builder Pattern - Block
// We reuse the above SportCarBuilder, we just change some interface
// Notice we instead are using the block for update the necessary properties
class SportCar {
typealias Builder = (builder: SportCarBuilder) -> Void
private init(builder: SportCarBuilder) {
super.init(doors: Door(2), engine: Engine(V85000), wheel: builder.wheel, color: builder.color)
}
static func make(with builderBlock: Builder) -> SportCar {
@abadikaka
abadikaka / BuilderDeclarative.swift
Created May 13, 2020 06:22
Builder Pattern Declarative Way
// This one is a SportCarBuilder for building a sport car
// We just need two properties of wheel and color that can be added and modified
// However for engine and door has been defined by SportCar class
final class SportCarBuilder {
private var wheel: Wheel = Wheel(type: .racing(tyre20))
private var color: Color = Color(.red)
func withColor(color: UIColor) {
self.color = Color(color)
@abadikaka
abadikaka / BuilderConstructor.swift
Last active May 13, 2020 14:34
Builder Pattern Constructor way
// This is the base Car class that has all of the foundation materials to make a Car
class Car {
let doors: Door
let wheel: Wheel
let engine: Engine
let color: Color
func buildCar() -> Car
}
@abadikaka
abadikaka / ShareViewController.swift
Created April 24, 2020 07:54
ShareViewController ShareKitTutorial
//
// ShareViewController.swift
// SharingExtension
//
// Created by Michael Abadi Santoso on 1/28/20.
// Copyright © 2020 Michael Abadi Santoso. All rights reserved.
//
import UIKit
import StorageKitTutorial
@abadikaka
abadikaka / NetworkKit.swift
Created April 24, 2020 07:43
NetworkKit ShareKitTutorial
//
// NetworkKit.swift
// NetworkKitTutorial
//
// Created by Michael Abadi Santoso on 1/27/20.
// Copyright © 2020 Michael Abadi Santoso. All rights reserved.
//
import Foundation
@abadikaka
abadikaka / StorageKit.swift
Created April 24, 2020 07:23
Storage Kit SharingKitTutorial
//
// StorageKit.swift
// StorageKitTutorial
//
// Created by Michael Abadi Santoso on 1/27/20.
// Copyright © 2020 Michael Abadi Santoso. All rights reserved.
//
import Foundation
@abadikaka
abadikaka / SelectorEngine.swift
Created April 24, 2020 06:49
Selector Engine ShareKitTutorial
//
// SelectorEngine.swift
// SelectorUIViewKitTutorial
//
// Created by Michael Abadi Santoso on 1/27/20.
// Copyright © 2020 Michael Abadi Santoso. All rights reserved.
//
import Foundation
import SwiftUI
@abadikaka
abadikaka / SelectorView.swift
Last active April 24, 2020 06:49
SelectorView Share Kit Tutorial
//
// SelectorView.swift
// SelectorUIViewKitTutorial
//
// Created by Michael Abadi Santoso on 1/27/20.
// Copyright © 2020 Michael Abadi Santoso. All rights reserved.
//
import SwiftUI