9 Commits

Author SHA1 Message Date
Sapozhnik Ivan 76733940b2 Update README.md 2021-11-19 23:04:48 +01:00
Sapozhnik Ivan a58be98a55 Update README.md 2020-09-15 11:22:31 +02:00
Sapozhnik Ivan 5f506926e0 Update README.md 2020-04-23 14:57:03 +02:00
Ivan Sapozhnik bde7399d29 Merge branch 'master' of https://github.com/iSapozhnik/Menu
# Conflicts:
#	README.md
2020-04-23 14:55:42 +02:00
Ivan Sapozhnik bcf6ce5e79 update readme 2020-04-23 14:53:23 +02:00
Sapozhnik Ivan 85a7c47899 Update README.md 2020-04-22 21:47:42 +02:00
Sapozhnik Ivan a0ab9eb3db Merge pull request #9 from iSapozhnik/feature/spacing-between-items
Spacing between items
2020-04-22 21:44:58 +02:00
Ivan Sapozhnik 322413636d Spacing between items 2020-04-22 21:43:25 +02:00
Sapozhnik Ivan e6489c051b Update README.md 2020-04-22 21:37:02 +02:00
7 changed files with 55 additions and 7 deletions
+11 -6
View File
@@ -5,6 +5,7 @@
![Swift](https://img.shields.io/badge/%20in-swift%205.0-orange.svg)
![macOS](https://img.shields.io/badge/macOS-10.12-green.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FiSapozhnik%2FMenu%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/iSapozhnik/Menu)
</div>
@@ -27,7 +28,7 @@ Update your `Package.swift` dependencies:
```
dependencies: [
.package(url: "https://github.com/iSapozhnik/Menu", from: "1.0.8")
.package(url: "https://github.com/iSapozhnik/Menu", from: "1.10.1")
]
```
@@ -47,6 +48,7 @@ public protocol Configuration {
var cornerRadius: CGFloat { get }
var hasShadow: Bool { get }
var appearsBelowSender: Bool { get }
var presentingOffset: CGFloat { get }
var animationDuration: TimeInterval { get }
var contentEdgeInsets: NSEdgeInsets { get }
var maximumContentHeight: CGFloat? { get }
@@ -66,6 +68,7 @@ public protocol Configuration {
var menuItemHoverCheckmarkColor: NSColor { get }
var menuItemCheckmarkHeight: CGFloat { get }
var menuItemCheckmarkThikness: CGFloat { get }
var menuItemHorizontalSpacing: CGFloat { get }
var menuItemImageHeight: CGFloat? { get }
var menuItemImageTintColor: NSColor? { get }
var menuItemHoverImageTintColor: NSColor? { get }
@@ -119,7 +122,7 @@ class ViewController: NSViewController {
myMenu.addItems(menuItems)
}
@IBAction func didClickedButton(_ sender: NSButton) {
@IBAction func didClickButton(_ sender: NSButton) {
myMenu.show(from: sender)
}
}
@@ -127,12 +130,14 @@ class ViewController: NSViewController {
## Examples
In this section I've collected some examples of what can be implemented by using **Menu** control. On the left side some random examples from Dribbble and on the right side there is my implementation.
In this section I've collected some examples of what can be i,plemented do using **Menu** control. On the left side some random example from Dribbble and on the right side my implementation.
| Dribbble | Menu |
| ------------- |:-------------:|
| Dribbble | Menu | Code |
| ------------- |:-------------:|:-------------:|
| [link](https://dribbble.com/shots/4233782-Snooze-notifications-in-Twist) | |
| ![](examples/twist.png) | ![](examples/example_twist.png) |
| ![](examples/twist.png) | ![](examples/menu_twist.png) | |
| [link](https://dribbble.com/shots/7055473-Dropdowns) | | |
| ![](examples/example_0.png) | ![](examples/menu_0.png) | [code](examples/examples.md) |
## Credits
+5
View File
@@ -74,6 +74,7 @@ public protocol Configuration {
var menuItemHoverCheckmarkColor: NSColor { get }
var menuItemCheckmarkHeight: CGFloat { get }
var menuItemCheckmarkThikness: CGFloat { get }
var menuItemHorizontalSpacing: CGFloat { get }
var menuItemImageHeight: CGFloat? { get }
var menuItemImageTintColor: NSColor? { get }
var menuItemHoverImageTintColor: NSColor? { get }
@@ -191,6 +192,10 @@ open class MenuConfiguration: Configuration {
return 1.0
}
open var menuItemHorizontalSpacing: CGFloat {
return .grid1
}
open var menuItemImageHeight: CGFloat? {
return .grid3
}
+1 -1
View File
@@ -151,7 +151,7 @@ class MenuElement: NSView {
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.orientation = .horizontal
stackView.distribution = .fill
stackView.spacing = .grid1
stackView.spacing = configuration.menuItemHorizontalSpacing
return stackView
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

+38
View File
@@ -0,0 +1,38 @@
## Example
![](menu_0.png)
### Code:
```
class Config: MenuConfiguration {
override var cornerRadius: CGFloat {
return 15.0
}
override var backgroundColor: NSColor {
return NSColor(red: 63/255, green: 59/255, blue: 59/255, alpha: 1.0)
}
override var menuItemHoverBackgroundColor: NSColor {
return NSColor(red: 86/255, green: 81/255, blue: 81/255, alpha: 1.0)
}
override var menuItemHoverCornerRadius: CGFloat {
return 10.0
}
override var contentEdgeInsets: NSEdgeInsets {
return NSEdgeInsets(top: 8, left: 16, bottom: 8, right: 16)
}
override var menuItemHeight: CGFloat {
return 40.0
}
override var menuItemHoverEdgeInsets: NSEdgeInsets {
return NSEdgeInsets(top: 0, left: 8, bottom: 0, right: 8)
}
}
```
Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB