Skip to content

Commit

Permalink
Merge pull request #241 from kyleve/kve/file-organization-1
Browse files Browse the repository at this point in the history
Reorganize files by splitting many apart ahead of writing missing docs.
  • Loading branch information
kyleve authored Dec 15, 2020
2 parents 5329a75 + c0a4a5f commit dee0a9b
Show file tree
Hide file tree
Showing 32 changed files with 584 additions and 464 deletions.
14 changes: 7 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@
Earlier releases were ad-hoc and not tracked. To see all changes, please reference [closed PRs on Github](https://github.com/kyleve/Listable/pulls?q=is%3Apr+is%3Aclosed).


[Main]: https://github.com/square/Blueprint/compare/0.13.0...HEAD
[0.13.0]: https://github.com/square/Blueprint/compare/0.12.1...0.13.0
[0.12.1]: https://github.com/square/Blueprint/compare/0.12.0...0.12.1
[0.12.0]: https://github.com/square/Blueprint/compare/0.11.0...0.12.0
[0.11.0]: https://github.com/square/Blueprint/compare/0.10.1...0.11.0
[0.10.1]: https://github.com/square/Blueprint/compare/0.10.0...0.10.1
[0.10.0]: https://github.com/square/Blueprint/compare/0.9.0...0.10.0
[Main]: https://github.com/kyleve/Listable/compare/0.13.0...HEAD
[0.13.0]: https://github.com/kyleve/Listable/compare/0.12.1...0.13.0
[0.12.1]: https://github.com/kyleve/Listable/compare/0.12.0...0.12.1
[0.12.0]: https://github.com/kyleve/Listable/compare/0.11.0...0.12.0
[0.11.0]: https://github.com/kyleve/Listable/compare/0.10.1...0.11.0
[0.10.1]: https://github.com/kyleve/Listable/compare/0.10.0...0.10.1
[0.10.0]: https://github.com/kyleve/Listable/compare/0.9.0...0.10.0
9 changes: 6 additions & 3 deletions ListableUI/Sources/AutoScrollAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

/// Options for auto-scrolling to items when the list is updated.
public enum AutoScrollAction {

/// The list never automatically scrolls.
case none

Expand Down Expand Up @@ -71,10 +72,11 @@ public enum AutoScrollAction {
}
}

public extension AutoScrollAction

extension AutoScrollAction
{
/// Where to scroll as a result of an `AutoScrollAction`.
enum ScrollDestination : Equatable
public enum ScrollDestination : Equatable
{
/// Scroll to the first item in the list.
case firstItem
Expand All @@ -94,8 +96,9 @@ public extension AutoScrollAction
}
}


/// Values used to configure the `scrollToItem(onInsertOf:)` action.
struct OnInsertedItem
public struct OnInsertedItem
{
/// The item in the list to scroll to when the `insertedIdentifier` is inserted.
public var destination : ScrollDestination
Expand Down
14 changes: 9 additions & 5 deletions ListableUI/Sources/Behavior.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ public struct Behavior : Equatable
}
}

public extension Behavior

extension Behavior
{
/// How to adjust the `contentInset` of the list when the keyboard visibility changes.
enum KeyboardAdjustmentMode : Equatable
public enum KeyboardAdjustmentMode : Equatable
{
/// The `contentInset` of the list is not adjusted when the keyboard appears or disappears.
case none
Expand All @@ -75,8 +76,9 @@ public extension Behavior
case adjustsWhenVisible
}


/// How to react when the user taps on the status bar of the application.
enum ScrollsToTop : Equatable
public enum ScrollsToTop : Equatable
{
/// No action is performed when the user taps on the status bar.
case disabled
Expand All @@ -85,8 +87,9 @@ public extension Behavior
case enabled
}


/// The selection mode of the list view, which controls how many items (if any) can be selected at once.
enum SelectionMode : Equatable
public enum SelectionMode : Equatable
{
/// The list view does not allow any selections.
case none
Expand All @@ -112,7 +115,8 @@ public extension Behavior
case multiple
}

struct Underflow : Equatable

public struct Underflow : Equatable
{
public var alwaysBounce : Bool
public var alignment : Alignment
Expand Down
2 changes: 1 addition & 1 deletion ListableUI/Sources/Content.swift
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public struct Content
}


internal extension Content
extension Content
{
struct Slice
{
Expand Down
52 changes: 26 additions & 26 deletions ListableUI/Sources/EmbeddedList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,6 @@ public extension Item where Content == EmbeddedList
}


public extension EmbeddedList
{
/// How you specify sizing for an embedded list. The surface area
/// of this `Sizing` enum is intentionally reduced from the standard `Sizing`
/// enum, because several of those values do not make sense for embedded lists.
enum Sizing : Equatable
{
/// Falls back to the default sizing of `Item`s in the list view.
case `default`

/// A fixed size item with the given width or height.
///
/// Note: Depending on the list layout type, only one of width or height may be used.
/// Eg, for list layouts, vertical lists only use the height, and horizontal lists only use the width.
case fixed(width: CGFloat = 0.0, height : CGFloat = 0.0)

var toStandardSizing : ListableUI.Sizing {
switch self {
case .default: return .default
case .fixed(let w, let h): return .fixed(width: w, height: h)
}
}
}
}


/// Describes item content which can be used to embed a list inside another list,
/// for example if you'd like to place a horizontally scrollable list within a vertically scrolling
/// list, or vice versa.
Expand Down Expand Up @@ -134,3 +108,29 @@ public struct EmbeddedList : ItemContent
ListView(frame: frame)
}
}


extension EmbeddedList
{
/// How you specify sizing for an embedded list. The surface area
/// of this `Sizing` enum is intentionally reduced from the standard `Sizing`
/// enum, because several of those values do not make sense for embedded lists.
public enum Sizing : Equatable
{
/// Falls back to the default sizing of `Item`s in the list view.
case `default`

/// A fixed size item with the given width or height.
///
/// Note: Depending on the list layout type, only one of width or height may be used.
/// Eg, for list layouts, vertical lists only use the height, and horizontal lists only use the width.
case fixed(width: CGFloat = 0.0, height : CGFloat = 0.0)

var toStandardSizing : ListableUI.Sizing {
switch self {
case .default: return .default
case .fixed(let w, let h): return .fixed(width: w, height: h)
}
}
}
}
31 changes: 31 additions & 0 deletions ListableUI/Sources/HeaderFooter/AnyHeaderFooter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// AnyHeaderFooter.swift
// ListableUI
//
// Created by Kyle Van Essen on 12/14/20.
//

import Foundation


public protocol AnyHeaderFooter : AnyHeaderFooter_Internal
{
var sizing : Sizing { get set }
var layout : HeaderFooterLayout { get set }
}


public protocol AnyHeaderFooter_Internal
{
var layout : HeaderFooterLayout { get }

func apply(
to headerFooterView : UIView,
for reason : ApplyReason,
with info : ApplyHeaderFooterContentInfo
)

func anyIsEquivalent(to other : AnyHeaderFooter) -> Bool

func newPresentationHeaderFooterState(performsContentCallbacks : Bool) -> Any
}
35 changes: 1 addition & 34 deletions ListableUI/Sources/HeaderFooter/HeaderFooter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,10 @@
//


public protocol AnyHeaderFooter : AnyHeaderFooter_Internal
{
var sizing : Sizing { get set }
var layout : HeaderFooterLayout { get set }
}

public protocol AnyHeaderFooter_Internal
{
var layout : HeaderFooterLayout { get }

func apply(
to headerFooterView : UIView,
for reason : ApplyReason,
with info : ApplyHeaderFooterContentInfo
)

func anyIsEquivalent(to other : AnyHeaderFooter) -> Bool

func newPresentationHeaderFooterState(performsContentCallbacks : Bool) -> Any
}


public typealias Header<Content:HeaderFooterContent> = HeaderFooter<Content>
public typealias Footer<Content:HeaderFooterContent> = HeaderFooter<Content>


public struct HeaderFooter<Content:HeaderFooterContent> : AnyHeaderFooter
{
public var content : Content
Expand Down Expand Up @@ -123,15 +102,3 @@ extension HeaderFooter : SignpostLoggable
)
}
}


public struct HeaderFooterLayout : Equatable
{
public var width : CustomWidth

public init(
width : CustomWidth = .default
) {
self.width = width
}
}
20 changes: 20 additions & 0 deletions ListableUI/Sources/HeaderFooter/HeaderFooterLayout.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// HeaderFooterLayout.swift
// ListableUI
//
// Created by Kyle Van Essen on 12/14/20.
//

import Foundation


public struct HeaderFooterLayout : Equatable
{
public var width : CustomWidth

public init(
width : CustomWidth = .default
) {
self.width = width
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// RefreshControl.PresentationState.swift
// ListableUI
//
// Created by Kyle Van Essen on 12/14/20.
//

import Foundation


extension PresentationState
{
internal final class RefreshControlState
{
public var model : RefreshControl
public var view : UIRefreshControl

public init(_ model : RefreshControl)
{
self.model = model
self.view = UIRefreshControl()

self.view.addTarget(self, action: #selector(refreshControlChanged), for: .valueChanged)
}

func update(with control : RefreshControl)
{
self.model = control

if let title = self.model.title {
switch title {
case .string(let string): self.view.attributedTitle = NSAttributedString(string: string)
case .attributed(let string): self.view.attributedTitle = string
}
} else {
self.view.attributedTitle = nil
}

self.view.tintColor = self.model.tintColor

if self.model.isRefreshing {
self.view.beginRefreshing()
} else {
self.view.endRefreshing()
}
}

@objc func refreshControlChanged()
{
self.model.onRefresh()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class PresentationState
// MARK: Properties
//

var refreshControl : RefreshControl.PresentationState?
var refreshControl : RefreshControlState?

var header : HeaderFooterViewStatePair = .init()
var footer : HeaderFooterViewStatePair = .init()
Expand Down Expand Up @@ -273,7 +273,7 @@ final class PresentationState
if let existing = self.refreshControl, let new = new {
existing.update(with: new)
} else if self.refreshControl == nil, let new = new {
let newControl = RefreshControl.PresentationState(new)
let newControl = RefreshControlState(new)
view.refreshControl = newControl.view
self.refreshControl = newControl
} else if self.refreshControl != nil, new == nil {
Expand Down
37 changes: 37 additions & 0 deletions ListableUI/Sources/Item/AnyItem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// AnyItem.swift
// ListableUI
//
// Created by Kyle Van Essen on 12/14/20.
//

import Foundation


public protocol AnyItem : AnyItem_Internal
{
var identifier : AnyIdentifier { get }

var anyContent : Any { get }

var sizing : Sizing { get set }
var layout : ItemLayout { get set }
var selectionStyle : ItemSelectionStyle { get set }
var insertAndRemoveAnimations : ItemInsertAndRemoveAnimations? { get set }
var swipeActions : SwipeActionsConfiguration? { get set }

var reordering : Reordering? { get set }
}


public protocol AnyItem_Internal
{
func anyWasMoved(comparedTo other : AnyItem) -> Bool
func anyIsEquivalent(to other : AnyItem) -> Bool

func newPresentationItemState(
with dependencies : ItemStateDependencies,
updateCallbacks : UpdateCallbacks,
performsContentCallbacks : Bool
) -> Any
}
Loading

0 comments on commit dee0a9b

Please sign in to comment.