Skip to content

Instantly share code, notes, and snippets.

View shial4's full-sized avatar
⌨️

Szymon shial4

⌨️
View GitHub Profile
@shial4
shial4 / DynamicList.swift
Last active February 29, 2024 20:56
SwiftUI Dynamic Horizontal or vertical List - loads only visible elements. Efficiency for large collections. Dynamic item size.
import SwiftUI
import Foundation
import PlaygroundSupport
public enum Orientation {
case horizontal
case vertical
}
public struct StackView<Content: View>: View {
@shial4
shial4 / DateField.swift
Last active June 4, 2021 14:55
SwiftUI text field with date picker as keyboard accessory view and toolbar with done button
//
// DateField.swift
//
// Created by Szymon Lorenz on 22/2/20.
// Copyright © 2020 Szymon Lorenz. All rights reserved.
//
import SwiftUI
struct DateTextField: UIViewRepresentable {
@shial4
shial4 / JoystickView.swift
Last active October 28, 2020 09:42
SwiftUI implementation based on "Among Us" movement joystick control.
import SwiftUI
struct JoystickView: View {
@State private var dragPosition: CGPoint? = nil
typealias JoystickAction = (CGPoint?) -> Void
private var translationAction: JoystickAction?
private var gripColor: Color = .white
init(_ translationAction: JoystickAction? = nil) {
@shial4
shial4 / Extensions
Created November 9, 2019 06:06
Easy use of Combine & URLSession publishers for performing API request
//
// Created by Szymon Lorenz on 9/11/19.
// Copyright © 2019 Szymon Lorenz. All rights reserved.
//
import Foundation
import Combine
/// Error localized description
enum DataTaskError : Error {
@shial4
shial4 / URLResponse.swift
Last active November 3, 2019 23:27
URLSession extension to chain operations
import Foundation
extension URLResponse {
var HTTPResponse: HTTPURLResponse? {
return self as? HTTPURLResponse
}
}
@shial4
shial4 / PushFromItemAnimator.swift
Last active September 28, 2018 02:29
Simple yet elegant push transition from the rect and back to the same rect.
//
// PushFromItemAnimator.swift
// Between
//
// Created by Shial on 11/9/18.
// Copyright © 2018 Szymon Lorenz Solutions. All rights reserved.
//
import UIKit
@shial4
shial4 / Log.swift
Last active August 27, 2018 02:38
Swift Logger
import Foundation
public class Log {
private enum LogType: Int, CustomStringConvertible {
public var description: String {
switch self {
case .verbose:
return "[VERBOSE]"
case .info:
return "[INFO]"