• Stars
    star
    206
  • Rank 184,543 (Top 4 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple motion detector for ⌚️ (watchOS) shake gesture.

WatchShaker

Simple motion detector for ⌚️ (watchOS) shake gesture.

Swift Version Platform github workflow DOI License


WatchShaker is a watchOS helper to get your ⌚️ shake movements

Requirements

  • watchOS 6.0+
  • Xcode 14.0+

Installation

Swift Package Manager

Once you have your Swift package set up, adding WatchShaker as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/ezefranca/WatchShaker.git")
]

Manually

  1. Download and drop WatchShaker folder in your project to your watch target.
  2. Congratulations!

Usage example

@StateObject style

import SwiftUI
import WatchShaker

struct ContentView: View {
    
    @StateObject var shaker:WatchShaker = WatchShaker(shakeSensibility: .shakeSensibilityNormal, delay: 0.2)
    
    var body: some View {
        VStack {
            if shaker.isShakerAvailable {
                Text("I'm shook! ⌚️⌚️⌚️")
                Text("\(shaker.shake.sensibility)")
                Text("\(shaker.shake.direction)")
            }
        }
    }
}

Closure Style

import WatchKit
import Foundation
import WatchShaker

class InterfaceController: WKInterfaceController {
    
    var shaker:WatchShaker = WatchShaker(shakeSensibility: .shakeSensibilityNormal, delay: 0.2)
    
    override func awake(withContext context: Any?) {
        super.awake(withContext: context)
    }
    
    override func willActivate() {
        super.willActivate()
        
        shaker.start()
        
        shaker.startWatchShakerUpdates = { shakeSensibility, error in
            
            guard error == nil else
            {
                print(error?.localizedDescription)
                return
            }
            print("I'm shook! ⌚️⌚️⌚️")
        }
    }
    
    override func didDeactivate() {
        super.didDeactivate()
        shaker.stop()
    }

}

Delegate Style

import WatchKit
import Foundation


class InterfaceController: WKInterfaceController {

    override func awake(withContext context: Any?) {
        super.awake(withContext: context)
        // Configure interface objects here.
    }

    var shaker:WatchShaker = WatchShaker(shakeSensibility: .shakeSensibilityNormal, delay: 0.2)

    override func willActivate() {

        super.willActivate()
        shaker.delegate = self
        shaker.start()
    }

    override func didDeactivate() {

        super.didDeactivate()
        shaker.stop()

    }

}

extension InterfaceController: WatchShakerDelegate
{
    func watchShaker(_ watchShaker: WatchShaker, didShakeWith sensibility: ShakeSensibility) {
        print("I'm shook! ⌚️⌚️⌚️")
    }

    func watchShaker(_ watchShaker: WatchShaker, didFailWith error: Error) {
        print(error.localizedDescription)
    }
}

Optional Directions

If you interested you can get the direction of the shake on the didShakeWith method.

func watchShaker(_ watchShaker: WatchShaker, didShakeWith sensibility: ShakeSensibility, 
                     direction: ShakeDirection) {
    print("I'm shook! ⌚️⌚️⌚️ \(direction)")
}

ShakeDirection is a simple enum who gives you up, down, left or right direction. The image bellow is the way used to determine what is each direction.


This gentleman bellow for example, is clearly doing a shake with ShakeDirection.shakeDirectionRight 😂


Contribute

We would love for you to contribute to WatchShaker, check the LICENSE file for more info.

Meta

Docs: Here

Ezequiel França – @ezefranca and all awesome Contributors

Distributed under the MIT license. See LICENSE for more information.

More Repositories

1

watchpresenter

⌚️ 🤓 Controlling your Keynote using Apple Watch
Swift
161
star
2

EFInternetIndicator

❌📱 A little swift Internet error status indicator using ReachabilitySwift
Swift
129
star
3

campeonato-brasileiro-api

API simples do Campeonato Brasileiro
JavaScript
83
star
4

FSK-Arduino-iOS

〰️ FSK Library for iOS interface with Arduino Development
Objective-C
81
star
5

EFImageViewZoom

DEPRECATED 🌃 A very simple IBDesignable UIImageView with pinch zoom swift
Swift
71
star
6

TDC-iOS

🇧🇷 :octocat: Repositório com dados das palestras e palestrantes do TDC na trilha iOS
Swift
54
star
7

brazil-ios-utils

🇧🇷 Utils libraries for specific use cases / business in Brazil
Swift
31
star
8

the-missing-apple-watch-loader

The missing apple watch loader ⌚️
Swift
24
star
9

datamuse-swift

A datamuse api swift wrapper without dependencies
Swift
22
star
10

TabbarControllerHideable

A drop in UITabbarController with show and hide options
Swift
18
star
11

testam-em-animais

Webservice da lista de empresas e produtos que efetuam testes em animais do portal Vista-se.
JavaScript
16
star
12

EFArduinoBLE

Kit IoT Wearable iOS http://iot.telefonicabeta.com/kit-iot-wearable
Objective-C
8
star
13

SpeedManagerModule

Simple Speedometer class to iOS and WatchOS.
Swift
7
star
14

EFIntroVideoViewController

A very simple IBDesignable Video Intro ViewController.
Swift
7
star
15

youtube-metadata-from-url

Simple module to get a video metadata from url
JavaScript
5
star
16

arduino-sketches

My arduino sketches backup
C++
5
star
17

m001-mongodb-basics

🍃 M001: MongoDB Basics - Fundamentals of MongoDB
JavaScript
4
star
18

iFodasse

iFodasse - o aplicativo do foda-se
3
star
19

facebook-bot-and-arduino

🤖 💡 Comunicação entre um bot do messenger do Facebook e Arduino Intel Galileo através de http pulling.
JavaScript
3
star
20

slides-cocoaheads-sp

Repositório com dados das palestras e palestrantes do CocoaHeads SP
3
star
21

api-ai-arduino-client

Arduino library for Api.ai
C++
3
star
22

yellow-app-reverse

Estudo de engenharia reversa da API do aplicativo Yellow 🚲🛴
3
star
23

nodeMCUTDCFloripa

Slides e exemplo na apresentação sobre NodeMCU no TDC Florianopolis 2017
Arduino
3
star
24

iOS-BLE-Terminal

Sample iOS app to demonstrate the bidirectional communication with Red Bear Lab BLE Shield for Arduino.
Objective-C
3
star
25

FavoritesManager

FavoritesManager is a lightweight and easy-to-use package for managing favorite items using iCloud in your Swift project.
Swift
3
star
26

ble-HM

Ble example iOS to module HM family
Objective-C
2
star
27

udacity-ios-nanodegree

My projects developed to Udacity iOS Nanodegree
Swift
2
star
28

sptrans-olho-vivo-iOS

Estudo muito simples de como acessar a API "Olho Vivo" da SPTrans em iOS
Objective-C
2
star
29

hackerrank-30-days

30 Days of Code is an opportunity for you to learn how to code or brush up on your fundamentals.
Python
2
star
30

speakerdeck-widget

A very simple Speaker Deck Widget to show yours last talks. Just two html lines.
HTML
2
star
31

Master-Exploder

Rock-Paper-Scissor game controlled by computer vision, in identification of hand gestures (hand-tracking). The proposed work is based on image segmentation and construction of a convex hull with Jarvis’s Algorithm, and determination of the pattern based on the extraction of area characteristics in the convex hull
C
2
star
32

SPTransSwift

Biblioteca Wrapper para acesso a API Olho Vivo da SPTrans
Swift
1
star
33

tomcat-viewer

A very simple macOS application to start/stop/open Java Tomcat without terminal
Objective-C
1
star
34

bepid-senac-sp

Projects in Bepid - (Brazilian Education Program for iOS Development) from second stage in SENAC-SP
Objective-C
1
star
35

always-remeber-arthur-do-val

1
star
36

SwiftLint-GitHooks

Small test with Git hooks and SwiftLint
Swift
1
star
37

Flip-Playground

Super Simple SwiftUI custom modifier to Flip Views.
Swift
1
star
38

iOS-Serial-Terminal

iOS sample app to demonstrate the usage of the Redpark TTL cable.
Objective-C
1
star
39

linear-algebra-swift

Refresh study of Linear Algebra using Swift
Swift
1
star
40

regular-show-generator

Generate image with regular show background and font
1
star
41

bolhadev

Ranking da #bolhadev no Twitter
JavaScript
1
star
42

LogiKiD-Allegro5-Game

LOGIKID 2013 - Proposta de um jogo Educativo
C
1
star
43

iBafometro

Breathanalyzer with arduino and iOS
Objective-C
1
star
44

map-filter-reduce-equinocios

📍 Playground com os exemplos de map, filter e reduce
Swift
1
star
45

frutas

Calculadora de frutas
1
star
46

vegan-list-sp

List of Vegans (or with options) restaurants, bar's and cafe's in SP
JavaScript
1
star
47

yuv_uiimage

Objective-C
1
star
48

happy-cow-api

JavaScript
1
star
49

Pi-Berto

Facebook posts and Checkin from Raspberry Pi
Python
1
star
50

MECHANIC-TURTLE-HERBICIDE

Projeto Integrador 4 -- Bacharelado em Ciência da Computação - Centro Universitário Senac
Python
1
star
51

tracking-image

Simple Tracking image in Unity (iOS, Android) using ARFoundation
C#
1
star
52

vegamoji-server

Server application to search recipes from chatbot
JavaScript
1
star
53

aprendizados-js

🐸 anotações.
1
star
54

ClickSign-iOS

A Wrapper Library to ClickSign https://www.clicksign.com to iOS
Swift
1
star
55

raspberry-pi-swift

Raspberry Pi Study and Examples with Swift
1
star
56

py-microscope

Um microscópio construido a partir de uma webcam USB e a visualização feita com Python.
Python
1
star
57

check-service

My dummy project to check status of API entrys
1
star
58

hackathon-instagram-track

Track images posted on Instagram with the hashtag #hackathon
1
star
59

lista-impropria-api

O lista-impropria-api é um módulo para consulta da lista de empresas listadas como impróprias pelo portal Vista-se.
JavaScript
1
star
60

tensorflow-lite-ios

TensorFlow Lite iOS
Swift
1
star
61

EFJailbreak

My simple jailbreak detection using DTTJailbreak classes
Objective-C
1
star
62

pichando-sampa

👮🏻 Agora você pode pixar o borba gato no conforto do seu lar
HTML
1
star
63

statistics

10 Days of Statistics - Hacker Rank
Swift
1
star
64

swift-json-stringfy

the simplest way to print a human readable json string in Swift
Swift
1
star