diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fdbb159..62eb4d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,18 +26,18 @@ jobs: DIFF_BASE: ${{ github.base_ref }} Latest: name: Test Latest (iOS, macOS, tvOS, watchOS) - runs-on: macOS-12 + runs-on: macOS-13 env: - DEVELOPER_DIR: "/Applications/Xcode_14.1.app/Contents/Developer" + DEVELOPER_DIR: "/Applications/Xcode_15.1.app/Contents/Developer" timeout-minutes: 10 strategy: fail-fast: false matrix: include: - - destination: "OS=16.1,name=iPhone 14 Pro" + - destination: "OS=17.0,name=iPhone 14 Pro" name: "iOS" sdk: iphonesimulator - - destination: "OS=16.1,name=Apple TV" + - destination: "OS=17.2,name=Apple TV" name: "tvOS" sdk: appletvsimulator - destination: "OS=9.1,name=Apple Watch Series 8 (45mm)" @@ -59,11 +59,11 @@ jobs: discover-typos: name: Discover Typos - runs-on: macOS-12 + runs-on: macOS-13 env: - DEVELOPER_DIR: /Applications/Xcode_14.1.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Discover typos run: | export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.11/bin" diff --git a/CHANGELOG.md b/CHANGELOG.md index 64fb782..adc7ce6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,20 @@ All notable changes to this project will be documented in this file. #### 1.x Releases -- `1.0.x` Releases - [1.0.0](#100) | [1.0.1](#101) +- `1.0.x` Releases - [1.0.0](#100) | [1.0.1](#101) | [1.0.2](#102) + +## [1.0.2](https://github.com/space-code/skeleton-ui/releases/tag/1.0.2) +Released on 2024-07-19. + +#### Added +- Add an index to each view + - Added in Pull Request[#6](https://github.com/space-code/skeleton-ui/pull/6). + +#### Updated +- Update the masking logic + - Updated in Pull Request [#7](https://github.com/space-code/skeleton-ui/pull/7). +- Update the snapshot tests + - Updated in Pull Request [#8](https://github.com/space-code/skeleton-ui/pull/8). ## [1.0.1](https://github.com/space-code/skeleton-ui/releases/tag/1.0.1) Released on 2024-01-14. diff --git a/Sources/SkeletonUI/Classes/Core/SkeletonConstants.swift b/Sources/SkeletonUI/Classes/Core/SkeletonConstants.swift index f34f27b..5e80a74 100644 --- a/Sources/SkeletonUI/Classes/Core/SkeletonConstants.swift +++ b/Sources/SkeletonUI/Classes/Core/SkeletonConstants.swift @@ -15,9 +15,9 @@ public enum SkeletonConstants { /// Default gradient for the skeleton view. public static let gradient: Gradient = .init( stops: [ - .init(color: .black.opacity(.opacity), location: 0.8), - .init(color: .black, location: 0.9), - .init(color: .black.opacity(.opacity), location: 1.0), + .init(color: .gray.opacity(.opacity), location: 0.8), + .init(color: .gray, location: 0.9), + .init(color: .gray.opacity(.opacity), location: 1.0), ] ) } diff --git a/Sources/SkeletonUI/Classes/Core/ViewModifiers/ShimmerViewModifier.swift b/Sources/SkeletonUI/Classes/Core/ViewModifiers/ShimmerViewModifier.swift index d047f79..5d9aa8d 100644 --- a/Sources/SkeletonUI/Classes/Core/ViewModifiers/ShimmerViewModifier.swift +++ b/Sources/SkeletonUI/Classes/Core/ViewModifiers/ShimmerViewModifier.swift @@ -34,8 +34,8 @@ public struct ShimmerViewModifier: ViewModifier { // MARK: ViewModifier public func body(content: Content) -> some View { - content - .mask(GradientAnimationView(gradient: gradient, animation: animation)) + GradientAnimationView(gradient: gradient, animation: animation) + .mask(content) } } diff --git a/Sources/SkeletonUI/Classes/Core/ViewModifiers/SkeletonViewModifier.swift b/Sources/SkeletonUI/Classes/Core/ViewModifiers/SkeletonViewModifier.swift index 095130a..7d3702a 100644 --- a/Sources/SkeletonUI/Classes/Core/ViewModifiers/SkeletonViewModifier.swift +++ b/Sources/SkeletonUI/Classes/Core/ViewModifiers/SkeletonViewModifier.swift @@ -55,8 +55,8 @@ public struct SkeletonViewModifier: ViewModifier { content(index) .frame(width: (configuration.scales[safe: index] ?? 1) * geometry.size.width) } + .shimmering(isActive: true, gradient: configuration.gradient, animation: configuration.animation) } - .shimmering(isActive: true, gradient: configuration.gradient, animation: configuration.animation) } .padding(configuration.insets) } diff --git a/Sources/SkeletonUI/Classes/Core/Views/SkeletonView.swift b/Sources/SkeletonUI/Classes/Core/Views/SkeletonView.swift index 90aa009..d6e9950 100644 --- a/Sources/SkeletonUI/Classes/Core/Views/SkeletonView.swift +++ b/Sources/SkeletonUI/Classes/Core/Views/SkeletonView.swift @@ -15,7 +15,7 @@ public struct SkeletonView< >: View where Data.Element: Identifiable { // MARK: Types - public typealias ContentBuilder = (_ data: Data.Element?) -> Content + public typealias ContentBuilder = (_ data: Data.Element?, _ index: Int) -> Content // MARK: Properties @@ -78,7 +78,7 @@ public struct SkeletonView< public var body: some View { containerView(viewType) { index in - builder(data.isEmpty ? nil : Array(data)[safe: index]) + builder(data.isEmpty ? nil : Array(data)[safe: index], index) .skeleton( isEnabled: isEnabled, configuration: configuration, diff --git a/Tests/SkeletonUITests/SnapshotTests/SkeletonUITests.swift b/Tests/SkeletonUITests/SnapshotTests/SkeletonUITests.swift index 472640c..db640c6 100644 --- a/Tests/SkeletonUITests/SnapshotTests/SkeletonUITests.swift +++ b/Tests/SkeletonUITests/SnapshotTests/SkeletonUITests.swift @@ -44,7 +44,7 @@ final class SkeletonUITests: XCTestCase { spacing: .spacing, insets: EdgeInsets(top: .spacing, leading: .spacing, bottom: .spacing, trailing: .spacing) ), - builder: { text in Text(text?.text ?? "") } + builder: { text, _ in Text(text?.text ?? "") } ), as: [.image(layout: .device(config: config), traits: .dark)], testName: #function + prefix @@ -109,7 +109,7 @@ final class SkeletonUITests: XCTestCase { // MARK: Private @ViewBuilder - private func builder(_ item: Item?) -> some View { + private func builder(_ item: Item?, index _: Int) -> some View { item.map { Text($0.text) } } } diff --git a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimatesASingleView_whenViewHasCustomConfiguration-iphone.1.png b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimatesASingleView_whenViewHasCustomConfiguration-iphone.1.png index 40d19a6..1d48bac 100644 Binary files a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimatesASingleView_whenViewHasCustomConfiguration-iphone.1.png and b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimatesASingleView_whenViewHasCustomConfiguration-iphone.1.png differ diff --git a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimatesASingleView_whenViewHasCustomConfiguration-tv.1.png b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimatesASingleView_whenViewHasCustomConfiguration-tv.1.png index 60b6beb..3e40eb6 100644 Binary files a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimatesASingleView_whenViewHasCustomConfiguration-tv.1.png and b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimatesASingleView_whenViewHasCustomConfiguration-tv.1.png differ diff --git a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimatesMultiplesView_whenViewHasCustomLayout-iphone.1.png b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimatesMultiplesView_whenViewHasCustomLayout-iphone.1.png index b86a93c..877801d 100644 Binary files a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimatesMultiplesView_whenViewHasCustomLayout-iphone.1.png and b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimatesMultiplesView_whenViewHasCustomLayout-iphone.1.png differ diff --git a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimatesMultiplesView_whenViewHasCustomLayout-tv.1.png b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimatesMultiplesView_whenViewHasCustomLayout-tv.1.png index b3647b1..8d9fc63 100644 Binary files a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimatesMultiplesView_whenViewHasCustomLayout-tv.1.png and b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimatesMultiplesView_whenViewHasCustomLayout-tv.1.png differ diff --git a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimationMultiplesView_whenDeviceIsIpad.1.png b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimationMultiplesView_whenDeviceIsIpad.1.png index 76504ed..031b024 100644 Binary files a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimationMultiplesView_whenDeviceIsIpad.1.png and b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimationMultiplesView_whenDeviceIsIpad.1.png differ diff --git a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimationMultiplesView_whenViewTypeIsPlain-iphone.1.png b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimationMultiplesView_whenViewTypeIsPlain-iphone.1.png index 9c4a4e2..156d716 100644 Binary files a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimationMultiplesView_whenViewTypeIsPlain-iphone.1.png and b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimationMultiplesView_whenViewTypeIsPlain-iphone.1.png differ diff --git a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimationMultiplesView_whenViewTypeIsPlain-tv.1.png b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimationMultiplesView_whenViewTypeIsPlain-tv.1.png index 54adcb6..e0395e8 100644 Binary files a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimationMultiplesView_whenViewTypeIsPlain-tv.1.png and b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsAndAnimationMultiplesView_whenViewTypeIsPlain-tv.1.png differ diff --git a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsViewContent_whenSkeletonIsDisabled-iphone.1.png b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsViewContent_whenSkeletonIsDisabled-iphone.1.png index 36f47f6..e3d8eab 100644 Binary files a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsViewContent_whenSkeletonIsDisabled-iphone.1.png and b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsViewContent_whenSkeletonIsDisabled-iphone.1.png differ diff --git a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsViewContent_whenSkeletonIsDisabled-tv.1.png b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsViewContent_whenSkeletonIsDisabled-tv.1.png index 27a4f0b..d605fee 100644 Binary files a/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsViewContent_whenSkeletonIsDisabled-tv.1.png and b/Tests/SkeletonUITests/SnapshotTests/__Snapshots__/SkeletonUITests/test_thatSkeletonViewShowsViewContent_whenSkeletonIsDisabled-tv.1.png differ