Skip to content

Commit

Permalink
Release 1.1.0 (#4)
Browse files Browse the repository at this point in the history
Release `1.1.0`
  • Loading branch information
ns-vasilev authored Aug 26, 2024
2 parents 816bbe2 + f8ff627 commit fd724c4
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: ${{ matrix.name }}
run: xcodebuild test -scheme "Blade-Package" -destination "platform=macOS" clean -enableCodeCoverage YES ${{ matrix.params }} -resultBundlePath "test_output/${{ matrix.name }}.xcresult" || exit 1
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3.1.0
uses: codecov/codecov-action@v4.5.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
xcode: true
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
- name: ${{ matrix.name }}
run: xcodebuild test -scheme "Blade-Package" -destination "${{ matrix.destination }}" clean -enableCodeCoverage YES ${{ matrix.params }} -resultBundlePath "test_output/${{ matrix.name }}.xcresult" || exit 1
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3.1.0
uses: codecov/codecov-action@v4.5.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
xcode: true
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:
- name: ${{ matrix.name }}
run: xcodebuild test -scheme "Blade-Package" -destination "${{ matrix.destination }}" clean -enableCodeCoverage YES ${{ matrix.params }} -resultBundlePath "test_output/${{ matrix.name }}.xcresult" || exit 1
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3.1.0
uses: codecov/codecov-action@v4.5.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
xcode: true
Expand Down
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
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.x` Releases - [1.0.0](#100) | [1.1.0](#110)

## [1.1.0](https://github.com/space-code/blade/releases/tag/1.1.0)
Released on 2024-08-26.

#### Added
- Integrate header and footer views into the list view.
- Added in Pull Request [#3](https://github.com/space-code/blade/pull/3).

## [1.0.0](https://github.com/space-code/blade/releases/tag/1.0.0)
Released on 2024-02-05.

#### Added
- Initial release of Blade.
- Added by [Nikita Vasilev](https://github.com/nik3212).
- Added by [Nikita Vasilev](https://github.com/nik3212).
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct LoadingViewModifier: ViewModifier {
// MARK: ViewModifier

func body(content: Content) -> some View {
VStack {
Group {
content

if isLoading {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,88 @@ import BladeTCA
import ComposableArchitecture
import SwiftUI

// MARK: - PaginatorListView

public struct PaginatorListView<
State: Equatable & Identifiable,
Action: Equatable,
Header: View,
Body: View,
Footer: View,
PositionType: Equatable,
Request: Equatable
>: View {
// MARK: Types

private typealias StoreType = ViewStoreOf<PaginatorReducer<State, Action, PositionType, Request>>

@SwiftUI.State private var isLoading = false

// MARK: Properties

public let store: Store<PaginatorState<State, PositionType>, PaginatorAction<State, Action, Request>>
public let header: () -> Header
public let content: (State) -> Body
public let footer: () -> Footer

public init(
store: Store<PaginatorState<State, PositionType>, PaginatorAction<State, Action, Request>>,
content: @escaping (State) -> Body
@ViewBuilder header: @escaping () -> Header,
@ViewBuilder content: @escaping (State) -> Body,
@ViewBuilder footer: @escaping () -> Footer
) {
self.store = store
self.header = header
self.content = content
self.footer = footer
}

// MARK: View

public var body: some View {
WithViewStore(store, observe: { $0 }) { (viewStore: StoreType) in
List(viewStore.items) { item in
content(item)
.onAppear {
viewStore.send(.itemAppeared(item.id))
List {
Section {
header()
}

WithViewStore(store, observe: { $0 }) { (viewStore: StoreType) in
Section(content: {
ForEach(viewStore.items) { item in
content(item)
.onAppear {
viewStore.send(.itemAppeared(item.id))
}
}
})
}

Section {
footer()
}

Section {
EmptyView()
.modifier(LoadingViewModifier(isLoading: isLoading))
}
.modifier(LoadingViewModifier(isLoading: viewStore.isLoading && !viewStore.items.isEmpty))
}
}
}

public extension PaginatorListView where Header == EmptyView, Footer == EmptyView {
init(
store: Store<PaginatorState<State, PositionType>, PaginatorAction<State, Action, Request>>,
@ViewBuilder content: @escaping (State) -> Body
) {
self.init(store: store, header: { EmptyView() }, content: content, footer: { EmptyView() })
}
}

public extension PaginatorListView where Header: View, Footer == EmptyView {
init(
store: Store<PaginatorState<State, PositionType>, PaginatorAction<State, Action, Request>>,
header: @escaping () -> Header,
@ViewBuilder content: @escaping (State) -> Body
) {
self.init(store: store, header: header, content: content, footer: { EmptyView() })
}
}
33 changes: 33 additions & 0 deletions Sources/BladeTCA/Classes/Presentation/Views/PaginatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ public struct PaginatorView<
Action: Equatable,
PositionType: Equatable,
Request: Equatable,
Header: View,
Body: View,
Footer: View,
RowContent: View
>: View {
// MARK: Types
Expand All @@ -24,35 +26,66 @@ public struct PaginatorView<
// MARK: Properties

public let store: Store<PaginatorState<State, PositionType>, PaginatorAction<State, Action, Request>>
public let header: () -> Header
public let content: ([State], @escaping (State) -> AnyView) -> Body
public let footer: () -> Footer
public let rowContent: (State) -> RowContent

// MARK: Initialization

public init(
store: Store<PaginatorState<State, PositionType>, PaginatorAction<State, Action, Request>>,
@ViewBuilder header: @escaping () -> Header,
@ViewBuilder content: @escaping ([State], @escaping (State) -> AnyView) -> Body,
@ViewBuilder footer: @escaping () -> Footer,
@ViewBuilder rowContent: @escaping (State) -> RowContent
) {
self.store = store
self.header = header
self.content = content
self.footer = footer
self.rowContent = rowContent
}

// MARK: View

public var body: some View {
WithViewStore(store, observe: { $0 }) { (viewStore: StoreType) in
header()

content(viewStore.items.elements) { item in
rowContent(item)
.onAppear { viewStore.send(.itemAppeared(item.id)) }
.any
}
.modifier(LoadingViewModifier(isLoading: viewStore.isLoading && !viewStore.items.isEmpty))

footer()
}
}
}

public extension PaginatorView where Header == EmptyView, Footer == EmptyView {
init(
store: Store<PaginatorState<State, PositionType>, PaginatorAction<State, Action, Request>>,
@ViewBuilder content: @escaping ([State], @escaping (State) -> AnyView) -> Body,
@ViewBuilder rowContent: @escaping (State) -> RowContent
) {
self.init(store: store, header: { EmptyView() }, content: content, footer: { EmptyView() }, rowContent: rowContent)
}
}

public extension PaginatorView where Header: View, Footer == EmptyView {
init(
store: Store<PaginatorState<State, PositionType>, PaginatorAction<State, Action, Request>>,
header: @escaping () -> Header,
@ViewBuilder content: @escaping ([State], @escaping (State) -> AnyView) -> Body,
@ViewBuilder rowContent: @escaping (State) -> RowContent
) {
self.init(store: store, header: header, content: content, footer: { EmptyView() }, rowContent: rowContent)
}
}

// MARK: Extension

private extension View {
Expand Down

0 comments on commit fd724c4

Please sign in to comment.