Skip to content

Commit a8e3250

Browse files
Merge pull request #5 from SimformSolutionsPvtLtd/feature/UNT-T20561-update-example-and-readme
UNT-T20561: Add a tap to close feature and update ReadMe
2 parents 1684e78 + 571ef45 commit a8e3250

File tree

7 files changed

+64
-45
lines changed

7 files changed

+64
-45
lines changed

Example/SSSwiftUISideMenuDemo/Container Views/Home.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct Home: View {
3030

3131
// State variables for various configuration options
3232
@State private var menuDirection = 0
33+
@State private var tapToClose = true
3334
@State private var swipeToClose = true
3435
@State private var titleColor: Color = .black
3536
@State private var iconTintColor: Color = .pink
@@ -47,7 +48,8 @@ struct Home: View {
4748
backgroundColor: backgroundColor,
4849
animationType: selectedAnimation,
4950
menuDirection: menuDirection == 0 ? .left : .right,
50-
swipeToClose: swipeToClose
51+
swipeToClose: swipeToClose,
52+
tapToClose: tapToClose
5153
)
5254
}
5355

@@ -78,6 +80,9 @@ struct Home: View {
7880
}
7981
.pickerStyle(.menu)
8082

83+
// Toggle for tap to close menu
84+
Toggle("Tap to close menu", isOn: $tapToClose)
85+
8186
// Toggle for swipe to close menu
8287
Toggle("Swipe to close menu", isOn: $swipeToClose)
8388
}
@@ -121,7 +126,7 @@ struct Home: View {
121126
.padding(.horizontal, -20)
122127
.listRowInsets(EdgeInsets())
123128
}
124-
.navigationBarTitle("SSSwiftUI SideMenu", displayMode: .inline)
129+
.navigationBarTitle("SSSwiftUISideMenu", displayMode: .inline)
125130
}
126131
.padding(.horizontal, 24)
127132
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 mobile-simformsolutions
3+
Copyright (c) 2023 mobile-simformsolutions
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<a href="https://www.simform.com/"><img src="https://github.com/SimformSolutionsPvtLtd/SSToastMessage/blob/master/simformBanner.png"></a>
1+
![ScreenShot](/Resources/banner.png)
22

33
# SSSwiftUISideMenu
44

@@ -16,44 +16,49 @@ SwiftUI package for creating custom sidemenu with animation and flexible design
1616
**About SSSwiftUISideMenu**<br/>
1717
SSSwiftUISideMenu is highly customisable and easy to use Side menu control for iOS Applications. It support the SideMenu operations from left / right panel. user can navigate through the container views that added with the SideMenu MenuItems. It allows user to customise UI and animation style of their choice.
1818

19-
## Example
19+
### Prerequisites
20+
- iOS 13.0+
21+
- Xcode 11.0+
22+
- [CocoaPods](http://cocoapods.org/)
2023

21-
To run the example project, clone the repo, and run `pod install` from the Example directory first.
24+
## Example
2225

23-
## Requirements
26+
![ScreenShot](/Resources/SSSwiftUISideMenu_example.gif)
2427

25-
This pod requires a deployment target of iOS 13.0 or greater
28+
- To run the example project, clone the repo, and run `pod install` from the Example directory first.
2629

27-
## Installation
30+
# Installation
31+
#### CocoaPods
2832

29-
### Cocoapods
33+
- You can use CocoaPods to install `SSSwiftUISideMenu` by adding it to your Podfile:
3034

31-
SSSwiftUISideMenu is available through [CocoaPods](https://cocoapods.org). <br/>To install
32-
it, simply add the following line to your Podfile:
35+
use_frameworks!
36+
pod 'SSSwiftUISideMenu'
3337

34-
```ruby
35-
pod 'SSSwiftUISideMenu'
36-
```
37-
and run `pod install` from the root directory of project and in your code add `import SSSwiftUISideMenu` and boom you're done.💥
38+
- Import SSSwiftUISideMenu in your file:
3839

39-
### Swift Package Manager
40+
import SSSwiftUISideMenu
4041

41-
When using Xcode 11 or later, you can install `SSLineChart` through [Swift Package Manager](https://swift.org/package-manager/) by going to your Project settings > `Swift Packages` and add the repository by providing the GitHub URL. Alternatively, you can go to `File` > `Swift Packages` > `Add Package Dependencies...`
42+
**Manually**
43+
- Download and drop **SSSwiftUISideMenu/Sources** folder in your project.
44+
- Grab yourself a cold 🍺.
4245

43-
### Manually
46+
#### Swift Package Manager (SPM)
47+
- When using Xcode 11 or later, you can install `SSSwiftUISideMenu` by going to your Project settings > `Swift Packages` and add the repository by providing the GitHub URL. Alternatively, you can go to `File` > `Swift Packages` > `Add Package Dependencies...`
4448

45-
1. Add `SSSwiftUISideMenu.swift` and `SSMenuConfig.swift` to your project.
46-
2. Grab yourself a cold 🍺.
49+
dependencies: [
50+
.package(url: "https://github.com/mobile-simformsolutions/SSSwiftUISideMenu.git", from: "1.0.0")
51+
]
4752

48-
## Usage
53+
# Usage Examples
4954

50-
Import the package in the file you would like to use it:
55+
- Import the package in the file you would like to use it:
5156

5257
```swiftui
5358
import SSSwiftUISideMenu
5459
```
5560

56-
This library shares one View which you can use as a sidemenu with many customizations like UI, animation, direction and many more.
61+
- This library shares one View which you can use as a sidemenu with many customizations like UI, animation, direction and many more.
5762
Basic example:
5863

5964
```swift
@@ -74,13 +79,12 @@ var body: some Scene {
7479
```
7580
The results of any interaction from sidemenu item will available in declared selectedIndex state variable. Also sidemnu open / close toggle value will be available in the openSideMenu state variable.
7681

77-
Customizations
78-
===
82+
# Customizations
7983

80-
You can customize almost every main thing in this library.
81-
For Customizations you have to pass another value of `menuConfig` during call of SSSwiftUISideMenu. This menuConfig argument is optional as well as Every arguments in `SSMenuConfig` is also Optional. So, you need to add only those arguments which yo wanted to customize. Here's the examples :
84+
- You can customize almost every main thing in this library.
85+
- For Customizations you have to pass another value of `menuConfig` during call of SSSwiftUISideMenu. This menuConfig argument is optional as well as Every arguments in `SSMenuConfig` is also Optional. So, you need to add only those arguments which yo wanted to customize. Here's the examples :
8286

83-
Change in Style
87+
## Change in Style
8488
-----
8589
*An example of customisation of styles*
8690

@@ -94,7 +98,7 @@ var body: some Scene {
9498
}
9599
```
96100

97-
Change SideMenu direction - Left / Right
101+
## Change SideMenu direction - Left / Right
98102
-----
99103
*An example of change sidemenu direction. left direction is default*
100104

@@ -106,7 +110,7 @@ var body: some Scene {
106110
}
107111
```
108112

109-
Add animation to your sidemenu
113+
## Add animation to your sidemenu
110114
-----
111115
*An example of applying a animation type to the sidemenu*
112116

@@ -118,10 +122,9 @@ var body: some Scene {
118122
}
119123
```
120124

121-
Other Customizations
122-
===
125+
# Other Customizations
123126

124-
SideMenu width
127+
#### SideMenu width
125128
----
126129
*You can change the menu width of your choice with the menuWidth. By default is '280'.*<br/>
127130

@@ -133,13 +136,13 @@ var body: some Scene {
133136
}
134137
```
135138

136-
Icon color and customizations
139+
#### Icon color and customizations
137140
-------
138141

139-
1. You can add leftIconPadding argument to change the icon padding from the left side of the sidemenu view.<br/>
140-
2. You can add imageToTitlePadding argument for adding a padding between a icon and title.<br/>
141-
3. You can add iconTintColor argument to change the icon tint color of your choice.<br/>
142-
4. You can add iconHeight and iconWidth argument change the size of the row icons.<br/>
142+
- You can add leftIconPadding argument to change the icon padding from the left side of the sidemenu view.<br/>
143+
- You can add imageToTitlePadding argument for adding a padding between a icon and title.<br/>
144+
- You can add iconTintColor argument to change the icon tint color of your choice.<br/>
145+
- You can add iconHeight and iconWidth argument change the size of the row icons.<br/>
143146

144147
```swift
145148

@@ -153,13 +156,13 @@ var body: some Scene {
153156
}
154157
```
155158

156-
Show App Version
159+
#### Show App Version
157160
-------
158161
*An example of showing your app version at bottom of the sidemenu. you can configure its style and color. All are optionally configured.*
159162

160-
1. Add showAppVersion argument to weather to show app versio or not. Default is false<br/>
161-
2. Add versionText argument for adding a pass the text of the version.<br/>
162-
3. Add versionTitleColor, versionAlignment or versionFont argument to change the font style and color of the version string.<br/>
163+
- Add showAppVersion argument to weather to show app versio or not. Default is false<br/>
164+
- Add versionText argument for adding a pass the text of the version.<br/>
165+
- Add versionTitleColor, versionAlignment or versionFont argument to change the font style and color of the version string.<br/>
163166

164167
```swift
165168

@@ -174,7 +177,7 @@ var body: some Scene {
174177

175178
## Coming Soon
176179

177-
1. Pass custom view directly to the sidemenu to create sidemenu of your choice.<br/>
180+
- Pass custom view directly to the sidemenu to create sidemenu of your choice.<br/>
178181

179182
**Up for a suggestions. Give suggestions for more features and customisations.**
180183

@@ -200,4 +203,3 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
200203
[PR-url]:http://makeapullrequest.com
201204
[swift-image]:https://img.shields.io/badge/swift-5.0-orange.svg
202205
[swift-url]: https://swift.org/
203-
459 KB
Loading

Resources/banner.png

1.76 MB
Loading

Sources/SSSwiftUISideMenu/SSMenuConfig.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public struct SSMenuConfig {
4444
private(set) var menuDirection: Directions
4545
/** Boolean for whether you want the menu close on swipe gesture . Default is: Enabled**/
4646
private(set) var swipeToClose: Bool
47+
/** Boolean for whether you want the close the menu on tap gesture(out side) . Default is: Enabled**/
48+
private(set) var tapToClose: Bool
4749
/** Boolean for whether you want to show App version . Default is: False**/
4850
private(set) var showAppVersion: Bool
4951
/** Specify the App version string . Default is: Empty**/
@@ -71,6 +73,7 @@ public struct SSMenuConfig {
7173
animationType: Animation = .default,
7274
menuDirection: Directions = .left,
7375
swipeToClose: Bool = true,
76+
tapToClose: Bool = true,
7477
showAppVersion: Bool = false,
7578
versionText: String = "",
7679
versionFont: Font = .caption,
@@ -92,6 +95,7 @@ public struct SSMenuConfig {
9295
self.animationType = animationType
9396
self.menuDirection = menuDirection
9497
self.swipeToClose = swipeToClose
98+
self.tapToClose = tapToClose
9599
self.showAppVersion = showAppVersion
96100
self.versionText = versionText
97101
self.versionFont = versionFont

Sources/SSSwiftUISideMenu/SSSwiftUISideMenu.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public struct SSSwiftUISideMenu: View {
6060
Button(action: {
6161
withAnimation(.spring()) {
6262
self.selectedIndex = value
63+
if menuConfig.tapToClose { return }
6364
self.openSideMenu.toggle()
6465
}
6566
}, label: {
@@ -121,6 +122,13 @@ public struct SSSwiftUISideMenu: View {
121122
}
122123
}
123124
})
125+
.gesture(
126+
TapGesture()
127+
.onEnded { _ in
128+
if !menuConfig.tapToClose { return }
129+
self.openSideMenu.toggle()
130+
}
131+
)
124132
}
125133

126134
}

0 commit comments

Comments
 (0)