Skip to content

Commit

Permalink
Merge pull request #28 from conmulligan/swift-6
Browse files Browse the repository at this point in the history
Update to Swift 6 language mode
  • Loading branch information
conmulligan authored Nov 24, 2024
2 parents a46ecc5 + d3f76ad commit 1d8d8f7
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Example/FlashExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
E1BC8F852879F5DB00CCFBAC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
E1BC8F882879F5DB00CCFBAC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
E1BC8F8A2879F5DB00CCFBAC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E1D41AEE2CF3D10A007A1A46 /* TestPlan.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = TestPlan.xctestplan; sourceTree = "<group>"; };
E1F176052A280AB700CB34B0 /* TestPlan.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = TestPlan.xctestplan; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -108,6 +109,7 @@
E1BC8F702879F5DA00CCFBAC = {
isa = PBXGroup;
children = (
E1D41AEE2CF3D10A007A1A46 /* TestPlan.xctestplan */,
E1BC8F902879F65C00CCFBAC /* Packages */,
E1BC8F7B2879F5DA00CCFBAC /* FlashExample */,
E174433F2A27F51A0036714C /* FlashExampleUITests */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
reference = "container:FlashExample.xctestplan"
default = "YES">
</TestPlanReference>
<TestPlanReference
reference = "container:TestPlan.xctestplan">
</TestPlanReference>
</TestPlans>
<Testables>
<TestableReference
Expand Down
31 changes: 31 additions & 0 deletions Example/TestPlan.xctestplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"configurations" : [
{
"id" : "4C1C88A8-C920-4DED-A4A6-DB68A29E089C",
"name" : "Configuration 1",
"options" : {

}
}
],
"defaultOptions" : {
"testTimeoutsEnabled" : true
},
"testTargets" : [
{
"target" : {
"containerPath" : "container:FlashExample.xcodeproj",
"identifier" : "E174433D2A27F51A0036714C",
"name" : "FlashExampleUITests"
}
},
{
"target" : {
"containerPath" : "container:..",
"identifier" : "FlashTests",
"name" : "FlashTests"
}
}
],
"version" : 1
}
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.9
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down
2 changes: 2 additions & 0 deletions Sources/Flash/FlashAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import UIKit
///
/// By default, the flash view uses the ``DefaultAnimator`` to animate in and out.
/// If you need finer control over the flash view's animation, create a new type that conforms to `FlashAnimator`.
@MainActor
public protocol FlashAnimator {
/// The animation completion handler.
typealias CompletionHandler = () -> Void
Expand Down Expand Up @@ -108,6 +109,7 @@ extension DefaultAnimator.Configuration {
///
/// You can adjust the animator's behaviour by creating a custom ``DefaultAnimator/Configuration-swift.struct``.
/// If you need finer control over the flash view's animation beyond what's possible with the default animator, see ``FlashAnimator``.
@MainActor
public struct DefaultAnimator: FlashAnimator {

// MARK: - Properties
Expand Down
6 changes: 5 additions & 1 deletion Sources/Flash/FlashView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import UIKit

extension FlashView {
/// The flash view configuration.
@MainActor
public struct Configuration {

/// The flash view's alignment, relative to its parent view.
Expand Down Expand Up @@ -153,6 +154,7 @@ extension FlashView.Configuration {
/// Use this static property to configure the shared configuration used by all flash views.
/// If you only want to customize the appearance of a single flash view, consider passing a ``FlashView/Configuration-swift.struct`` instance to
/// ``FlashView/init(text:image:configuration:)`` instead.
@MainActor
public static var shared: FlashView.Configuration = .defaultConfiguration()

/// The default configuration.
Expand Down Expand Up @@ -437,7 +439,9 @@ public class FlashView: UIView {
guard timer == nil, duration > 0 else { return }

timer = Timer.scheduledTimer(withTimeInterval: duration, repeats: false) { _ in
self.hide()
Task { @MainActor in
self.hide()
}
}
}
}
Expand Down
17 changes: 9 additions & 8 deletions Tests/FlashTests/FlashTests.swift
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import XCTest
import Testing
@testable import Flash

final class FlashTests: XCTestCase {
func testInitCustomConfiguration() {
@MainActor
struct FlashTests {
@Test func testInitCustomConfiguration() {
let configuration = FlashView.Configuration(alignment: .bottom)
let flash = FlashView(text: "Test", configuration: configuration)
XCTAssert(flash.configuration.alignment == configuration.alignment)
#expect(flash.configuration.alignment == configuration.alignment)
}

func testInitCustomAnimatorConfiguration() {
@Test func testInitCustomAnimatorConfiguration() {
let configuration = DefaultAnimator.Configuration(duration: 10)
let animator = DefaultAnimator(configuration: configuration)
XCTAssert(animator.configuration.duration == configuration.duration)
#expect(animator.configuration.duration == configuration.duration)
}

func testSharedConfiguration() {
@Test func testSharedConfiguration() {
FlashView.Configuration.shared.alignment = .bottom
let flash = FlashView(text: "Test")
XCTAssert(flash.configuration.alignment == .bottom)
#expect(flash.configuration.alignment == .bottom)
}
}

0 comments on commit 1d8d8f7

Please sign in to comment.