Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into kve/horizontal-list-l…
Browse files Browse the repository at this point in the history
…ayout

* origin/main: (61 commits)
  Prep 0.30.1 (#348)
  Fix keyboard inset (#347)
  Update CI to run tests on iOS 15 and Xcode 13 (#346)
  Update docs
  Prep 0.30.0
  Convert several demos to result builders
  Update CHANGELOG
  Update changelog
  Documentation
  Code review from Westin
  Add task list
  Tests
  Self review, cleanup
  Add examples of two syntaxes, update SwipeActions
  Add examples for best practices
  Update CHANGELOG
  Make public the various layout types
  Revert file
  SPM Test support
  Ensure we always update the Environment on the HeaderFooter's backing view.
  ...
  • Loading branch information
kyleve committed Nov 21, 2021
2 parents c0f3226 + 44a3519 commit bd902cd
Show file tree
Hide file tree
Showing 555 changed files with 89,458 additions and 33,244 deletions.
66 changes: 31 additions & 35 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md
# https://github.com/actions/cache/blob/ff937cc95032836a535d249de4ce2fc52aeae834/examples.md


Expand All @@ -9,14 +9,14 @@ on:

jobs:

ios_14:
name: iOS 14
ios_15:
name: iOS 15

runs-on: macos-10.15
runs-on: macos-11

steps:
- name: Switch To Xcode 12
run: sudo xcode-select -switch /Applications/Xcode_12.2.app
- name: Switch To Xcode 13.1
run: sudo xcode-select -switch /Applications/Xcode_13.1.app

- name: Checkout repository
uses: actions/checkout@v1
Expand Down Expand Up @@ -50,19 +50,18 @@ jobs:
run: bundle exec pod install --repo-update

- name: Run Tests
run: Scripts/run_ios14_tests.sh

run: Scripts/run_ios15_tests.sh

ios_13:
name: iOS 13
ios_14:
name: iOS 14

runs-on: macos-10.15
runs-on: macos-11

steps:
- name: Switch To Xcode 12
run: sudo xcode-select -switch /Applications/Xcode_12.2.app
- name: Switch To Xcode 12.5.1
run: sudo xcode-select -switch /Applications/Xcode_12.5.1.app

- name: Checkout Repository
- name: Checkout repository
uses: actions/checkout@v1

# Build Caching
Expand All @@ -85,29 +84,26 @@ jobs:
# Install & Build

- name: Bundle Install
- name: Bundle install
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Pod Install
run: bundle exec pod install --repo-update

- name: Install iOS 13.2
run: xcversion simulators --install="iOS 13.2"

- name: Run Tests
run: Scripts/run_ios13_tests.sh
run: Scripts/run_ios14_tests.sh


ios_12:
name: iOS 12
ios_13:
name: iOS 13

runs-on: macos-10.15
runs-on: macos-11

steps:
- name: Switch To Xcode 12
run: sudo xcode-select -switch /Applications/Xcode_12.2.app
- name: Switch To Xcode 12.5.1
run: sudo xcode-select -switch /Applications/Xcode_12.5.1.app

- name: Checkout Repository
uses: actions/checkout@v1
Expand Down Expand Up @@ -140,21 +136,21 @@ jobs:
- name: Pod Install
run: bundle exec pod install --repo-update

- name: Install iOS 12.1
run: xcversion simulators --install="iOS 12.1"
- name: Install iOS 13.2
run: xcversion simulators --install="iOS 13.2"

- name: Run Tests
run: Scripts/run_ios12_tests.sh
run: Scripts/run_ios13_tests.sh


ios_11:
name: iOS 11
ios_12:
name: iOS 12

runs-on: macos-10.15
runs-on: macos-11

steps:
- name: Switch To Xcode 12
run: sudo xcode-select -switch /Applications/Xcode_12.2.app
- name: Switch To Xcode 12.5.1
run: sudo xcode-select -switch /Applications/Xcode_12.5.1.app

- name: Checkout Repository
uses: actions/checkout@v1
Expand Down Expand Up @@ -187,8 +183,8 @@ jobs:
- name: Pod Install
run: bundle exec pod install --repo-update

- name: Install iOS 11.1
run: xcversion simulators --install="iOS 11.1"
- name: Install iOS 12.1
run: xcversion simulators --install="iOS 12.1"

- name: Run Tests
run: Scripts/run_ios11_tests.sh
run: Scripts/run_ios12_tests.sh
6 changes: 3 additions & 3 deletions BlueprintUILists.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Pod::Spec.new do |s|
s.author = { 'Kyle' => '[email protected]' }
s.source = { git: 'https://github.com/kyleve/Listable.git', tag: "#{s.version}" }

s.ios.deployment_target = '11.0'
s.ios.deployment_target = '12.0'

s.swift_versions = ['5.0']
s.swift_versions = ['5.4']

s.dependency 'ListableUI'
s.dependency 'BlueprintUI'
Expand All @@ -27,7 +27,7 @@ Pod::Spec.new do |s|
test_spec.ios.resource_bundle = { 'BlueprintUIListsResources' => 'BlueprintUILists/Tests/Resources/**/*.*' }

test_spec.framework = 'XCTest'

test_spec.libraries = 'swiftsimd', 'swiftCoreGraphics', 'swiftFoundation', 'swiftUIKit'

test_spec.requires_app_host = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import BlueprintUI
import ListableUI
import UIKit


/// Alias to allow less verbose creation of headers.
Expand Down
1 change: 1 addition & 0 deletions BlueprintUILists/Sources/BlueprintItemContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import BlueprintUI
import ListableUI
import UIKit


///
Expand Down
83 changes: 83 additions & 0 deletions BlueprintUILists/Sources/List.Measurement.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//
// List.Measurement.swift
// BlueprintUILists
//
// Created by Kyle Van Essen on 3/25/21.
//

import ListableUI


///
/// Provides the possible options for how to size and measure a list when its measured size is queried
/// by the layout system.
///
/// You have two options: `.fillParent` and `.measureContent`.
///
/// When using `.fillParent`, the full available fitting size will be taken up, regardless
/// of the size of the content itself.
///
/// When using `.measureContent`, the content will be measured within the provided fitting size
/// and the smallest of the two sizes will be returned.
/// ```
/// .fillParent:
/// ┌───────────┐
/// │┌─────────┐│
/// ││ ││
/// ││ ││
/// ││ ││
/// ││ ││
/// ││ ││
/// │└─────────┘│
/// └───────────┘
///
/// .measureContent
/// ┌───────────┐
/// │ │
/// │ │
/// │┌─────────┐│
/// ││ ││
/// ││ ││
/// ││ ││
/// │└─────────┘│
/// └───────────┘
/// ```
extension List {

public enum Measurement : Equatable
{
/// When using `.fillParent`, the full available space will be taken up, regardless
/// of the content size of the list itself.
///
/// Eg, if the fitting size passed to the list is (200w, 1000h), and the list's content
/// is only (200w, 500h), (200w, 1000h) will still be returned.
///
/// This is the setting you want to use when your list is being used to fill the content
/// of a screen, such as if it is being presented in a navigation controller or tab bar controller.
///
/// This option is the most performant, because no content measurement has to occur.
case fillParent

/// When using `.measureContent`, the content of the list will be measured within the provided fitting size
/// and the smallest of the two sizes will be returned.
///
/// If you are putting a list into a sheet or popover (or even another list!), this is generally the `Sizing` type
/// you will want to use, to ensure the sheet or popover takes up the minimum amount of space possible.
///
/// - parameters:
/// - cacheKey: If provided, the underlying `Element`'s `measurementCacheKey` will be set to this value.
/// Note that this value must be unique within the entire blueprint view – so please provide a sufficiently unique value,
/// or measurement collisions will occur (one element's measurement being used for another) for duplicate keys.
///
/// - itemLimit: When measuring the list, how many items should be measured to determine the height. Defaults
/// to 50, which is usually enough to fill the `fittingSize`. If you truly want to determine the entire height of all of
/// the content in the list, set this to `nil` (but you should rarely need to do this). The lower this value, the less
/// overall measurement that has to occur (if the value is less than the number of items in the list), which improvements
/// measurement and layout performance.
///
case measureContent(
cacheKey : AnyHashable? = nil,
itemLimit : Int? = ListView.defaultContentSizeItemLimit
)
}
}
38 changes: 26 additions & 12 deletions BlueprintUILists/Sources/List.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//

import BlueprintUI

import ListableUI
import UIKit


///
Expand All @@ -18,13 +18,13 @@ import ListableUI
/// on `ListView` itself.
/// ```
/// List { list in
/// list.content.header = HeaderFooter(PodcastsHeader())
/// list.header = PodcastsHeader()
///
/// let podcasts = Podcast.podcasts.sorted { $0.episode < $1.episode }
///
/// list += Section("podcasts") { section in
///
/// section.header = HeaderFooter(PodcastsSectionHeader())
/// section.header = PodcastsSectionHeader()
///
/// section += podcasts.map { podcast in
/// PodcastRow(podcast: podcast)
Expand Down Expand Up @@ -53,8 +53,8 @@ public struct List : Element
/// it will take up all the size it is given. You can change this to
/// `.measureContent` to instead measure the optimal size.
///
/// See the `ListSizing` documentation for more.
public var sizing : ListSizing
/// See the `List.Measurement` documentation for more.
public var measurement : List.Measurement

//
// MARK: Initialization
Expand All @@ -63,14 +63,28 @@ public struct List : Element
/// Create a new list, configured with the provided properties,
/// configured with the provided `ListProperties` builder.
public init(
sizing : ListSizing = .fillParent,
measurement : List.Measurement = .fillParent,
configure : ListProperties.Configure
) {
self.sizing = sizing
self.measurement = measurement

self.properties = .default(with: configure)
}

/// Create a new list, configured with the provided properties,
/// configured with the provided `ListProperties` builder, and the provided `sections`.
public init(
measurement : List.Measurement = .fillParent,
configure : ListProperties.Configure = { _ in },
@ListableBuilder<Section> sections : () -> [Section]
) {
self.measurement = measurement

self.properties = .default(with: configure)

self.properties.sections += sections()
}

//
// MARK: Element
//
Expand All @@ -79,7 +93,7 @@ public struct List : Element
ElementContent { size, env in
ListContent(
properties: self.properties,
sizing: self.sizing,
measurement: self.measurement,
environment: env
)
}
Expand All @@ -96,25 +110,25 @@ extension List {
fileprivate struct ListContent : Element {

var properties : ListProperties
var sizing : ListSizing
var measurement : List.Measurement

init(
properties : ListProperties,
sizing : ListSizing,
measurement : List.Measurement,
environment : Environment
) {
var properties = properties

properties.environment.blueprintEnvironment = environment

self.properties = properties
self.sizing = sizing
self.measurement = measurement
}

// MARK: Element

public var content : ElementContent {
switch self.sizing {
switch self.measurement {
case .fillParent:
return ElementContent { constraint -> CGSize in
constraint.maximum
Expand Down
1 change: 1 addition & 0 deletions BlueprintUILists/Sources/ListReorderGesture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import BlueprintUI
import ListableUI
import UIKit


///
Expand Down
Loading

0 comments on commit bd902cd

Please sign in to comment.