-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98bf05c
commit f24aa1a
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
Binary file modified
BIN
+3.77 KB
(100%)
...proj/project.xcworkspace/xcuserdata/tahatesser.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
SwiftUIPlayground/Samples/Animations/MatchedGeometryEffectSample.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// MatchedGeometryEffectSample.swift | ||
// SwiftUIPlayground | ||
// | ||
// Created by Taha Tesser on 07.10.2024. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct MatchedGeometryEffectSample: View { | ||
@Namespace private var animation | ||
@State private var isExpanded: Bool = false | ||
|
||
var body: some View { | ||
ZStack { | ||
if isExpanded { | ||
ZStack { | ||
RoundedRectangle(cornerRadius: 10) | ||
.fill(.black) | ||
.clipShape(RoundedRectangle(cornerRadius: 16)) | ||
Image(systemName: "rainbow") | ||
.symbolRenderingMode(.multicolor) | ||
.resizable() | ||
.scaledToFit() | ||
.padding() | ||
.matchedGeometryEffect(id: "park", in: animation) | ||
|
||
} | ||
} else { | ||
ZStack { | ||
RoundedRectangle(cornerRadius: 10) | ||
.fill(.black) | ||
.frame(height: 100) | ||
.clipShape(RoundedRectangle(cornerRadius: 16)) | ||
Image(systemName: "rainbow") | ||
.symbolRenderingMode(.multicolor) | ||
.resizable() | ||
.scaledToFit() | ||
.frame(height: 80) | ||
.matchedGeometryEffect(id: "park", in: animation) | ||
} | ||
.padding() | ||
} | ||
} | ||
.onTapGesture { | ||
withAnimation(.spring()) { | ||
isExpanded.toggle() | ||
} | ||
} | ||
.ignoresSafeArea() } | ||
} | ||
|
||
#Preview { | ||
MatchedGeometryEffectSample() | ||
} |