-
Notifications
You must be signed in to change notification settings - Fork 16
/
TikTok.swift
72 lines (59 loc) · 2.21 KB
/
TikTok.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// ContentView.swift
// TikTok
//
// Created by Ganesh on 29/08/23.
//
import SwiftUI
struct TikTok: View{
@State private var isglitch:Bool = false
private let timer = Timer.publish(every: 0.1, on: .main, in: .common).autoconnect()
private let symbol = """
⠀⠀⠀⠀⠀⠀⠀⠀⣶⣶⣶⡀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣷⣄⣀
⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿
⠀⠀⢀⣠⣴⣶⣶⠀⣿⣿⣿⠉⠉⠉
⠀⣴⣿⣿⣿⣿⣿⠀⣿⣿⣿⠀⠀⠀
⢸⣿⣿⡿⠉⠀⠈⠀⣿⣿⣿⠀⠀⠀
⢹⣿⣿⣷⡀⠀⠀⣰⣿⣿⣿⠀⠀⠀
⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠀⠀⠀
⠀⠀⠙⠻⠿⠿⠿⠿⠋⠁⠀⠀⠀⠀
"""
private let text = "TikTok"
private let offsetRange = -10...10
var body: some View{
ZStack{
VStack(spacing: 10){
Text(symbol)
.font(.system(size: 20).bold())
Text(text)
.font(.system(size: 80).bold())
}
.foregroundColor(.pink)
.offset(x: isglitch ? CGFloat(Int.random(in: offsetRange)) : 0, y: isglitch ? CGFloat(Int.random(in: offsetRange)): 0)
VStack(spacing: 10){
Text(symbol)
.font(.system(size: 20).bold())
Text(text)
.font(.system(size: 80).bold())
}
.foregroundColor(.cyan)
.offset(x: isglitch ? CGFloat(Int.random(in: offsetRange)) : 0, y: isglitch ? CGFloat(Int.random(in: offsetRange)) : 0)
VStack(spacing: 10){
Text(symbol)
.font(.system(size: 20).bold())
Text(text)
.font(.system(size: 80).bold())
}
.preferredColorScheme(.dark)
.onReceive(timer) { _ in
DispatchQueue.main.asyncAfter(deadline: .now() + Double.random(in: 0...0.1)){
self.isglitch.toggle()
}
}
.onDisappear{
self.timer.upstream.connect().cancel()
}
}
}
}