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 AccessibilityValueExample: View { | |
| @State private var value = 10 | |
| var body: some View { | |
| VStack(spacing: 20) { | |
| Text("Value: \(value)") | |
| Button("Increment") { |
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 DifferentiateWithoutColorExample: View { | |
| @Environment(\.accessibilityDifferentiateWithoutColor) var differentiateWithoutColor | |
| var body: some View { | |
| HStack { | |
| if differentiateWithoutColor { | |
| Image(systemName: "checkmark.circle") | |
| } |
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 ReduceTransparencyExample: View { | |
| @Environment(\.accessibilityReduceTransparency) var reduceTransparency | |
| var body: some View { | |
| Text("Hello, World!") | |
| .padding() | |
| .background(reduceTransparency ? .black : .black.opacity(0.5)) | |
| .foregroundColor(.white) |
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 PhotosUI | |
| import SwiftUI | |
| struct ImagePicker: UIViewControllerRepresentable { | |
| @Binding var image: UIImage? | |
| class Coordinator: NSObject, PHPickerViewControllerDelegate { | |
| let parent: ImagePicker | |
| init(_ parent: ImagePicker) { |
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 CameraManager: UIViewControllerRepresentable { | |
| @Binding var image: UIImage? | |
| class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate { | |
| let parent: PictureManager | |
| init(_ parent: PictureManager) { | |
| self.parent = parent |
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 CoreImage | |
| import CoreImage.CIFilterBuiltins | |
| struct CoreImageExample: View { | |
| @State private var image: Image? | |
| // We can have a filter picker in order to make this property dynamic | |
| @State private var currentFilter: CIFilter = CIFilter.sepiaTone() | |
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 | |
| class ImageSaver: NSObject { | |
| var successHandler: (() -> Void)? | |
| var errorHandler: ((Error) -> Void)? | |
| func writeToPhotoAlbum(image: UIImage) { | |
| UIImageWriteToSavedPhotosAlbum(image, self, #selector(saveCompleted), nil) | |
| } | |
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 Location: Identifiable { | |
| let id: UUID | |
| var name: String | |
| let latitude: Double | |
| let longitude: Double | |
| var coordinate: CLLocationCoordinate2D { |
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 CoreLocation | |
| class LocationFetcher: NSObject, CLLocationManagerDelegate { | |
| let manager = CLLocationManager() | |
| var location: ((CLLocation) -> Void)? | |
| var authorizationChanged: ((Bool) -> Void)? | |
| override 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 openSettings() { | |
| guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else { | |
| return | |
| } | |
| if UIApplication.shared.canOpenURL(settingsUrl) { | |
| UIApplication.shared.open(settingsUrl) { success in | |
| print("Settings opened: \(success)") | |
| } | |
| } | |
| } |