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

Add SPM Support & Dark Mode Support #45

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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

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

33 changes: 33 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "SwiftPullToRefresh",
platforms: [
.macOS(.v10_14),
.iOS(.v11)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "SwiftPullToRefresh",
targets: ["SwiftPullToRefresh"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "SwiftPullToRefresh",
dependencies: []),
.testTarget(
name: "SwiftPullToRefreshTests",
dependencies: ["SwiftPullToRefresh"]),
],
swiftLanguageVersions: [.v5]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// UIActivityIndicatorViewStyle+Extensions.swift
//
//
// Created by Brandon Stillitano on 22/12/21.
//

import Foundation
import UIKit

extension UIActivityIndicatorView.Style {
/// Version safe method of access `UIActivityIndicatorView.Style.medium`. On versions prior to iOS 13.0 this will return `.gray`.
static var systemMedium: UIActivityIndicatorView.Style {
if #available(iOS 13.0, *) {
return .medium
} else {
return .gray
}
}
}
20 changes: 20 additions & 0 deletions Sources/SwiftPullToRefresh/Extensions/UIColor+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// UIColor+Extensions.swift
// SwiftPullToRefresh
//
// Created by Brandon Stillitano on 22/12/21.
// Copyright © 2021 Brandon Stillitano. All rights reserved.
//

import UIKit

extension UIColor {
/// Version safe method of access `UIColor.label`. On versions prior to iOS 13.0 this will return `.black`.
static var systemLabel: UIColor {
if #available(iOS 13.0, *) {
return .label
} else {
return .black
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class GIFHeader: RefreshView {

}

protocol AnimatedImage: class {
protocol AnimatedImage: AnyObject {
var size: CGSize { get }
var frameCount: Int { get }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class GIFTextHeader: GIFHeader {
private lazy var label: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 14)
label.textColor = UIColor.black.withAlphaComponent(0.8)
label.textColor = UIColor.systemLabel.withAlphaComponent(0.8)
return label
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class IndicatorView: RefreshView {

let layer = CAShapeLayer()
layer.path = path.cgPath
layer.strokeColor = UIColor.black.withAlphaComponent(0.8).cgColor
layer.strokeColor = UIColor.systemLabel.withAlphaComponent(0.8).cgColor
layer.lineWidth = 2
layer.lineCap = .round
return layer
}()

let indicator = UIActivityIndicatorView(style: .gray)
let indicator = UIActivityIndicatorView(style: .systemMedium)

private let isHeader: Bool

Expand Down
6 changes: 6 additions & 0 deletions Sources/SwiftPullToRefresh/SwiftPullToRefresh.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public struct SwiftPullToRefresh {
public private(set) var text = "Hello, World!"

public init() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TextAutoFooter: IndicatorAutoFooter {
private lazy var label: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 14)
label.textColor = UIColor.black.withAlphaComponent(0.8)
label.textColor = UIColor.systemLabel.withAlphaComponent(0.8)
return label
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TextView: IndicatorView {
private lazy var label: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 14)
label.textColor = UIColor.black.withAlphaComponent(0.8)
label.textColor = UIColor.systemLabel.withAlphaComponent(0.8)
return label
}()

Expand Down
5 changes: 3 additions & 2 deletions SwiftPullToRefresh.podspec
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
Pod::Spec.new do |s|
s.name = "SwiftPullToRefresh"
s.version = "3.1.1"
s.version = "3.1.2"
s.summary = "An easy way to implement pull-to-refresh feature based on UIScrollView extension, written in Swift 5."
s.description = <<-DESC
An easy way to implement pull-to-refresh feature based on UIScrollView extension, written in Swift 5. Provide default style header and footer controls which you can directly use in your project, and also support for customization. GIF is also supported.
DESC

s.homepage = "https://github.com/WXGBridgeQ/SwiftPullToRefresh"
s.license = "MIT"
s.author = { "Leo Zhou" => "[email protected]" }
s.platform = :ios, "8.0"
s.swift_version = "5.0"
s.source = { :git => "https://github.com/WXGBridgeQ/SwiftPullToRefresh.git", :tag => "#{s.version}" }
s.source_files = "SwiftPullToRefresh/*.{swift}"
s.source_files = "Sources/SwiftPullToRefresh/**/*.{swift}"
end
Loading