Skip to content

Commit

Permalink
Fix PageView and Select
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed Jul 15, 2023
1 parent d4d3c48 commit 0b5c220
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Sources/OversizeUI/Controls/PageView/PageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public struct PageView<Content, LeadingBar, TrailingBar, TopToolbar, TitleLabel>
}

public var body: some View {
ScrollViewOffset(offset: $offset) {
ScrollViewOffset(offset: $offset, coordinateSpace: .named("Page")) {
content
}
.frame(maxWidth: .infinity, alignment: .leading)
.frame(maxWidth: .infinity, alignment: .center)
.background(background.ignoresSafeArea())
.safeAreaInset(edge: .top) { header }
.onChange(of: offset) { offset in
Expand All @@ -57,6 +57,7 @@ public struct PageView<Content, LeadingBar, TrailingBar, TopToolbar, TitleLabel>
}
}
}
.coordinateSpace(name: "Page")
}

@ViewBuilder
Expand Down
14 changes: 11 additions & 3 deletions Sources/OversizeUI/Controls/Select/Select.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import SwiftUI

// swiftlint:disable all
public struct Select<Element, Content, Selection, Actions, ContentUnavailable: View>: View
public struct Select<Element: Equatable, Content, Selection, Actions, ContentUnavailable: View>: View
where
Content: View,
Actions: View,
Expand Down Expand Up @@ -80,7 +80,6 @@ public struct Select<Element, Content, Selection, Actions, ContentUnavailable: V
)
.headline(.medium)
.foregroundColor(.onSurfaceHighEmphasis)

.sheet(isPresented: $showModal) {
#if os(iOS)
if #available(iOS 16.0, *) {
Expand All @@ -99,6 +98,16 @@ public struct Select<Element, Content, Selection, Actions, ContentUnavailable: V
showModal = state
}
}
.onAppear {
let selctedValue = selection
var index = 0
for dataValue in data {
if selctedValue == dataValue {
selectedIndex = index
}
index += 1
}
}
}
}

Expand Down Expand Up @@ -206,7 +215,6 @@ struct Select_Preview: PreviewProvider {
Text(selected)
}
}

.padding()
}
}
Expand Down

0 comments on commit 0b5c220

Please sign in to comment.