Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bk/add swift linting #270

Merged
merged 2 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ on:

jobs:
build:

runs-on: macos-latest

strategy:
matrix:
destination: ['platform=iOS Simulator,OS=11.0,name=iPhone 8', 'platform=iOS Simulator,OS=16.2,name=iPhone 14']
steps:
- uses: actions/checkout@v2
- name: Build
run: xcodebuild clean build -scheme HorizonCalendar
- name: Run tests
run: xcodebuild clean test -project HorizonCalendar.xcodeproj -scheme HorizonCalendar -destination "name=iPhone 8,OS=16.2"

lint-swift:
runs-on: macos-13
steps:
- uses: actions/checkout@v2
- name: Build
run: xcodebuild clean build -scheme HorizonCalendar
- name: Run tests
run: xcodebuild clean test -project HorizonCalendar.xcodeproj -scheme HorizonCalendar -destination "name=iPhone 8,OS=16.2"
- uses: actions/checkout@v2
- name: Lint Swift
run: swift package --allow-writing-to-package-directory format --lint


7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added the ability to change the aspect ratio of individual day-of-the-week items
- Added support for self-sizing month headers
- Added a new `setContent(_:animated:)` function, enabling developers to perform animated content updates
- Added Swift format integration to enforce consistent code style
bryankeller marked this conversation as resolved.
Show resolved Hide resolved

### Fixed
- Fixed an issue that could cause the calendar to programmatically scroll to a month or day to which it had previously scrolled
Expand All @@ -31,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Allowed `CalendarItemViewRepresentable` to have no `Content` type if the conforming view does not depend on any variable data
- Changed `ItemView` to determine user interaction capabilities from its content view's `hitTest` / `pointInside` functions
- Updated content-change animations so that the same scroll offset is maintained throughout the animation
- Changed the Swift version needed to use HorizonCalendar to 5.8

## [v1.16.0](https://github.com/airbnb/HorizonCalendar/compare/v1.15.0...v1.16.0) - 2023-01-30

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ import UIKit
@UIApplicationMain
final class AppDelegate: UIResponder, UIApplicationDelegate {

// MARK: Internal

var window: UIWindow?

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?)
_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?)
-> Bool
{
window = UIWindow(frame: UIScreen.main.bounds)
Expand All @@ -38,4 +36,3 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ final class DayRangeIndicatorView: UIView {
backgroundColor = .clear
}

required init?(coder: NSCoder) {
required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: Internal

override func draw(_ rect: CGRect) {
override func draw(_: CGRect) {
let context = UIGraphicsGetCurrentContext()
context?.setFillColor(indicatorColor.cgColor)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ enum DayRangeSelectionHelper {
{
switch state {
case .began:
if day != existingDayRange?.lowerBound && day != existingDayRange?.upperBound {
if day != existingDayRange?.lowerBound, day != existingDayRange?.upperBound {
existingDayRange = day...day
}
initialDayRange = existingDayRange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ final class DayRangeSelectionDemoViewController: BaseDemoViewController {

DayRangeSelectionHelper.updateDayRange(
afterTapSelectionOf: day,
existingDayRange: &self.selectedDayRange)
existingDayRange: &selectedDayRange)

self.calendarView.setContent(self.makeContent())
calendarView.setContent(makeContent())
}

calendarView.multiDaySelectionDragHandler = { [weak self, calendar] day, state in
guard let self else { return }

DayRangeSelectionHelper.updateDayRange(
afterDragSelectionOf: day,
existingDayRange: &self.selectedDayRange,
initialDayRange: &self.selectedDayRangeAtStartOfDrag,
existingDayRange: &selectedDayRange,
initialDayRange: &selectedDayRangeAtStartOfDrag,
state: state,
calendar: calendar)

self.calendarView.setContent(self.makeContent())
calendarView.setContent(makeContent())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class BaseDemoViewController: UIViewController, DemoViewController {
super.init(nibName: nil, bundle: nil)
}

required init?(coder: NSCoder) {
required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,3 @@ final class MonthBackgroundDemoViewController: BaseDemoViewController {
private var selectedDate: Date?

}

Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ final class PartialMonthVisibilityDemoViewController: BaseDemoViewController {
calendarView.daySelectionHandler = { [weak self] day in
guard let self else { return }

self.selectedDate = self.calendar.date(from: day.components)
self.calendarView.setContent(self.makeContent())
selectedDate = calendar.date(from: day.components)
calendarView.setContent(makeContent())
}
}

override func makeContent() -> CalendarViewContent {
let startDate = calendar.date(from: DateComponents(year: 2020, month: 01, day: 16))!
let endDate = calendar.date(from: DateComponents(year: 2020, month: 12, day: 05))!

let selectedDate = self.selectedDate
let selectedDate = selectedDate

return CalendarViewContent(
calendar: calendar,
Expand Down Expand Up @@ -59,4 +59,3 @@ final class PartialMonthVisibilityDemoViewController: BaseDemoViewController {
private var selectedDate: Date?

}

Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ final class SelectedDayTooltipDemoViewController: BaseDemoViewController {
calendarView.daySelectionHandler = { [weak self] day in
guard let self else { return }

self.selectedDate = self.calendar.date(from: day.components)
self.calendarView.setContent(self.makeContent())
selectedDate = calendar.date(from: day.components)
calendarView.setContent(makeContent())
}
}

override func makeContent() -> CalendarViewContent {
let startDate = calendar.date(from: DateComponents(year: 2020, month: 01, day: 01))!
let endDate = calendar.date(from: DateComponents(year: 2021, month: 12, day: 31))!

let selectedDate = self.selectedDate
let selectedDate = selectedDate

let overlaidItemLocations: Set<OverlaidItemLocation>
if let selectedDate = selectedDate {
if let selectedDate {
overlaidItemLocations = [.day(containingDate: selectedDate)]
} else {
overlaidItemLocations = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ final class SingleDaySelectionDemoViewController: BaseDemoViewController {
selectedDate = calendar.date(from: DateComponents(year: 2020, month: 01, day: 19))!
}

required init?(coder: NSCoder) {
required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: Internal

override func viewDidLoad() {
Expand All @@ -39,16 +39,16 @@ final class SingleDaySelectionDemoViewController: BaseDemoViewController {
calendarView.daySelectionHandler = { [weak self] day in
guard let self else { return }

self.selectedDate = self.calendar.date(from: day.components)
self.calendarView.setContent(self.makeContent())
selectedDate = calendar.date(from: day.components)
calendarView.setContent(makeContent())
}
}

override func makeContent() -> CalendarViewContent {
let startDate = calendar.date(from: DateComponents(year: 2020, month: 01, day: 01))!
let endDate = calendar.date(from: DateComponents(year: 2021, month: 12, day: 31))!

let selectedDate = self.selectedDate
let selectedDate = selectedDate

return CalendarViewContent(
calendar: calendar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
// limitations under the License.

import HorizonCalendar
import UIKit
import SwiftUI
import UIKit

final class SwiftUIItemModelsDemoViewController: BaseDemoViewController {

Expand All @@ -29,16 +29,16 @@ final class SwiftUIItemModelsDemoViewController: BaseDemoViewController {
calendarView.daySelectionHandler = { [weak self] day in
guard let self else { return }

self.selectedDate = self.calendar.date(from: day.components)
self.calendarView.setContent(self.makeContent())
selectedDate = calendar.date(from: day.components)
calendarView.setContent(makeContent())
}
}

override func makeContent() -> CalendarViewContent {
let startDate = calendar.date(from: DateComponents(year: 2020, month: 01, day: 01))!
let endDate = calendar.date(from: DateComponents(year: 2021, month: 12, day: 31))!

let selectedDate = self.selectedDate
let selectedDate = selectedDate

return CalendarViewContent(
calendar: calendar,
Expand Down
Loading