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
| class User: ObservableObject { | |
| @Published var name = "Ryan" | |
| } | |
| struct EditView: View { | |
| @EnvironmentObject var user: User | |
| var body: some View { | |
| TextField("Name", text: $user.name) | |
| } |
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 AlertControl: UIViewControllerRepresentable { | |
| @Binding var textString: String | |
| @Binding var textString2: String | |
| @Binding var show: Bool | |
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 FirstScreen: View { | |
| // MARK: - Properties | |
| @State private var isUnlocked = false | |
| // MARK: - Body | |
| var body: some View { | |
| Group { | |
| if isUnlocked { |
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 | |
| import LocalAuthentication | |
| struct AuthView: View { | |
| @Binding var isUnlocked: Bool | |
| @State private var showingAuthenticationError = false | |
| @State private var authenticationErrorTitle = "" | |
| @State private var authenticationErrorMessage = "" | |
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
| class CodableMKPointAnnotation: MKPointAnnotation, Codable { | |
| enum CodingKeys: CodingKey { | |
| case title, subtitle, latitude, longitude | |
| } | |
| override init() { | |
| super.init() | |
| } | |
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 fetchNearbyPlaces() { | |
| let urlString = "https://en.wikipedia.org/w/api.php?ggscoord=\(placemark.coordinate.latitude)%7C\(placemark.coordinate.longitude)&action=query&prop=coordinates%7Cpageimages%7Cpageterms&colimit=50&piprop=thumbnail&pithumbsize=500&pilimit=50&wbptterms=description&generator=geosearch&ggsradius=10000&ggslimit=50&format=json" | |
| guard let url = URL(string: urlString) else { | |
| print("Bad URL: \(urlString)") | |
| return | |
| } | |
| URLSession.shared.dataTask(with: url) { data, response, error in | |
| if let data = data { | |
| let decoder = JSONDecoder() |
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 Foundation | |
| struct QueryWiki: Codable { | |
| let query: Query | |
| } | |
| struct Query: Codable { | |
| let pages: [Int: Page] | |
| } |
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 | |
| import MapKit | |
| struct ContentView: View { | |
| // MARK: - Properties | |
| @State private var centerCoordinate = CLLocationCoordinate2D() | |
| @State private var locations = [MKPointAnnotation]() | |
| @State private var selectedPlace: MKPointAnnotation? | |
| @State private var showingPlaceDetails = 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
| import MapKit | |
| import SwiftUI | |
| struct EditView: View { | |
| // MARK: - Properties | |
| @Environment(\.presentationMode) var presentationMode | |
| @ObservedObject var placemark: MKPointAnnotation | |
| // MARK: - Body |
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 MapKit | |
| extension MKPointAnnotation: ObservableObject { | |
| public var wrappedTitle: String { | |
| get { | |
| self.title ?? "Unknown value" | |
| } | |
| set { | |
| title = newValue |