Skip to content

Commit 8287acb

Browse files
authored
Updated README.md
1 parent ea0ac6b commit 8287acb

File tree

1 file changed

+83
-64
lines changed

1 file changed

+83
-64
lines changed

README.md

Lines changed: 83 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -5,124 +5,132 @@
55
[![Carthage](https://img.shields.io/badge/Carthage-compatible-brightgreen.svg)](https://github.com/Carthage/Carthage)
66
[![SPM](https://img.shields.io/badge/SPM-compatible-brightgreen.svg)](https://swift.org/package-manager/)
77
[![Swift](https://img.shields.io/badge/Swift-5.9+-orange.svg)](https://swift.org)
8-
[![License](https://img.shields.io/github/license/efremidze/Magnetic.svg)](https://github.com/efremidze/Magnetic/blob/master/LICENSE)
8+
[![License](https://img.shields.io/github/license/efremidze/Magnetic.svg)](LICENSE)
99

10-
**Magnetic** is a customizable bubble picker like the Apple Music genre selection.
10+
**Magnetic** is a customizable bubble picker inspired by Apple Music’s genre selection.
1111

12-
<img src="/Images/demo2.gif" width="250" />
12+
<p align="center">
13+
<img src="/Images/demo2.gif" width="250" />
14+
</p>
1315

16+
```sh
17+
pod try Magnetic
1418
```
15-
$ pod try Magnetic
16-
```
1719

18-
## Features
20+
---
21+
22+
## ✨ Features
23+
24+
- Add/remove nodes dynamically
25+
- Smooth selection/deselection/removal animations
26+
- Multiple selection support
27+
- Node images and multiline labels
28+
- [Documentation](https://efremidze.github.io/Magnetic)
1929

20-
- [x] Adding/Removing Nodes
21-
- [x] Selection/Deselection/Removed Animations
22-
- [x] Multiple Selection
23-
- [x] Images
24-
- [x] Multiline Label
25-
- [x] [Documentation](https://efremidze.github.io/Magnetic)
30+
---
2631

27-
## Requirements
32+
## 📋 Requirements
2833

29-
- iOS 13.0+ (Magnetic 3.3.x), iOS 9.0+ (Magnetic 3.2.1)
30-
- Swift 5 (Magnetic 3.x), Swift 4 (Magnetic 2.x), Swift 3 (Magnetic 1.x)
34+
| Version | iOS | Swift |
35+
|----------------|------------|----------|
36+
| Magnetic 3.3.x | iOS 13.0+ | Swift 5 |
37+
| Magnetic 3.2.1 | iOS 9.0+ | Swift 5 |
38+
| Magnetic 2.x | iOS 9.0+ | Swift 4 |
39+
| Magnetic 1.x | iOS 9.0+ | Swift 3 |
3140

32-
## Usage
41+
---
3342

34-
A `Magnetic` object is an [SKScene](https://developer.apple.com/reference/spritekit/skscene).
43+
## 🚀 Usage
3544

36-
To display, you present it from an [SKView](https://developer.apple.com/reference/spritekit/skview) object.
45+
`Magnetic` is an [`SKScene`](https://developer.apple.com/documentation/spritekit/skscene) subclass that is presented from an [`SKView`](https://developer.apple.com/documentation/spritekit/skview).
3746

3847
```swift
3948
import Magnetic
4049

4150
class ViewController: UIViewController {
4251

4352
var magnetic: Magnetic?
44-
53+
4554
override func loadView() {
4655
super.loadView()
47-
48-
let magneticView = MagneticView(frame: self.view.bounds)
56+
let magneticView = MagneticView(frame: view.bounds)
4957
magnetic = magneticView.magnetic
50-
self.view.addSubview(magneticView)
58+
view.addSubview(magneticView)
5159
}
52-
5360
}
5461
```
5562

56-
#### Properties
63+
### 🧠 Properties
5764

5865
```swift
59-
var magneticDelegate: MagneticDelegate? // magnetic delegate
60-
var allowsMultipleSelection: Bool // controls whether you can select multiple nodes. defaults to true
61-
var selectedChildren: [Node] // returns selected chidren
66+
var magneticDelegate: MagneticDelegate? // Delegate
67+
var allowsMultipleSelection: Bool // Defaults to true
68+
var selectedChildren: [Node] // Currently selected nodes
6269
```
6370

64-
### Nodes
71+
---
6572

66-
A `Node` object is a SKShapeNode subclass.
73+
## 🟣 Nodes
6774

68-
#### Interaction
75+
A `Node` is a subclass of `SKShapeNode`.
76+
77+
### ➕ Interaction
6978

7079
```swift
71-
// add circular node
7280
let node = Node(text: "Italy", image: UIImage(named: "italy"), color: .red, radius: 30)
7381
magnetic.addChild(node)
7482

75-
// add custom node
76-
let node = Node(text: "France", image: UIImage(named: "france"), color: .blue, path: path, marginScale: 1.1)
77-
magnetic.addChild(node)
83+
let customNode = Node(text: "France", image: UIImage(named: "france"), color: .blue, path: path, marginScale: 1.1)
84+
magnetic.addChild(customNode)
7885

79-
// remove node
8086
node.removeFromParent()
8187
```
8288

83-
#### Properties
89+
### ⚙️ Node Properties
8490

8591
```swift
86-
var text: String? // node text
87-
var image: UIImage? // node image
88-
var color: UIColor // node color
92+
var text: String?
93+
var image: UIImage?
94+
var color: UIColor
8995
```
9096

91-
#### Animations
97+
### 🎞️ Animations
9298

9399
```swift
94100
override func selectedAnimation() {
95-
// override selected animation
101+
// Customize selected animation
96102
}
97103

98104
override func deselectedAnimation() {
99-
// override deselected animation
105+
// Customize deselected animation
100106
}
101107

102108
override func removedAnimation(completion: @escaping () -> Void) {
103-
// override removed animation
109+
// Customize removal animation
104110
}
105111
```
106112

107-
### Delegation
113+
---
108114

109-
The `MagneticDelegate` protocol provides a number of functions for observing the current state of nodes.
115+
## 🔄 Delegation
116+
117+
Use `MagneticDelegate` to observe selection state changes:
110118

111119
```swift
112120
func magnetic(_ magnetic: Magnetic, didSelect node: Node) {
113-
// handle node selection
121+
// Handle selection
114122
}
115123

116124
func magnetic(_ magnetic: Magnetic, didDeselect node: Node) {
117-
// handle node deselection
125+
// Handle deselection
118126
}
119127
```
120128

121-
### Customization
129+
---
122130

123-
Subclass the Node for customization.
131+
## 🎨 Customization
124132

125-
For example, a node with an image by default:
133+
Subclass `Node` to define your own behavior or visuals:
126134

127135
```swift
128136
class ImageNode: Node {
@@ -131,40 +139,51 @@ class ImageNode: Node {
131139
texture = image.map { SKTexture(image: $0) }
132140
}
133141
}
142+
134143
override func selectedAnimation() {}
135144
override func deselectedAnimation() {}
136145
}
137146
```
138147

139-
## Installation
148+
---
149+
150+
## 📦 Installation
140151

141152
### CocoaPods
142-
To install with [CocoaPods](http://cocoapods.org/), simply add this in your `Podfile`:
153+
143154
```ruby
144155
use_frameworks!
145156
pod "Magnetic"
146157
```
147158

148159
### Carthage
149-
To install with [Carthage](https://github.com/Carthage/Carthage), simply add this in your `Cartfile`:
150-
```ruby
160+
161+
```bash
151162
github "efremidze/Magnetic"
152163
```
153164

154-
## Mentions
165+
---
166+
167+
## 📰 Mentions
168+
169+
- [Natasha The Robot's Newsletter #126](https://swiftnews.curated.co/issues/126#start)
170+
171+
---
172+
173+
## 🤝 Contributing
155174

156-
- [Natasha The Robot's Newsleter 126](https://swiftnews.curated.co/issues/126#start)
175+
- Found a bug? [Open an issue](https://github.com/efremidze/Magnetic/issues)
176+
- Have a feature request? [Open an issue](https://github.com/efremidze/Magnetic/issues)
177+
- Want to contribute? [Submit a pull request](https://github.com/efremidze/Magnetic/pulls)
157178

158-
## Communication
179+
---
159180

160-
- If you **found a bug**, open an issue.
161-
- If you **have a feature request**, open an issue.
162-
- If you **want to contribute**, submit a pull request.
181+
## 🙏 Acknowledgments
163182

164-
## Credits
183+
Inspired by [igalata/Bubble-Picker](https://github.com/igalata/Bubble-Picker)
165184

166-
https://github.com/igalata/Bubble-Picker
185+
---
167186

168-
## License
187+
## 📄 License
169188

170-
Magnetic is available under the MIT license. See the LICENSE file for more info.
189+
Magnetic is available under the MIT license. See the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)