Skip to content

Commit

Permalink
SPM support
Browse files Browse the repository at this point in the history
  • Loading branch information
leoru committed Jul 26, 2023
1 parent 859a50b commit 3d03ac0
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 67 deletions.
18 changes: 18 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// swift-tools-version: 5.8
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "SwiftLoader",
platforms: [.iOS(.v13)],
products: [
.library(
name: "SwiftLoader",
targets: ["SwiftLoader"]),
],
targets: [
.target(
name: "SwiftLoader"),
]
)
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,24 @@ and set new config for SwiftLoader:


## Install

### CocoaPods

SwiftSpinner is available through CocoaPods. To install it, simply add the following line to your Podfile:

```swift
pod 'SwiftLoader', '1.0.0'
pod 'SwiftLoader', '1.1.0'
```

### Swift Package Manager

Add as a dependecy to your Swift Package

dependencies: [
.package(url: "https://github.com/leoru/SwiftLoader.git", branch: "master")
]


In case you don’t want to use CocoaPods - just copy the file SwiftLoader/SwiftLoader.swift to your Xcode project.

### Maintainers
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions SwiftLoader.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SwiftLoader"
s.version = "1.0.0"
s.version = "1.1.0"
s.summary = "A simple and beautiful activity indicator"
s.description = <<-DESC
SwiftLoader is a simple and beautiful activity indicator written in Swift.
Expand All @@ -14,6 +14,6 @@ Pod::Spec.new do |s|
s.swift_version = '5.0'
s.platform = :ios, '13.0'
s.requires_arc = true
s.source_files = 'src/SwiftLoader'
s.source_files = 'Sources/SwiftLoader/SwiftLoader'
s.frameworks = 'UIKit'
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
archiveVersion = 1;
classes = {
};
objectVersion = 55;
objectVersion = 60;
objects = {

/* Begin PBXBuildFile section */
6A7E7AFD1A8B62AB00B7F3B2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A7E7AFC1A8B62AB00B7F3B2 /* AppDelegate.swift */; };
6A7E7AFF1A8B62AB00B7F3B2 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A7E7AFE1A8B62AB00B7F3B2 /* ViewController.swift */; };
6A7E7B041A8B62AB00B7F3B2 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6A7E7B031A8B62AB00B7F3B2 /* Images.xcassets */; };
6A7E7B071A8B62AB00B7F3B2 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6A7E7B051A8B62AB00B7F3B2 /* LaunchScreen.xib */; };
6A7E7B1E1A8B62B700B7F3B2 /* SwiftLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A7E7B1D1A8B62B700B7F3B2 /* SwiftLoader.swift */; };
CC6F02942A710A64005275A2 /* SwiftLoader in Frameworks */ = {isa = PBXBuildFile; productRef = CC6F02932A710A64005275A2 /* SwiftLoader */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -21,14 +21,14 @@
6A7E7AFE1A8B62AB00B7F3B2 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
6A7E7B031A8B62AB00B7F3B2 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
6A7E7B061A8B62AB00B7F3B2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
6A7E7B1D1A8B62B700B7F3B2 /* SwiftLoader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftLoader.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
6A7E7AF41A8B62AB00B7F3B2 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
CC6F02942A710A64005275A2 /* SwiftLoader in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -54,7 +54,6 @@
6A7E7AF91A8B62AB00B7F3B2 /* SwiftLoaderExample */ = {
isa = PBXGroup;
children = (
6A7E7B1C1A8B62B700B7F3B2 /* SwiftLoader */,
6A7E7AFC1A8B62AB00B7F3B2 /* AppDelegate.swift */,
6A7E7AFE1A8B62AB00B7F3B2 /* ViewController.swift */,
6A7E7B031A8B62AB00B7F3B2 /* Images.xcassets */,
Expand All @@ -72,15 +71,6 @@
name = "Supporting Files";
sourceTree = "<group>";
};
6A7E7B1C1A8B62B700B7F3B2 /* SwiftLoader */ = {
isa = PBXGroup;
children = (
6A7E7B1D1A8B62B700B7F3B2 /* SwiftLoader.swift */,
);
name = SwiftLoader;
path = ../../../src/SwiftLoader;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand All @@ -97,6 +87,9 @@
dependencies = (
);
name = SwiftLoaderExample;
packageProductDependencies = (
CC6F02932A710A64005275A2 /* SwiftLoader */,
);
productName = SwiftLoaderExample;
productReference = 6A7E7AF71A8B62AB00B7F3B2 /* SwiftLoaderExample.app */;
productType = "com.apple.product-type.application";
Expand Down Expand Up @@ -126,6 +119,9 @@
Base,
);
mainGroup = 6A7E7AEE1A8B62AB00B7F3B2;
packageReferences = (
CC6F02922A710A64005275A2 /* XCLocalSwiftPackageReference "../.." */,
);
productRefGroup = 6A7E7AF81A8B62AB00B7F3B2 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand All @@ -152,7 +148,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6A7E7B1E1A8B62B700B7F3B2 /* SwiftLoader.swift in Sources */,
6A7E7AFF1A8B62AB00B7F3B2 /* ViewController.swift in Sources */,
6A7E7AFD1A8B62AB00B7F3B2 /* AppDelegate.swift in Sources */,
);
Expand Down Expand Up @@ -333,6 +328,20 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
CC6F02922A710A64005275A2 /* XCLocalSwiftPackageReference "../.." */ = {
isa = XCLocalSwiftPackageReference;
relativePath = ../..;
};
/* End XCLocalSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
CC6F02932A710A64005275A2 /* SwiftLoader */ = {
isa = XCSwiftPackageProductDependency;
productName = SwiftLoader;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 6A7E7AEF1A8B62AB00B7F3B2 /* Project object */;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22138.1" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22113"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand All @@ -13,12 +13,6 @@
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Copyright (c) 2022 Kirill Kunst. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" systemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="SwiftLoader" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
Expand All @@ -30,9 +24,6 @@
<constraints>
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l"/>
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0"/>
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9"/>
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
Expand Down
79 changes: 40 additions & 39 deletions example/SwiftLoaderExample/SwiftLoaderExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,52 @@
//

import UIKit
import SwiftLoader

class ViewController: UIViewController {

func delay(seconds: Double, completion: @escaping () -> Void) {
DispatchQueue.main.asyncAfter(deadline: .now() + seconds, execute: completion)
}

override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .white
self.addButton()
}

func addButton() {
let size : CGFloat = 200.0
let actionButton = UIButton(frame: CGRect(x: (self.view.frame.width - size) / 2, y: size, width: size, height: size))
actionButton.setTitleColor(UIColor(red:0.52, green:0.07, blue:0.72, alpha:1), for: .normal)
actionButton.addTarget(self, action: #selector(actionShowLoader), for: .touchUpInside)
actionButton.setTitle("Show loader", for: .normal)
self.view.addSubview(actionButton)
}

@objc func actionShowLoader() {
var config : SwiftLoader.Config = SwiftLoader.Config()
config.size = 170
config.backgroundColor = UIColor(red:0.03, green:0.82, blue:0.7, alpha:1)
config.spinnerColor = .white
config.titleTextColor = .white
config.spinnerLineWidth = 2.0
config.foregroundColor = UIColor.black
config.foregroundAlpha = 0.5

func delay(seconds: Double, completion: @escaping () -> Void) {
DispatchQueue.main.asyncAfter(deadline: .now() + seconds, execute: completion)
}

override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor(red:0.98, green:0.93, blue:0.81, alpha:1)
self.addButton()
}
SwiftLoader.setConfig(config)

func addButton() {
let size : CGFloat = 200.0
let actionButton = UIButton(frame: CGRect(x: (self.view.frame.width - size) / 2, y: size, width: size, height: size))
actionButton.setTitleColor(UIColor(red:0.52, green:0.07, blue:0.72, alpha:1), for: .normal)
actionButton.addTarget(self, action: #selector(actionShowLoader), for: .touchUpInside)
actionButton.setTitle("Show loader", for: .normal)
self.view.addSubview(actionButton)
}
SwiftLoader.show(animated: true)

@objc func actionShowLoader() {
var config : SwiftLoader.Config = SwiftLoader.Config()
config.size = 170
config.backgroundColor = UIColor(red:0.03, green:0.82, blue:0.7, alpha:1)
config.spinnerColor = UIColor(red:0.88, green:0.26, blue:0.18, alpha:1)
config.titleTextColor = UIColor(red:0.88, green:0.26, blue:0.18, alpha:1)
config.spinnerLineWidth = 2.0
config.foregroundColor = UIColor.black
config.foregroundAlpha = 0.5

SwiftLoader.setConfig(config)

SwiftLoader.show(animated: true)

delay(seconds: 3.0) { () -> () in
SwiftLoader.show(title: "Loading...", animated: true)
}

delay(seconds: 6.0) { () -> () in
SwiftLoader.hide()
}
delay(seconds: 3.0) { () -> () in
SwiftLoader.show(title: "Loading...", animated: true)
}


delay(seconds: 6.0) { () -> () in
SwiftLoader.hide()
}
}


}

0 comments on commit 3d03ac0

Please sign in to comment.