Skip to content

Commit e60a9ff

Browse files
authored
Merge pull request #1 from Navideck/add_example
Add example
2 parents 8d3799b + 137cc5f commit e60a9ff

File tree

49 files changed

+1626
-664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1626
-664
lines changed

.build/workspace-state.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"object" : {
3+
"artifacts" : [
4+
{
5+
"kind" : "xcframework",
6+
"packageRef" : {
7+
"identity" : "public",
8+
"kind" : "root",
9+
"location" : "/Users/rohitsangwan/Drive/Devlopment/Navideck/gesturedeck_sdk/gesturedeck_sdk_ios/public",
10+
"name" : "public"
11+
},
12+
"path" : "/Users/rohitsangwan/Drive/Devlopment/Navideck/gesturedeck_sdk/gesturedeck_sdk_ios/public/GesturedeckiOS.xcframework",
13+
"source" : {
14+
"type" : "local"
15+
},
16+
"targetName" : "GesturedeckiOS"
17+
}
18+
],
19+
"dependencies" : [
20+
21+
]
22+
},
23+
"version" : 6
24+
}

README.md

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,42 @@ import GesturedeckiOS
4848

4949
Select one of the following options based on your app's setup:
5050

51-
##### Option 1: Using AppDelegate
51+
##### Option 1: SwiftUI
5252

53-
It is recommended to initialize the SDK in the `applicationDidBecomeActive` or later event, as the window might not be initialized in the `didFinishLaunchingWithOptions` lifecycle event. Make sure that you avoid initializing Gesturedeck multiple times.
53+
If you're using SwiftUI, there is no need for AppDelegate or SceneDelegate.
5454

5555
```swift
56-
class AppDelegate: UIResponder, UIApplicationDelegate {
56+
@main
57+
struct gesturedeckApp: App {
58+
@Environment(\.scenePhase) var scenePhase
59+
@State var gesturedeck: Gesturedeck?
60+
```
5761

58-
var window: UIWindow?
59-
var gesturedeck: Gesturedeck?
62+
```swift
63+
var body: some Scene {
64+
WindowGroup {
65+
...
66+
}
67+
.onChange(of: scenePhase) { oldValue, newValue in
68+
if newValue == .active {
69+
gesturedeck = gesturedeck ?? Gesturedeck()
70+
gesturedeck?.tapAction = {
71+
print("Tapped")
72+
}
6073

61-
func applicationDidBecomeActive(_ application: UIApplication) {
62-
// Initialize Gesturedeck
63-
gesturedeck = gesturedeck ?? Gesturedeck()
64-
}
74+
gesturedeck?.swipeLeftAction = {
75+
print("Swiped Left")
76+
}
77+
78+
gesturedeck?.swipeRightAction = {
79+
print("Swiped Right")
80+
}
81+
}
82+
}
6583
}
6684
```
6785

68-
##### Option 2: Using SceneDelegate
86+
##### Option 2: UIKit / SceneDelegate
6987

7088
Initialize the SDK in the `sceneDidBecomeActive` event or later. Make sure that you avoid initializing Gesturedeck multiple times.
7189

@@ -97,38 +115,20 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
97115
}
98116
```
99117

100-
##### Option 3: SwiftUI Integration
118+
##### Option 3: UIKit / AppDelegate
101119

102-
If you're using SwiftUI, there is no need for AppDelegate or SceneDelegate.
103-
104-
```swift
105-
@main
106-
struct gesturedeckApp: App {
107-
@Environment(\.scenePhase) var scenePhase
108-
@State var gesturedeck: Gesturedeck?
109-
```
120+
It is recommended to initialize the SDK in the `applicationDidBecomeActive` or later event, as the window might not be initialized in the `didFinishLaunchingWithOptions` lifecycle event. Make sure that you avoid initializing Gesturedeck multiple times.
110121

111122
```swift
112-
var body: some Scene {
113-
WindowGroup {
114-
...
115-
}
116-
.onChange(of: scenePhase) { phase in
117-
if phase == .active {
118-
gesturedeck = gesturedeck ?? Gesturedeck()
119-
gesturedeck?.tapAction = {
120-
print("Tapped")
121-
}
123+
class AppDelegate: UIResponder, UIApplicationDelegate {
122124

123-
gesturedeck?.swipeLeftAction = {
124-
print("Swiped Left")
125-
}
125+
var window: UIWindow?
126+
var gesturedeck: Gesturedeck?
126127

127-
gesturedeck?.swipeRightAction = {
128-
print("Swiped Right")
129-
}
130-
}
131-
}
128+
func applicationDidBecomeActive(_ application: UIApplication) {
129+
// Initialize Gesturedeck
130+
gesturedeck = gesturedeck ?? Gesturedeck()
131+
}
132132
}
133133
```
134134

@@ -152,6 +152,8 @@ GesturedeckMedia is a specialized implementation built on top of Gesturedeck, ta
152152

153153
You can initialize GesturedeckMedia without any arguments and have **start/stop**, **skip next/previous** and **volume up/down** work out of the box. Note that due to iOS limitations, skip next/previous only works for the system media player.
154154

155+
When using the default gesture actions you need to add the `NSAppleMusicUsageDescription` key in your project's `Info` tab with a value explaining why you need this permission (e.g. `"Control music playback"`).
156+
155157
### Getting Started with GesturedeckMedia
156158

157159
To use GesturedeckMedia for showing media controls UI, follow these steps:
@@ -168,7 +170,6 @@ or initialize `GesturedeckMedia` with `GesturedeckMediaOverlay` and actions:
168170
let gesturedeckMedia = GesturedeckMedia(
169171
context: self,
170172
gesturedeckMediaOverlay: GesturedeckMediaOverlay(
171-
tintColor: UIColor(red: 28.0 / 255, green: 30.0 / 255, blue: 57.0 / 255, alpha: 0.9),
172173
topIcon: YOUR_TOP_ICON,
173174
iconTap: YOUR_ICON_TAP,
174175
iconTapToggled: YOUR_ICON_TAP_TOGGLED,

example/GdeckObjC/AppDelegate.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// AppDelegate.h
3+
// GdeckObjC
4+
//
5+
// Created by Rohit Sangwan on 13/10/23.
6+
//
7+
8+
#import <UIKit/UIKit.h>
9+
10+
@interface AppDelegate : UIResponder <UIApplicationDelegate>
11+
12+
13+
@end
14+

example/GdeckObjC/AppDelegate.m

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// AppDelegate.m
3+
// GdeckObjC
4+
//
5+
// Created by Rohit Sangwan on 13/10/23.
6+
//
7+
8+
#import "AppDelegate.h"
9+
10+
@interface AppDelegate ()
11+
12+
@end
13+
14+
@implementation AppDelegate
15+
16+
17+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
18+
// Override point for customization after application launch.
19+
return YES;
20+
}
21+
22+
23+
#pragma mark - UISceneSession lifecycle
24+
25+
26+
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
27+
// Called when a new scene session is being created.
28+
// Use this method to select a configuration to create the new scene with.
29+
return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
30+
}
31+
32+
33+
- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
34+
// Called when the user discards a scene session.
35+
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
36+
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
37+
}
38+
39+
40+
@end
File renamed without changes.
33.6 KB
Loading

example/Gesturedeck example/Assets.xcassets/AppIcon.appiconset/Contents.json renamed to example/GdeckObjC/Assets.xcassets/AppIcon.appiconset/Contents.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"images" : [
33
{
4+
"filename" : "2023-10-13 14.46.21.jpg",
45
"idiom" : "universal",
56
"platform" : "ios",
67
"size" : "1024x1024"
File renamed without changes.
File renamed without changes.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina6_12" orientation="portrait" appearance="light"/>
4+
<dependencies>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/>
7+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
8+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
9+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
10+
</dependencies>
11+
<scenes>
12+
<!--View Controller-->
13+
<scene sceneID="tne-QT-ifu">
14+
<objects>
15+
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
16+
<view key="view" contentMode="scaleToFill" id="Oyg-2e-E3s">
17+
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
18+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
19+
<subviews>
20+
<navigationBar contentMode="scaleToFill" translucent="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hhe-gC-tCT">
21+
<rect key="frame" x="0.0" y="59" width="393" height="44"/>
22+
<constraints>
23+
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="44" id="i5N-kV-dMS"/>
24+
</constraints>
25+
<items>
26+
<navigationItem title="Gesturedeck Example ObjC" largeTitleDisplayMode="always" id="iAI-P9-NOR"/>
27+
</items>
28+
</navigationBar>
29+
<stackView opaque="NO" contentMode="scaleToFill" spacing="40" translatesAutoresizingMaskIntoConstraints="NO" id="WFZ-iy-P2G">
30+
<rect key="frame" x="10" y="123" width="373" height="40"/>
31+
<subviews>
32+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ypy-rt-nGB">
33+
<rect key="frame" x="0.0" y="0.0" width="166.66666666666666" height="40"/>
34+
<state key="normal" title="Button"/>
35+
<buttonConfiguration key="configuration" style="filled" title="Start"/>
36+
<connections>
37+
<action selector="onStartButtonTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Jw3-tb-1ZF"/>
38+
</connections>
39+
</button>
40+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="sXD-SP-rII">
41+
<rect key="frame" x="206.66666666666663" y="0.0" width="166.33333333333337" height="40"/>
42+
<state key="normal" title="Button"/>
43+
<buttonConfiguration key="configuration" style="filled" title="Stop"/>
44+
<connections>
45+
<action selector="onStopButtonTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="GOR-1o-lt8"/>
46+
</connections>
47+
</button>
48+
</subviews>
49+
<constraints>
50+
<constraint firstAttribute="height" relation="lessThanOrEqual" constant="40" id="zfB-7g-6om"/>
51+
</constraints>
52+
</stackView>
53+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="shf-p4-1tW">
54+
<rect key="frame" x="0.0" y="184.66666666666666" width="393" height="1"/>
55+
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
56+
<constraints>
57+
<constraint firstAttribute="height" constant="1" id="22L-Or-1dw"/>
58+
<constraint firstAttribute="height" relation="greaterThanOrEqual" id="HEg-3T-Wl1"/>
59+
</constraints>
60+
</view>
61+
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="ZgI-WI-9IS">
62+
<rect key="frame" x="0.0" y="173" width="393" height="645"/>
63+
<subviews>
64+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Perform Gestures" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YXW-24-v9X">
65+
<rect key="frame" x="0.0" y="0.0" width="393" height="645"/>
66+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
67+
<nil key="textColor"/>
68+
<nil key="highlightedColor"/>
69+
</label>
70+
</subviews>
71+
</stackView>
72+
</subviews>
73+
<viewLayoutGuide key="safeArea" id="Cza-J9-hGS"/>
74+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
75+
<constraints>
76+
<constraint firstItem="shf-p4-1tW" firstAttribute="trailing" secondItem="Cza-J9-hGS" secondAttribute="trailing" id="0Z1-V1-vVh"/>
77+
<constraint firstItem="Cza-J9-hGS" firstAttribute="bottom" secondItem="ZgI-WI-9IS" secondAttribute="bottom" id="2id-G5-p6y"/>
78+
<constraint firstItem="WFZ-iy-P2G" firstAttribute="top" secondItem="hhe-gC-tCT" secondAttribute="bottom" constant="20" id="6tu-Fp-NwV"/>
79+
<constraint firstItem="ZgI-WI-9IS" firstAttribute="leading" secondItem="Cza-J9-hGS" secondAttribute="leading" id="7Uv-JR-6Vd"/>
80+
<constraint firstItem="shf-p4-1tW" firstAttribute="leading" secondItem="Cza-J9-hGS" secondAttribute="leading" id="BTl-qH-Rgg"/>
81+
<constraint firstItem="Cza-J9-hGS" firstAttribute="trailing" secondItem="shf-p4-1tW" secondAttribute="trailing" id="DGB-aN-w9G"/>
82+
<constraint firstItem="WFZ-iy-P2G" firstAttribute="leading" secondItem="Cza-J9-hGS" secondAttribute="leading" constant="10" id="Dii-2J-7do"/>
83+
<constraint firstItem="Cza-J9-hGS" firstAttribute="trailing" secondItem="WFZ-iy-P2G" secondAttribute="trailing" constant="10" id="EE6-El-aqj"/>
84+
<constraint firstItem="ZgI-WI-9IS" firstAttribute="trailing" secondItem="Cza-J9-hGS" secondAttribute="trailing" id="FHz-AT-px4"/>
85+
<constraint firstItem="hhe-gC-tCT" firstAttribute="leading" secondItem="Cza-J9-hGS" secondAttribute="leading" id="PGB-xt-mWD"/>
86+
<constraint firstItem="WFZ-iy-P2G" firstAttribute="leading" secondItem="Cza-J9-hGS" secondAttribute="leading" constant="10" id="Teo-Wt-Ofe"/>
87+
<constraint firstItem="hhe-gC-tCT" firstAttribute="trailing" secondItem="Cza-J9-hGS" secondAttribute="trailing" id="acP-Cl-dGw"/>
88+
<constraint firstItem="hhe-gC-tCT" firstAttribute="top" secondItem="Cza-J9-hGS" secondAttribute="top" id="e9Y-1d-srV"/>
89+
<constraint firstItem="Cza-J9-hGS" firstAttribute="trailing" secondItem="ZgI-WI-9IS" secondAttribute="trailing" id="iYQ-VD-aC2"/>
90+
<constraint firstItem="ZgI-WI-9IS" firstAttribute="top" secondItem="WFZ-iy-P2G" secondAttribute="bottom" constant="10" id="ihh-at-Sje"/>
91+
<constraint firstItem="ZgI-WI-9IS" firstAttribute="leading" secondItem="Cza-J9-hGS" secondAttribute="leading" id="kBX-Xx-oxN"/>
92+
<constraint firstItem="shf-p4-1tW" firstAttribute="leading" secondItem="Cza-J9-hGS" secondAttribute="leading" id="r59-Pi-gW6"/>
93+
<constraint firstItem="Cza-J9-hGS" firstAttribute="trailing" secondItem="WFZ-iy-P2G" secondAttribute="trailing" constant="10" id="y5c-hM-xLj"/>
94+
<constraint firstItem="ZgI-WI-9IS" firstAttribute="top" secondItem="WFZ-iy-P2G" secondAttribute="bottom" constant="10" id="z63-6a-oyE"/>
95+
<constraint firstItem="shf-p4-1tW" firstAttribute="top" secondItem="WFZ-iy-P2G" secondAttribute="bottom" constant="21.670000000000002" id="zru-NN-IdD"/>
96+
</constraints>
97+
</view>
98+
<connections>
99+
<outlet property="btnStart" destination="ypy-rt-nGB" id="aAE-al-suz"/>
100+
<outlet property="btnStop" destination="sXD-SP-rII" id="kbY-jQ-eX1"/>
101+
</connections>
102+
</viewController>
103+
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
104+
</objects>
105+
<point key="canvasLocation" x="131" y="-27"/>
106+
</scene>
107+
</scenes>
108+
<resources>
109+
<systemColor name="systemBackgroundColor">
110+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
111+
</systemColor>
112+
</resources>
113+
</document>

0 commit comments

Comments
 (0)