Created
March 24, 2022 09:34
-
-
Save philipyoungg/562536bb461f5d48d626b4cb041449a1 to your computer and use it in GitHub Desktop.
Won't compile on XCode 13.3
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
// | |
// ContentView.swift | |
// Shared | |
// | |
// Created by Philip Young on 2022-03-24. | |
// | |
import SwiftUI | |
struct CustomTextField: View, Equatable { | |
static func == (lhs: Self, rhs: Self) -> Bool { | |
return lhs.text == rhs.text | |
} | |
@Binding var text: String | |
@Binding var isFocused: Bool | |
init(text: Binding<String>, isFocused: Binding<Bool>) { | |
self._text = text | |
self._isFocused = isFocused | |
} | |
var body: some View { | |
return Group { | |
TextField("Placeholder", text: $text) | |
}.frame(maxWidth: .infinity, maxHeight: .infinity) | |
} | |
} | |
struct ContentView: View { | |
@State var text = "" | |
@State var isFocused = false | |
var body: some View { | |
VStack { | |
CustomTextField(text: $text, isFocused: $isFocused).equatable() | |
} | |
.padding() | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
CustomTextField(text: .constant("AWDAWD"), isFocused: .constant(false)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment