-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestAlert.swift
96 lines (85 loc) · 3 KB
/
TestAlert.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//
// TestAlert.swift
// MovieList
//
// Created by Misha Dovhiy on 25.12.2023.
//
import UIKit
import AlertViewLibrary
struct TestAlert {
private var alert:AlertManager {
AppModel.Appearence.alert
}
func load() {
test2Perform()
}
}
fileprivate extension TestAlert {
func test3Perform() {
alert.showAlert(title: nil, appearence: .type(.error))
alert.showAlert(title: nil, appearence: .type(.error))
}
func test2Perform() {
alert.showLoading(description: "Your loading description")
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(4), execute: {
self.alert.showAlert(title: "Your title", description: "Your Description", appearence: .with({
$0.primaryButton = .with({
$0.title = "Some title"
$0.close = false
$0.action = self.test2Perform
})
}))
})
}
func testAI(canMany:Bool = true) {
let ai = AppModel.Appearence.alert
ai.showLoading(description: "Your") {
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(4), execute: {
ai.showAlert(title: canMany ? nil : "some erfewd egrfwd tegrf wer svdcsd rwe", appearence: .with({
if canMany {
$0.primaryButton = .with({
$0.title = "many alerts"
$0.action = {
for i in 0..<5{
self.testRegulare()
}
}
})
} else {
$0.primaryButton = .with({
$0.style = .link
$0.title = "loading test"
$0.action = self.loadingTest
})
}
$0.secondaryButton = .with({
$0.style = .error
$0.close = false
$0.action = {
self.testAI(canMany: false)
}
$0.title = "fuck you"
})
$0.type = canMany ? .internetError : .standard
}))
})
}
}
private func loadingTest() {
let ai = AppModel.Appearence.alert
ai.showLoading(title: "some title", completion: {
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3), execute: {
ai.showAlert(title: "areer", appearence: .with({
if #available(iOS 13.0, *) {
$0.image = .image(.add)
}
}))
})
})
}
private func testRegulare() {
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2), execute: {
let ai = AppModel.Appearence.alert
})
}
}