Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Added SPM & update to Swift5 #257

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
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

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

15 changes: 9 additions & 6 deletions Chameleon.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -660,6 +661,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -709,6 +711,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -734,7 +737,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -755,7 +758,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.viccalexander.Chameleon;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -780,7 +783,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.viccalexander.ChameleonDemo-Swift";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -805,7 +808,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.viccalexander.ChameleonDemo-Swift";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -819,7 +822,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.viccalexander.ChameleonDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -832,7 +835,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.viccalexander.ChameleonDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
2 changes: 1 addition & 1 deletion ChameleonDemo-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
}

Expand Down
28 changes: 14 additions & 14 deletions ChameleonDemo-Swift/FirstViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,24 @@ class FirstViewController: UITableViewController {
func initChameleonColors() {

let randomFlatColor = UIColor.randomFlat
let randomFlatColorContract = ContrastColorOf(randomFlatColor, returnFlat: true)
let randomFlatColorContract = ContrastColorOf(randomFlatColor(), returnFlat: true)
// Nav bar
navigationController?.navigationBar.barTintColor = randomFlatColor
navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: randomFlatColorContract]
navigationController?.navigationBar.barTintColor = randomFlatColor()
navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: randomFlatColorContract]
// Tab bar
tabBarController?.tabBar.barTintColor = randomFlatColor
tabBarController?.tabBar.barTintColor = randomFlatColor()
tabBarController?.tabBar.tintColor = randomFlatColorContract
// Refresh button
refreshButton.tintColor = randomFlatColorContract
// Random flat color
randomFlatColorLabel.text = "Aa \u{25A0}"
randomFlatColorLabel.textColor = randomFlatColor
randomFlatColorLabel.textColor = randomFlatColor()
// Complementary flat color
complementaryFlatColorLabel.text = "Aa \u{25A0}"
complementaryFlatColorLabel.textColor = ComplementaryFlatColorOf(randomFlatColor)
complementaryFlatColorLabel.textColor = ComplementaryFlatColorOf(randomFlatColor())
// Contrast flat color
contrastFlatColorLabel.text = "Aa \u{25A0}"
contrastFlatColorLabel.textColor = ContrastColorOf(randomFlatColor, returnFlat: true)
contrastFlatColorLabel.textColor = ContrastColorOf(randomFlatColor(), returnFlat: true)
// Flattening non-flat color
let randomColor = generateRandomColor() // custom method, not part of Chameleon
flatteningNonFlatColorLabel.text = "Aa \u{25A0}"
Expand All @@ -82,16 +82,16 @@ class FirstViewController: UITableViewController {
beforeFlatteningColorLabel.textColor = randomColor
// Lighter color > not yet reliable
lighterColorLabel.text = "Aa \u{25A0}"
lighterColorLabel.textColor = randomFlatColor.lighten(byPercentage: 0.5)
lighterColorLabel.textColor = randomFlatColor().lighten(byPercentage: 0.5)
// Darker color > not yet reliable
darkerColorLabel.text = "Aa \u{25A0}"
darkerColorLabel.textColor = randomFlatColor.darken(byPercentage: 0.5)
darkerColorLabel.textColor = randomFlatColor().darken(byPercentage: 0.5)
// Gradient color
let firstRandomColor = UIColor.randomFlat
let secondRandomColor = UIColor.randomFlat
let thirdRandomColor = UIColor.randomFlat
let firstRandomColor = UIColor.randomFlat()
let secondRandomColor = UIColor.randomFlat()
let thirdRandomColor = UIColor.randomFlat()
let gradientColor = GradientColor(.leftToRight, frame: gradientColorLabel.frame, colors: [firstRandomColor, secondRandomColor, thirdRandomColor])
let gradientColorLargeFrame = GradientColor(.leftToRight, frame: gradientWithContrastLabel.frame, colors: [firstRandomColor, secondRandomColor, thirdRandomColor])
let gradientColorLargeFrame = GradientColor(.leftToRight, frame: gradientWithContrastLabel.frame, colors: [firstRandomColor,secondRandomColor,thirdRandomColor])
gradientColorLabel.text = "Aa \u{25A0}"
gradientColorLabel.textColor = gradientColor
// Gradient backgorund with contrast text
Expand Down Expand Up @@ -119,7 +119,7 @@ class FirstViewController: UITableViewController {
let green = Float(arc4random_uniform(256))/255.0
let blue = Float(arc4random_uniform(256))/255.0

return UIColor(colorLiteralRed: red, green: green, blue: blue, alpha: 1.0)
return UIColor(_colorLiteralRed: red, green: green, blue: blue, alpha: 1.0)
}
}

Expand Down
4 changes: 2 additions & 2 deletions ChameleonDemo-Swift/SecondViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SecondViewController: UITableViewController {

override func viewDidLoad() {
super.viewDidLoad()
navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: tabBarController?.tabBar.tintColor ?? UIColor.gray]
navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: tabBarController?.tabBar.tintColor ?? UIColor.gray]
navigationController?.navigationBar.barTintColor = tabBarController?.tabBar.barTintColor ?? UIColor.lightGray
sampleOneImageView.image = #imageLiteral(resourceName: "SampleImageOne")
sampleTwoImageView.image = #imageLiteral(resourceName: "SampleImageTwo")
Expand All @@ -54,7 +54,7 @@ class SecondViewController: UITableViewController {
}

override func viewWillAppear(_ animated: Bool) {
navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: tabBarController?.tabBar.tintColor ?? UIColor.gray]
navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: tabBarController?.tabBar.tintColor ?? UIColor.gray]
navigationController?.navigationBar.barTintColor = tabBarController?.tabBar.barTintColor ?? UIColor.lightGray
}

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

import PackageDescription

let package = Package(
name: "Chameleon",
platforms: [
.iOS(.v8)
],
products: [
.library(
name: "Chameleon",
targets: ["Chameleon"]),
.library(
name: "ChameleonSwift",
targets: ["ChameleonSwift"]),
],
dependencies: [
],
targets: [
.target(
name: "Chameleon",
path:"Pod/Classes/Objective-C"
),
// .target(
// name: "Chameleons",
// // dependencies: ["Chameleon/Default"],
// path:"Chameleon", resources: [.process("Chameleon/Info.plist")]
// ),
.target(
name: "ChameleonSwift",
dependencies: ["Chameleon"],
path:"Pod/Classes/Swift"
)
]
)
Loading