Skip to content

Instantly share code, notes, and snippets.

@RoLYroLLs
RoLYroLLs / DeviceConstant.swift
Created December 31, 2019 19:03
A list of all Apple device names easily accessible through enums. particularly useful for PreviewProvider in Swift
//
// DeviceConstants.swift
// SampleApp
//
// Created by RoLY roLLs on 12/31/19.
// Copyright © 2019 RoLYroLLs Enterprises, LLC. All rights reserved.
//
/// Taken from https://developer.apple.com/documentation/swiftui/securefield/3289399-previewdevice
//
// BottomSheetView.swift
//
// Created by Majid Jabrayilov
// Copyright © 2019 Majid Jabrayilov. All rights reserved.
//
import SwiftUI
fileprivate enum Constants {
static let radius: CGFloat = 16
final fileprivate class Weak<A: AnyObject> {
weak var value: A?
init(_ value: A) {
self.value = value
}
}
final class ImageManager {
fileprivate var values: [URL:Weak<Resource<UIImage>>] = [:]
@mshafer
mshafer / ContentView.swift
Last active June 20, 2025 00:36
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")
@jstheoriginal
jstheoriginal / SearchBar.swift
Created June 20, 2019 00:42
A simple SwiftUI search bar
struct SearchBar : View {
@Binding var searchText: String
var body: some View {
HStack {
Image(systemName: "magnifyingglass").foregroundColor(.secondary)
TextField(
$searchText,
placeholder: Text("Search")) {
UIApplication.shared.keyWindow?.endEditing(true)
final class Loader: BindableObject {
let didChange = PassthroughSubject<Data?, Never>()
var task: URLSessionDataTask!
var data: Data? = nil {
didSet {
didChange.send(data)
}
}
init(_ url: URL) {
@rr-codes
rr-codes / KeyboardDelegate.swift
Last active May 28, 2019 14:34
A protocol to easily manipulate subviews upon the keyboard showing / hiding
//
// KeyboardDelegate.swift
//
// Created by Richard Robinson on 2019-05-26.
// Copyright © 2019 Richard Robinson. All rights reserved.
//
import Foundation
import UIKit
@koingdev
koingdev / ExportOptions.plist
Last active October 15, 2025 06:22
Script to automatically upload iOS App to AppStore and TestFlight (including versioning)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>destination</key>
<string>upload</string>
<key>method</key>
<string>app-store</string>
<key>provisioningProfiles</key>
<dict>
@overtheleaves
overtheleaves / swift4-text-bold-using-ns-attributed-string.swift
Last active January 14, 2020 19:47
[Swift4] Text Bold Using NSAttributedString
extension NSAttributedString {
func bold(range: NSRange) -> NSAttributedString {
let mutableAttributedString = NSMutableAttributedString(attributedString: self)
mutableAttributedString.beginEditing()
// option .longestEffectiveRangeNotRequired (we need to look over all attributes in range.)
self.enumerateAttribute(.font, in: range, options: .longestEffectiveRangeNotRequired) { (value, r, stop) in
@parrotbait
parrotbait / Best UIView Extension
Created April 3, 2019 17:26
Add basic missing functionality to UIKit
extension UIView {
var isVisible: Bool {
set {
self.isHidden = !newValue
}
get {
return !self.isHidden
}
}
}