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 | |
/* | |
This is here to make working with state and bindings in previews easier. See below for an example. | |
If you're using a recent version of Xcode you can use the [Previewable](https://developer.apple.com/documentation/SwiftUI/Previewable()) macro instead. | |
*/ | |
struct WithState<Value, Content: View>: View { | |
@ViewBuilder var content: (Binding<Value>) -> Content |
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" |
NewerOlder