This file contains 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 ComposableArchitecture | |
import SwiftUI | |
struct Parent: Reducer { | |
struct State: Equatable { | |
@PresentationState var child: Child.State? | |
} | |
enum Action: Equatable { | |
case presentChildButtonTapped |
This file contains 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
/// MIT License | |
/// | |
/// Copyright (c) 2023 Dariusz Rybicki Darrarski | |
/// | |
/// Permission is hereby granted, free of charge, to any person obtaining a copy | |
/// of this software and associated documentation files (the "Software"), to deal | |
/// in the Software without restriction, including without limitation the rights | |
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
/// copies of the Software, and to permit persons to whom the Software is | |
/// furnished to do so, subject to the following conditions: |
This file contains 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 | |
@dynamicMemberLookup | |
public actor CurrentValueAsyncSequence<Value>: AsyncSequence where Value: Sendable { | |
public typealias Element = Value | |
public init(_ value: Value) { | |
self.value = value | |
} |
This file contains 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 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 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
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: cyan; icon-glyph: clock; | |
// list of time zones: https://gist.github.com/rxaviers/8481876 | |
let configs = [ | |
{name: "Warsaw", timzeZone: "Europe/Berlin", bgColor: new Color("BF0D3E",1)}, | |
{name: "Recife", timeZone: "America/Recife", bgColor: new Color("009639",1)}, | |
{name: "Los Angeles", timeZone: "America/Los_Angeles", bgColor: new Color("3878d1",1)} | |
] |
This file contains 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 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 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
// Based on "Lazy navigation in SwiftUI" blogpost by Majid Jabrayilov | |
// Blogpost url: https://swiftwithmajid.com/2021/01/27/lazy-navigation-in-swiftui/ | |
// This gist shows an issue with using conditional NavigationLinks. | |
// When using StackNavigationViewStyle push animations are not present. | |
import SwiftUI | |
@main | |
struct LazyNavApp: App { | |
var body: some Scene { |