@@ -8,6 +8,7 @@ import UIKit
88/// items will not cause the toolbar to be updated. The toolbar is only updated when the view
99/// containing the ``View/keyboardToolbar(animateChanges:body:)`` modifier is updated, so any
1010/// state necessary for the toolbar should live in the view itself.
11+ @available ( tvOS, unavailable)
1112public protocol ToolbarItem {
1213 /// The type of bar button item used to represent this item in UIKit.
1314 associatedtype ItemType : UIBarButtonItem
@@ -19,6 +20,7 @@ public protocol ToolbarItem {
1920 func updateBarButtonItem( _ item: inout ItemType )
2021}
2122
23+ @available ( tvOS, unavailable)
2224@resultBuilder
2325public enum ToolbarBuilder {
2426 public enum Component {
@@ -56,6 +58,7 @@ public enum ToolbarBuilder {
5658 }
5759}
5860
61+ @available ( tvOS, unavailable)
5962extension Button : ToolbarItem {
6063 public final class ItemType : UIBarButtonItem {
6164 var callback : ( ) -> Void
@@ -91,6 +94,7 @@ extension Button: ToolbarItem {
9194}
9295
9396@available ( iOS 14 , macCatalyst 14 , tvOS 14 , * )
97+ @available ( tvOS, unavailable)
9498extension Spacer : ToolbarItem {
9599 public func createBarButtonItem( ) -> UIBarButtonItem {
96100 if let minLength, minLength > 0 {
@@ -110,6 +114,7 @@ extension Spacer: ToolbarItem {
110114 }
111115}
112116
117+ @available ( tvOS, unavailable)
113118struct FixedWidthToolbarItem < Base: ToolbarItem > : ToolbarItem {
114119 var base : Base
115120 var width : Int ?
@@ -132,6 +137,7 @@ struct FixedWidthToolbarItem<Base: ToolbarItem>: ToolbarItem {
132137
133138// Setting width on a flexible space is ignored, you must use a fixed space from the outset
134139@available ( iOS 14 , macCatalyst 14 , tvOS 14 , * )
140+ @available ( tvOS, unavailable)
135141struct FixedWidthSpacerItem : ToolbarItem {
136142 var width : Int ?
137143
@@ -148,6 +154,7 @@ struct FixedWidthSpacerItem: ToolbarItem {
148154 }
149155}
150156
157+ @available ( tvOS, unavailable)
151158struct ColoredToolbarItem < Base: ToolbarItem > : ToolbarItem {
152159 var base : Base
153160 var color : Color
@@ -164,13 +171,14 @@ struct ColoredToolbarItem<Base: ToolbarItem>: ToolbarItem {
164171 }
165172}
166173
174+ @available ( tvOS, unavailable)
167175extension ToolbarItem {
168176 /// A toolbar item with the specified width.
169177 ///
170178 /// If `width` is positive, the item will have that exact width. If `width` is zero or
171179 /// nil, the item will have its natural size.
172180 public func frame( width: Int ? ) -> any ToolbarItem {
173- if #available( iOS 14 , macCatalyst 14 , tvOS 14 , * ) ,
181+ if #available( iOS 14 , macCatalyst 14 , * ) ,
174182 self is Spacer || self is FixedWidthSpacerItem
175183 {
176184 FixedWidthSpacerItem ( width: width)
@@ -185,6 +193,7 @@ extension ToolbarItem {
185193 }
186194}
187195
196+ @available ( tvOS, unavailable)
188197indirect enum ToolbarItemLocation : Hashable {
189198 case expression( inside: ToolbarItemLocation ? )
190199 case block( index: Int , inside: ToolbarItemLocation ? )
@@ -194,6 +203,7 @@ indirect enum ToolbarItemLocation: Hashable {
194203 case eitherSecond( inside: ToolbarItemLocation ? )
195204}
196205
206+ @available ( tvOS, unavailable)
197207final class KeyboardToolbar : UIToolbar {
198208 var locations : [ ToolbarItemLocation : UIBarButtonItem ] = [ : ]
199209
@@ -205,7 +215,7 @@ final class KeyboardToolbar: UIToolbar {
205215 var newLocations : [ ToolbarItemLocation : UIBarButtonItem ] = [ : ]
206216
207217 visitItems ( component: components, inside: nil ) { location, expression in
208- var item =
218+ let item =
209219 if let oldItem = locations [ location] {
210220 updateErasedItem ( expression, oldItem)
211221 } else {
@@ -270,10 +280,12 @@ final class KeyboardToolbar: UIToolbar {
270280 }
271281}
272282
283+ @available ( tvOS, unavailable)
273284enum ToolbarKey : EnvironmentKey {
274285 static let defaultValue : ( ( KeyboardToolbar ) -> Void ) ? = nil
275286}
276287
288+ @available ( tvOS, unavailable)
277289extension EnvironmentValues {
278290 var updateToolbar : ( ( KeyboardToolbar ) -> Void ) ? {
279291 get { self [ ToolbarKey . self] }
@@ -287,6 +299,7 @@ extension View {
287299 /// - animateChanges: Whether to animate updates when an item is added, removed, or
288300 /// updated
289301 /// - body: The toolbar's contents
302+ @available ( tvOS, unavailable)
290303 public func keyboardToolbar(
291304 animateChanges: Bool = true ,
292305 @ToolbarBuilder body: @escaping ( ) -> ToolbarBuilder . FinalResult
0 commit comments