Skip to content

Instantly share code, notes, and snippets.

View piercifani's full-sized avatar
🙈

Pierluigi Cifani piercifani

🙈
View GitHub Profile
@piercifani
piercifani / swiftui-transition.md
Last active September 26, 2023 13:55
iOS Apps with SwiftUI

Transitioning to SwiftUI

At TheLeftBit we've built great UIKit apps that have stood the test of time and scaled beautifully by following three basic rules:

  • Keep it simple
  • Pass values to functions
  • Don't fight the platform

Now, as we transition to SwiftUI, we're formalizing how things are structured in order for our developers to tackle creating beautiful user interfaces without too much fuzz. We wanted the code to adopt modern Swift concepts like Structured Concurrency, Result Builders and Generics in order to be even more efficient than what we where when building UIs with UIKit.

@piercifani
piercifani / AsyncStateView.swift
Last active June 14, 2021 12:26
AsyncStateView
//
// Created by Pierluigi Cifani on 13/6/21.
//
import SwiftUI
struct AsyncView<V: View>: View {
let viewGenerator: ViewGenerator
typealias ViewGenerator = () async throws -> V
"{\"threeDS2\":false,\"orderId\":182}"
@import url(https://fonts.googleapis.com/css?family=Roboto:400,700,500,300);@import url(https://fonts.googleapis.com/css?family=Roboto+Mono:400,700,500,300);@keyframes a{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes b{0%{opacity:1}50%{opacity:0}to{opacity:1}}[src$="blue.png"]{background-image:url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4IiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIxOCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBmaWxsPSIjMDA5Njg4IiBkPSJNMTIgMkM2LjQ4IDIgMiA2LjQ4IDIgMTJzNC40OCAxMCAxMCAxMCAxMC00LjQ4IDEwLTEwUzE3LjUyIDIgMTIgMnptLTIgMTVsLTUtNSAxLjQxLTEuNDFMMTAgMTQuMTdsNy41OS03LjU5TDE5IDhsLTkgOXoiLz48L3N2Zz4=)}[src$="red.png"]{background-image:url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4IiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIxOCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBmaWxsPSIjRjQ0MzM2IiBkPSJNMTIgMkM2LjQ4IDIgMiA2LjQ4IDIgMTJzNC40OCAxMCAxMCAxMCAxMC00LjQ4IDEwLTEwUzE3LjUyIDIgMTIgMnptMSAxNWgtMnYtMmgydjJ6bTAtNGgtMlY3aDJ2NnoiLz48L3N2Zz4=)}[src$="yellow.png
//
// Created by Pierluigi Cifani on 24/09/2018.
// Copyright © 2018 The Left Bit. All rights reserved.
//
import UIKit
let childVCHeight: CGFloat = 80
@UIApplicationMain
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
DispatchQueue.main.async {
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var observer: ProgressObserver?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
@piercifani
piercifani / DeferredProgressCrash-v2.swift
Last active October 13, 2016 05:11
Crash on observing NSProgress
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var observer: ProgressObserver?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// MARK:- Make Tasks Great Again
import Foundation
import Deferred
SyncManager.syncAll {
print($0)
}
class SyncManager: NSObject {
@protocol WPCAppLifecycleProtocol <NSObject>
- (void)applicationDidExceedBackgroundTime;
- (void)applicationDidEnterForeground;
- (void)applicationDidEnterBackground;
- (void)applicationWillTerminate;
@end