Skip to content
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
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: xcodebuild build -scheme Cordate -destination 'platform=iOS Simulator,name=iPhone 17'
1 change: 0 additions & 1 deletion Cartfile

This file was deleted.

3 changes: 0 additions & 3 deletions Cartfile.private

This file was deleted.

3 changes: 0 additions & 3 deletions Cartfile.resolved

This file was deleted.

26 changes: 0 additions & 26 deletions Cordate.podspec

This file was deleted.

12 changes: 6 additions & 6 deletions Cordate.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -542,7 +542,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down Expand Up @@ -579,7 +579,7 @@
SKIP_INSTALL = YES;
SUPPORTS_MACCATALYST = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -609,7 +609,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTS_MACCATALYST = NO;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -632,7 +632,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.cordate.demo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -655,7 +655,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.cordate.demo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
26 changes: 13 additions & 13 deletions Cordate/Sources/Core/Calendar/CalendarDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@ import UIKit

public class CalendarDataSource {

public enum CalendarMode {
public enum CalendarMode: Sendable {
case birthDate

var range: (minimum: Date?, maximum: Date?) {
switch self {
case .birthDate:
let maximum = Date().heart.local
let minimum = Date(day: 1, month: 1, year: maximum.heart.year - 150)
return (minimum, maximum)
}
}
}

public struct Common {
public struct Common: Sendable {

private static let formatter: DateFormatter = {
let formatter = DateFormatter()
Expand All @@ -34,7 +25,7 @@ public class CalendarDataSource {

}

public enum Component {
public enum Component: Sendable {
case day(month: Int, year: Int)
case month(year: Int)
case year
Expand All @@ -47,13 +38,22 @@ public class CalendarDataSource {
return minimumDate.heart.year...maximumDate.heart.year
}

private static func modeRange(_ mode: CalendarMode) -> (minimum: Date?, maximum: Date?) {
switch mode {
case .birthDate:
let maximum = Date().heart.local
let minimum = Date(day: 1, month: 1, year: maximum.heart.year - 150)
return (minimum, maximum)
}
}

public init(minimumDate: Date? = nil, maximumDate: Date? = nil) {
self.minimumDate = minimumDate ?? Date.distantPast
self.maximumDate = maximumDate ?? Date.distantFuture
}

public convenience init(mode: CalendarMode) {
let (minimum, maximum) = mode.range
let (minimum, maximum) = CalendarDataSource.modeRange(mode)
self.init(minimumDate: minimum, maximumDate: maximum)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class CalendarDateSelectionController: UIViewController {
private var selectedMonth = Int?.none {
didSet { selectedDay = nil }
}

private var selectedDay = Int?.none

/// Performs an initial layout pass in viewDidLayoutSubviews which prepares the collection view's
Expand Down Expand Up @@ -399,7 +399,7 @@ extension CalendarDateSelectionController: UICollectionViewDelegate {
}

public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let generator = SelectionFeedbackGenerator()
let generator = UISelectionFeedbackGenerator()
generator.prepare()
switch currentComponent {
case .year:
Expand Down Expand Up @@ -497,27 +497,3 @@ extension CalendarDateSelectionController: UIViewControllerTransitioningDelegate
fileprivate func warn(_ message: String, _ function: String = #function, _ line: Int = #line) {
print("\(CalendarDateSelectionController.self).\(function):\(line) WARN - \(message).")
}

fileprivate struct SelectionFeedbackGenerator {

private let generator: Any?

init() {
if #available(iOS 10.0, *) {
generator = UISelectionFeedbackGenerator()
} else { generator = nil }
}

func prepare() {
if #available(iOS 10.0, *) {
(generator as? UISelectionFeedbackGenerator)?.prepare()
}
}

func selectionChanged() {
if #available(iOS 10.0, *) {
(generator as? UISelectionFeedbackGenerator)?.selectionChanged()
}
}

}
2 changes: 1 addition & 1 deletion Cordate/Sources/Core/Calendar/CalendarLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import UIKit

public class CalendarLayout: UICollectionViewFlowLayout {

public enum AnimationStyle {
public enum AnimationStyle: Sendable {
case simple
case detailed
}
Expand Down
12 changes: 3 additions & 9 deletions Cordate/Sources/Core/Calendar/CalendarStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ public struct CalendarStyle {
}

/// Drives which buttons are shown on the calendar.
public enum ButtonConfiguration {
public enum ButtonConfiguration: Sendable {

/// The calendar shows no buttons and produces values continuously.
case none

/// The calendar shows a confirmation button and only produces a value when it is pressed.
case confirmationOnly

/// The calendar shows both a confirmation button and a clear button.
/// The calendar shows both a confirmation button and a clear button.
case all

}
Expand Down Expand Up @@ -74,14 +74,8 @@ public struct CalendarStyle {
/// The font for the calendar controls.
public var calendarFont = UIFont.systemFont(ofSize: UIFont.systemFontSize)

private var _usesHaptics: Bool = true

/// Controls whether selection events trigger haptic feedback.
@available(iOS 10.0, *)
public var usesHaptics: Bool {
get { return _usesHaptics }
set { _usesHaptics = newValue }
}
public var usesHaptics: Bool = true

/// Controls which controls are provided by the calendar.
public var buttonConfiguration = ButtonConfiguration.all
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import Foundation
import UIKit

fileprivate let defaultStyle: UIBlurEffect.Style = {
if #available(iOS 10.0, *) { return .regular }
return .light
}()

/// The `CalendarPresentationController` class is a subclass of `UIPresentationController` which
/// provides default behaviors and styling for the `CalendarDateSelectionController`.
public class CalendarPresentationController: UIPresentationController {
Expand All @@ -14,8 +9,7 @@ public class CalendarPresentationController: UIPresentationController {
private let tapGestureRecognizer = UITapGestureRecognizer()

/// The blur effect used by the overlay.
/// On iOS 10 and above, this defaults to `.regular`; on iOS 9, the default is `.light`.
public var blurEffect = UIBlurEffect(style: defaultStyle)
public var blurEffect = UIBlurEffect(style: .regular)

/// Controls whether touches on the blur overlay trigger a dismissal.
///
Expand Down Expand Up @@ -73,4 +67,3 @@ public class CalendarPresentationController: UIPresentationController {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import Foundation

public extension ManualDateField {

struct Format {
struct Format: Sendable {

enum Day: String {
enum Day: String, Sendable {
case `default` = "dd"
}

enum Month: String {
enum Month: String, Sendable {
case `default` = "MM"
}

public enum Year: String {
public enum Year: String, Sendable {
case short = "yy"
case long = "yyyy"
}
Expand Down Expand Up @@ -41,4 +41,3 @@ public extension ManualDateField {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

public extension ManualDateField {

struct Order {
struct Order: Sendable {
public static let dayMonthYear = Order((.day, .month, .year))
public static let monthDayYear = Order((.month, .day, .year))
public static let yearDayMonth = Order((.year, .day, .month))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

public extension ManualDateField {

enum Separator: String {
enum Separator: String, Sendable {
case slash = "/"
case dash = "-"
case period = "."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public class ManualDateField: UITextField {
}

public override func copy() -> Any {
return text.map(formatText) ?? ""
MainActor.assumeIsolated { text.map { formatText($0) } ?? "" }
}

public override func drawText(in rect: CGRect) {
Expand Down
6 changes: 3 additions & 3 deletions Cordate/Sources/Core/Extensions/Heart.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

public struct Heart<Base> {
public struct Heart<Base>: Sendable where Base: Sendable {

public let base: Base

Expand All @@ -11,13 +11,13 @@ public struct Heart<Base> {
}

public protocol HeartCompatible {
associatedtype CompatibleType
associatedtype CompatibleType: Sendable

var heart: Heart<CompatibleType> { get }

}

extension HeartCompatible {
extension HeartCompatible where Self: Sendable {

public var heart: Heart<Self> {
return Heart(self)
Expand Down
8 changes: 4 additions & 4 deletions Cordate/Sources/Core/Extensions/Internal/UIButton.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Foundation
import UIKit

fileprivate var key = UInt8.max
nonisolated(unsafe) fileprivate var key = UInt8.max

extension UIButton {

class Closure: NSObject {
let closure: () -> ()
let closure: @MainActor () -> ()

init(_ closure: @escaping () -> ()) {
init(_ closure: @escaping @MainActor () -> ()) {
self.closure = closure
}
}
Expand All @@ -18,7 +18,7 @@ extension UIButton {
closure.closure()
}

func onTap(_ closure: @escaping () -> ()) {
func onTap(_ closure: @escaping @MainActor () -> ()) {
objc_setAssociatedObject(self, &key, Closure(closure), .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
addTarget(self, action: #selector(invoke), for: .touchUpInside)
}
Expand Down
Loading
Loading