Skip to content

Instantly share code, notes, and snippets.

Avatar

Oliver Drobnik odrobnik

View GitHub Profile
View RankingsView.view
//
// RankingsView.swift
// ChessClub
//
// Created by Oliver Drobnik on 22.04.22.
//
import SwiftUI
struct RankingsView: View
View Observing.swift
import Foundation
import Combine
import ProoficsSDK
import SwiftUI
class BundleViewModel: ObservableObject
{
@Published var title: String = ""
@Published var subtitle: String?
View FastnotesSettings.swift
import SwiftUI
struct Modifier: Identifiable
{
let id = UUID()
@State var title: String
}
struct FastnotesSettings: View
@odrobnik
odrobnik / PlatformSpecific.swift
Created Jul 13, 2021
Platform-specific modifier application
View PlatformSpecific.swift
import SwiftUI
struct Platform: OptionSet
{
let rawValue: Int
static let iOS = Platform(rawValue: 1<<0)
static let tvOS = Platform(rawValue: 1<<1)
static let watchOS = Platform(rawValue: 1<<2)
@odrobnik
odrobnik / NavPicker.swift
Last active Feb 9, 2021
Trying to emulate Picker behaviour inside a List
View NavPicker.swift
//
// NavPicker.swift
// ColorCore Demo
//
// Created by Oliver Drobnik on 09.02.21.
//
import SwiftUI
public struct NavPicker<Label, Items> : View where Label : View, Items: CustomStringConvertible & Identifiable
@odrobnik
odrobnik / ContentView.swift
Last active Aug 15, 2020
So far it outputs the frames of the cells, but I am stuck trying to hide the ones that are outside of the widget
View ContentView.swift
import SwiftUI
struct RegularEventCell: View {
let color: Color
let title: String
let description: String?
var body: some View {
View Refreshable.swift
@objc protocol Refreshable
{
/// The refresh control
var refreshControl: UIRefreshControl? { get set }
/// The table view
var tableView: UITableView! { get set }
/// the function to call when the user pulls down to refresh
@objc func handleRefresh(_ sender: Any);
View expectation.swift
func testHangSquareBracket()
{
let input = "Text [-( Text"
let expectation = self.expectation(description: "Should not hang")
DispatchQueue.global().async {
let builder = BBCodeAttributedStringBuilder(bbcode: input)
let output = builder.attributedString
XCTAssertNotNil(output)
@odrobnik
odrobnik / UIImage+Util.swift
Created Dec 7, 2016
Convenience method creating a new image by drawing into a context
View UIImage+Util.swift
import UIKit
extension UIImage
{
/// Creates an image from drawing into a context
convenience init(size: CGSize, opaque: Bool = true, operations: (CGContext)->())
{
UIGraphicsBeginImageContextWithOptions(size, opaque, 0)
let ctx = UIGraphicsGetCurrentContext()!
View TypeInfer.swift
public enum VanillaRequestError: Error
{
case unexpectedResult(String)
case restfulError(NSError)
}
// the result from a Vanilla API request
public enum VanillaRequestResult<T>
{