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 ContentView: View { | |
@State var progress: Double = 0 | |
var body: some View { | |
VStack { | |
Slider(value: $progress, in: 0...1) | |
Text("Hello, world") |
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 Helper<Result: View>: _VariadicView_MultiViewRoot { | |
var _body: (_VariadicView.Children) -> Result | |
func body(children: _VariadicView.Children) -> some View { | |
_body(children) | |
} |
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 MyTextEditor: NSViewRepresentable { | |
@Binding var text: String | |
final class Coordinator: NSObject, NSTextViewDelegate { | |
var text: Binding<String> |
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 ContentView: View { | |
@State private var toggle = true | |
@Namespace private var ns | |
var body: some View { | |
let box = Rectangle() | |
.fill(.tertiary) |
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 UIKit | |
import SwiftUI | |
struct ContentView2: View { | |
var body: some View { | |
VStack { | |
SimpleRepresentable(text: "Test") | |
} | |
} | |
} |
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 MyProgress: View, Animatable { | |
var progress: Double | |
var animatableData: Double { | |
get { progress } | |
set { progress = newValue } |
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 ContentView: View { | |
@State private var color0 = Color.red | |
@State private var color1 = Color.red | |
var body: some View { | |
VStack { | |
color0 | |
color1 | |
} |
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 | |
import Observation | |
// easeInBounce | |
// | |
// https://easings.net | |
// https://gist.github.com/girish3/11167208 |
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
disabled_rules: | |
- trailing_comma | |
opt_in_rules: | |
- file_header | |
file_header: | |
forbidden_pattern: /./ | |
custom_rules: | |
state_private: | |
name: "Private SwiftUI State" | |
regex: "\\@State\\s*var" |
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 | |
extension View { | |
@MainActor | |
func pdf(size: ProposedViewSize) -> Data { | |
let renderer = ImageRenderer(content: self) | |
renderer.proposedSize = size | |
var pdfData = NSMutableData() | |
renderer.render { size, render in | |
var mediaBox = CGRect(origin: .zero, size: size) |
NewerOlder