Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ let applePlatforms = TargetDependencyCondition.when(
var packageDependencies: [Package.Dependency] = [
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing.git", from: "1.19.4"),
.package(url: "https://github.com/theleftbit/BSWFoundation.git", from: "8.0.0"),
.package(url: "https://github.com/kean/Nuke.git", from: "13.1.0"),
.package(url: "https://github.com/kean/Nuke.git", from: "13.2.0"),
]

if skipIsEnabled {
packageDependencies.append(contentsOf: [
.package(url: "https://source.skip.tools/skip.git", from: "1.9.5"),
.package(url: "https://source.skip.tools/skip.git", from: "1.9.6"),
.package(url: "https://source.skip.tools/skip-fuse-ui.git", from: "1.18.1"),
])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public extension Color {
}
}

#if canImport(UIKit.UIColor)
#if canImport(UIKit)

import UIKit

Expand Down
42 changes: 17 additions & 25 deletions Sources/BSWInterfaceKit/SwiftUI/Views/GalleryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,30 +71,13 @@ public struct GalleryView: View {
cell(url, index: index)
}
}
.overlay(alignment: .bottom) {
PageIndicator(
itemIDs: pageIDs,
selectedID: String(currentPhotoSelectedIndex),
)
.padding(.bottom, 16)
}
#if canImport(UIKit)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.toolbar { toolbarContent }
.tabViewStyle(.page(indexDisplayMode: .never))
#endif
#if os(Android)
.navigationBarHidden(true)
.overlay(alignment: .topTrailing) {
fallbackButton
.padding([.top, .trailing], 16)
}
.tabViewStyle(.page(indexDisplayMode: .never))
/// SkipUI renders page-style TabView as a Compose HorizontalPager,
/// which cannot be measured intrinsically. A fixed height prevents Compose
/// from crashing while measuring the full-screen gallery.
#endif
.platformPageIndicator(
itemIDs: pageIDs,
selectedID: String(currentPhotoSelectedIndex)
)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}

@ViewBuilder
Expand All @@ -118,18 +101,27 @@ public struct GalleryView: View {
#endif
}

#if canImport(UIKit)
@ToolbarContentBuilder
private var toolbarContent: some ToolbarContent {
ToolbarItem(placement: .topBarTrailing) {
ToolbarItem(placement: {
#if os(macOS)
.primaryAction
#else
.topBarTrailing
#endif
}()) {
#if canImport(UIKit)
if #available(iOS 26.0, *) {
Button(role: .close, action: dismiss.callAsFunction)
} else {
fallbackButton
}
#elseif os(Android)
fallbackButton
#endif
}
}
#endif


@ViewBuilder
private var fallbackButton: some View {
Expand Down
30 changes: 26 additions & 4 deletions Sources/BSWInterfaceKit/SwiftUI/Views/PageIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,37 @@ import SkipFuseUI
import SwiftUI
#endif

/// The native PageTabViewStyle indicator is not rendered consistently by Skip on Android.
/// Uses native page indicators on iOS and a custom indicator on Android,
/// where white native dots are not visible on white backgrounds.

public struct PageIndicator: View {
public extension View {

@ViewBuilder
func platformPageIndicator(itemIDs: [String], selectedID: String) -> some View {
#if canImport(UIKit)
tabViewStyle(.page(indexDisplayMode: .always))
#elseif os(Android)
tabViewStyle(.page(indexDisplayMode: .never))
.overlay(alignment: .bottom) {
PageIndicator(
itemIDs: itemIDs,
selectedID: selectedID
)
.padding(.bottom, 16)
}
#else
self
#endif
}
}

struct PageIndicator: View {

private let itemIDs: [String]
private let selectedID: String
private let color: Color

public init(
init(
itemIDs: [String],
selectedID: String,
color: Color = .primary
Expand All @@ -26,7 +48,7 @@ public struct PageIndicator: View {
self.color = color
}

public var body: some View {
var body: some View {
HStack(spacing: 8) {
ForEach(itemIDs.indices, id: \.self) { index in
Circle()
Expand Down
Loading