Skip to content

Instantly share code, notes, and snippets.

View aaronlab's full-sized avatar
🛫

Aaron Lee aaronlab

🛫
View GitHub Profile
🌞 Morning 93 commits █░░░░░░░░░░░░░░░░░░░░ 4.8%
🌆 Daytime 845 commits █████████▏░░░░░░░░░░░ 43.8%
🌃 Evening 781 commits ████████▌░░░░░░░░░░░░ 40.5%
🌙 Night 210 commits ██▎░░░░░░░░░░░░░░░░░░ 10.9%
@aaronlab
aaronlab / ContentView.swift
Created December 1, 2020 06:16 — forked from diamantidis/ContentView.swift
A SwiftUI field with a UIPickerView as a keyboard
import SwiftUI
struct ContentView: View {
@State var selectedIndex: Int? = nil
let options: [String] = ["Option1", "Option2"]
var body: some View {
PickerField("Select an option", data: self.options, selectionIndex: self.$selectedIndex)
}
}
@aaronlab
aaronlab / isDetailLink.swift
Last active July 24, 2022 09:38
SwiftUI Navigation Link Issue Solution: Navigation Bar overlapped
@aaronlab
aaronlab / MyTextView.swift
Created January 26, 2021 07:55
UIViewRepresentable with UITextView
struct MyTextView: UIViewRepresentable {
@Binding var text: String
init(text: Binding<String>) {
self._text = text
}
func makeUIView(context: UIViewRepresentableContext<MyTextView>) -> UITextView {
let textView = UITextView(frame: .zero)
@aaronlab
aaronlab / TextEditorPlaceHolder.swift
Last active December 27, 2023 05:25
SwiftUI TextEditor Placeholder
struct TextEditorPlaceHolder: View {
@State private var text: String = ""
private let screenWidth = UIScreen.main.bounds.width
var body: some View {
VStack {
@aaronlab
aaronlab / TextEditorPlaceholderWithNoti.swift
Created January 27, 2021 03:15
SwiftUI TextEditor Placeholder with NotificationCenter
struct ContentView: View {
@State var text = "Placeholder"
var body: some View {
TextEditor(text: self.$text)
.foregroundColor(self.text == "Placeholder" ? .gray : .primary)
.onAppear {
NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillShowNotification, object: nil, queue: .main) { (noti) in
@aaronlab
aaronlab / PHPickerViewMultiple.swift
Last active January 27, 2021 06:21
SwiftUI PHPickerView for multiple images
import SwiftUI
import PhotosUI
struct ImagePickerView: UIViewControllerRepresentable {
let numOfSelectedPictures: Int // This is the number of selected photos
@Binding var images: [UIImage]
init(numOfSelectedPictures: Int, images: Binding<[UIImage]>) {
self.numOfSelectedPictures = numOfSelectedPictures
@aaronlab
aaronlab / PHPickerViewSingle.swift
Last active January 27, 2021 06:21
SwiftUI PHPickerView for a single photo
import SwiftUI
import PhotosUI
struct ImagePickerView: UIViewControllerRepresentable {
@Binding var image: UIImage
init(image: Binding<UIImage>) {
self._image = image
}
@aaronlab
aaronlab / OptionalSheet.swift
Last active February 25, 2021 07:15
SwiftUI: Chooseable ViewModifier to use fullScreenCover and sheet modal at the same time.
// MARK: - Modifier
/// Choosable Sheet for FullScreen or Sheet Modal
struct ChooseableSheet<Destination>: ViewModifier where Destination: View {
// Select it's fullscreen sheet or modal sheet
@Binding var isFullScreen: Bool
@Binding var isPresented: Bool
private let fullScreenContent: () -> Destination?
@aaronlab
aaronlab / Django_Vgrantfile
Created March 1, 2021 10:49
Vgrantfile for Django
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at