-
Notifications
You must be signed in to change notification settings - Fork 250
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
f2d7c25
commit 801a908
Showing
16 changed files
with
1,076 additions
and
1 deletion.
There are no files selected for viewing
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
Binary file modified
BIN
+45.4 KB
(140%)
...proj/project.xcworkspace/xcuserdata/amosgyamfi.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
69 changes: 69 additions & 0 deletions
69
OpenSwiftUIAnimations/AIThinkingAnimations/CombinedSymbolEffects.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,69 @@ | ||
// | ||
// Thinking2.swift | ||
// CoreSwiftUI | ||
// | ||
import SwiftUI | ||
|
||
struct ThinkingWithAlex: View { | ||
@State private var currentPhraseIndex = 0 | ||
private let timer = Timer.publish(every: 5, on: .main, in: .common).autoconnect() | ||
@State private var thinking = true | ||
|
||
private static let phrases = [ | ||
"Thinking ", | ||
"Weighing Options ", | ||
"Evaluating Sentence" | ||
] | ||
|
||
var body: some View { | ||
HStack { | ||
//Spacer() | ||
animatedSparklesIcon | ||
//Spacer() | ||
//animatedPhrase | ||
//Spacer() | ||
} | ||
.padding(.horizontal, 90) | ||
.onReceive(timer) { _ in | ||
withAnimation { | ||
currentPhraseIndex = (currentPhraseIndex + 1) % Self.phrases.count | ||
} | ||
} | ||
} | ||
|
||
private var animatedSparklesIcon: some View { | ||
Image(systemName: "sparkles") | ||
.font(.system(size: 128, weight: .heavy)) | ||
.foregroundStyle(EllipticalGradient(colors: [.blue, .indigo], center: .center, startRadiusFraction: 0.0, endRadiusFraction: 0.5)) | ||
.phaseAnimator([false , true]) { sparkleSymbol, animate in | ||
sparkleSymbol | ||
.symbolEffect(.wiggle.byLayer, options: .repeat(3), value: animate) | ||
.symbolEffect(.bounce.byLayer, options: .repeat(3), value: animate) | ||
.symbolEffect(.pulse.byLayer, options: .repeat(3), value: animate) | ||
.symbolEffect(.breathe.byLayer, options: .repeat(3), value: animate) | ||
} | ||
} | ||
|
||
private var animatedPhrase: some View { | ||
HStack(spacing: 0) { | ||
ForEach(Array(Self.phrases[currentPhraseIndex].enumerated()), id: \.offset) { index, letter in | ||
Text(String(letter)) | ||
.foregroundStyle(.blue) | ||
.hueRotation(.degrees(thinking ? 220 : 0)) | ||
.opacity(thinking ? 1 : 0) | ||
.scaleEffect(thinking ? 1 : 0.5, anchor: .bottom) | ||
.animation( | ||
.easeInOut(duration: 0.5) | ||
.repeatForever(autoreverses: true) | ||
.delay(Double(index) * 0.05), | ||
value: thinking | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
ThinkingWithAlex() | ||
.preferredColorScheme(.dark) | ||
} |
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,50 @@ | ||
// | ||
// Thinking.swift | ||
|
||
import SwiftUI | ||
|
||
struct Thinking: View { | ||
@State private var counter: Int = 0 | ||
private let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect() | ||
@State private var thinking: Bool = false | ||
//let letters = Array("Thinking") | ||
//let letters = Array("Weighing Options") | ||
let letters = Array("Evaluating Sentence") | ||
|
||
let slideGently = Animation.easeOut(duration: 0.5).delay(2).repeatForever(autoreverses: false).delay(-0.67) | ||
|
||
var body: some View { | ||
HStack { | ||
Image(systemName: "sparkles") | ||
.font(.title) | ||
.foregroundStyle(EllipticalGradient(colors:[.blue, .indigo], center: .center, startRadiusFraction: 0.0, endRadiusFraction: 0.5)) | ||
.phaseAnimator([false , true]) { ai, thinking in | ||
ai | ||
.symbolEffect(.breathe.byLayer, value: thinking) | ||
} | ||
|
||
HStack(spacing: 0) { | ||
ForEach(0..<letters.count, id: \.self) { think in | ||
Text(String(letters[think])) | ||
.foregroundStyle(.blue) | ||
.hueRotation(.degrees(thinking ? 220 : 0)) | ||
.opacity(thinking ? 0 : 1) | ||
.scaleEffect(x: thinking ? 0.75 : 1, y: thinking ? 1.25 : 1, anchor: .bottom) | ||
//.offset(y: thinking ? -2 : 0) | ||
.animation(.easeInOut(duration: 0.5).delay(1).repeatForever(autoreverses: false).delay(Double(think) / 20), value: thinking) | ||
//.animation(.timingCurve(0.68, -0.6, 0.32, 1.6).delay(2).repeatForever(autoreverses: false).delay(Double(think) / 20), value: thinking) | ||
} | ||
|
||
} | ||
|
||
} | ||
.onAppear { | ||
thinking = true | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
Thinking() | ||
.preferredColorScheme(.dark) | ||
} |
Oops, something went wrong.