Skip to content

Commit

Permalink
add typealias
Browse files Browse the repository at this point in the history
  • Loading branch information
CalvinChangCC committed May 22, 2024
1 parent f43f715 commit c796b81
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SectionKit
of a model to be displayed and the list of items may dynamically change.
*/
@MainActor
open class DiffingListSectionController<Model, Item: Differentiable>: ListSectionController<Model, Item> {
open class DiffingListFlowLayoutSectionController<Model, Item: Differentiable>: ListFlowLaoutSectionController<Model, Item> {
override open func calculateUpdate(
from oldData: [Item],
to newData: [Item]
Expand All @@ -23,3 +23,12 @@ open class DiffingListSectionController<Model, Item: Differentiable>: ListSectio
)
}
}

@available(
*,
deprecated,
renamed: "DiffingListFlowLayoutSectionController",
message: "It has been renamed to DiffingListFlowLayoutSectionController"
)

public typealias DiffingListSectionController = DiffingListFlowLayoutSectionController
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import SectionKit
`Item` type, instead it requires closures to get diffing information for an item.
*/
@MainActor
open class ManualDiffingListSectionController<
open class ManualDiffingListFlowLayoutSectionController<
Model,
Item
>: ListSectionController<Model, Item> {
>: ListFlowLaoutSectionController<Model, Item> {
private let itemId: @MainActor (Item) -> AnyHashable
private let itemContentIsEqual: @MainActor (Item, Item) -> Bool

Expand Down Expand Up @@ -55,7 +55,7 @@ open class ManualDiffingListSectionController<
}
}

extension ManualDiffingListSectionController where Item: Equatable {
extension ManualDiffingListFlowLayoutSectionController where Item: Equatable {
/**
Initialise an instance of `ManualDiffingListSectionController`.

Expand All @@ -69,7 +69,7 @@ extension ManualDiffingListSectionController where Item: Equatable {
}

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension ManualDiffingListSectionController where Item: Identifiable {
extension ManualDiffingListFlowLayoutSectionController where Item: Identifiable {
/**
Initialise an instance of `ManualDiffingListSectionController`.

Expand All @@ -89,7 +89,7 @@ extension ManualDiffingListSectionController where Item: Identifiable {
the base init (apart from the default values), we have to specify `@_disfavoredOverload` so it doesn't call itself.
*/
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension ManualDiffingListSectionController where Item: Identifiable & Equatable {
extension ManualDiffingListFlowLayoutSectionController where Item: Identifiable & Equatable {
/**
Initialise an instance of `ManualDiffingListSectionController`.

Expand All @@ -108,3 +108,12 @@ extension ManualDiffingListSectionController where Item: Identifiable & Equatabl
self.init(model: model, itemId: itemId, itemContentIsEqual: itemContentIsEqual)
}
}

@available(
*,
deprecated,
renamed: "ManualDiffingListFlowLayoutSectionController",
message: "It has been renamed to ManualDiffingListFlowLayoutSectionController"
)

public typealias ManualDiffingListSectionController = ManualDiffingListFlowLayoutSectionController
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import UIKit
of a model to be displayed and the list of items (almost) never changes or should not perform animated updates.
*/
@MainActor
open class ListSectionController<Model, Item>: BaseFlowLayoutSectionController {
open class ListFlowLaoutSectionController<Model, Item>: BaseFlowLayoutSectionController {
/**
Initialise an instance of `ListSectionController`.

Expand Down Expand Up @@ -112,3 +112,11 @@ open class ListSectionController<Model, Item>: BaseFlowLayoutSectionController {

override open func numberOfItems(in context: CollectionViewContext) -> Int { items.count }
}

@available(
*,
deprecated,
renamed: "ListFlowLaoutSectionController",
message: "It has been renamed to ListFlowLaoutSectionController"
)
public typealias ListSectionController = ListFlowLaoutSectionController
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import UIKit
- Warning: If `numberOfItems` is overridden, `calculateUpdate(from:to:)` needs to be overridden as well.
*/
@MainActor
open class SingleItemSectionController<Model, Item>: BaseFlowLayoutSectionController {
open class SingleItemFlowLayoutSectionController<Model, Item>: BaseFlowLayoutSectionController {
private let areItemsEqual: @MainActor (Item, Item) -> Bool

/**
Expand Down Expand Up @@ -133,7 +133,7 @@ open class SingleItemSectionController<Model, Item>: BaseFlowLayoutSectionContro
override open func numberOfItems(in context: CollectionViewContext) -> Int { item != nil ? 1 : 0 }
}

extension SingleItemSectionController where Item: Equatable {
extension SingleItemFlowLayoutSectionController where Item: Equatable {
/**
Initialise an instance of `SingleItemSectionController`
which will only reload when the new item is different from the old one.
Expand All @@ -144,3 +144,11 @@ extension SingleItemSectionController where Item: Equatable {
self.init(model: model, areItemsEqual: ==)
}
}

@available(
*,
deprecated,
renamed: "SingleItemFlowLayoutSectionController",
message: "It has been renamed to SingleItemFlowLayoutSectionController"
)
public typealias SingleItemSectionController = SingleItemFlowLayoutSectionController
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import UIKit
it is recommended to use `ListSectionController` instead.
*/
@MainActor
open class SingleModelSectionController<Model>: BaseFlowLayoutSectionController {
open class SingleModelFlowLayoutSectionController<Model>: BaseFlowLayoutSectionController {
/**
Initialise an instance of `SingleModelSectionController`.

Expand Down Expand Up @@ -76,3 +76,11 @@ open class SingleModelSectionController<Model>: BaseFlowLayoutSectionController

override open func numberOfItems(in context: CollectionViewContext) -> Int { 1 }
}

@available(
*,
deprecated,
renamed: "SingleModelFlowLayoutSectionController",
message: "It has been renamed to SingleModelFlowLayoutSectionController"
)
public typealias SingleModelSectionController = SingleModelFlowLayoutSectionController

0 comments on commit c796b81

Please sign in to comment.