Skip to content

Instantly share code, notes, and snippets.

View jayesh15111988's full-sized avatar

Jayesh Kawli jayesh15111988

View GitHub Profile
@jayesh15111988
jayesh15111988 / ImageDownloader.swift
Created April 26, 2020 21:37
A gist for image downloader and caching library written in Swift for iOS applications
import UIKit
// Image downloader utility class. We are going to use the singleton instance to be able to download required images and store them into in-memory cache.
final class ImageDownloader {
static let shared = ImageDownloader()
private var cachedImages: [String: UIImage]
private var imagesDownloadTasks: [String: URLSessionDataTask]
//
// MovieCell.swift
//
import UIKit
final class MovieCell: UITableViewCell {
let posterImageView = UIImageView(frame: .zero)
@jayesh15111988
jayesh15111988 / StackViewScrollView.swift
Created April 20, 2023 08:08
A demo to show how to use scroll behavior with stack view and scroll view in Swift
//
// ScrollViewController.swift
// Test
//
// Created by Jayesh Kawli on 19/04/2023.
//
// custom scroll view stack view in Swift
import Foundation
@jayesh15111988
jayesh15111988 / HorizontalScrollView.swift
Created April 22, 2023 10:55
A source code for horizontally scrolling content view
//
// HorizontalScrollView.swift
// Test
//
// Created by Jayesh Kawli on 4/21/23.
//
import UIKit
class HorizontalScrollView : UIViewController {
@jayesh15111988
jayesh15111988 / VerticalScrollView.swift
Created April 22, 2023 11:14
A source code for demonstrating working of a vertically scrolling content view
class VerticalScrollView : UIViewController {
init() {
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@jayesh15111988
jayesh15111988 / InfiniteLoadingScreen.swift
Created April 30, 2023 10:10
A SwiftUI, Swift and iOS source code to demonstrate working of infinite loading screen with pagination
//
// InfiniteLoadingScreen.swift
// Test
//
// Created by Jayesh Kawli on 1/12/23.
//
import SwiftUI
struct Employee: Identifiable, Equatable {
@jayesh15111988
jayesh15111988 / RequestHandler.swift
Created May 1, 2023 09:58
An implementation for building a network stack on iOS using Swift
import Foundation
enum APIRouteDomain {
case userLoginManagement(APIRoute)
case accountInfoManagement(APIRoute)
case accountManagement(APIRoute)
var associatedApiRoute: APIRoute {
switch self {
case .userLoginManagement(let apiRoute), .accountInfoManagement(let apiRoute), .accountManagement(let apiRoute):
@jayesh15111988
jayesh15111988 / CustomViewDidLoad.swift
Last active May 1, 2023 18:53
A source code to demo view did load behavior on SwiftUI view
import SwiftUI
struct CustomViewDidLoad: View {
var body: some View {
VStack {
Text("Hello")
}
}
@jayesh15111988
jayesh15111988 / MockDispatchQueue.swift
Created May 2, 2023 08:23
A source code on how to implement DispatchQueue mock for unit testing in the iOS app
// A protocol for mocking DispatchQueue instance
protocol DispatchQueueType {
func async(execute work: @escaping @convention(block) () -> Void)
}
// Confirming existing DispatchQueue to DispatchQueueType
extension DispatchQueue: DispatchQueueType {
func async(execute work: @escaping @convention(block) () -> Void) {
async(group: nil, qos: .unspecified, flags: [], execute: work)
@jayesh15111988
jayesh15111988 / RoundedCornerBorderAndShadowStyles.swift
Created May 2, 2023 16:32
A source code to demonstrate how to apply rounded corner, rounded borders and shadow to a SwiftUI view
// An utility view extension
extension View {
@ViewBuilder
func `if`<Transform: View>(_ condition: Bool, transform: (Self) -> Transform) -> some View {
if condition { transform(self) }
else { self }
}
}