Skip to content

Commit

Permalink
Remove 'prefix CM'
Browse files Browse the repository at this point in the history
  • Loading branch information
changemin committed Jan 29, 2021
1 parent 431664e commit 5d14b9a
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 76 deletions.
20 changes: 5 additions & 15 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: [])
]
)
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<p align="center">
<a href="" rel="noopener">
<img width=300px src="src/Logo.gif" alt="Project logo"></a>
<img width=300px src="imgs/Logo.gif" alt="Project logo"></a>
</p>

<h3 align="center">🕹 CM Pressable Button 🕹</h3>
<h3 align="center">🕹 SwiftUI Pressable Button 🕹</h3>

<div align="center">

![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)

</div>

Expand All @@ -17,7 +17,7 @@
## 📹 Preview

<p align="center">
<img src="src/appVideo.gif" width="40%" />
<img src="imgs/appVideo.gif" width="40%" />
</p>

## 🏁 Getting Started
Expand All @@ -33,20 +33,20 @@
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
}
```
* `action` : Functions to execute

#### 🛠Custom Modifiers
```Swift
CMPressableButton(action: { YOUR ACTION }) {
PressableButton(action: { YOUR ACTION }) {
// YOUR VIEW
}.accentColor(_ color: color)
.cornerRadius(_ amount: CGFloat)
Expand All @@ -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)
Expand All @@ -77,17 +77,17 @@ struct ContentView: View {
```
#### Result
<p float="left">
<img src="src/Example-simple-1.png" width="25%">
<img src="src/Example-simple-2.png" width="25%">
<img src="imgs/Example-simple-1.png" width="25%">
<img src="imgs/Example-simple-2.png" width="25%">
</p>

### 🛠 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)
Expand All @@ -101,8 +101,8 @@ struct ContentView: View {

### Result
<p float="left">
<img src="src/Example-customModifier-1.png" width="25%">
<img src="src/Example-customModifier-2.png" width="25%">
<img src="imgs/Example-customModifier-1.png" width="25%">
<img src="imgs/Example-customModifier-2.png" width="25%">
</p>

## ✅ TODO
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
import SwiftUI

public struct CMPressableButton<Content: View> : 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<Content: View> : View{
@State var isPressed: Bool = false
var color: Color = Color(.sRGB, red: 50/255, green: 200/255, blue: 165/255)
var cornerRadius: CGFloat = 5
Expand Down Expand Up @@ -71,9 +87,9 @@ public struct CMPressableButton<Content: View> : 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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

enum CMPressableButtonStyle {
enum PressableButtonStyle {
case FlatStyle
case RoundedStyle
case PushButtonStyle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// File.swift
// TouchEventModifier.swift
//
//
// Created by 변경민 on 2020/12/30.
Expand Down
15 changes: 0 additions & 15 deletions Tests/CMPressableButtonTests/CMPressableButtonTests.swift

This file was deleted.

9 changes: 0 additions & 9 deletions Tests/CMPressableButtonTests/XCTestManifests.swift

This file was deleted.

7 changes: 0 additions & 7 deletions Tests/LinuxMain.swift

This file was deleted.

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes

0 comments on commit 5d14b9a

Please sign in to comment.