2019-08-12 17:59:40 +08:00
|
|
|
|
//
|
|
|
|
|
// TestToastVC.swift
|
|
|
|
|
// Example
|
|
|
|
|
//
|
|
|
|
|
// Created by xaoxuu on 2019/8/12.
|
|
|
|
|
// Copyright © 2019 Titan Studio. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
import ProHUD
|
|
|
|
|
|
|
|
|
|
class TestToastVC: BaseListVC {
|
|
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
|
super.viewDidLoad()
|
|
|
|
|
|
|
|
|
|
// Do any additional setup after loading the view.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override var titles: [String] {
|
|
|
|
|
return ["场景:正在同步",
|
2020-06-22 16:34:21 +08:00
|
|
|
|
"场景:正在同步(更新进度)",
|
2019-08-12 17:59:40 +08:00
|
|
|
|
"场景:同步成功",
|
|
|
|
|
"场景:同步失败",
|
|
|
|
|
"场景:设备电量过低",
|
|
|
|
|
"传入指定图标",
|
|
|
|
|
"禁止手势移除",
|
2019-08-12 20:20:07 +08:00
|
|
|
|
"组合使用示例",
|
|
|
|
|
"避免重复发布同一条信息",
|
2020-06-19 09:49:24 +08:00
|
|
|
|
"根据id查找并修改实例",
|
|
|
|
|
"测试较长的标题和内容",
|
2020-06-19 13:50:17 +08:00
|
|
|
|
"测试特别长的标题和内容",
|
2020-06-19 19:13:33 +08:00
|
|
|
|
"测试只有title",
|
2020-06-22 10:36:33 +08:00
|
|
|
|
"测试只有message",
|
|
|
|
|
"自定义旋转的图片"]
|
2019-08-12 17:59:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
|
|
|
tableView.deselectRow(at: indexPath, animated: true)
|
|
|
|
|
let row = indexPath.row
|
|
|
|
|
if row == 0 {
|
|
|
|
|
Toast.push(scene: .loading, title: "正在同步", message: "请稍等片刻") { (vm) in
|
|
|
|
|
vm.identifier = "loading"
|
2020-06-22 13:27:54 +08:00
|
|
|
|
}.startRotate()
|
2019-08-12 17:59:40 +08:00
|
|
|
|
simulateSync()
|
|
|
|
|
} else if row == 1 {
|
2020-06-23 10:35:15 +08:00
|
|
|
|
if let _ = Toast.find("progress").last {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
Toast.push("progress") { (t) in
|
|
|
|
|
t.update { (vm) in
|
|
|
|
|
vm.scene = .loading
|
|
|
|
|
vm.title = "正在同步"
|
|
|
|
|
vm.message = "请稍等片刻"
|
|
|
|
|
}
|
|
|
|
|
t.startRotate()
|
|
|
|
|
t.update(progress: 0)
|
|
|
|
|
let s = DispatchSemaphore(value: 1)
|
|
|
|
|
DispatchQueue.global().async {
|
|
|
|
|
for i in 0 ... 5 {
|
|
|
|
|
s.wait()
|
|
|
|
|
DispatchQueue.main.async {
|
|
|
|
|
Toast.find("progress", last: { (t) in
|
|
|
|
|
t.update(progress: CGFloat(i)/5)
|
|
|
|
|
print("\(CGFloat(i)/5)")
|
|
|
|
|
if i == 5 {
|
|
|
|
|
t.update { (vm) in
|
|
|
|
|
vm.scene = .success
|
|
|
|
|
vm.title = "同步成功"
|
|
|
|
|
vm.message = "xxx"
|
|
|
|
|
}
|
2020-06-22 16:34:21 +08:00
|
|
|
|
}
|
2020-06-23 10:35:15 +08:00
|
|
|
|
})
|
|
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now()+1) {
|
|
|
|
|
s.signal()
|
2020-06-22 16:34:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-23 10:35:15 +08:00
|
|
|
|
|
2020-06-22 16:34:21 +08:00
|
|
|
|
} else if row == 2 {
|
2019-08-12 17:59:40 +08:00
|
|
|
|
let t = Toast.push(scene: .success, title: "同步成功", message: "点击查看详情")
|
|
|
|
|
t.didTapped { [weak self, weak t] in
|
|
|
|
|
self?.presentEmptyVC(title: "详情")
|
|
|
|
|
t?.pop()
|
|
|
|
|
}
|
2020-06-22 16:34:21 +08:00
|
|
|
|
} else if row == 3 {
|
2019-08-12 20:20:07 +08:00
|
|
|
|
Toast.push(scene: .error, title: "同步失败", message: "请稍后重试。点击查看详情") { (vc) in
|
|
|
|
|
vc.update { (vm) in
|
|
|
|
|
vm.duration = 0
|
|
|
|
|
}
|
|
|
|
|
vc.didTapped { [weak self, weak vc] in
|
|
|
|
|
self?.presentEmptyVC(title: "这是错误详情")
|
|
|
|
|
vc?.pop()
|
|
|
|
|
}
|
2019-08-12 17:59:40 +08:00
|
|
|
|
}
|
2020-06-22 16:34:21 +08:00
|
|
|
|
} else if row == 4 {
|
2019-08-12 17:59:40 +08:00
|
|
|
|
Toast.push(scene: .warning, title: "设备电量过低", message: "请及时对设备进行充电,以免影响使用。")
|
|
|
|
|
|
2020-06-22 16:34:21 +08:00
|
|
|
|
} else if row == 5 {
|
2019-08-12 20:20:07 +08:00
|
|
|
|
Toast.push(scene: .default, title: "传入指定图标测试", message: "这是消息内容") { (vc) in
|
|
|
|
|
vc.update { (vm) in
|
2020-06-19 19:13:33 +08:00
|
|
|
|
if #available(iOS 13.0, *) {
|
|
|
|
|
vc.imageView.tintColor = .brown
|
|
|
|
|
vm.icon = UIImage(systemName: "icloud.and.arrow.down")
|
|
|
|
|
} else {
|
|
|
|
|
vm.icon = UIImage(named: "icloud.and.arrow.down")
|
|
|
|
|
}
|
2019-08-12 20:20:07 +08:00
|
|
|
|
}
|
2019-08-12 17:59:40 +08:00
|
|
|
|
}
|
2020-06-22 16:34:21 +08:00
|
|
|
|
} else if row == 6 {
|
2019-08-12 20:20:07 +08:00
|
|
|
|
Toast.push(scene: .default, title: "禁止手势移除", message: "这条消息无法通过向上滑动移出屏幕。5秒后自动消失,每次拖拽都会刷新倒计时。") { (vc) in
|
2019-08-13 11:32:27 +08:00
|
|
|
|
vc.isRemovable = false
|
2019-08-12 20:20:07 +08:00
|
|
|
|
vc.update { (vm) in
|
|
|
|
|
vm.duration = 5
|
|
|
|
|
}
|
2019-08-12 17:59:40 +08:00
|
|
|
|
}
|
2020-06-22 16:34:21 +08:00
|
|
|
|
} else if row == 7 {
|
2020-06-19 19:13:33 +08:00
|
|
|
|
Toast.push(scene: .message, title: "好友邀请", message: "你收到一条好友邀请,点击查看详情。", duration: 10) { (vc) in
|
2019-08-12 20:20:07 +08:00
|
|
|
|
vc.identifier = "xxx"
|
|
|
|
|
vc.didTapped { [weak vc] in
|
|
|
|
|
vc?.pop()
|
|
|
|
|
Alert.push(scene: .confirm, title: "好友邀请", message: "用户xxx想要添加你为好友,是否同意?") { (vc) in
|
|
|
|
|
vc.update { (vm) in
|
|
|
|
|
vm.add(action: .default, title: "接受") { [weak vc] in
|
|
|
|
|
vc?.pop()
|
|
|
|
|
Toast.push(scene: .success, title: "好友添加成功", message: "这是消息内容")
|
|
|
|
|
}
|
|
|
|
|
vm.add(action: .cancel, title: "拒绝") {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-12 17:59:40 +08:00
|
|
|
|
}
|
2019-08-12 20:20:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-22 16:34:21 +08:00
|
|
|
|
} else if row == 8 {
|
2020-06-22 14:09:34 +08:00
|
|
|
|
if let t = Toast.find("aaa").last {
|
2019-08-13 09:14:30 +08:00
|
|
|
|
t.pulse()
|
|
|
|
|
t.update() { (vm) in
|
2019-08-12 20:20:07 +08:00
|
|
|
|
vm.title = "已经存在了"
|
|
|
|
|
}
|
2020-06-22 14:09:34 +08:00
|
|
|
|
} else {
|
2019-08-12 20:20:07 +08:00
|
|
|
|
Toast.push(title: "这是一条id为aaa的横幅", message: "避免重复发布同一条信息") { (t) in
|
|
|
|
|
t.identifier = "aaa"
|
|
|
|
|
t.update { (vm) in
|
|
|
|
|
vm.scene = .warning
|
|
|
|
|
vm.duration = 0
|
2019-08-12 17:59:40 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-22 16:34:21 +08:00
|
|
|
|
} else if row == 9 {
|
2020-06-22 14:09:34 +08:00
|
|
|
|
Toast.push("aaa") { (t) in
|
2019-08-12 20:20:07 +08:00
|
|
|
|
t.update { (vm) in
|
|
|
|
|
vm.scene = .success
|
|
|
|
|
vm.title = "找到了哈哈"
|
|
|
|
|
vm.message = "根据id查找并修改实例"
|
|
|
|
|
}
|
2020-06-22 14:09:34 +08:00
|
|
|
|
t.pulse()
|
|
|
|
|
}
|
2020-06-22 16:34:21 +08:00
|
|
|
|
} else if row == 10 {
|
2020-06-19 09:49:24 +08:00
|
|
|
|
Toast.push() { (a) in
|
|
|
|
|
a.update { (vm) in
|
|
|
|
|
vm.title = "正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过"
|
|
|
|
|
vm.message = "正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过"
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-22 16:34:21 +08:00
|
|
|
|
} else if row == 11 {
|
2020-06-19 09:49:24 +08:00
|
|
|
|
Toast.push() { (a) in
|
|
|
|
|
a.update { (vm) in
|
|
|
|
|
vm.title = "正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过"
|
|
|
|
|
vm.message = "正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过"
|
2020-06-19 13:50:17 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-22 16:34:21 +08:00
|
|
|
|
} else if row == 12 {
|
2020-06-19 13:50:17 +08:00
|
|
|
|
Toast.push() { (a) in
|
|
|
|
|
a.update { (vm) in
|
|
|
|
|
vm.scene = .warning
|
2020-06-19 19:13:33 +08:00
|
|
|
|
vm.title = "正在同步看到了你撒地"
|
2020-06-19 09:49:24 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-22 16:34:21 +08:00
|
|
|
|
} else if row == 13 {
|
2020-06-22 10:36:33 +08:00
|
|
|
|
Toast.push() { (a) in
|
|
|
|
|
a.update { (vm) in
|
|
|
|
|
vm.scene = .warning
|
|
|
|
|
vm.message = "正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过"
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-22 16:34:21 +08:00
|
|
|
|
} else if row == 14 {
|
2020-06-22 10:36:33 +08:00
|
|
|
|
|
|
|
|
|
Toast.push(scene: .privacy, title: "正在授权", message: "请稍等片刻") { (t) in
|
|
|
|
|
t.identifier = "loading"
|
|
|
|
|
let imgv = UIImageView(image: UIImage(named: "prohud.rainbow.circle"))
|
|
|
|
|
t.imageView.addSubview(imgv)
|
|
|
|
|
imgv.snp.makeConstraints { (mk) in
|
|
|
|
|
mk.center.equalToSuperview()
|
|
|
|
|
mk.width.height.equalTo(18)
|
|
|
|
|
}
|
2020-06-22 13:27:54 +08:00
|
|
|
|
t.startRotate(imgv.layer, speed: 4)
|
2020-06-22 10:36:33 +08:00
|
|
|
|
}
|
|
|
|
|
simulateSync()
|
|
|
|
|
}
|
2019-08-12 17:59:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func simulateSync() {
|
2020-06-19 19:13:33 +08:00
|
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 10) {
|
2019-08-12 20:20:07 +08:00
|
|
|
|
Toast.find("loading", last: { (t) in
|
2019-08-12 17:59:40 +08:00
|
|
|
|
t.update { (vm) in
|
|
|
|
|
vm.scene = .success
|
|
|
|
|
vm.title = "同步成功"
|
|
|
|
|
vm.message = "啊哈哈哈哈哈哈哈哈"
|
|
|
|
|
}
|
2019-08-12 20:20:07 +08:00
|
|
|
|
})
|
2019-08-12 17:59:40 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|