Skip to content

Commit 85b63ef

Browse files
authored
Merge pull request #9 from gadirom/adding_touchpad
Adding touchpad
2 parents 6b67c6d + f0cac99 commit 85b63ef

File tree

22 files changed

+880
-502
lines changed

22 files changed

+880
-502
lines changed

.swiftpm/xcode/xcuserdata/gadirom.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>TransformGesture.xcscheme_^#shared#^_</key>
88
<dict>
99
<key>orderHint</key>
10-
<integer>1</integer>
10+
<integer>2</integer>
1111
</dict>
1212
</dict>
1313
</dict>

Example/.DS_Store

0 Bytes
Binary file not shown.

Example/Example.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@
344344
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
345345
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
346346
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
347+
IPHONEOS_DEPLOYMENT_TARGET = 17.6;
347348
LD_RUNPATH_SEARCH_PATHS = (
348349
"$(inherited)",
349350
"@executable_path/Frameworks",
@@ -373,6 +374,7 @@
373374
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
374375
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
375376
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
377+
IPHONEOS_DEPLOYMENT_TARGET = 17.6;
376378
LD_RUNPATH_SEARCH_PATHS = (
377379
"$(inherited)",
378380
"@executable_path/Frameworks",

Example/Example.xcodeproj/xcuserdata/gadirom.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

Lines changed: 80 additions & 96 deletions
Large diffs are not rendered by default.

Example/Example/BuildingBlocks/RenderParticles.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@ struct RenderParticles<T: RenderableParticle>: MetalBuildingBlock {
3333
let particlesBuffer: MTLBufferContainer<T>
3434
let toTexture: MTLTextureContainer? = nil
3535

36-
@ObservedObject var transform: TouchTransform
36+
let transform: TouchTransform
3737

3838
var metalContent: MetalContent{
39+
var transform = Bindable(transform)
3940
Render(type: .point, count: particlesCount)
4041
.toTexture(toTexture)
4142
.vertexBuf(particlesBuffer, name: "particles")
42-
.vertexBytes($transform.matrix, type: "float3x3", name: "transform")
43+
.vertexBytes(transform.matrix, type: "float3x3", name: "transform")
4344
.vertexBytes(context.$viewportToDeviceTransform)
44-
.vertexBytes($transform.floatScale, type: "float", name: "scale")
45+
.vertexBytes(transform.floatScale, type: "float", name: "scale")
4546
.vertexBytes(context.$scaleFactor)
4647
.pipelineColorAttachment(pipColorDesc)
4748
.colorAttachement(

Example/Example/ContentView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct ContentView: View {
4848
@MetalState var particlesCountState = particlesCount
4949
@MetalState var canvasSizeState = canvasSize
5050

51-
@StateObject var transform = TouchTransform(
51+
@State var transform = TouchTransform(
5252
translation: CGSize(width: 0,
5353
height:0),
5454
scale: 1,
@@ -97,7 +97,7 @@ struct ContentView: View {
9797
Rectangle()
9898
.fill(Color.gray)
9999
.frame(width: CGFloat(canvasSize.x), height: CGFloat(canvasSize.y))
100-
.transformEffect(transform)
100+
.transformEffect($transform)
101101
MetalBuilderView(viewSettings: viewSettings) { context in
102102
EncodeGroup(active: $justStarted){
103103
ClearRender()
@@ -242,7 +242,7 @@ struct ContentView: View {
242242
.fill(Color.clear)
243243
.border(Color.white, width: transform.scaleSnapped ? 2 : 1)
244244
.frame(width: CGFloat(canvasSize.x), height: CGFloat(canvasSize.y))
245-
.transformEffect(transform)
245+
.transformEffect($transform)
246246
let offset = CGSize(width: transform.centerPoint.x,
247247
height: transform.centerPoint.y)
248248
ZStack{

Example/Example/HapticsEngine.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,45 @@ import TransformGesture
44

55
struct HapticsEffects: ViewModifier {
66

7-
@ObservedObject var transform: TouchTransform
7+
let transform: TouchTransform
88

99
@Environment(\.scenePhase) var scenePhase
1010
@State var hapticsEngine = HapticsEngine()
1111

1212
func body(content: Content) -> some View {
1313
content
14-
.onChange(of: transform.offset) { newValue in
14+
.onChange(of: transform.offset) { newValue, oldValue in
1515
hapticsEngine.onDraw()
1616
}
17-
.onChange(of: transform.translationXSnapped) { newValue in
17+
.onChange(of: transform.translationXSnapped) { newValue, oldValue in
1818
if newValue{
1919
hapticsEngine.onSnap()
2020
}else{
2121
hapticsEngine.offSnap()
2222
}
2323
}
24-
.onChange(of: transform.translationYSnapped) { newValue in
24+
.onChange(of: transform.translationYSnapped) { newValue, oldValue in
2525
if newValue{
2626
hapticsEngine.onSnap()
2727
}else{
2828
hapticsEngine.offSnap()
2929
}
3030
}
31-
.onChange(of: transform.rotationSnapped) { newValue in
31+
.onChange(of: transform.rotationSnapped) { newValue, oldValue in
3232
if newValue{
3333
hapticsEngine.onSnap()
3434
}else{
3535
hapticsEngine.offSnap()
3636
}
3737
}
38-
.onChange(of: transform.scaleSnapped) { newValue in
38+
.onChange(of: transform.scaleSnapped) { newValue, oldValue in
3939
if newValue{
4040
hapticsEngine.onSnap()
4141
}else{
4242
hapticsEngine.offSnap()
4343
}
4444
}
45-
.onChange(of: scenePhase) { newValue in
45+
.onChange(of: scenePhase) { newValue, oldValue in
4646
if newValue == .active{
4747
hapticsEngine.start()
4848
}

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// swift-tools-version: 5.6
1+
// swift-tools-version: 6.0
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
55

66
let package = Package(
77
name: "TransformGesture",
8-
platforms: [.iOS(.v15)],
8+
platforms: [.iOS(.v17)],
99
products: [
1010
// Products define the executables and libraries a package produces, and make them visible to other packages.
1111
.library(

0 commit comments

Comments
 (0)