Skip to content

Instantly share code, notes, and snippets.

@angelinaFri
angelinaFri / checkbox-radio-button-extension.swift
Created February 1, 2021 13:56 — forked from kobeumut/checkbox-radio-button-extension.swift
Swift Checkbox and Radio Buttons Extension
//Checkbox
import UIKit
class CheckBox: UIButton {
// Images
let checkedImage = UIImage(named: "ic_check_box")! as UIImage
let uncheckedImage = UIImage(named: "ic_check_box_outline_blank")! as UIImage
// Bool property
var isChecked: Bool = false {
@angelinaFri
angelinaFri / CustomTextField.swift
Created January 16, 2021 11:47 — forked from soggybag/CustomTextField.swift
Adds border, corner radius, and padding to the UITextField. These properties can be set via the attribute inspector in storyboard.
import UIKit
@IBDesignable
class CustomTextField: UITextField {
var padding: UIEdgeInsets {
get {
return UIEdgeInsets(top: 0, left: paddingValue, bottom: 0, right: paddingValue)
}
}
@angelinaFri
angelinaFri / ServiceAdapter.swift
Created June 17, 2020 18:25
Populating UI from Multiple Services
struct Article {}
struct Picture {}
typealias ArticleLoaderResult = Swift.Result<[Article], Error>
protocol ArticleLoader {
func load(date: Date, completion: @escaping (ArticleLoaderResult) -> Void)
}
typealias PictureLoaderResult = Swift.Result<[Picture], Error>
protocol PictureLoader {
import Foundation
// MARK: - TeamPlayersResponse
struct TeamPlayersResponse: Codable {
let copyright: String
let roster: [Roster]
let link: String
}
// MARK: - Roster
@angelinaFri
angelinaFri / Protocols & Generics.swift
Last active April 26, 2020 07:19
Protocols & Generics
import UIKit
// Global variable
public var baseUrl = URL(string: "www.myApi.com")!
// Protocols
protocol Fetchable: Decodable {
static var apiBase: String { get }
}
protocol Transport {
import SwiftUI
struct MainView: View {
@State var isPresent = true
@State var showFullScreen = false
@State var showModal = false