-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 04257a1
Showing
39 changed files
with
2,044 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
/*.xcodeproj | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/config/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
7 changes: 7 additions & 0 deletions
7
Example.swiftpm/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
Example.swiftpm/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
11 changes: 11 additions & 0 deletions
11
Example.swiftpm/Assets.xcassets/AccentColor.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Example.swiftpm/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"platform" : "ios", | ||
"size" : "1024x1024" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import SwiftUI | ||
import ColorPicker | ||
|
||
struct ContentView: View { | ||
var body: some View { | ||
VStack { | ||
Image(systemName: "globe") | ||
.imageScale(.large) | ||
.foregroundColor(.accentColor) | ||
Text("Hello, world!") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import SwiftUI | ||
|
||
@main | ||
struct MyApp: App { | ||
var body: some Scene { | ||
WindowGroup { | ||
ContentView() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"object": { | ||
"pins": [ | ||
{ | ||
"package": "SnapKit", | ||
"repositoryURL": "https://github.com/SnapKit/SnapKit", | ||
"state": { | ||
"branch": null, | ||
"revision": "d458564516e5676af9c70b4f4b2a9178294f1bc6", | ||
"version": "5.0.1" | ||
} | ||
}, | ||
{ | ||
"package": "UIColorHexSwift", | ||
"repositoryURL": "https://github.com/yeahdongcn/UIColor-Hex-Swift", | ||
"state": { | ||
"branch": null, | ||
"revision": "4e0c1bc57c02fcb19c3b34ec5e6188383a95aa94", | ||
"version": "5.1.8" | ||
} | ||
} | ||
] | ||
}, | ||
"version": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// swift-tools-version: 5.5 | ||
|
||
// WARNING: | ||
// This file is automatically generated. | ||
// Do not edit it by hand because the contents will be replaced. | ||
|
||
import PackageDescription | ||
import AppleProductTypes | ||
|
||
let package = Package( | ||
name: "Example", | ||
platforms: [ | ||
.iOS("15.2") | ||
], | ||
products: [ | ||
.iOSApplication( | ||
name: "Example", | ||
targets: ["AppModule"], | ||
bundleIdentifier: "dev.noppe.Example", | ||
teamIdentifier: "FBQ6Z8AF3U", | ||
displayVersion: "1.0", | ||
bundleVersion: "1", | ||
iconAssetName: "AppIcon", | ||
accentColorAssetName: "AccentColor", | ||
supportedDeviceFamilies: [ | ||
.pad, | ||
.phone | ||
], | ||
supportedInterfaceOrientations: [ | ||
.portrait, | ||
.landscapeRight, | ||
.landscapeLeft, | ||
.portraitUpsideDown(.when(deviceFamilies: [.pad])) | ||
] | ||
) | ||
], | ||
dependencies: [ | ||
.package(path: "../") | ||
], | ||
targets: [ | ||
.executableTarget( | ||
name: "AppModule", | ||
dependencies: ["ColorPicker"], | ||
path: "." | ||
) | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"pins" : [ | ||
{ | ||
"identity" : "snapkit", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/SnapKit/SnapKit", | ||
"state" : { | ||
"revision" : "d458564516e5676af9c70b4f4b2a9178294f1bc6", | ||
"version" : "5.0.1" | ||
} | ||
}, | ||
{ | ||
"identity" : "uicolor-hex-swift", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/yeahdongcn/UIColor-Hex-Swift", | ||
"state" : { | ||
"revision" : "4e0c1bc57c02fcb19c3b34ec5e6188383a95aa94", | ||
"version" : "5.1.8" | ||
} | ||
} | ||
], | ||
"version" : 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// swift-tools-version: 5.6 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "ColorPicker", | ||
platforms: [.iOS(.v15)], | ||
products: [ | ||
.library( | ||
name: "ColorPicker", | ||
targets: ["ColorPicker"] | ||
), | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/SnapKit/SnapKit", from: "5.0.1"), | ||
.package(url: "https://github.com/yeahdongcn/UIColor-Hex-Swift", from: "5.1.8"), | ||
], | ||
targets: [ | ||
.target( | ||
name: "ColorPicker", | ||
dependencies: [ | ||
"SnapKit", | ||
.product(name: "UIColorHexSwift", package: "UIColor-Hex-Swift") | ||
] | ||
), | ||
.testTarget( | ||
name: "ColorPickerTests", | ||
dependencies: ["ColorPicker"]), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# ColorPicker | ||
|
||
A description of this package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import UIKit | ||
import SnapKit | ||
|
||
class AddColorCell: UICollectionViewCell { | ||
let backgroundColorView: UIView = .init(frame: .null) | ||
let imageView: UIImageView = .init(frame: .null) | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
|
||
contentView.addSubview(backgroundColorView) | ||
backgroundColorView.snp.makeConstraints { make in | ||
make.center.equalToSuperview() | ||
make.size.equalTo(30) | ||
} | ||
backgroundColorView.backgroundColor = .systemGray5 | ||
backgroundColorView.layer.cornerRadius = 15 | ||
|
||
backgroundColorView.addSubview(imageView) | ||
imageView.snp.makeConstraints { make in | ||
make.center.equalToSuperview() | ||
make.size.equalTo(16) | ||
} | ||
|
||
imageView.image = UIImage(systemName: "plus") | ||
imageView.tintColor = .systemGray2 | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import UIKit | ||
|
||
class ColorCell: UICollectionViewCell { | ||
|
||
override var isSelected: Bool { | ||
didSet { setNeedsDisplay() } | ||
} | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
backgroundColor = .clear | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
override func draw(_ rect: CGRect) { | ||
let context = UIGraphicsGetCurrentContext()! | ||
if isSelected { | ||
do { // inner ellipse | ||
let size = CGSize(width: 17, height: 17) | ||
context.setFillColor(tintColor.cgColor) | ||
let origin = CGPoint( | ||
x: (rect.width - size.width) / 2, | ||
y: (rect.height - size.height) / 2 | ||
) | ||
context.fillEllipse(in: CGRect(origin: origin, size: size)) | ||
} | ||
do { // outline | ||
let size = CGSize(width: 28, height: 28) | ||
let origin = CGPoint( | ||
x: (rect.width - size.width) / 2, | ||
y: (rect.height - size.height) / 2 | ||
) | ||
context.setStrokeColor(tintColor.cgColor) | ||
context.setLineWidth(3) | ||
context.strokeEllipse(in: CGRect(origin: origin, size: size)) | ||
} | ||
} else { | ||
let size = CGSize(width: 30, height: 30) | ||
context.setFillColor(tintColor.cgColor) | ||
let origin = CGPoint( | ||
x: (rect.width - size.width) / 2, | ||
y: (rect.height - size.height) / 2 | ||
) | ||
context.fillEllipse(in: CGRect(origin: origin, size: size)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import UIKit | ||
|
||
class HairlineView: UIVisualEffectView { | ||
init() { | ||
let effect = UIVibrancyEffect( | ||
blurEffect: UIBlurEffect( | ||
style: .systemChromeMaterial | ||
), | ||
style: .separator | ||
) | ||
super.init(effect: effect) | ||
contentView.backgroundColor = .systemBackground | ||
self.snp.makeConstraints { make in | ||
make.height.equalTo(1) | ||
} | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import UIKit | ||
|
||
extension UIColor { | ||
var hsba: (hue: CGFloat, saturation: CGFloat, brightness: CGFloat, alpha: CGFloat) { | ||
var hue: CGFloat = 0 | ||
var saturation: CGFloat = 0 | ||
var brightness: CGFloat = 0 | ||
var alpha: CGFloat = 0 | ||
getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: &alpha) | ||
return (hue, saturation, brightness, alpha) | ||
} | ||
} |
Oops, something went wrong.