diff --git a/Package.swift b/Package.swift index 55eda46..9cad564 100644 --- a/Package.swift +++ b/Package.swift @@ -4,29 +4,19 @@ import PackageDescription let package = Package( - name: "CMPressableButton", + name: "PressableButton", platforms: [ .iOS(.v14), .macOS(.v11) ], products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. .library( - name: "CMPressableButton", - targets: ["CMPressableButton"]), - ], - dependencies: [ - // Dependencies declare other packages that this package depends on. - // .package(url: /* package url */, from: "1.0.0"), + name: "PressableButton", + targets: ["PressableButton"]), ], 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: "CMPressableButton", - dependencies: []), - .testTarget( - name: "CMPressableButtonTests", - dependencies: ["CMPressableButton"]), + name: "PressableButton", + dependencies: []) ] ) diff --git a/README.md b/README.md index f28fac3..40a0367 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@

- Project logo + Project logo

-

๐Ÿ•น CM Pressable Button ๐Ÿ•น

+

๐Ÿ•น SwiftUI Pressable Button ๐Ÿ•น

-![License](https://img.shields.io/github/license/CM-Material/CMPressableButton?style=for-the-badge) -![Release](https://img.shields.io/github/v/release/CM-Material/CMPressableButton?style=for-the-badge) +![License](https://img.shields.io/github/license/Changemin/PressableButton?style=for-the-badge) +![Release](https://img.shields.io/github/v/release/Changemin/PressableButton?style=for-the-badge)
@@ -17,7 +17,7 @@ ## ๐Ÿ“น Preview

- +

## ๐Ÿ Getting Started @@ -33,12 +33,12 @@ File โžœ Swift Packages โžœ Add Package Dependancy.. ```Swift -.package(url: "https://github.com/CM-Material/CMPressableButton", from: "1.0.0") +.package(url: "https://github.com/Changemin/PressableButton", from: "1.1.0") ``` ## ๐ŸŽˆUsage ```Swift -CMPressableButton(action: { YOUR ACTION }) { +PressableButton(action: { YOUR ACTION }) { // YOUR VIEW } ``` @@ -46,7 +46,7 @@ CMPressableButton(action: { YOUR ACTION }) { #### ๐Ÿ› Custom Modifiers ```Swift -CMPressableButton(action: { YOUR ACTION }) { +PressableButton(action: { YOUR ACTION }) { // YOUR VIEW }.accentColor(_ color: color) .cornerRadius(_ amount: CGFloat) @@ -63,11 +63,11 @@ CMPressableButton(action: { YOUR ACTION }) { ## Example #### ๐Ÿ‘ถ Simple ```Swift -import CMPressableButton +import PressableButton struct ContentView: View { var body: some View { - CMPressableButton(action: { + PressableButton(action: { print("Button pressed") }) { Text("Simple Example").foregroundColor(.white) @@ -77,17 +77,17 @@ struct ContentView: View { ``` #### Result

- - + +

### ๐Ÿ›  Custom Modifiers ```Swift -import CMPressableButton +import PressableButton struct ContentView: View { var body: some View { - CMPressableButton(action: { + PressableButton(action: { print("Button pressed") }) { Text("PUSH ME !").foregroundColor(.white) @@ -101,8 +101,8 @@ struct ContentView: View { ### Result

- - + +

## โœ… TODO diff --git a/Sources/CMPressableButton/CMPressableButton.swift b/Sources/PressableButton/PressableButton.swift similarity index 85% rename from Sources/CMPressableButton/CMPressableButton.swift rename to Sources/PressableButton/PressableButton.swift index 7b39cc1..2150680 100644 --- a/Sources/CMPressableButton/CMPressableButton.swift +++ b/Sources/PressableButton/PressableButton.swift @@ -1,6 +1,22 @@ import SwiftUI -public struct CMPressableButton : View{ +/** + Pressable Animated Button for SwiftUI + + - Parameters: + - action: action to do when button pressed + - content: View in the Button + + # Example # + ``` + PressableButton(action: { + // YOUR ACTION HERE + }) { + // YOUR VIEW HERE + } + ``` + */ +public struct PressableButton : View{ @State var isPressed: Bool = false var color: Color = Color(.sRGB, red: 50/255, green: 200/255, blue: 165/255) var cornerRadius: CGFloat = 5 @@ -71,9 +87,9 @@ public struct CMPressableButton : View{ } } -extension CMPressableButton { - public func accentColor(_ color: Color) -> CMPressableButton { - CMPressableButton(action: self.action, +extension PressableButton { + public func accentColor(_ color: Color) -> PressableButton { + PressableButton(action: self.action, content: { self.content }, width: self.width, height: self.height, @@ -82,8 +98,8 @@ extension CMPressableButton { useHaptic: self.hapticEffect.0, hapticIntensity: self.hapticEffect.1) } - public func cornerRadius(_ amount: CGFloat) -> CMPressableButton { - CMPressableButton(action: self.action, + public func cornerRadius(_ amount: CGFloat) -> PressableButton { + PressableButton(action: self.action, content: { self.content }, width: self.width, height: self.height, @@ -92,8 +108,8 @@ extension CMPressableButton { useHaptic: self.hapticEffect.0, hapticIntensity: self.hapticEffect.1) } - public func frame(width: CGFloat, height: CGFloat) -> CMPressableButton { - CMPressableButton(action: self.action, + public func frame(width: CGFloat, height: CGFloat) -> PressableButton { + PressableButton(action: self.action, content: { self.content }, width: width, height: height, @@ -102,8 +118,8 @@ extension CMPressableButton { useHaptic: self.hapticEffect.0, hapticIntensity: self.hapticEffect.1) } - public func enableHaptic(intensity: UIImpactFeedbackGenerator.FeedbackStyle) -> CMPressableButton { - CMPressableButton(action: self.action, + public func enableHaptic(intensity: UIImpactFeedbackGenerator.FeedbackStyle) -> PressableButton { + PressableButton(action: self.action, content: { self.content }, width: self.width, height: self.height, @@ -112,8 +128,8 @@ extension CMPressableButton { useHaptic: self.hapticEffect.0, hapticIntensity: intensity) } - public func disableHaptic() -> CMPressableButton { - CMPressableButton(action: self.action, + public func disableHaptic() -> PressableButton { + PressableButton(action: self.action, content: { self.content }, width: self.width, height: self.height, diff --git a/Sources/CMPressableButton/CMPressableButtonStyle.swift b/Sources/PressableButton/PressableButtonStyle.swift similarity index 84% rename from Sources/CMPressableButton/CMPressableButtonStyle.swift rename to Sources/PressableButton/PressableButtonStyle.swift index 8e3d2e4..7ec35d5 100644 --- a/Sources/CMPressableButton/CMPressableButtonStyle.swift +++ b/Sources/PressableButton/PressableButtonStyle.swift @@ -7,7 +7,7 @@ import Foundation -enum CMPressableButtonStyle { +enum PressableButtonStyle { case FlatStyle case RoundedStyle case PushButtonStyle diff --git a/Sources/CMPressableButton/TouchEventModifier.swift b/Sources/PressableButton/TouchEventModifier.swift similarity index 96% rename from Sources/CMPressableButton/TouchEventModifier.swift rename to Sources/PressableButton/TouchEventModifier.swift index 2a6d592..f87c2bb 100644 --- a/Sources/CMPressableButton/TouchEventModifier.swift +++ b/Sources/PressableButton/TouchEventModifier.swift @@ -1,5 +1,5 @@ // -// File.swift +// TouchEventModifier.swift // // // Created by ๋ณ€๊ฒฝ๋ฏผ on 2020/12/30. diff --git a/Tests/CMPressableButtonTests/CMPressableButtonTests.swift b/Tests/CMPressableButtonTests/CMPressableButtonTests.swift deleted file mode 100644 index 8b25f25..0000000 --- a/Tests/CMPressableButtonTests/CMPressableButtonTests.swift +++ /dev/null @@ -1,15 +0,0 @@ -import XCTest -@testable import CMPressableButton - -final class CMPressableButtonTests: XCTestCase { - func testExample() { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct - // results. - XCTAssertEqual(CMPressableButton().text, "Hello, World!") - } - - static var allTests = [ - ("testExample", testExample), - ] -} diff --git a/Tests/CMPressableButtonTests/XCTestManifests.swift b/Tests/CMPressableButtonTests/XCTestManifests.swift deleted file mode 100644 index a5c2db4..0000000 --- a/Tests/CMPressableButtonTests/XCTestManifests.swift +++ /dev/null @@ -1,9 +0,0 @@ -import XCTest - -#if !canImport(ObjectiveC) -public func allTests() -> [XCTestCaseEntry] { - return [ - testCase(CMPressableButtonTests.allTests), - ] -} -#endif diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift deleted file mode 100644 index b30db43..0000000 --- a/Tests/LinuxMain.swift +++ /dev/null @@ -1,7 +0,0 @@ -import XCTest - -import CMPressableButtonTests - -var tests = [XCTestCaseEntry]() -tests += CMPressableButtonTests.allTests() -XCTMain(tests) diff --git a/src/Example-customModifier-1.png b/imgs/Example-customModifier-1.png similarity index 100% rename from src/Example-customModifier-1.png rename to imgs/Example-customModifier-1.png diff --git a/src/Example-customModifier-2.png b/imgs/Example-customModifier-2.png similarity index 100% rename from src/Example-customModifier-2.png rename to imgs/Example-customModifier-2.png diff --git a/src/Example-simple-1.png b/imgs/Example-simple-1.png similarity index 100% rename from src/Example-simple-1.png rename to imgs/Example-simple-1.png diff --git a/src/Example-simple-2.png b/imgs/Example-simple-2.png similarity index 100% rename from src/Example-simple-2.png rename to imgs/Example-simple-2.png diff --git a/src/Logo.gif b/imgs/Logo.gif similarity index 100% rename from src/Logo.gif rename to imgs/Logo.gif diff --git a/src/appVideo.gif b/imgs/appVideo.gif similarity index 100% rename from src/appVideo.gif rename to imgs/appVideo.gif