This file contains hidden or 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 EventKit | |
| class RemindersSync { | |
| let eventStore = EKEventStore() | |
| var remindersCalendar: EKCalendar? = nil | |
| var reminders: [EKReminder] = [] | |
| /// Requests access to the Reminders app |
This file contains hidden or 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 | |
| // MARK: - Root view | |
| struct SheetPresenterView: View { | |
| @State private var isPresented = false | |
| var body: some View { | |
| Button(action: showSheet) { |
This file contains hidden or 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 | |
| struct TestItemView: View { | |
| @State var dragAmount = CGSize.zero | |
| let letter: String | |
| var body: some View { | |
| Image(systemName: "\(letter).square") |
This file contains hidden or 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 | |
| class Task: ObservableObject, Identifiable { | |
| let id = UUID() | |
| var text: String | |
| var done: Bool | |
| init(text: String, done: Bool = false) { | |
| self.text = text | |
| self.done = done |
This file contains hidden or 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 | |
| extension UITextField { | |
| func handlePhoneNumberField(withReplacingString string: String, in range: NSRange) { | |
| let textFieldString = text! as NSString | |
| var newString = textFieldString.replacingCharacters(in: range, with: string) | |
| let validationSet = CharacterSet.decimalDigits.inverted | |
| let numberArray = newString.components(separatedBy: validationSet) |
This file contains hidden or 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
| extension String { | |
| func height(withConstraintWidth width: CGFloat, font: UIFont = UIFont.systemFont(ofSize: 17)) -> CGFloat { | |
| let constraintRect = CGSize(width: width, height: .greatestFiniteMagnitude) | |
| let boundingBox = self.boundingRect(with: constraintRect, | |
| options: .usesLineFragmentOrigin, | |
| attributes: [NSAttributedString.Key.font: font], | |
| context: nil) | |
| return ceil(boundingBox.height) |
This file contains hidden or 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
| extension UIColor { | |
| static func rgb(red: CGFloat, green: CGFloat, blue: CGFloat) -> UIColor { | |
| return UIColor(red: red/255, green: green/255, blue: blue/255, alpha: 1) | |
| } | |
| } |
This file contains hidden or 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
| extension UIView { | |
| func anchor(top: NSLayoutYAxisAnchor?, leading: NSLayoutXAxisAnchor?, bottom: NSLayoutYAxisAnchor?, trailing: NSLayoutXAxisAnchor?, padding: UIEdgeInsets = .zero, size: CGSize = .zero) { | |
| translatesAutoresizingMaskIntoConstraints = false | |
| if let top = top { | |
| topAnchor.constraint(equalTo: top, constant: padding.top).isActive = true | |
| } | |
| if let leading = leading { | |
| leadingAnchor.constraint(equalTo: leading, constant: padding.left).isActive = true |