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 | |
extension View { | |
/// For sheets, we will follow the SwiftUI built-in approach: | |
/// | |
/// If we only need to present one possible sheet, we can use a Boolean binding and use `.sheet(isPresented:)` | |
/// | |
/// `.sheet(isPresented:)` | |
/// =================================== | |
/// ```swift |
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 | |
import SwiftUI | |
struct ImageSelectorOptionsModifier: ViewModifier { | |
var title: String | |
var titleVisibility: Visibility | |
var galleryOptionTitle: String | |
var takePictureOptionTitle: String | |
@Binding var isPresentingSourceSelector: Bool | |
@Binding var selectedImage: UIImage? |
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 | |
/// SwiftUI Wrapper for UIImagePickerController. | |
struct ImagePicker: UIViewControllerRepresentable { | |
var sourceType: UIImagePickerController.SourceType = .photoLibrary | |
@Binding var selectedImage: UIImage? | |
@Environment(\.dismiss) private var dismiss | |
func makeUIViewController(context: UIViewControllerRepresentableContext<ImagePicker>) -> UIImagePickerController { |
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 | |
extension View { | |
/// Adds the `LongPressShrinkModifier` modifier. | |
/// A modifier that adds a LongPressGesture action, that shrinks the view while it's being tapped. | |
/// - Parameters: | |
/// - animationDuration: The shrink animation duration. `Default = 0.3`. | |
/// - shrinkScale: The scale value for when the view is pressed. `Default = 0.85`. | |
/// - defaultScale: The scale value for when the view is not pressed: `Default = 1.0`. | |
/// - minimumLongPressDuration: The minimum long press duration. `Default = 0.5`. |
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 | |
extension View { | |
/// Adds the `TapShrinkModifier` modifier. | |
/// A modifier that adds a shrink animation on tap. | |
/// - Parameters: | |
/// - animationDuration: The shrink animation duration. `Default = 0.3`. | |
/// - shrinkScale: The scale value for when the view is pressed. `Default = 0.85`. | |
/// - defaultScale: The scale value for when the view is not pressed: `Default = 1.0`. | |
/// - action: The action to execute. |
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 | |
/// An adaptable stack view that switches between `HStack` and `VStack` based on the dynamic text size. | |
struct AdaptableStack<Content>: View where Content: View { | |
@Environment(\.dynamicTypeSize) private var size: DynamicTypeSize | |
/// The primary axis along which the stack arranges its children. | |
private var axis: StackAxis | |
/// The dynamic type size threshold above which the stack axis will switch. | |
private var sizeThreshold: DynamicTypeSize | |
/// Alignment of children along the X-axis for vertical stack. |
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
/// Mock instance of NotificationCenter, to be used in tests' targets | |
public final class NotificationCenterMock: NotificationCenter { | |
public var postCalls = 0 | |
public var postedNotifications: [NSNotification.Name] = [] | |
public var postReceivedObject: Any? | |
public var postReceivedUserInfos: [[AnyHashable: Any]] = [] | |
public var addObserverCalls = 0 | |
public var addObserverReceivedSelector: Selector? | |
public var addObserverReceivedName: NSNotification.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
/// Reflects notification publisher functionality of `NotificationCenter`. | |
public protocol NotificationPublisherProtocol: AnyObject { | |
/// Returns a publisher that emits events when broadcasting notifications. | |
/// - Parameters: | |
/// - name: The name of the notification to publish. | |
/// - object: The object posting the named notification. If `nil`, the publisher emits elements for any object | |
/// producing a notification with the given name. | |
/// - Returns: A publisher that emits events when broadcasting notifications. | |
func publisher(for name: Notification.Name, object: AnyObject?) -> NotificationCenter.Publisher | |
} |
NewerOlder