minor refactor

pull/891/head
ryanzhao 2 years ago
parent 1842422a67
commit e1c662030f

@ -9,8 +9,6 @@ import SessionUtilitiesKit
struct LandingView: View { struct LandingView: View {
@EnvironmentObject var host: HostWrapper @EnvironmentObject var host: HostWrapper
@State var numberOfBubblesShown: Int = 0
var body: some View { var body: some View {
ZStack(alignment: .center) { ZStack(alignment: .center) {
if #available(iOS 14.0, *) { if #available(iOS 14.0, *) {
@ -33,24 +31,7 @@ struct LandingView: View {
Spacer(minLength: 0) Spacer(minLength: 0)
.frame(maxHeight: 2 * Values.mediumSpacing) .frame(maxHeight: 2 * Values.mediumSpacing)
FakeChat($numberOfBubblesShown) FakeChat()
.onAppear {
guard numberOfBubblesShown < 4 else { return }
Timer.scheduledTimerOnMainThread(withTimeInterval: 0.2, repeats: false) { _ in
withAnimation(.spring().speed(0.68)) {
numberOfBubblesShown = 1
}
Timer.scheduledTimerOnMainThread(withTimeInterval: 1.5, repeats: true) { timer in
withAnimation(.spring().speed(0.68)) {
numberOfBubblesShown += 1
if numberOfBubblesShown >= 4 {
timer.invalidate()
}
}
}
}
}
Spacer(minLength: 0) Spacer(minLength: 0)
.frame(maxHeight: Values.massiveSpacing) .frame(maxHeight: Values.massiveSpacing)
@ -192,7 +173,7 @@ struct ChatBubble: View {
} }
struct FakeChat: View { struct FakeChat: View {
@Binding var numberOfBubblesShown: Int @State var numberOfBubblesShown: Int = 0
let chatBubbles: [ChatBubble] = [ let chatBubbles: [ChatBubble] = [
ChatBubble(text: "onboarding_chat_bubble_1".localized(), outgoing: false), ChatBubble(text: "onboarding_chat_bubble_1".localized(), outgoing: false),
@ -201,10 +182,6 @@ struct FakeChat: View {
ChatBubble(text: "onboarding_chat_bubble_4".localized(), outgoing: true), ChatBubble(text: "onboarding_chat_bubble_4".localized(), outgoing: true),
] ]
init(_ numberOfBubblesShown: Binding<Int>) {
self._numberOfBubblesShown = numberOfBubblesShown
}
var body: some View { var body: some View {
VStack( VStack(
alignment: .leading, alignment: .leading,
@ -235,6 +212,23 @@ struct FakeChat: View {
alignment: .bottom alignment: .bottom
) )
.padding(.horizontal, 36) .padding(.horizontal, 36)
.onAppear {
guard numberOfBubblesShown < 4 else { return }
Timer.scheduledTimerOnMainThread(withTimeInterval: 0.2, repeats: false) { _ in
withAnimation(.spring().speed(0.68)) {
numberOfBubblesShown = 1
}
Timer.scheduledTimerOnMainThread(withTimeInterval: 1.5, repeats: true) { timer in
withAnimation(.spring().speed(0.68)) {
numberOfBubblesShown += 1
if numberOfBubblesShown >= 4 {
timer.invalidate()
}
}
}
}
}
} }
} }

Loading…
Cancel
Save