New in SwiftUI 3: FocusState in SwiftUI 3 and iOS 15
@FocusState
is a new property wrapper introduced in iOS 15 in conjunction with focused
modifier. FocusState
this property wrapper provides a way to read and write current focus positions within the view hierarchy.
The way this property wrapper works is when focus enters the view being modified, the wrapped value for the property wrapper updates to match a given prototype value and when focus leaves the view, wrapped value resets to false or nil. Depending upon the focus state you can take actions on entered data.