File tree Expand file tree Collapse file tree 1 file changed +16
-12
lines changed
Examples/Sources/ForEachExample Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -24,25 +24,28 @@ struct ForEachApp: App {
2424 #hotReloadable {
2525 ScrollView {
2626 VStack {
27- Text ( " Items " )
28-
2927 Button ( " Append " ) {
3028 biggestValue += 1
3129 items. append ( . init( " \( biggestValue) " ) )
3230 }
3331
34- Button ( " Insert in front of current item at position \( insertionPosition) " ) {
35- biggestValue += 1
36- items. insert ( . init( " \( biggestValue) " ) , at: insertionPosition)
37- }
38- Slider ( $insertionPosition, minimum: 0 , maximum: items. count - 1 )
39- . onChange ( of: items. count) {
40- guard insertionPosition > items. count - 1 else {
41- return
42- }
43- insertionPosition = max ( items. count - 1 , 0 )
32+ #if !os(tvOS)
33+ Button (
34+ " Insert in front of current item at position \( insertionPosition) "
35+ ) {
36+ biggestValue += 1
37+ items. insert ( . init( " \( biggestValue) " ) , at: insertionPosition)
4438 }
4539
40+ Slider ( $insertionPosition, minimum: 0 , maximum: items. count - 1 )
41+ . onChange ( of: items. count) {
42+ guard insertionPosition > items. count - 1 else {
43+ return
44+ }
45+ insertionPosition = max ( items. count - 1 , 0 )
46+ }
47+ #endif
48+
4649 ForEach ( items) { item in
4750 ItemRow (
4851 item: item, isFirst: Optional ( item. id) == items. first? . id,
@@ -66,6 +69,7 @@ struct ForEachApp: App {
6669 }
6770 . padding ( 10 )
6871 }
72+ . focusable ( )
6973 }
7074 }
7175 . defaultSize ( width: 400 , height: 800 )
You can’t perform that action at this time.
0 commit comments