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 EmojiPickerView: UIViewRepresentable { | |
@Binding var isFirstResponder: Bool | |
var onPick: (String) -> Void | |
var onDelete: () -> Void | |
func makeUIView(context: Context) -> UIViewType { | |
UIViewType(view: self) | |
} |
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 XCTestDynamicOverlay | |
{% for func in functions %} | |
public struct {% for text in func.name|split:"(" %}{% if forloop.first %}{{ text|upperFirstLetter }}{% endif %}{% endfor %} { | |
public var run: ({% for param in func.parameters %}{{ param.typeName }}{% ifnot forloop.last %}, {% endif %}{% endfor %}){% if func.throws %} throws{% endif %} -> {{ func.returnTypeName }} | |
public func callAsFunction({% if func.parameters.count > 0 %} | |
{% for param in func.parameters %} | |
{{ param.asSource }}{% ifnot forloop.last %},{% endif %} | |
{% endfor %} |
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 ExampleView: View { | |
var body: some View { | |
Color.blue | |
.gesture( | |
TapGesture(count: 1) | |
.simultaneously(with: DragGesture(minimumDistance: 0)) | |
.onEnded { value in | |
if value.first != nil, let location = value.second?.startLocation { |
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 InterfaceOrientationObservingViewModifier: ViewModifier { | |
let onChange: (UIInterfaceOrientation) -> Void | |
func body(content: Content) -> some View { | |
content.background(InterfaceOrientationObservingView(onChange: onChange)) | |
} | |
} |
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 CoreMotion | |
import SwiftUI | |
struct DeviceOrientationObservingViewModifier: ViewModifier { | |
let onChange: (UIDeviceOrientation) -> Void | |
func body(content: Content) -> some View { | |
content.background(DeviceOrientationObservingView(onChange: onChange)) | |
} | |
} |
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 { | |
func bottomBar<Bar: View>( | |
ignoresKeyboard: Bool = true, | |
frameChangeAnimation: Animation? = .default, | |
@ViewBuilder bar: @escaping () -> Bar | |
) -> some View { | |
modifier(BottomBarViewModifier( | |
ignoresKeyboard: ignoresKeyboard, |
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 { | |
func geometryReader<Geometry: Codable>( | |
geometry: @escaping (GeometryProxy) -> Geometry, | |
onChange: @escaping (Geometry) -> Void | |
) -> some View { | |
modifier(GeometryReaderViewModifier( | |
geometry: geometry, | |
onChange: onChange |
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 | |
public extension View { | |
func onSizeChange( | |
ignoreSafeArea: Bool = false, | |
round: Bool = false, | |
perform action: @escaping (CGSize) -> Void | |
) -> some View { | |
modifier(SizeChangeModifier( | |
ignoreSafeArea: ignoreSafeArea, |
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 CoreMotion | |
import SwiftUI | |
public final class DeviceOrientationObserver: ObservableObject { | |
public init() { | |
manager.startAccelerometerUpdates(to: OperationQueue.main) { [weak self] data, error in | |
guard error == nil, let acceleration = data?.acceleration else { | |
self?.value = .unknown | |
return | |
} |