This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
// Adapted from: https://stackoverflow.com/questions/62102647/swiftui-hstack-with-wrap-and-dynamic-height/62103264#62103264 | |
struct WrappingHStack<Model, V>: View where Model: Hashable, V: View { | |
typealias ViewGenerator = (Model) -> V | |
var models: [Model] | |
var viewGenerator: ViewGenerator | |
var horizontalSpacing: CGFloat = 2 | |
var verticalSpacing: CGFloat = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if canImport(UIKit) | |
import UIKit | |
extension UIColor { | |
static var random: UIColor { | |
return UIColor( | |
red: .random(in: 0...1), | |
green: .random(in: 0...1), | |
blue: .random(in: 0...1) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Color+UIColor.swift | |
// Swatches | |
// | |
// Created by Timothy Sanders on 2019-11-15. | |
import Foundation | |
import SwiftUI | |
import UIKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
class NotificationService { | |
static private var _instance: NotificationService! = nil | |
static var sharedInstance: NotificationService { | |
get { | |
if NotificationService._instance == nil { | |
NotificationService._instance = NotificationService() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func jpegDataFrom(image:NSImage) -> Data { | |
let cgImage = image.cgImage(forProposedRect: nil, context: nil, hints: nil)! | |
let bitmapRep = NSBitmapImageRep(cgImage: cgImage) | |
let jpegData = bitmapRep.representation(using: NSBitmapImageRep.FileType.jpeg, properties: [:])! | |
return jpegData | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class NibLoadableView: UIView { | |
@IBOutlet var view: UIView! | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let styles: [UIFont.TextStyle] = [ | |
// iOS 17 | |
.extraLargeTitle, .extraLargeTitle2, | |
// iOS 11 | |
.largeTitle, | |
// iOS 9 | |
.title1, .title2, .title3, .callout, | |
// iOS 7 | |
.headline, .subheadline, .body, .footnote, .caption1, .caption2, | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIColor.swift | |
// previously Color+HexAndCSSColorNames.swift | |
// | |
// Created by Norman Basham on 12/8/15. | |
// Copyright ©2018 Black Labs. All rights reserved. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
let vc = UIViewController() | |
vc.view.backgroundColor = .whiteColor() | |
vc.navigationItem.title = "This is a view controller" | |
let searchController = UISearchController(searchResultsController: nil) | |
//searchController.searchBar.barTintColor = UIColor(red:0.16, green:0.45, blue:0.72, alpha:1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let state = [ "AK - Alaska", | |
"AL - Alabama", | |
"AR - Arkansas", | |
"AS - American Samoa", | |
"AZ - Arizona", | |
"CA - California", | |
"CO - Colorado", | |
"CT - Connecticut", | |
"DC - District of Columbia", | |
"DE - Delaware", |
NewerOlder