Skip to content

Instantly share code, notes, and snippets.

View wotjd's full-sized avatar

wotjd wotjd

  • Seoul, South Korea
View GitHub Profile
@tigi44
tigi44 / SheetPresentation.swift
Last active February 20, 2024 14:40
Using a UISheetPresentationController on SwiftUI
import SwiftUI
// MARK: - SheetPresentation
public extension View {
func sheetPresentation<SheetView: View>(isPresented: Binding<Bool>, @ViewBuilder sheetView: @escaping () -> SheetView, onDismiss: SheetPresentationController<SheetView>.DefaultClosureType? = nil) -> some View {
self.background(
@StarLard
StarLard / DetentSheet.swift
Last active January 7, 2023 07:22
A simple implementation of an UISheetPresentationController wrapper using SwiftUI
//
// DetentSheet.swift
// StarLardKit
//
// Created by Caleb Friden on 9/28/21.
//
import SwiftUI
// MARK: - Public
@nrubin29
nrubin29 / homebrew_m1.sh
Last active November 24, 2023 11:27
Install Native Homebrew on Apple Silicon M1
# We'll be installing Homebrew in the /opt directory.
cd /opt
# Create a directory for Homebrew. This requires root permissions.
sudo mkdir homebrew
# Make us the owner of the directory so that we no longer require root permissions.
sudo chown -R $(whoami) /opt/homebrew
# Download and unzip Homebrew. This command can be found at https://docs.brew.sh/Installation.
import UIKit
import PlaygroundSupport
protocol WaterfallLayoutDelegate: AnyObject {
    func numberOfColumns() -> Int
    func columnsSize(at indexPath: IndexPath) -> CGSize
    func columnSpace() -> CGFloat
}
final class WaterfallLayoutViewController: UIViewController, UICollectionViewDataSource {
@inso-
inso- / Weak.swift
Created July 7, 2020 14:37
Weak Property Wrapper + Hashable
@propertyWrapper
public struct Weak<Wrapped: AnyObject> {
private weak var value: AnyObject?
public init(_ value: Wrapped? = nil) {
self.value = value
}
public var wrappedValue: Wrapped? {
get { value as? Wrapped }
@NunciosChums
NunciosChums / AuthService.swift
Last active June 8, 2023 04:25
Moya + renewal token when Unauthorized(401)
import Foundation
import Moya
import RxSwift
/// 인증 관련 API
final class AuthService: BaseService<AuthAPI> {
static let shared = AuthService()
private override init() {}
/// 토큰 재발급
//
// CancelBag.swift
// CountriesSwiftUI
//
// Created by Alexey Naumov on 04.04.2020.
// Copyright © 2020 Alexey Naumov. All rights reserved.
//
import Combine
import SwiftUI
@prasadpamidi
prasadpamidi / SegmentedCollectionViewController.swift
Last active October 30, 2022 11:30
Issue with large navigation bar and collection view
import UIKit
class SegmentedControlSupplementaryView: UICollectionReusableView {
let segmentControl = UISegmentedControl(items: ["Item 1", "Items 2", "Items 3"])
static let reuseIdentifier = "segmented-supplementary-reuse-identifier"
override init(frame: CGRect) {
super.init(frame: frame)
self.backgroundColor = .white
@wearhere
wearhere / TextDocumentProxy.swift
Last active April 11, 2024 19:47
A generic implementation of the `UITextDocumentProxy` protocol that should work for anything that conforms to `UIResponder` and `UITextInput`. Useful to put text fields inside custom keyboards and then reuse your keyboard's regular handling logic with this text field. See https://github.com/danielsaidi/KeyboardKit/issues/45 for more info.
//
// documentProxy.swift
// KeyboardKitDemoKeyboard
//
// Created by Jeffrey Wear on 4/28/20.
//
import UIKit
class TextDocumentProxy<TextDocument: UIResponder & UITextInput>: NSObject, UITextDocumentProxy {
{
"PD-KB401W": {
"typeNumber": "PD-KB401W",
"layoutType": 1,
"colorType": 0,
"series": 0,
"layoutTypeName": 1,
"postfix": "",
"isKeymapChangeable": true,
"firmTypeNumber": "AHHX01",