Skip to content

Instantly share code, notes, and snippets.

View aaronlab's full-sized avatar
πŸ›«

Aaron Lee aaronlab

πŸ›«
  • Witi Corp.
  • Anywhere
  • 12:50 (UTC +09:00)
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / isDetailLink.swift
Last active July 24, 2022 09:38
SwiftUI Navigation Link Issue Solution: Navigation Bar overlapped
@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)
}
}
🌞 Morning 93 commits β–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 4.8%
πŸŒ† Daytime 845 commits β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 43.8%
πŸŒƒ Evening 781 commits β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 40.5%
πŸŒ™ Night 210 commits β–ˆβ–ˆβ–Žβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 10.9%