Shake & Share is a SwiftUI-based iOS app designed to make real-world profile sharing intuitive and fun. Simply shake your iPhone to reveal options to share your profile via a QR code or AirDrop. The app also includes a persistent history of sharing activity and customizable settings, all wrapped in a playful, modern interface.
- Uses CoreMotion to detect shake gestures via the device's accelerometer
- Triggers the sharing menu UI upon detection
func startShakeDetection() {
motionManager.startAccelerometerUpdates(...) {
if isShake(acceleration) {
handleShake()
}
}
}- User chooses how to share their profile
- Automatically logs the method and timestamp
func showQRCode() {
showQR = true
logVM.addLog(method: "QR")
}
func shareViaAirDrop() {
isSharing = true
logVM.addLog(method: "AirDrop")
}- Generates a QR code from the user's set profile URL
- Displayed with animation and design enhancements
func generateQRCode(from string: String) -> UIImage {
... // using CoreImage
}- Keeps the last 10 share actions (QR or AirDrop)
- Stored via UserDefaults, persisted across sessions
struct ShareLog: Codable, Identifiable { ... }
class ShareLogViewModel: ObservableObject { ... }- First launch prompts for profile URL input
- User can change the URL anytime via the side menu
@AppStorage("userProfileURL") private var profileURL: String- Pull-tab style menu from the left side (width = 200pt)
- Includes buttons to edit URL or close the menu manually
- Background tap to dismiss the menu
if showMenu {
Color.black.opacity(0.001).onTapGesture { showMenu = false }
renderSideMenu()
}- App launches and optionally prompts for URL
- User shakes device
- Share options appear
- User selects QR or AirDrop
- Sharing method is logged
- Side menu available to update URL or view history
- SwiftUI for UI design
- CoreMotion for shake detection
- CoreImage for QR code generation
- UserDefaults via
@AppStorageand custom ViewModel - UIKit integration for AirDrop via
UIActivityViewController
MIT
Happy shaking & sharing! 🤝