matt54633/swtools
Installation
SWTools uses Swift Package Manager. Therefore, add https://github.com/matt54633/SWTools as a package dependency to your project.
Once installed, import SWTools where required using:
import SWToolsUsage
MacOS Detection
If using the MacOS(Designed for iPad) destination, running specific code for MacOS can be challenging. To simplify this process, use the isOnMac environment property:
@Environment(\.isOnMac) var isOnMac
if isOnMac {
// execute code
}iPad Detection
To detect if the current device in use is an iPad, use the isOnIpad environment property:
@Environment(\.isOnIpad) var isOnIpad
if isOnIpad {
// execute code
}Safe Area Detection
To detect the safe area insets of a device, use the safeAreaInsets environment property:
@Environment(\.safeAreaInsets) var safeAreaInsets
if safeAreaInsets.bottom > 20 {
// execute code
}Haptic Feedback
To provide simple haptic feedback, use the hapticFeedback function:
Rectangle()
.onTapGesture {
hapticFeedback(.medium)
}Shake Detection
To detect a shake gesture simply add the .onShake modifier to a View:
Rectangle()
.onShake {
// execute code
}Other Tools
Calendar Extensions
- Number of Days Between Dates
Color Extensions
- Return RGBA Components - Return HEX Code - Return HSL Components - Convert to Hex Code - Convert to HSL
See the source code for further information!
Package Metadata
Repository: matt54633/swtools
Default branch: main
README: README.md