-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for Cocoapods and Carthage Updating documentation Adding resources SwiftUIMenuExample Fixing image source in README
- Loading branch information
Fernando Moya de Rivas
committed
Feb 25, 2020
1 parent
e8f6e21
commit 2fc0645
Showing
30 changed files
with
1,229 additions
and
38 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
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
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
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 @@ | ||
// | ||
// ProfileHeader.swift | ||
// SwiftUIMenuExample | ||
// | ||
// Created by Fernando Moya de Rivas on 21/02/2020. | ||
// Copyright © 2020 Fernando Moya de Rivas. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ProfileHeader: View { | ||
var body: some View { | ||
HStack { | ||
Image("profile") | ||
.resizable() | ||
.frame(size: CGSize(width: 60, height: 60)) | ||
Spacer() | ||
VStack(alignment: .trailing) { | ||
Text("Name and surname") | ||
Text("email@example.com") | ||
.font(.system(size: 12)) | ||
.italic() | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct ProfileHeader_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ProfileHeader() | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Example/SwiftUIMenuExample/Support/Assets.xcassets/profile.imageset/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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "profile.jpg" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Binary file added
BIN
+107 KB
Example/SwiftUIMenuExample/Support/Assets.xcassets/profile.imageset/profile.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,3 +1,144 @@ | ||
# SwiftUIMenu | ||
|
||
A description of this package. | ||
[![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager) | ||
[![Cocoapods](https://img.shields.io/cocoapods/v/SwiftUIMenu.svg)](https://cocoapods.org/pods/SwiftUIMenu) | ||
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) | ||
[![CocoaPods platforms](https://img.shields.io/cocoapods/p/SwiftUIMenu.svg)](https://cocoapods.org/pods/SwiftUIMenu) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
|
||
SwiftUIMenu is a component that allows you to implement Menu Navigation Pattern in your App. `Menu` presents a content and a list of of options that's easily displayed by swiping or reacting to an external event such as a navbar button tap. | ||
|
||
## Requirements | ||
* iOS 13.0+ | ||
* macOS 10.15+ | ||
* watchOS 6.0+ | ||
* Swift 5.1+ | ||
|
||
## Installation | ||
|
||
### CocoaPods | ||
``` | ||
pod 'SwiftUIMenu' | ||
``` | ||
### Swift Package Manager | ||
|
||
Go to XCode: | ||
* File -> Swift Packages -> Add Package Dependency... | ||
* Use the URL https://github.com/fermoya/SwiftUIMenu.git | ||
|
||
### Carthage | ||
|
||
``` | ||
github "fermoya/SwiftUIMenu" | ||
``` | ||
|
||
## Usage | ||
|
||
### Initialization | ||
|
||
You can create a `Menu` by passing: | ||
- Binding to the selected index | ||
- Binding to determine if `Menu` is open | ||
- Array of items to populate the menu | ||
- `ViewBuilder` to build each row | ||
- `ViewBuilder` to build the content for the selected index | ||
|
||
```swift | ||
Menu(indexSelected: self.$index, | ||
isOpen: self.$isMenuOpen, | ||
menuItems: menuItems, | ||
menuItemRow: { index in | ||
Text("Option \(index)") | ||
}, | ||
menuItemContent: { section in | ||
Text("Welcome to section \(section)") | ||
}) | ||
}) | ||
``` | ||
|
||
<img src="resources/usage.gif" alt="Example of usage" height="640"/> | ||
|
||
### UI customization | ||
|
||
There're plenty of view-modifiers available to customize your `Menu` and give it a personal touch. You can specify its position, style or add a header, among others. | ||
|
||
By default, `Menu` is configured to: | ||
- Reveal from the left | ||
- Have an overlap style | ||
- Take up the whole screen | ||
- Allow dragging | ||
|
||
#### Alignment | ||
|
||
Changes the position of the menu so that it reveals from the left or right of the screen. | ||
|
||
```swift | ||
Menu(...) | ||
.alignment(.right) | ||
``` | ||
|
||
##### Left Menu | ||
|
||
<img src="resources/left-menu.gif" alt="Left menu" height="640"/> | ||
|
||
##### Right Menu | ||
|
||
<img src="resources/right-menu.gif" alt="Right menu" height="640"/> | ||
|
||
#### Header & Footer | ||
|
||
Use these modifiers to add a header and/or footer to `Menu`. | ||
|
||
```swift | ||
Menu(...) | ||
.header { MyMenuHeader() } | ||
.footer { MyMenuFooter() } | ||
``` | ||
|
||
<img src="resources/header-footer.gif" alt=Menu with header and footer" height="640"/> | ||
|
||
#### Style | ||
|
||
Adds a different effect to the way `Menu` is revealed. | ||
|
||
```swift | ||
Menu(...) | ||
.style(.stretch) | ||
``` | ||
|
||
##### Overlap | ||
|
||
<img src="resources/overlap.gif" alt="Overlap-style menu" height="640"/> | ||
|
||
##### Push | ||
|
||
<img src="resources/push.gif" alt="Push-style menu" height="640"/> | ||
|
||
##### Stretch | ||
|
||
<img src="resources/stretch.gif" alt="Stretch-style menu" height="640"/> | ||
|
||
#### More features | ||
|
||
You can also: | ||
- Change the ratio of available space that `Menu` will take up when open with `revealRatio` | ||
- Disable the `DragGesture` with `disableDragging` | ||
- Shade the content when `Menu` is open with `shadeContent` | ||
|
||
```swift | ||
Menu(...) | ||
.revealRatio(0.8) | ||
.shadeContent() | ||
``` | ||
|
||
### Sample projects | ||
|
||
For more information, please check the [sample app](/Example). | ||
|
||
Your feedback is more than welcome, don't hesitate to open an issue or ping me at [fmdr.ct@gmail.com](mailto:fmdr.ct@gmail.com). | ||
|
||
Feel free to collaborate and make this framework better. | ||
|
||
## License | ||
|
||
`SwiftUIMenu` is available under the MIT license. See the [LICENSE](/LICENSE) file for more info. |
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
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
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
Oops, something went wrong.