Skip to content

Instantly share code, notes, and snippets.

View jstheoriginal's full-sized avatar
👨‍💻

Justin Stanley jstheoriginal

👨‍💻
View GitHub Profile
@jstheoriginal
jstheoriginal / BottomAnchoredModalTransitioner.swift
Last active April 14, 2021 17:01
A bottom anchored modal (bottom sheet) that allows adding a child view controller. It will self-size itself based on the content in the child view controller. It respects the safe area, including having a max height. To ensure content can be fully viewed if it hits the max height, the child view controller needs to have a tableview or scrollview.
//
// BottomAnchoredModalTransitioner.swift
// BB Links
//
// Created by Justin Stanley on 2017-09-07.
// Copyright © 2017 Justin Stanley. All rights reserved.
//
import Foundation
import UIKit
@jstheoriginal
jstheoriginal / CustomTabView.swift
Last active October 29, 2020 02:13
SwiftUI TabView With Full Screen Background Color Ignoring Safe Area
import SwiftUI
struct ContentView: View {
@State private var currentIndex = 0
private let colors: [Color] = [.red, .white, .blue, .green, .yellow]
private var whiteIsSelected: Bool {
colors[currentIndex] == .white
}
var body: some View {
@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)