Skip to content

Commit

Permalink
fix: added support for Swift 6
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriyGo committed Sep 23, 2024
1 parent 84448d2 commit 70ac766
Show file tree
Hide file tree
Showing 23 changed files with 33 additions and 43 deletions.
Binary file added .DS_Store
Binary file not shown.
8 changes: 4 additions & 4 deletions Instructions.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
};
name = Debug;
};
Expand Down Expand Up @@ -771,7 +771,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
};
name = Release;
};
Expand Down Expand Up @@ -920,7 +920,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
};
name = Debug;
};
Expand Down Expand Up @@ -949,7 +949,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class CoachMarksViewController: UIViewController {
}

deinit {
deregisterFromSystemEventChanges()
NotificationCenter.default.removeObserver(self)
}

// Called after the view was loaded.
Expand Down Expand Up @@ -217,7 +217,7 @@ class CoachMarksViewController: UIViewController {
func detachFromWindow() {
switch presentationFashion {
case .window:
deregisterFromSystemEventChanges()
NotificationCenter.default.removeObserver(self)
let window = view.window
window?.isHidden = true
window?.rootViewController = nil
Expand All @@ -227,7 +227,7 @@ class CoachMarksViewController: UIViewController {
self.willMove(toParent: nil)
self.view.removeFromSuperview()
self.removeFromParent()
deregisterFromSystemEventChanges()
NotificationCenter.default.removeObserver(self)
}
}

Expand Down Expand Up @@ -376,10 +376,6 @@ extension CoachMarksViewController {
center.addObserver(self, selector: #selector(restoreAfterChangeDidComplete),
name: UIApplication.didChangeStatusBarFrameNotification, object: nil)
}

func deregisterFromSystemEventChanges() {
NotificationCenter.default.removeObserver(self)
}
}

// MARK: - Private Extension: User Events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import UIKit

// MARK: - Main Class
/// Handles a set of coach marks, and display them successively.
@MainActor
public class CoachMarksController {
// MARK: - Public properties
/// Implement the data source protocol and supply
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

import UIKit

@MainActor
public protocol CoachMarkBackgroundStyle {
var innerColor: UIColor { get set }
var borderColor: UIColor { get set }
var highlightedInnerColor: UIColor { get set }
var highlightedBorderColor: UIColor { get set }
}

@MainActor
public protocol CoachMarkBodyBackgroundStyle: AnyObject, CoachMarkBackgroundStyle {
var isHighlighted: Bool { get set }
var cornerRadius: CGFloat { get set }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import UIKit

@MainActor
protocol CoachMarkComponent {
var frame: CGRect { get set }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import UIKit

@MainActor
class CoachMarkInnerLayoutHelper {
func horizontalArrowConstraints(for coachMarkViews: CoachMarkViews,
withPosition position: ArrowPosition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import UIKit

class CoachMarkLayoutHelper {
@MainActor class CoachMarkLayoutHelper {
var layoutDirection: UIUserInterfaceLayoutDirection = .leftToRight

// TODO: Improve the layout system. Make it smarter.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Instructions/Helpers/Public/CoachMarkHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import UIKit

public class CoachMarkHelper {
@MainActor public class CoachMarkHelper {

let instructionsRootView: InstructionsRootView
let flowManager: FlowManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import UIKit

/// This class deals with the layout of coach marks.
class CoachMarkDisplayManager {
@MainActor class CoachMarkDisplayManager {
// MARK: - Public properties
weak var dataSource: CoachMarksControllerProxyDataSource!
weak var animationDelegate: CoachMarksControllerAnimationProxyDelegate?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import UIKit
///
/// TODO: Look for ways to improve everything, I'm fairly confident we can optimize
/// a bunch of things.
class BlurringOverlayStyleManager: OverlayStyleManager {
@MainActor class BlurringOverlayStyleManager: OverlayStyleManager {
// MARK: Properties
weak var overlayView: OverlayView? {
didSet {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import UIKit
/// This protocol expected to be implemented by the CoachMarkController.
/// A snapshottable object will return a snapshot view of its content.
/// Useful when dealing with multiple windows.
@MainActor
protocol Snapshottable: AnyObject {
/// Returns: A snapshot of the view hierarchy.
func snapshot() -> UIView?
Expand All @@ -15,7 +16,7 @@ protocol Snapshottable: AnyObject {
/// (Blurring the content behind, simple background color, etc.)
/// Takes care of displaying and animating the overlay / cutout path (doesn't
/// deals with the coach mark view itself).
protocol OverlayStyleManager: AnyObject {
@MainActor protocol OverlayStyleManager: AnyObject {
/// The overlay managed by the styleManager.
var overlayView: OverlayView? { get set }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import UIKit

/// This class deals with the layout of the "skip" view.
class SkipViewDisplayManager {
@MainActor class SkipViewDisplayManager {
// MARK: - Internal properties
/// Datasource providing the constraints to use.
weak var dataSource: CoachMarksControllerProxyDataSource?
Expand Down
9 changes: 1 addition & 8 deletions Sources/Instructions/Managers/Public/FlowManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import UIKit

public class FlowManager {
@MainActor public class FlowManager {
// MARK: - Internal Properties
/// `true` if coach marks are curently being displayed, `false` otherwise.
public var isStarted: Bool { return currentIndex > -1 }
Expand Down Expand Up @@ -294,13 +294,6 @@ public class FlowManager {

showPreviousCoachMark(hidePrevious: true)
}

// MARK: Renamed Public Properties
@available(*, unavailable, renamed: "isStarted")
public var started: Bool = false

@available(*, unavailable, renamed: "isPaused")
public var paused: Bool = false
}

extension FlowManager: CoachMarksViewControllerDelegate {
Expand Down
15 changes: 1 addition & 14 deletions Sources/Instructions/Managers/Public/OverlayManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import UIKit

// Overlay a blocking view on top of the screen and handle the cutout path
// around the point of interest.
public class OverlayManager {
@MainActor public class OverlayManager {
// MARK: - Public properties
/// The background color of the overlay
public var backgroundColor: UIColor = InstructionsColor.overlay {
Expand Down Expand Up @@ -186,19 +186,6 @@ public class OverlayManager {
return translucentOverlayStyleManager
}
}

// MARK: Renamed Public Properties
@available(*, unavailable, renamed: "backgroundColor")
public var color: UIColor = InstructionsColor.overlay

@available(*, unavailable, renamed: "isUserInteractionEnabled")
public var allowTap: Bool = true

@available(*, unavailable, renamed: "isUserInteractionEnabledInsideCutoutPath")
public var allowTouchInsideCutoutPath: Bool = false

@available(*, unavailable, renamed: "areTouchEventsForwarded")
public var forwardTouchEvents: Bool = false
}

// swiftlint:disable class_delegate_protocol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the terms of the MIT License.

/// Used by the CoachMarksViewController to notify user or system related events.
protocol CoachMarksViewControllerDelegate: AnyObject {
@MainActor protocol CoachMarksViewControllerDelegate: AnyObject {
/// The given `coachMarkView` was tapped.
///
/// - Parameter coachMarkView: the view that was tapped.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import UIKit

/// A protocol to which all the "arrow views" of a coach mark must conform.
@MainActor
public protocol CoachMarkArrowView: AnyObject {
/// A method to change the arrow highlighted state.
/// If you feel the arrow should mirror the state of the "body view",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import UIKit
/// Delegate the hilight mecanism of the arrow. This protocol is
/// useful in case the whole body itself is the active control and
/// we want the arrow to looks like it is part of this control.
public protocol CoachMarkBodyHighlightArrowDelegate: AnyObject {
@MainActor public protocol CoachMarkBodyHighlightArrowDelegate: AnyObject {

/// Set wethe ror not the arrow should get in its
/// highlighted state.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import UIKit

/// A protocol to which all the "body views" of a coach mark must conform.
@MainActor
public protocol CoachMarkBodyView: AnyObject {
/// The control that will trigger the change between the current coach mark
/// and the next one.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import UIKit

/// A protocol to which all the "skip views" must conform.
@MainActor
public protocol CoachMarkSkipView: AnyObject {
/// The control that will trigger the stop, in the display flow.
var skipControl: UIControl? { get }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import UIKit

/// Describe how a coachmark datasource should behave.
/// It works a bit like `UITableViewDataSource`.
@MainActor
public protocol CoachMarksControllerDataSource: AnyObject {
/// Asks for the number of coach marks to display.
///
Expand Down Expand Up @@ -66,6 +67,7 @@ public extension CoachMarksControllerDataSource {
}
}

@MainActor
internal protocol CoachMarksControllerProxyDataSource: AnyObject {
/// Asks for the number of coach marks to display.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import UIKit

///
public protocol CoachMarksControllerAnimationDelegate: AnyObject {
@MainActor public protocol CoachMarksControllerAnimationDelegate: AnyObject {
func coachMarksController(_ coachMarksController: CoachMarksController,
fetchAppearanceTransitionOfCoachMark coachMarkView: UIView,
at index: Int,
Expand Down Expand Up @@ -38,7 +38,7 @@ public extension CoachMarksControllerAnimationDelegate {
using manager: CoachMarkAnimationManager) { }
}

protocol CoachMarksControllerAnimationProxyDelegate: AnyObject {
@MainActor protocol CoachMarksControllerAnimationProxyDelegate: AnyObject {
func fetchAppearanceTransition(OfCoachMark coachMarkView: UIView,
at index: Int,
using manager: CoachMarkTransitionManager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import UIKit

/// Give a chance to react when coach marks are displayed
@MainActor
public protocol CoachMarksControllerDelegate: AnyObject {
func coachMarksController(_ coachMarksController: CoachMarksController,
configureOrnamentsOfOverlay overlay: UIView)
Expand Down Expand Up @@ -36,6 +37,7 @@ public protocol CoachMarksControllerDelegate: AnyObject {
at index: Int) -> Bool
}


public extension CoachMarksControllerDelegate {
func coachMarksController(_ coachMarksController: CoachMarksController,
configureOrnamentsOfOverlay overlay: UIView) { }
Expand Down Expand Up @@ -82,6 +84,7 @@ public extension CoachMarksControllerDelegate {
}
}

@MainActor
protocol CoachMarksControllerProxyDelegate: AnyObject {
func configureOrnaments(ofOverlay: UIView)

Expand Down

0 comments on commit 70ac766

Please sign in to comment.