profile
viewpoint

bryankeller/BLKFlexibleHeightBar 3073

Create condensing header bars like those seen in the Facebook, Square Cash, and Safari iOS apps.

bryankeller/PSP-Exploit-Super-Collapse-3 6

Allows unsigned code execution on official Sony PSP firmware

bryankeller/AloeStackView 2

A simple class for laying out a collection of views with a convenient API, while leveraging the power of Auto Layout.

bryankeller/KPCB-Queue 0

My implementation of a queue data structure for the 2015 KPCB Engineering Fellows application.

bryankeller/PackageList 0

The master list of repositories for the Swift Package Index.

bryankeller/ppsspp 0

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us in #ppsspp on freenode (IRC) or just send pull requests / issues. For discussion use the forums on ppsspp.org.

bryankeller/swift 0

Airbnb's Swift Style Guide.

bryankeller/Swift4OptimizationBug 0

Sample code to reproduce a Swift 4.2 compiler optimization bug

issue commentairbnb/HorizonCalendar

Question: Center Horizontal Calendar

Hi @zachterrell57, I was able to get the behavior you want working in the example project by adding the following to SingleDaySelectionDemoViewController.swift

override func viewDidLoad() {
  // ...
  calendarView.insetsLayoutMarginsFromSafeArea = false
  // ...
}
override func viewWillLayoutSubviews() {
    super.viewWillLayoutSubviews()

    if case .horizontal(let monthWidth) = monthsLayout {
      let marginSize = (view.bounds.width - monthWidth) / 2
      calendarView.layoutMargins.left = marginSize
      calendarView.layoutMargins.right = marginSize

      calendarView.setContent(makeContent().withInterMonthSpacing(marginSize))
    }
  }

Hope this helps! Note that there isn't currently any snapping behavior for the horizontal layout, but this is something I'm looking into adding in the near future!

zachterrell57

comment created time in 6 hours

issue commentairbnb/HorizonCalendar

Any plans to support this library on SwiftUI?

Hi @sethi-ishmeet - this is something that's definitely on our radar. My understanding is that support could be added by wrapping it with UIViewRepresentable. I'll be exploring this in the coming weeks!

sethi-ishmeet

comment created time in 3 days

create barnchairbnb/HorizonCalendar

branch : bk/horizon-calendar-2.0/base

created branch time in 5 days

created tagairbnb/HorizonCalendar

tagv1.3.1

A declarative, performant, iOS calendar UI component that supports use cases ranging from simple date pickers all the way up to fully-featured calendar apps.

created time in 5 days

delete branch airbnb/HorizonCalendar

delete branch : bk/fix-scroll-to-item-crash

delete time in 5 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha ea442ef7e7d75425c4b4e00867afd03763326b80

Bk/fix scroll to item crash (#41) * Fix scroll-to-item crash * Bump version

view details

push time in 5 days

PR merged airbnb/HorizonCalendar

Bk/fix scroll to item crash bug

Details

This fixes a crash than can occur if the content of the calendar is set while it's programmatically scrolling. In this scenario, the display link does not get invalidated even though our scrollToItemContext is set to nil. If the scrollToItemContext is nil the next time the display link fires, then we hit a precondition failure.

To simplify things, we should really just invalidate the display link whenever our scrollToItemContext is set. This PR makes that change.

Related Issue

N/A

Motivation and Context

Crash fix.

How Has This Been Tested

iOS simulator example app and Airbnb app (where the repro case was identified).

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [ ] Docs change / refactoring / dependency upgrade
  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [x] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.
+15 -16

0 comment

3 changed files

bryankeller

pr closed time in 5 days

Pull request review commentairbnb/HorizonCalendar

Bk/fix scroll to item crash

 extension CalendarView: UIScrollViewDelegate {      let isUserInitiatedScrolling = scrollView.isDragging && scrollView.isTracking -    if isUserInitiatedScrolling, scrollToItemDisplayLink != nil {-      scrollToItemDisplayLink?.invalidate()

scrollToItemContext is set to nil just a few lines down, so no need to manually invalidate here anymore.

bryankeller

comment created time in 5 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 5189d7412e320357ae13617eb65de7650714b5f5

Fix scroll-to-item crash

view details

Bryan Keller

commit sha 40ad43d16aec60a154bb26ec5df8d6a776ead1f8

Bump version

view details

push time in 5 days

PR opened airbnb/HorizonCalendar

Reviewers
Bk/fix scroll to item crash bug

Details

This fixes a crash than can occur if the content of the calendar is set while it's programmatically scrolling. In this scenario, the display link does not get invalidated even though our scrollToItemContext is set to nil. If the scrollToItemContext is nil the next time the display link fires, then we hit a precondition failure.

To simplify things, we should really just invalidate the display link whenever our scrollToItemContext is set. This PR makes that change.

Related Issue

N/A

Motivation and Context

Crash fix.

How Has This Been Tested

iOS simulator example app and Airbnb app (where the repro case was identified).

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [ ] Docs change / refactoring / dependency upgrade
  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [x] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.
+13 -15

0 comment

3 changed files

pr created time in 5 days

create barnchairbnb/HorizonCalendar

branch : bk/fix-scroll-to-item-crash

created branch time in 5 days

created tagairbnb/HorizonCalendar

tagv1.3.0

A declarative, performant, iOS calendar UI component that supports use cases ranging from simple date pickers all the way up to fully-featured calendar apps.

created time in 5 days

delete branch airbnb/HorizonCalendar

delete branch : bk/days-of-the-week-row-separator

delete time in 5 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha b7eb9c11e10a1669003a18901870f29ac9afe1e7

Bk/days of the week row separator (#40) * Add public API for separator and bump version Add defaults * Add implementation of separator views * Add tests Fix tests * Update README

view details

push time in 5 days

PR merged airbnb/HorizonCalendar

Bk/days of the week row separator

Details

This adds the ability to configure a separator view below the days-of-the-week row - whether it's a pinned row or a row that appears separately in each month.

Pr-month Vertical Per-month Horizontal Pinned
Simulator Screen Shot - iPhone 8 - 2020-08-03 at 13 42 26 Simulator Screen Shot - iPhone 8 - 2020-08-03 at 13 54 59 Simulator Screen Shot - iPhone 8 - 2020-08-03 at 13 56 42

Related Issue

N/A

Motivation and Context

This adds back a key piece of functionality that used to exist in pre-release versions but was removed from the public 1.0 release.

How Has This Been Tested

iOS simulator, unit tests.

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [x] Docs change / refactoring / dependency upgrade
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [x] My change requires a change to the documentation.
  • [x] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [x] I have added tests to cover my changes.
+185 -37

0 comment

9 changed files

bryankeller

pr closed time in 5 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 2e6b66262e5942b2e7b4394047c0dbba37897f06

Add tests Fix tests

view details

Bryan Keller

commit sha 02f37f59160b55cf28740874d13c9776677cda8c

Update README

view details

push time in 5 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 5fe511a7e4dcf5c712819243c9151f21f3ee4e2a

Bk/fix horizontal layout clipping (#39) * Fix horizontal layout clipping * Add unit tests * Bump version * Fix typo

view details

Bryan Keller

commit sha 71f4013b2bd9b190e0cdddd38ecfc7cd7c8d6fd9

Add public API for separator and bump version Add defaults

view details

Bryan Keller

commit sha a5b1805f3b138d13a61f532e3549fb08d1befe3d

Add implementation of separator views

view details

Bryan Keller

commit sha abd372d3afbc51d915e5226d9f262ec757bf2642

Add tests

view details

Bryan Keller

commit sha 8e37493f571bd0023dbce3ade6e15f8c22c56bef

Update README

view details

push time in 5 days

created tagairbnb/HorizonCalendar

tagv1.2.3

A declarative, performant, iOS calendar UI component that supports use cases ranging from simple date pickers all the way up to fully-featured calendar apps.

created time in 5 days

delete branch airbnb/HorizonCalendar

delete branch : bk/fix-horizontal-layout-clipping

delete time in 5 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 5fe511a7e4dcf5c712819243c9151f21f3ee4e2a

Bk/fix horizontal layout clipping (#39) * Fix horizontal layout clipping * Add unit tests * Bump version * Fix typo

view details

push time in 5 days

PR merged airbnb/HorizonCalendar

Bk/fix horizontal layout clipping

Details

I noticed an issue where month headers were getting clipped too soon when figuring out which items are visible / not visible in a horizontal layout calendar. The root issue is that my heuristic for figuring out what intersects the visible rect was wrong for horizontal layouts.

Before After
ezgif-4-ed9a537cf4de ezgif-4-e3ec00150639

Related Issue

N/A

Motivation and Context

Bug fix.

How Has This Been Tested

iOS sim, unit test.

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [ ] Docs change / refactoring / dependency upgrade
  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [ ] I have read the CONTRIBUTING document.
  • [x] I have added tests to cover my changes.
+77 -41

0 comment

5 changed files

bryankeller

pr closed time in 5 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 75c3d0fe568469b6fbf131b06b6f570e73872c0a

Fix typo

view details

push time in 5 days

Pull request review commentairbnb/HorizonCalendar

Bk/fix horizontal layout clipping

 public enum MonthsLayout {    // MARK: Internal +  var isHorizontal: Bool {

Yeah, it's only exposed internally but yes, it's a way to avoid an awkward case let in the VisibleItemsProvider.

bryankeller

comment created time in 5 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha e9b7263bf880d8e7cddf2f938223607a93a49314

Update README

view details

push time in 6 days

Pull request review commentairbnb/HorizonCalendar

Bk/days of the week row separator

 final class FrameProviderTests: XCTestCase {     XCTAssert(frame3 == expectedFrame3, "Incorrect frame for day of week.")   } -  func testDayOfWeekBackgroundFrame() {-    let frame1 = verticalFrameProvider.frameOfDayOfWeekBackground(-      inMonthWithOrigin: CGPoint(x: 0, y: 200))-      .alignedToPixels(forScreenWithScale: 3)-    let expectedFrame1 = CGRect(x: 0, y: 255, width: 320, height: 34.857142857142854)-      .alignedToPixels(forScreenWithScale: 3)-    XCTAssert(frame1 == expectedFrame1, "Incorrect frame for day of week background.")--    let frame2 = verticalPinnedDaysOfWeekFrameProvider.frameOfDayOfWeekBackground(-      inMonthWithOrigin: CGPoint(x: 0, y: 150))-      .alignedToPixels(forScreenWithScale: 3)-    let expectedFrame2 = CGRect(x: 0, y: 205, width: 320, height: 34.857142857142854)-      .alignedToPixels(forScreenWithScale: 3)-    XCTAssert(frame2 == expectedFrame2, "Incorrect frame for day of week background.")--    let frame3 = horizontalFrameProvider.frameOfDayOfWeekBackground(-      inMonthWithOrigin: CGPoint(x: 200, y: 0))-      .alignedToPixels(forScreenWithScale: 3)-    let expectedFrame3 = CGRect(x: 200, y: 55, width: 300, height: 32)-      .alignedToPixels(forScreenWithScale: 3)-    XCTAssert(frame3 == expectedFrame3, "Incorrect frame for day of week background.")-  }

not used anywhere besides this unit test

bryankeller

comment created time in 6 days

PR opened airbnb/HorizonCalendar

Reviewers
Bk/days of the week row separator

Details

This adds the ability to configure a separator view below the days-of-the-week row - whether it's a pinned row or a row that appears separately in each month.

Pr-month Vertical Per-month Horizontal Pinned
Simulator Screen Shot - iPhone 8 - 2020-08-03 at 13 42 26 Simulator Screen Shot - iPhone 8 - 2020-08-03 at 13 54 59 Simulator Screen Shot - iPhone 8 - 2020-08-03 at 13 56 42

Related Issue

N/A

Motivation and Context

This adds back a key piece of functionality that used to exist in pre-release versions but was removed from the public 1.0 release.

How Has This Been Tested

iOS simulator, unit tests.

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [x] Docs change / refactoring / dependency upgrade
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [x] My change requires a change to the documentation.
  • [x] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [x] I have added tests to cover my changes.
+183 -37

0 comment

9 changed files

pr created time in 6 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 82bb3f2cb41aed32096834c998e7c693f643c6f3

Add public API for separator and bump version Add defaults

view details

Bryan Keller

commit sha c53776b773105a3c5458c30d428b675fce4294db

Add implementation of separator views

view details

Bryan Keller

commit sha aafd9bac0801da7571ac679c8ff6a769199fece6

Add tests

view details

Bryan Keller

commit sha 4c235add25b419f771b7743e3ddbe86227ceb848

Update README

view details

push time in 6 days

PR opened airbnb/HorizonCalendar

Reviewers
Bk/fix horizontal layout clipping

Details

I noticed an issue where month headers were getting clipped too soon when figuring out which items are visible / not visible in a horizontal layout calendar. The root issue is that my heuristic for figuring out what intersects the visible rect was wrong for horizontal layouts.

Before After
ezgif-4-e3ec00150639 ezgif-4-ed9a537cf4de

Related Issue

N/A

Motivation and Context

Bug fix.

How Has This Been Tested

iOS sim, unit test.

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [ ] Docs change / refactoring / dependency upgrade
  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [ ] I have read the CONTRIBUTING document.
  • [x] I have added tests to cover my changes.
+78 -41

0 comment

5 changed files

pr created time in 6 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 07f7dbe0951a1562360b059a0201dfcabd333e29

Add unit tests

view details

Bryan Keller

commit sha bf7b596b2e81a5c4b4b89f725e55f979edbcc831

Bump version

view details

push time in 6 days

create barnchairbnb/HorizonCalendar

branch : bk/fix-horizontal-layout-clipping

created branch time in 6 days

create barnchairbnb/HorizonCalendar

branch : bk/days-of-the-week-row-separator

created branch time in 6 days

created tagairbnb/HorizonCalendar

tagv1.2.2

A declarative, performant, iOS calendar UI component that supports use cases ranging from simple date pickers all the way up to fully-featured calendar apps.

created time in 8 days

delete branch airbnb/HorizonCalendar

delete branch : bk/days-of-the-week-row-background

delete time in 8 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 3a4251264893428a60f2635342a02dfb7d3fd5ce

Bk/days of the week row background (#37) * Fix layout regression from layout margins addition * Add background under pinned days of the week row * Bump version * Add tests

view details

push time in 8 days

PR merged airbnb/HorizonCalendar

Bk/days of the week row background bug

Details

This PR fixes 2 bugs

  • Pinned days of the week are not inset by the view's layout margins
  • Pinned days of the week show content scrolling underneath them if there's a horizontalDayMargin >= 0 configured

Video demonstrating the second issue: ezgif-6-fbd5fffb86c4

Related Issue

N/A

Motivation and Context

Bug fixes

How Has This Been Tested

iOS simulator

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [ ] Docs change / refactoring / dependency upgrade
  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [x] I have added tests to cover my changes.
+27 -5

0 comment

6 changed files

bryankeller

pr closed time in 8 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 37fcfd33913b972a66829e33bd9c478d750d3da9

Add tests

view details

push time in 8 days

PR opened airbnb/HorizonCalendar

Reviewers
Bk/days of the week row background bug

Details

This PR fixes a 2 bugs

  • Pinned days of the week are not inset by the view's layout margins
  • Pinned days of the week ill show content scrolling underneath them if there's a horizontalDayMargin configured

Video demonstrating the second issue: ezgif-6-fbd5fffb86c4

Related Issue

N/A

Motivation and Context

Bug fixes

How Has This Been Tested

iOS simulator

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [ ] Docs change / refactoring / dependency upgrade
  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [ ] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.
+23 -5

0 comment

5 changed files

pr created time in 8 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha b285e781e49af28e9f40e08f928993f0f0a63846

Bump version

view details

push time in 8 days

create barnchairbnb/HorizonCalendar

branch : bk/days-of-the-week-row-background

created branch time in 8 days

push eventairbnb/MagazineLayout

Roman Podymov

commit sha 341620e53be2b06f2e55cdbefc41e0fcf113012a

tvOS support (#81) * Supported in iOS only * Supported in iOS only * CreationPanelViewController is not supported in tvOS * refreshControl is not supported in tvOS * tvOS support * tvOS target * Create Info.plist * Add files via upload * tvOS 10.0 * Update MagazineLayout.podspec * tvOS 10.0+ * tvOS deployment target * tvOS deployment target * Fixing tvOS build errors * Fixing tvOS build errors * Update LaunchScreen.storyboard * Fixing Travis CI errors * Fixing Travis CI errors * Update .travis.yml * Update .travis.yml * Update .travis.yml * Update project.pbxproj * Update project.pbxproj * Update .travis.yml * Update project.pbxproj * Update project.pbxproj * SPM + tvOS

view details

push time in 10 days

pull request commentairbnb/MagazineLayout

tvOS support

thanks a bunch @RomanPodymov !

RomanPodymov

comment created time in 10 days

issue closedairbnb/HorizonCalendar

How can I add bottom contentInsets scroll view?

Hello, is it possible to add bottom contentInsets for scroll view?

closed time in 11 days

misha8414

issue commentairbnb/HorizonCalendar

How can I add bottom contentInsets scroll view?

@misha8414 @JulienLevallois @alex-sarkisov I've added the ability to set insets using UIView's layoutMargins and directionalLayoutMargins properties. The changes are included in v1.2.0. Thank you again for reporting this and for your patience as I investigated a good way to do this 🙂

misha8414

comment created time in 11 days

created tagairbnb/HorizonCalendar

tagv1.2.1

A declarative, performant, iOS calendar UI component that supports use cases ranging from simple date pickers all the way up to fully-featured calendar apps.

created time in 11 days

PR merged airbnb/HorizonCalendar

Bk/remove unnecessary layout margins bug

Details

This removes some legacy behavior that overwrote the month header's layout margins with the left/right values from monthDateInsets.

Related Issue

N/A

Motivation and Context

API consumers should be free to set whatever layout margins they want on their month headers, without being overwritten by the calendar.

How Has This Been Tested

Tested in the Airbnb app and in the demo project. Confirmed that layout margins are not reset / overwritten.

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [ ] Docs change / refactoring / dependency upgrade
  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.
+3 -14

0 comment

3 changed files

bryankeller

pr closed time in 11 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 5ed41520ef2c0cda9ebaca3e626eafd68c972d6f

Bk/remove unnecessary layout margins (#36) * Stop overriding layout margins on month headers * Bump version to 1.2.1

view details

push time in 11 days

PR opened airbnb/HorizonCalendar

Reviewers
Bk/remove unnecessary layout margins bug

Details

This removes some legacy behavior that overwrote the month header's layout margins with the left/right values from monthDateInsets.

Related Issue

N/A

Motivation and Context

API consumers should be free to set whatever layout margins they want on their month headers, without being overwritten by the calendar.

How Has This Been Tested

Tested in the Airbnb app and in the demo project. Confirmed that layout margins are not reset / overwritten.

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [ ] Docs change / refactoring / dependency upgrade
  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.
+3 -14

0 comment

3 changed files

pr created time in 12 days

create barnchairbnb/HorizonCalendar

branch : bk/remove-unnecessary-layout-margins

created branch time in 12 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha d7f3a30cd1993714dcb3666ec1b11c2f82e1c234

Bk/improve voiceover support (#33) * Prevent voiceover focus from being lost when an day is selected * Fix visible month range implementation and heading not found bug * Bump version to 1.1.5 * Fix CI

view details

Bryan Keller

commit sha 6a08153691a1938d403049c00af4871c6f80e5c6

Bk/inset support (#35) * Bump version * Update public API and documentation * Add content inset support via layout margins * PR feedback

view details

Bryan Keller

commit sha d6584af236bb1286298cf97ab1651e67b4546316

Simplify `CalendarItem` by introducing `CalendarItemView`

view details

Bryan Keller

commit sha ecb0b478b6178db532e10f5ea537558e872dcc22

Rename InitialConfiguration to InvariantViewProperties

view details

push time in 12 days

created tagairbnb/HorizonCalendar

tagv1.2.0

A declarative, performant, iOS calendar UI component that supports use cases ranging from simple date pickers all the way up to fully-featured calendar apps.

created time in 12 days

delete branch airbnb/HorizonCalendar

delete branch : bk/content-inset-support

delete time in 12 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 6a08153691a1938d403049c00af4871c6f80e5c6

Bk/inset support (#35) * Bump version * Update public API and documentation * Add content inset support via layout margins * PR feedback

view details

push time in 12 days

PR merged airbnb/HorizonCalendar

Bk/inset support enhancement

Details

This adds support for insetting the content without affecting the scrollable / user-interact-able region using the layoutMargins and directionalLayoutMargins properties on CalendarView.swift

The approach of using layout margins seems to work pretty well - one nice thing we get for free is automatic safe area inset respecting (which can be turned off via the flag on UIView). The one quirk is that we don't support negative layout margins, since this causes really weird scrolling / layout logic. I can't really think of a valid reason to use negative values either, but hopefully I'm not missing something obvious.

One other caveat - For horizontal layout calendars, the current sizing logic doesn't take into account the vertical dimension of the frame. Instead, it's determined by the monthWidth that's passed into CalendarViewContent. In hindsight, this probably isn't how the horizontal layout should work - instead, the horizontal layout should determine its month width by looking at the available height. Because of this shortcoming with how the horizontal layout works, there's not a great way to make layout margins work perfectly in the vertical dimension, since the available space in the vertical dimension isn't taken into account. I don't think this is a showstopper, as the leading / trailing / top margins all work well. It's only when you use both a top and bottom margin that the latter is basically just ignored. As part of the 2.0 release of HorizonCalendar, I'll change this API / behavior so that it works in a more predictable way, which will have the consequence of making the layout margins work correctly for top / bottom when using a horizontal layout.

Vertical Horizontal (just leading / trailing margins)
ezgif-6-41b58e78f50a ezgif-6-eaf73940399e

Related Issue

https://github.com/airbnb/HorizonCalendar/issues/19

Motivation and Context

It's common for people to want to inset their calendar's content without adjusting the frame or scrollable region. For example, this could be useful when displaying a vertically scrolling calendar on iPad, where the content would look way too big if it went edge-to-edge horizontally. By setting layout margins, the content of the calendar can be inset while still allowing scroll gestures all the way to the edge of the screen.

How Has This Been Tested

Tested on simulator and device.

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [x] Docs change / refactoring / dependency upgrade
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [x] My change requires a change to the documentation.
  • [x] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.
+87 -17

0 comment

9 changed files

bryankeller

pr closed time in 12 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha b1d5df127be4d262e69a369962c0e165a09f255e

PR feedback

view details

push time in 12 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha b3f05a6ae8af237cfba736311441f2a36f2c661c

Add content inset support via layout margins

view details

push time in 13 days

PR opened airbnb/HorizonCalendar

Reviewers
Bk/inset support enhancement

Details

This adds support for insetting the content without affecting the scrollable / user-interact-able region using the layoutMargins and directionalLayoutMargins properties on CalendarView.swift

The approach of using layout margins seems to work pretty well - one nice thing we get for free is automatic safe area inset respecting (which can be turned off via the flag on UIView). The one quirk is that we don't support negative layout margins, since this causes really weird scrolling / layout logic. I can't really think of a valid reason to use negative values either, but hopefully I'm not missing something obvious.

One other caveat - For horizontal layout calendars, the current sizing logic doesn't take into account the vertical dimension of the frame. Instead, it's determined by the monthWidth that's passed into CalendarViewContent. In hindsight, this probably isn't how the horizontal layout should work - instead, the horizontal layout should determine its month width by looking at the available height. Because of this shortcoming with how the horizontal layout works, there's not a great way to make layout margins work perfectly in the vertical dimension, since the available space in the vertical dimension isn't taken into account. I don't think this is a showstopper, as the leading / trailing / top margins all work well. It's only when you use both a top and bottom margin that the latter is basically just ignored. As part of the 2.0 release of HorizonCalendar, I'll change this API / behavior so that it works in a more predictable way, which will have the consequence of making the layout margins work correctly for top / bottom when using a horizontal layout.

Vertical Horizontal (just leading / trailing margins)
ezgif-6-41b58e78f50a ezgif-6-eaf73940399e

Related Issue

https://github.com/airbnb/HorizonCalendar/issues/19

Motivation and Context

It's common for people to want to inset their calendar's content without adjusting the frame or scrollable region. For example, this could be useful when displaying a vertically scrolling calendar on iPad, where the content would look way too big if it went edge-to-edge horizontally. By setting layout margins, the content of the calendar can be inset while still allowing scroll gestures all the way to the edge of the screen.

How Has This Been Tested

Tested on simulator and device.

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [x] Docs change / refactoring / dependency upgrade
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [x] My change requires a change to the documentation.
  • [x] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.
+86 -17

0 comment

9 changed files

pr created time in 13 days

create barnchairbnb/HorizonCalendar

branch : bk/content-inset-support

created branch time in 13 days

issue commentairbnb/MagazineLayout

Why MagazineLayoutCollectionViewLayoutAttributes is `final`?

@AntonBelousov sorry for the delay - I think making MagazineLayout open, marking most of the functions as final, and having an open function called makelayoutAttributes(forCellAtIndexPath indexPath: IndexPath) -> MagazineLayoutCollectionViewLayoutAttributes seems like a reasonable change. If this is something you still need / have already implemented, feel free to make a pull request with the changes!

AntonBelousov

comment created time in 17 days

issue commentairbnb/MagazineLayout

iOS 12 Compatibility?

Hi @markturnip - MagazineLayout should definitely support iOS 12. Can you post an example of the issues / crashes you're seeing?

markturnip

comment created time in 17 days

pull request commentairbnb/MagazineLayout

tvOS support

Than ks @RomanPodymov ! If you can get the build working, then this seems like a good change! https://travis-ci.com/github/airbnb/MagazineLayout/builds/176573279

RomanPodymov

comment created time in 17 days

issue commentairbnb/MagazineLayout

Animating header resize

@markturnip does that fix it? I'll close out until I hear otherwise. I do think that in general, animating header size changes is something collection view does not handle well. Even the insert / delete animations are kind of glitchy.

I think the best workaround is to just use a cell, or if what you're doing by manually calling layoutIfNeeded works, then that seems reasonable!

markturnip

comment created time in 17 days

issue closedairbnb/MagazineLayout

Animating header resize

What's the appropriate way to animate the resize of a header?

I'm currently trying using:

UIView.animate(withDuration: 0.3) {
  collectionView?.collectionViewLayout.invalidateLayout()
}

closed time in 17 days

markturnip

issue closedairbnb/MagazineLayout

Waterfall (pinterest-like) layout

Will this library support a cascading style layout similar to pinterest? (see CHTCollectionViewWaterfallLayout(

closed time in 17 days

halpz

issue commentairbnb/MagazineLayout

Waterfall (pinterest-like) layout

Hi @halpz - at this time, something like that is out-of-scope for this project.

halpz

comment created time in 17 days

issue commentairbnb/HorizonCalendar

Is it possible to add RTL support for Arabic and Persian calendar?

This is being worked on soon @shayan77 - stay tuned!

shayan77

comment created time in 17 days

delete branch airbnb/HorizonCalendar

delete branch : bk/improve-voiceover-support

delete time in 18 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha d7f3a30cd1993714dcb3666ec1b11c2f82e1c234

Bk/improve voiceover support (#33) * Prevent voiceover focus from being lost when an day is selected * Fix visible month range implementation and heading not found bug * Bump version to 1.1.5 * Fix CI

view details

push time in 18 days

PR merged airbnb/HorizonCalendar

Bk/improve voiceover support bug

Details

Improves Voiceover behavior when navigating by month heading:

To fix navigating by heading, I had to add a proper visibleMonthRange implementation. The previous implementation just looked at the min / max of the visibleDayRange, which caused partially visible months that only had their month header visible (but no days) to be excluded from the visibleMonthRange. This resulted in a the infamous "Heading not found" voiceover bug since my one month lookahead/behind logic depended on the visibleMonthRange being accurate.

Reduces delay when a user selects a day using voiceover

I was unnecessarily triggering a layoutChanged voiceover notification whenever a user selected a day, which would cause the user's focus to be lost. That notification wasn't necessary, and was actually probably causing some minor confusion since the layoutChanged notification actually plays a short blip sound to indicate re-layout.


ezgif-2-1eca7222362b

Related Issue

N/A

Motivation and Context

Get Voiceover working great!

How Has This Been Tested

Tested using Voiceover in the example app on a real device.

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [ ] Docs change / refactoring / dependency upgrade
  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.
+30 -13

0 comment

5 changed files

bryankeller

pr closed time in 18 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 75e0ddcfa8075e0e21635ecb152f8899ef2cf915

Fix CI

view details

push time in 19 days

issue commentairbnb/HorizonCalendar

Is it possible to add a "footer" to the bottom of each month on the vertical calendar?

Hey @seanperez29 ! This is a cool suggestion, I could see us using something like this in the Airbnb app one day.

This isn't something that's currently on the roadmap, but I think this would be a great API addition if it's something you'd be interested in tackling. I've tagged this as being a good issue for first-time contributors!


If anyone wants to look into implementing this, it would probably be a new item provider on CalendarViewContent (some kind of footer item type).

The more complicated parts are deciding how to lay something like this out. Does it have its own padding values? Does it self-size, or statically size? Is this a one-off item provider type, or part of a more general system for adding supplementary content to various parts of the calendar - a month footer being just one of several supported locations.

If we can think through a great API that will serve us well for this feature / potentially others in the future, that would be a great first step!

seanperez29

comment created time in 19 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 2e1915589f25f848a44774f3d86d2845533b9103

Fix visible month range implementation and heading not found bug

view details

Bryan Keller

commit sha 047484c80599aa45a34c8a004879d317f266798e

Bump version to 1.1.5

view details

push time in 19 days

PR opened airbnb/HorizonCalendar

Reviewers
Bk/improve voiceover support bug

Details

Improves Voiceover behavior when navigating by month heading:

To fix navigating by heading, I had to add a proper visibleMonthRange implementation. The previous implementation just looked at the min / max of the visibleDayRange, which caused partially visible months that only had their month header visible (but no days) to be excluded from the visibleMonthRange. This resulted in a the infamous "Heading not found" voiceover bug since my one month lookahead/behind logic depended on the visibleMonthRange being accurate.

Reduces delay when a user selects a day using voiceover

I was unnecessarily triggering a layoutChanged voiceover notification whenever a user selected a day, which would cause the user's focus to be lost. That notification wasn't necessary, and was actually probably causing some minor confusion since the layoutChanged notification actually plays a short blip sound to indicate re-layout.


ezgif-2-1eca7222362b

Related Issue

N/A

Motivation and Context

Get Voiceover working great!

How Has This Been Tested

Tested using Voiceover in the example app on a real device.

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [ ] Docs change / refactoring / dependency upgrade
  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.
+28 -11

0 comment

4 changed files

pr created time in 19 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha c26f09d41dae550104fbc2c260b7dcabb47d5f3d

Fix visible month range implementation and heading not found bug

view details

Bryan Keller

commit sha 0b9704b033c4a25abf6937b48b4ecc85f7746c90

Bump version to 1.1.5

view details

push time in 19 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 4e604cac10396f7e716d04c4fd6b5ee45e0bbb0d

Bump version to 1.1.5

view details

push time in 19 days

create barnchairbnb/HorizonCalendar

branch : bk/improve-voiceover-support

created branch time in 19 days

issue closedairbnb/HorizonCalendar

Init with selected day

I'd like to have a CalendarView and a UIDatePicker on the same screen, and be able to initialize the CalendarView with a selected day already provided. Without the user having to select a date.

When trying to create a new Day object I get the error: "'Day' initializer is inaccessible due to 'internal' protection level". So, I tried adding a public init() {} to the Day object with some initial values, but it still is giving the error. The same error happens with the Month object.

I would just make a public init on the Day and Month objects and it would fix my problem, but it's still giving the error.

closed time in 20 days

thecoolwinter

issue commentairbnb/HorizonCalendar

Init with selected day

Hi @thecoolwinter - I need an FAQ for this question since it gets asked quite a bit 😛

The short answer - those are intentionally internal to prevent you from making a Day using the wrong Calendar object (which would result in a Day that is incompatible with other Days).

If you want to make a certain day appear selected, you can do so in your dayItemProvider closure. You can convert the provided Day to a Date by doing let date = calendar.date(from: day.dateComponents)!. Then, you can use any of the standard Calendar functions to compare Dates. For example, you could check whether a particular date is "today" and return a different, highlighted calendar item if that condition is true.

More context here: https://github.com/airbnb/HorizonCalendar/pull/28

thecoolwinter

comment created time in 20 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 249b15cfc13d20f72f875d26cceb530f79bc933e

Simplify `CalendarItem` by introducing `CalendarItemView`

view details

push time in 25 days

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 943e165cb3b809c0ab3678a8eb1d1db49f93d81e

Simplify `CalendarItem` by introducing `CalendarItemView`

view details

push time in a month

Pull request review commentairbnb/HorizonCalendar

Simplify `CalendarItem` by introducing `CalendarItemView`

+// Created by Bryan Keller on 7/15/20.+// Copyright © 2020 Airbnb Inc. All rights reserved.++// Licensed under the Apache License, Version 2.0 (the "License");+// you may not use this file except in compliance with the License.+// You may obtain a copy of the License at+//+// http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing, software+// distributed under the License is distributed on an "AS IS" BASIS,+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+// See the License for the specific language governing permissions and+// limitations under the License.++import UIKit++// MARK: - CalendarItemView++/// A protocol to which all views displayed in `CalendarView` must conform. By conforming to this protocol, `CalendarView` is+/// able to treat each view as a function of its `initialConfiguration` and its `viewModel`, making the declarative API much+/// easier to reason about.+public protocol CalendarItemView: UIView {

@brynbodayle here's the new protocol that all views in the calendar need to conform to. This, along with the changes in CalendarItem.swift, are a good starting place for understanding how this change works.

bryankeller

comment created time in a month

PR opened airbnb/HorizonCalendar

Reviewers
Simplify `CalendarItem` by introducing `CalendarItemView` enhancement

Details

This PR greatly simplifies the API for making CalendarItems. Once this change is merged, API consumers will no longer need to:

  • figure out what styleIDs are / how to use them
  • know that there's view recycling / reusing going on under the hood (related to styleID)
  • understand what each of the CalendarItem closures does (there are no more closures 😄)

We're going from this:

.withDayItemProvider { day in
        let isSelected = day == selectedDay

        return CalendarItem<DayView, Day>(
          viewModel: day,
          styleID: isSelected ? "Selected" : "Default",
          buildView: { DayView(isSelectedStyle: isSelected) },
          updateViewModel: { [weak self] dayView, day in
            dayView.dayText = "\(day.day)"

            if let date = self?.calendar.date(from: day.components) {
              dayView.dayAccessibilityText = self?.dayDateFormatter.string(from: date)
            } else {
              dayView.dayAccessibilityText = nil
            }
          },
          updateHighlightState: { dayView, isHighlighted in
            dayView.isHighlighted = isHighlighted
          })
      }

to this:

.withDayItemProvider { [weak self] day in
        let dayAccessibilityText: String?
        if let date = self?.calendar.date(from: day.components) {
          dayAccessibilityText = self?.dayDateFormatter.string(from: date)
        } else {
          dayAccessibilityText = nil
        }

        return CalendarItem<DayView>(
          initialConfiguration: .init(isSelectedStyle: day == selectedDay),
          viewModel: .init(dayText: "\(day.day)", dayAccessibilityText: dayAccessibilityText))
      }

The core idea behind this change is that any view an API consumer wants to display in the calendar must conform to CalendarItemView. CalendarItemView has a required initializer for doing view setup, and a single function for updating the view model. I'm kicking myself for not looking into this before releasing 1.0 - it's really so much simpler 😅

Note that I won't merge this for some time. It's mostly complete, but I need to do more extensive testing to make sure this doesn't introduce any issues. Also, I can't merge this until version 2.0.0 since it has backwards-incompatible changes. There are a few things I'd like to merge into 1.X.X releases first, but then I'd love to push ahead on this in the new few weeks.

Related Issue

Inspired by this issue https://github.com/airbnb/HorizonCalendar/issues/29

Motivation and Context

Simplifying the API and making it way harder for for tricky bugs to happen.

How Has This Been Tested

Simulator. More to come.

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [x] Docs change / refactoring / dependency upgrade
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [x] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [x] My change requires a change to the documentation.
  • [x] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [x] I have added tests to cover my changes.
+607 -376

0 comment

20 changed files

pr created time in a month

create barnchairbnb/HorizonCalendar

branch : bk/simplify-api-view-model-style-id

created branch time in a month

issue closedairbnb/HorizonCalendar

Calendar not being refreshed when new events are fetched from the sever

First of all, thanks for this amazing library.

I've noticed the following issue when using the library, the data is not being refreshed properly after fetching data from the server. I am attaching screenshots at the bottom.

example:

  var events: [String: Any] = [:]

  var presenter: CalendarPresenterDelegate!

  override func viewDidLoad() {
      super.viewDidLoad()
      /// some networking logic
      presenter.fetchEvents()
  }

  override func makeContext() -> CalendarViewContent {

        let startDate = Date()
        let endDate = calendar.date(from: DateComponents(year: 2021, month: 12, day: 31))!

        return CalendarViewContent(calendar: calendar,
                                   visibleDateRange: startDate...endDate,
                                   monthsLayout: .horizontal(monthWidth: min(view.frame.height, view.frame.width) - 40))
            .withDayItemProvider { day -> CalendarItem<EventLabel, Day> in
                let date = self.calendar.date(from: day.components)!
                let isSelectedDay = self.selectedDates.contains(date)
                return CalendarItem<EventLabel, Day>(
                    viewModel: day,
                    styleID: isSelectedDay ? "SelectedDayLabelStyle" : "DayLabelStyle",
                    buildView: {
                        return EventLabel()
                    },
                    updateViewModel: self.setupEvent)
            }
            .withInterMonthSpacing(16)
            .withVerticalDayMargin(8)
            .withHorizontalDayMargin(8)
    }

    func setEvents(events: [String: Any]) {
        self.events = events
        let newContent = makeContent()
        calendarView.setContent(newContent)
    }

    override func setupEvent(label: EventLabel, day: Day) {

        label.text = "\(day.day)"
        // clear the events
        label.hasNoEvents()

        if isSelectedDay {
            label.backgroundColor = Colors.colorAccent
        } else {
            label.backgroundColor = isToday ? Colors.colorPrimary : .clear
        }

        guard let object = getEvents(date: date) else {
            return
        }

        if (object["event1"] as? Bool) == true {
            label.hasEvent1()
            label.textColor = .lightGray
            return
        }

        if (object["event2"] as? [String])?.isEmpty == false {
            label.hasEvent2()
        }
    }

This is what we get after setEvents being called, however the result we need is in the second image: image 1 Screen Shot 2020-07-14 at 7 11 14 PM image 2 Screen Shot 2020-07-14 at 7 11 00 PM

PS: if we scroll to September and back the UI refreshes and the UI updates properly. it seems as if the calendarView.setContent(newContent) is not setting the content properly.

closed time in a month

mustiikhalil

issue commentairbnb/HorizonCalendar

Calendar not being refreshed when new events are fetched from the sever

Awesome, really glad that fixed the issue for you!

For what it's worth, I think having the color dots be part of your view model makes a lot of sense, particularly if that's data that might change a lot due to API response updates. If you want to speed up your rendering / repaint cost, you could implement those dot indicators using CoreGraphics in drawRect, or by just setting a dot view's isHidden / backgroundColor property if you want to keep using UIViews to represent the dots. I think either of those options will be cheaper than adding / removing subviews dynamically, which will cause auto layout constraints to churn a bit 🙂

Best of luck!

mustiikhalil

comment created time in a month

issue commentairbnb/HorizonCalendar

Calendar not being refreshed when new events are fetched from the sever

This has really got me thinking about ways to make this way simpler for developers... stay tuned 😄

mustiikhalil

comment created time in a month

issue commentairbnb/HorizonCalendar

Calendar not being refreshed when new events are fetched from the sever

@mustiikhalil ah, I see the problem! Thanks a bunch for the repro case... although I should have caught this from your original code snippet 😅

The problem is that you're using the updateViewModel closure to do configuration that is not captured by your view model. Internally, HorizonCalendar will only update views whose view model has changed - that's why the viewModel you pass in must be equatable - so that we know when a view has changed.

You'll need to refactor your code like this:


struct EventData: Equatable {
    let day: Day
    let hasEvent1: Bool
    let hasEvent2: Bool
}

...

 return CalendarItem<EventLabel, EventData>(
                    viewModel: EventData(day: day, hasEvent1: object.event1, hasEvent2: object.event2),
                    styleID: "Default",
                    buildView: {
                        return EventLabel()
                    },
                    updateViewModel: { label, eventData in
                        ...
                    }

This is a failure on my part for not making this clearer in the documentation. The key with these CalendarItem instances is that they try to force you to make your UIView a pure function of its view model, but there's no way to enforce this completely without rewriting UIKit.


One other side note - you only need to provide a custom styleID if you're using the same UIView subclass but with different initialization / setup properties. For example, if you used a UILabel with a red font for selected days, and a UILabel with a black font for unselected days, and this color was configured in the buildView closure, then you'd need to provide a different styleID for each variation. You can see this in the HorizonCalendar example code. If I had built the selection demo view controller by making the selected state part of the view model instead, then I would not need to use a styleID. Maybe that property needs a different name, or better documentation 🙂

mustiikhalil

comment created time in a month

issue closedairbnb/HorizonCalendar

content

closed time in a month

acdc2019

issue commentairbnb/HorizonCalendar

Ability to configure scrolling behaviour

Hi @Pattio - this is definitely a feature that we want to add support for! And I agree, manually messing with that internal scroll view is probably not a good idea.

I think we could probably support the programatic scrolling via buttons by having your code call:

public func scroll(
    toMonthContaining dateInTargetMonth: Date,
    scrollPosition: CalendarViewScrollPosition,
    animated: Bool)

But we'd still need the snapping behavior. I'll get around to working on this in the next few weeks!


As for RTL layout, I wonder what that would look like? Would the order of months change for the horizontal layout? I guess we don't support that right now, but that's a great callout. PRs are welcome if you'd like to tackle that one, but otherwise I'll leave this open so it's being tracked.

Pattio

comment created time in a month

issue closedairbnb/HorizonCalendar

Fixed Day Header

Hello! Love the library so far! Have a quick question.

Is it possible to have a fixed day header? Not sure what they are exactly called but here's a picture of it. Screen Shot 2020-07-12 at 7 19 01 PM

I haven't noticed there to be any item providers for them; or maybe I missed them??😅

Thanks a bunch and keep up the good work guys :)

closed time in a month

mosaic-engineering

issue commentairbnb/HorizonCalendar

Fixed Day Header

Hi again @mosaic-engineering ! Glad you like the library 🙂

We support pinned days of the week for the vertical layout like this:

let layoutOptions = VerticalMonthsLayoutOptions(
  pinDaysOfWeekToTop: true, // this is the important line
  alwaysShowCompleteBoundaryMonths: false)
CalendarViewContent(
      calendar: calendar,
      visibleDateRange: startDate...endDate,
      monthsLayout: .vertical(options: layoutOptions))

We don't support this for horizontal layouts yet, but I will likely add support for this in the future!

mosaic-engineering

comment created time in a month

issue commentairbnb/HorizonCalendar

Week View

Hi @rs658726 - do you mean something like this?

image

If so, my answer is: we don't have plans to support that right now, but if there's enough people asking for this, then maybe 🙂

rs658726

comment created time in a month

pull request commentairbnb/HorizonCalendar

Make Day & Month inits public

Hi @mosaic-engineering , thanks for the proposed change. I think this is something that I could probably make clearer in the documentation. With that said...

These two structs are intentionally internal to the calendar, as only HorizonCalendar has the necessary pieces of information (a Date range and a Calendar instance) to be able to construct these. HorizonCalendar ensures that only valid Day / Month structs are created by always deriving them from the Calendar instance that you initialized CalendarViewContent with. If any consumer could construct these, then there could be programmer errors where invalid Days are created. For example, Day(year: 2020, month: 01, day: 500) makes no sense.

The basic philosophy is that consumers of the API always provide Dates and a Calendar instance to HorizonCalendar, and HorizonCalendar always passes Day and Month instances to you that are guaranteed to be valid for the current date range and calendar combination.


Having the right DayRangeItemProvider enum to apply the appropriate selection style for start/end dates

I think the key to solving your problem is knowing that you can always convert a Day to a Date. You can use let date = calendar.date(from: day.dateComponents)! to convert a selected day into a corresponding date. Make sure to use the same calendar instance that you used to initialize the CalendarViewContent otherwise you'll have some weird bugs due to calendar conversion issues!

I also think the example project code could be useful. I do a conversion from Day -> Date here for the purpose of using the withDayRangeItemProvider https://github.com/airbnb/HorizonCalendar/blob/master/Example/HorizonCalendarExample/HorizonCalendarExample/Demo%20View%20Controllers/DayRangeSelectionDemoViewController.swift#L121


Let me know if that solves your issue 🙂

mosaic-engineering

comment created time in a month

issue commentairbnb/HorizonCalendar

Calendar not being refreshed when new events are fetched from the sever

@mustiikhalil glad you're finding the library useful 🙂

Some ideas:

  • Is setEvents being called on the main thread? If not, that would definitely cause weird UI quirks. I should probably add an assert in setContent to prevent this / make it obvious what's wrong
  • Have you set a breakpoint in setupEvent to make sure it gets called for each visible day after you call setContent? HorizonCalendar should invoke that function n times after you call setContent, where n is the number of currently visible days.

If neither of those suggestions lead you to an answer, if you could post some sample code (try to repro in the included example project if it's easy) I'd be happy to help investigate more!

mustiikhalil

comment created time in a month

delete branch airbnb/HorizonCalendar

delete branch : bk/improve-layout-validation

delete time in a month

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha d0c742106923383e1c8c9831dddf5a1a524c504a

Bk/improve layout validation (#22) * Improve invalid layout assert wording and math * Bump version

view details

push time in a month

PR merged airbnb/HorizonCalendar

Bk/improve layout validation bug

Details

Improves the layout metric validation code used to determine if a horizontally-laid-out calendar has enough room to fit all of its calendar elements along the vertical axis.

Related Issue

N/A

Motivation and Context

This check wasn't quite right before.

How Has This Been Tested

Tested on simulator.

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [ ] Docs change / refactoring / dependency upgrade
  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [x] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.
+15 -12

0 comment

3 changed files

bryankeller

pr closed time in a month

delete branch airbnb/HorizonCalendar

delete branch : bk/deprecate-public-scroll-view-delegate-functions

delete time in a month

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 05f74ac51af54876a3b518615801129f9d888461

Deprecate public scroll view delegate functions (#23) * Deprecate public scroll view delegate functions * Docuemntation tweak

view details

push time in a month

PR merged airbnb/HorizonCalendar

Deprecate public scroll view delegate functions documentation

Details

This deprecates the public UIScrollViewDelegate functions on CalendarView - in v2.0, I'll hide this conformance in an internal type so that they won't even show up when users look at the autocomplete options after typing calendarView..

Related Issue

N/A

Motivation and Context

Prepping for 2.0 release which will make several API changes, including removing these functions from the public interface.

How Has This Been Tested

Tested using Xcode autocomplete. image

Types of changes

<!--- What types of changes does your code introduce? Put an x in all the boxes that apply: -->

  • [x] Docs change / refactoring / dependency upgrade
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

<!--- Go over all the following points, and put an x in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.
+13 -1

0 comment

1 changed file

bryankeller

pr closed time in a month

push eventairbnb/HorizonCalendar

Bryan Keller

commit sha 3e5d6c8cad4872e55d89ea96d6c5d48051ae8a31

Docuemntation tweak

view details

push time in a month

more