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 | |
@available(watchOS 10.0, *) | |
@available(iOS 17.0, *) | |
private struct ContentMarginsFollowReadableWidthModifier: ViewModifier { | |
static let readableWidth: Double = 672 | |
static let minInsetLength: Double = 16 | |
@ViewBuilder | |
func body(content: Content) -> some View { |
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 | |
@main | |
struct WindowPresentationFunApp: App { | |
@State var appState = AppState() | |
var body: some Scene { | |
WindowGroup { | |
RootView(appState: appState) | |
.onAppear { |
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 | |
private struct SafeAreaInsetsFollowReadableWidthModifier: ViewModifier { | |
static let readableWidth: Double = 672 | |
@ViewBuilder | |
func body(content: Content) -> some View { | |
GeometryReader { geometry in | |
let insetLength = max(0, geometry.size.width - Self.readableWidth) / 2 |
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 | |
private extension Bundle { | |
private static let packageName = "my-package" | |
private static let moduleName = "MyModule" | |
static var swiftUIPreviewsCompatibleModule: Bundle { | |
final class CurrentBundleFinder {} | |
let isPreview = ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" |
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 | |
// Works around a critical issue observed on iPads with a trackpad cursor. | |
// | |
// With highPriorityGesture, other interactive content on the screen can become unresponsive after | |
// triggering the gesture with an iPad cursor. It's as if the gesture seems to never relinquish its | |
// grasp on the entire UI, until you interact with the screen directly with a tap or trigger a | |
// context menu. | |
// | |
// This view modifier and extension works around this by forcing the gesture to be "cancelled" by |
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 | |
// Models | |
enum Lyric { | |
case line(String) | |
case pause(TimeInterval) | |
} | |
class ScrollToModel: ObservableObject { |
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 WidthPreferenceKey: PreferenceKey { | |
typealias Value = CGFloat? | |
static var defaultValue: CGFloat? | |
static func reduce(value: inout CGFloat?, nextValue: () -> CGFloat?) { | |
if let nextValue = nextValue(), value != nextValue { | |
value = nextValue |
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 | |
public class RemoteInspector { | |
private struct UpdateMessage<T: Encodable>: Encodable { | |
let type = "update" | |
var id: String | |
var data: T | |
} | |
private struct LogMessage: Encodable { |
NewerOlder