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
| let gradientStart = Color(red: 239.0 / 255, green: 120.0 / 255, blue: 221.0 / 255) | |
| let gradientStartDark = Color(red: 95.0 / 255, green: 169.0 / 255, blue: 244.0 / 255) | |
| let gradientEnd = Color(red: 239.0 / 255, green: 172.0 / 255, blue: 120.0 / 255) | |
| let gradientEndDark = Color(red: 79.0 / 255, green: 178.0 / 255, blue: 141.0 / 255) | |
| let toggleTextcolorLight = Color(red: 227.0 / 255, green: 227.0 / 255, blue: 227.0 / 255) | |
| let toggleTextcolorDark = Color(red: 34.0 / 255, green: 38.0 / 255, blue: 58.0 / 255) | |
| let textColorDark = Color(red: 238.0 / 255, green: 238.0 / 255, blue: 238.0 / 255) |
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 ContentView: View { | |
| @Environment(\.colorScheme) var colorScheme | |
| var body: some View { | |
| ZStack { | |
| ZStack(alignment: .top) { | |
| ShapeView().offset(x: -80, y : -389).shadow(radius: 12) | |
| } | |
| VStack { |
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
| struct ContactInfo : Identifiable{ | |
| var id = UUID() | |
| var firstName: String | |
| var lastName: String | |
| var phoneNumber: CNPhoneNumber? | |
| } |
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 Contacts | |
| class FetchContacts { | |
| func fetchingContacts() -> [ContactInfo]{ | |
| var contacts = [ContactInfo]() | |
| let keys = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactPhoneNumbersKey] | |
| let request = CNContactFetchRequest(keysToFetch: keys as [CNKeyDescriptor]) | |
| do { | |
| try CNContactStore().enumerateContacts(with: request, usingBlock: { (contact, stopPointer) in | |
| contacts.append(ContactInfo(firstName: contact.givenName, lastName: contact.familyName, phoneNumber: contact.phoneNumbers.first?.value)) |
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 UIApplication { | |
| func endEditing(_ force: Bool) { | |
| self.windows | |
| .filter{$0.isKeyWindow} | |
| .first? | |
| .endEditing(force) | |
| } | |
| } |
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
| struct ContactRow: View { | |
| var contact: ContactInfo | |
| var body: some View { | |
| Text("\(contact.firstName) \(contact.lastName)").foregroundColor(.primary) | |
| } | |
| } |
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
| @State private var contacts = [ContactInfo.init(firstName: "", lastName: "", phoneNumber: nil)] | |
| @State private var searchText = "" | |
| @State private var showCancelButton: Bool = false | |
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
| func getContacts() { | |
| DispatchQueue.main.async { | |
| self.contacts = FetchContacts().fetchingContacts() | |
| } | |
| } | |
| } |
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
| func requestAccess() { | |
| let store = CNContactStore() | |
| switch CNContactStore.authorizationStatus(for: .contacts) { | |
| case .authorized: | |
| self.getContacts() | |
| case .denied: | |
| store.requestAccess(for: .contacts) { granted, error in | |
| if granted { | |
| self.getContacts() | |
| } |
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
| // Search view | |
| HStack { | |
| HStack { | |
| //search bar magnifying glass image | |
| Image(systemName: "magnifyingglass").foregroundColor(.secondary) | |
| //search bar text field | |
| TextField("search", text: self.$searchText, onEditingChanged: { isEditing in | |
| self.showCancelButton = true | |
| }) |
OlderNewer