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 | |
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 MyValue: _ViewTraitKey { | |
static var defaultValue: Int = 0 | |
} | |
extension View { | |
func myValue(_ value: Int) -> some View { | |
_trait(MyValue.self, 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 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
struct LazyView<Content: View>: View { | |
let build: () -> Content | |
init(_ build: @autoclosure @escaping () -> Content) { | |
self.build = build | |
} | |
var body: Content { | |
build() | |
} | |
} |
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) |
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 SizeKey: PreferenceKey { | |
static func reduce(value: inout CGSize?, nextValue: () -> CGSize?) { | |
value = value ?? nextValue() | |
} | |
} | |
struct ContentView: View { | |
@State var width: CGFloat? = nil | |
var body: some View { |
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
// | |
// ContentView.swift | |
// AnimationTimingCurve | |
// | |
// Created by Chris Eidhof on 25.09.19. | |
// Copyright © 2019 Chris Eidhof. All rights reserved. | |
// | |
import SwiftUI |
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
// | |
// ContentView.swift | |
// DeleteMe | |
// | |
// Created by Chris Eidhof on 02.02.21. | |
// | |
import SwiftUI | |
/* |
NewerOlder