Skip to content

Instantly share code, notes, and snippets.

@ulusalomer
ulusalomer / KeychainManager.swift
Last active September 11, 2023 18:08
KeychainManager example
//
// KeychainManager.swift
//
// Created by Ömer Ulusal on 11/09/2023.
//
import AuthenticationServices
final class KeychainManager {
static let shared: KeychainManager = .init()
@ulusalomer
ulusalomer / ConfigManager.swift
Created September 9, 2023 12:35
ConfigManager for FirebaseRemote
//
// ConfigManager.swift
//
// Created by Ömer Ulusal on 19/08/2023.
//
import FirebaseRemoteConfig
final class ConfigManager {
static let shared = ConfigManager()
@ulusalomer
ulusalomer / autoHeightBottomSheet.swift
Created July 13, 2023 21:17
Auto Height Bottom Sheet
import SwiftUI
public struct ContentView: View {
@State private var showingBottomSheet = false
@State private var sheetContentHeight = CGFloat(0)
public init() {}
public var body: some View {
Button("Show Bottom Sheet") {
@ulusalomer
ulusalomer / LocalJsonWrapper.swift
Last active June 16, 2023 22:05
LocalJsonWrapper example
import Foundation
@propertyWrapper
struct LocalJson<T> where T: Decodable {
private let fileName: String
var wrappedValue: T {
guard let result = loadJson(fileName: fileName) else {
fatalError("Cannot load json data \(fileName)")
}
@ulusalomer
ulusalomer / reference-value-types.swift
Last active May 5, 2024 06:18
Reference Value Types Questions
import Foundation
// Question 1
struct Cat {
var age: Int
}
var cat = Cat(age: 5)
var fluffyCat = cat
fluffyCat.age = 3
@ulusalomer
ulusalomer / some-any-tests.swift
Created September 29, 2022 20:28
Playground for some and any keywords in Swift
import Foundation
protocol AnimalFeed {
associatedtype CropType: Crop where CropType.FeedType == Self
static func grow() -> CropType
}
protocol Crop {
associatedtype FeedType: AnimalFeed
func harvest() -> FeedType
@ulusalomer
ulusalomer / CreditCardView.swift
Created August 21, 2020 22:00
CreditCardView SwiftUI
import SwiftUI
struct ContentView: View {
@State var isFaceUp: Bool = true
let timer = Timer.publish(every: 2, on: .main, in: .common).autoconnect()
var body: some View {
ZStack {
FrontCardSide().opacity(isFaceUp ? 1 : 0)