Skip to content

Instantly share code, notes, and snippets.

@philipyoungg
Created March 24, 2022 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philipyoungg/562536bb461f5d48d626b4cb041449a1 to your computer and use it in GitHub Desktop.
Save philipyoungg/562536bb461f5d48d626b4cb041449a1 to your computer and use it in GitHub Desktop.
Won't compile on XCode 13.3
//
// 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