Skip to content

Instantly share code, notes, and snippets.

View damodarnamala's full-sized avatar

Damodar damodarnamala

  • Hyderabad
View GitHub Profile
@damodarnamala
damodarnamala / StickyLayout.swift
Created September 16, 2022 03:41 — forked from ilyapuchka/StickyLayout.swift
Really sticky collection view layout
// The issue with sectionHeadersPinToVisibleBounds and sectionFootersPinToVisibleBounds is that they do not pin
// first header and last footer when bouncing. This layout subclass fixes that.
class StickyLayout: UICollectionViewFlowLayout {
override init() {
super.init()
self.sectionFootersPinToVisibleBounds = true
self.sectionHeadersPinToVisibleBounds = true
}
@damodarnamala
damodarnamala / Client.swift
Created September 16, 2022 03:41 — forked from kean/Client.swift
API Client (Archived)
// The MIT License (MIT)
//
// Copyright (c) 2017 Alexander Grebenyuk (github.com/kean).
import Foundation
import Alamofire
import RxSwift
import RxCocoa
// This post is **archived**. For a modern version that uses Async/Await and Actors, see the new article
@damodarnamala
damodarnamala / PreviewProviderModifier.swift
Created September 16, 2022 03:39 — forked from davidsteppenbeck/PreviewProviderModifier.swift
A SwiftUI view modifier for simple preview providers.
import SwiftUI
enum PreviewProviderMode: CaseIterable {
/// Use for a light appearance preview.
case lightMode
/// Use for a dark appearance preview.
case darkMode
@damodarnamala
damodarnamala / Scanner.swift
Created September 16, 2022 03:38 — forked from s-aska/Scanner.swift
Scanner
//
// DataScanner.swift
// DataScanner
//
// Created by Shinichiro Aska on 8/20/15.
// Copyright © 2015 Shinichiro Aska. All rights reserved.
//
import Foundation
@damodarnamala
damodarnamala / Keychain.swift
Created September 16, 2022 03:37 — forked from s-aska/Keychain.swift
Swift Keychain class ( supported Xcode 6.0.1 )
import UIKit
import Security
class Keychain {
class func save(key: String, data: NSData) -> Bool {
let query = [
kSecClass as String : kSecClassGenericPassword as String,
kSecAttrAccount as String : key,
kSecValueData as String : data ]
// Authoer: The SwiftUI Lab
// Full article: https://swiftui-lab.com/scrollview-pull-to-refresh/
import SwiftUI
struct RefreshableScrollView<Content: View>: View {
@State private var previousScrollOffset: CGFloat = 0
@State private var scrollOffset: CGFloat = 0
@State private var frozen: Bool = false
@State private var rotation: Angle = .degrees(0)
@damodarnamala
damodarnamala / collectionview.swift
Created September 16, 2022 03:28 — forked from chriseidhof/collectionview.swift
SwiftUI Flow Layout
//
// ContentView.swift
// DeleteMe
//
// Created by Chris Eidhof on 02.02.21.
//
import SwiftUI
/*
@damodarnamala
damodarnamala / ContentView.swift
Created September 16, 2022 03:25 — forked from mshafer/ContentView.swift
Slide-over card (like in Maps or Stocks) using SwiftUI
import SwiftUI
struct ContentView : View {
var body: some View {
ZStack(alignment: Alignment.top) {
MapView()
SlideOverCard {
VStack {
CoverImage(imageName: "maitlandbay")
Text("Maitland Bay")
@damodarnamala
damodarnamala / AutoLayoutDSL.swift
Created September 16, 2022 03:22 — forked from V8tr/AutoLayoutDSL.swift
Auto Layout DSL
import UIKit
/// Represents a single `NSLayoutConstraint`
enum LayoutAnchor {
case constant(attribute: NSLayoutConstraint.Attribute,
relation: NSLayoutConstraint.Relation,
constant: CGFloat)
case relative(attribute: NSLayoutConstraint.Attribute,
relation: NSLayoutConstraint.Relation,
final class Loader: BindableObject {
let didChange = PassthroughSubject<Data?, Never>()
var task: URLSessionDataTask!
var data: Data? = nil {
didSet {
didChange.send(data)
}
}
init(_ url: URL) {