@@ -3,33 +3,32 @@ import SwiftUI
3
3
@available ( iOS 18 , macOS 15 , visionOS 2 , tvOS 18 , * )
4
4
struct NewTabView : AnyTabView {
5
5
@ObservedObject var props : TabViewProps
6
-
6
+
7
7
var onLayout : ( CGSize ) -> Void
8
8
var onSelect : ( String ) -> Void
9
9
var updateTabBarAppearance : ( ) -> Void
10
-
10
+
11
11
@ViewBuilder
12
12
var body : some View {
13
13
TabView ( selection: $props. selectedPage) {
14
- ForEach ( props. children. indices, id: \. self) { index in
15
- if let tabData = props. items [ safe: index] {
14
+ ForEach ( props. children, id: \. self) { child in
15
+ if let index = props. children. firstIndex ( of: child) ,
16
+ let tabData = props. items [ safe: index] {
16
17
let isFocused = props. selectedPage == tabData. key
17
-
18
+
18
19
if !tabData. hidden || isFocused {
19
20
let icon = props. icons [ index]
20
-
21
- let platformChild = props. children [ safe: index] ?? PlatformView ( )
22
- let child = RepresentableView ( view: platformChild)
21
+
23
22
let context = TabAppearContext (
24
23
index: index,
25
24
tabData: tabData,
26
25
props: props,
27
26
updateTabBarAppearance: updateTabBarAppearance,
28
27
onSelect: onSelect
29
28
)
30
-
29
+
31
30
Tab ( value: tabData. key, role: tabData. role? . convert ( ) ) {
32
- child
31
+ RepresentableView ( view : child)
33
32
. ignoresSafeArea ( . container, edges: . all)
34
33
. tabAppear ( using: context)
35
34
} label: {
0 commit comments