Skip to content

Instantly share code, notes, and snippets.

View tobitech's full-sized avatar
🌎
Changing the World

Tobi Omotayo tobitech

🌎
Changing the World
View GitHub Profile
@tobitech
tobitech / WebViewExampleViewController.swift
Created June 10, 2020 21:05 — forked from fxm90/WebViewExampleViewController.swift
Show progress of WKWebView in UIProgressBar that is attached to an UINavigationBar
//
// WebViewExampleViewController.swift
//
// Created by Felix Mau on 06.01.18.
// Copyright © 2018 Felix Mau. All rights reserved.
//
import UIKit
import WebKit
@tobitech
tobitech / ImageDownloader.swift
Created May 27, 2020 12:05
Reactive ImageDownloader with Alamofire + Cache
//
// ImageDownloader.swift
// ImageDownloader
//
// Created by Oluwatobi Omotayo on 27/05/2020.
// Copyright © 2020 Oluwatobi Omotayo. All rights reserved.
//
import UIKit
import RxSwift
@tobitech
tobitech / Timer.swift
Created May 25, 2020 19:14
Count down timer with RxSwift
let timer = Observable<Int>.interval(.seconds(1), scheduler: MainScheduler.instance)
.take(60)
.startWith(0)
.share(replay: 1)
timer
.map { 60 - $0 }
.map { "\($0)" }
.bind(to: timerLabel.rx.text)
.disposed(by: disposeBag)
timer
@tobitech
tobitech / NestableCodingKey.swift
Last active February 12, 2020 01:54 — forked from AliSoftware/Demo.swift
NestableCodingKey: Nice way to define nested coding keys for properties
import Foundation
//: # NestedKey
///
/// Use this to annotate the properties that require a depth traversal during decoding.
/// The corresponding `CodingKey` for this property must be a `NestableCodingKey`
@propertyWrapper
struct NestedKey<T: Decodable>: Decodable {
var wrappedValue: T
struct AnyCodingKey: CodingKey {
@tobitech
tobitech / CustomSegmentedControl.swift
Last active December 6, 2019 21:37
A custom segmented control with modern design. Support for Titles, subtitles with and or only images. Can also be used in Interface builder
//
// CustomSegmentedControl.swift
// CustomSegmentedControl
//
// Created by Oluwatobi Omotayo on 06/09/2019.
// Copyright © 2019 Oluwatobi Omotayo. All rights reserved.
//
import UIKit
@tobitech
tobitech / APIService.swift
Created August 15, 2019 09:03
APIService examples using Swift 5 Result Type
// model for user profile
struct UserProfile: Codable {
let email: String?
let names: String?
let phone: String?
}
// model for all api response with generic data
struct DataResponse<T: Decodable>: Decodable {
let status: Int?
@tobitech
tobitech / ModalViewController.swift
Created November 28, 2018 11:55
Simple flow for pushing another view controller on modal dismiss
protocol ModalViewControllerDelegate {
func pushToAnotherScreen()
}
class ModalViewController: UIViewController {
// MARK: - Properties
weak var delegate: ModalViewControllerDelegate
lazy var cancelButton: UIButton = {
@tobitech
tobitech / Camera.swift
Created July 24, 2018 10:16
A simple class abstracting display of photo, video selection or capture from user's device
//
// Camera.swift
// Tobi Omotayo
//
// Created by Oluwatobi Omotayo on 20/07/2018.
// Copyright © 2018 Oluwatobi Omotayo. All rights reserved.
//
import UIKit
import MobileCoreServices
import UIKit
import XCTest
import MapKit
class ExampleTests: XCTestCase {
//declaring the ViewController under test as an implicitly unwrapped optional
var viewControllerUnderTest : ViewController!
override func setUp() {
@tobitech
tobitech / Constants.swift
Created January 9, 2018 11:05
A Sample Swift file for keeping your Projects Constants
import Foundation
import UIKit
struct Colors {
static let brightOrange = UIColor(red: 255.0/255.0, green: 69.0/255.0, blue: 0.0/255.0, alpha: 1.0)
static let red = UIColor(red: 255.0/255.0, green: 115.0/255.0, blue: 115.0/255.0, alpha: 1.0)
static let brandColor = UIColor(red: 255.0/255.0, green: 115.0/255.0, blue: 115.0/255.0, alpha: 1.0)
static let secondaryColor = UIColor(red: 255.0/255.0, green: 115.0/255.0, blue: 115.0/255.0, alpha: 1.0)
static let darkColor = UIColor(red: 255.0/255.0, green: 115.0/255.0, blue: 115.0/255.0, alpha: 1.0)
}