This commit is contained in:
xaoxuu 2020-06-24 14:09:12 +08:00
parent b6f4fdd781
commit 7a0eaac1ae
2 changed files with 68 additions and 24 deletions

View File

@ -9,6 +9,7 @@
import UIKit import UIKit
import ProHUD import ProHUD
import Inspire import Inspire
import WebKit
class TestGuardVC: BaseListVC { class TestGuardVC: BaseListVC {
@ -16,8 +17,8 @@ class TestGuardVC: BaseListVC {
super.viewDidLoad() super.viewDidLoad()
vm.addSection(title: "简单使用") { (sec) in vm.addSection(title: "简单使用") { (sec) in
// MARK: // MARK:
sec.addRow(title: "场景:删除菜单") { sec.addRow(title: "示例:删除菜单") {
Guard.push("del") { (vc) in Guard.push("del") { (vc) in
vc.update { (vm) in vc.update { (vm) in
vm.add(action: .destructive, title: "删除") { [weak vc] in vm.add(action: .destructive, title: "删除") { [weak vc] in
@ -36,8 +37,8 @@ class TestGuardVC: BaseListVC {
} }
} }
// MARK: // MARK:
sec.addRow(title: "场景:升级至专业版") { sec.addRow(title: "示例:升级至专业版") {
// id // id
Guard.push("pro") { (vc) in Guard.push("pro") { (vc) in
vc.identifier = "pro" vc.identifier = "pro"
@ -84,10 +85,9 @@ class TestGuardVC: BaseListVC {
} }
vm.addSection(title: "添加自定义视图") { (sec) in vm.addSection(title: "添加自定义视图") { (sec) in
// MARK: // MARK:
sec.addRow(title: "场景:选项切换", subtitle: "很方便地添加自定义控件") { sec.addRow(title: "示例:修改背景蒙版", subtitle: "很方便地添加自定义控件") {
Guard.push() { (vc) in Guard.push() { (vc) in
if #available(iOS 13.0, *) { if #available(iOS 13.0, *) {
let imgv = UIImageView(image: UIImage(systemName: "photo.fill.on.rectangle.fill")) let imgv = UIImageView(image: UIImage(systemName: "photo.fill.on.rectangle.fill"))
vc.textStack.addArrangedSubview(imgv) vc.textStack.addArrangedSubview(imgv)
@ -99,15 +99,20 @@ class TestGuardVC: BaseListVC {
// Fallback on earlier versions // Fallback on earlier versions
} }
//
vc.vm.add(title: "背景蒙版") vc.vm.add(title: "背景蒙版")
//
vc.vm.add(subTitle: "选择一种模糊效果") vc.vm.add(subTitle: "选择一种模糊效果")
//
let seg = UISegmentedControl(items: ["extraLight", "light", "dark", "none"]) let seg = UISegmentedControl(items: ["extraLight", "light", "dark", "none"])
seg.selectedSegmentIndex = 1 seg.selectedSegmentIndex = 1
vc.textStack.addArrangedSubview(seg) vc.textStack.addArrangedSubview(seg)
seg.snp.makeConstraints { (mk) in seg.snp.makeConstraints { (mk) in
mk.height.equalTo(40) mk.height.equalTo(40)
} }
//
vc.vm.add(subTitle: "设置蒙版透明度") vc.vm.add(subTitle: "设置蒙版透明度")
//
let slider = UISlider() let slider = UISlider()
slider.minimumValue = 0 slider.minimumValue = 0
slider.maximumValue = 100 slider.maximumValue = 100
@ -116,31 +121,39 @@ class TestGuardVC: BaseListVC {
slider.snp.makeConstraints { (mk) in slider.snp.makeConstraints { (mk) in
mk.height.equalTo(40) mk.height.equalTo(40)
} }
//
vc.vm.add(action: .default, title: "OK") { [weak vc] in vc.vm.add(action: .default, title: "OK") { [weak vc] in
vc?.pop() vc?.pop()
} }
} }
} }
// MARK: // MARK:
sec.addRow(title: "场景:隐私协议页面", subtitle: "也可以完全控制整个页面") { sec.addRow(title: "示例:弹出隐私协议页面", subtitle: "也可以完全控制整个页面") {
Guard.push("license") { (vc) in Guard.push("license") { (vc) in
//
vc.isFullScreen = true vc.isFullScreen = true
vc.update { (vm) in //
let titleLabel = vm.add(title: "隐私协议") vc.vm.add(title: "隐私协议").snp.makeConstraints { (mk) in
titleLabel.snp.makeConstraints { (mk) in
mk.height.equalTo(44) mk.height.equalTo(44)
} }
let tv = UITextView() //
tv.backgroundColor = .white let web = WKWebView.init(frame: .zero)
tv.isEditable = false web.layer.masksToBounds = true
vc.textStack.addArrangedSubview(tv) web.layer.cornerRadius = ProHUD.shared.config.guard.buttonCornerRadius
tv.text = "这里可以插入一个webView" web.scrollView.showsHorizontalScrollIndicator = false
vm.add(message: "请认真阅读以上内容,当您阅读完毕并同意协议内容时点击接受按钮。") if let url = URL(string: "https://xaoxuu.com/wiki/prohud/") {
web.load(URLRequest(url: url))
vm.add(action: .default, title: "接受") { [weak vc] in
vc?.pop()
} }
vc.textStack.addArrangedSubview(web)
web.snp.makeConstraints { (mk) in
mk.leading.trailing.equalToSuperview()
}
//
vc.vm.add(message: "请认真阅读以上内容,当您阅读完毕并同意协议内容时点击接受按钮。")
//
vc.vm.add(action: .default, title: "接受") { [weak vc] in
vc?.pop()
} }
} }
} }

View File

@ -9,6 +9,7 @@
import UIKit import UIKit
import ProHUD import ProHUD
import SnapKit import SnapKit
import WebKit
class ViewController: BaseListVC { class ViewController: BaseListVC {
@ -17,6 +18,7 @@ class ViewController: BaseListVC {
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
title = "\(Bundle.main.infoDictionary?["CFBundleName"] ?? "ProHUD")" title = "\(Bundle.main.infoDictionary?["CFBundleName"] ?? "ProHUD")"
vm.addSection(title: "测试项目") { (sec) in vm.addSection(title: "测试项目") { (sec) in
sec.addRow(title: "Toast", subtitle: "横幅控件,支持图片、标题和正文。\n不支持添加按钮,但可以接受一个点击事件。") { sec.addRow(title: "Toast", subtitle: "横幅控件,支持图片、标题和正文。\n不支持添加按钮,但可以接受一个点击事件。") {
let vc = TestToastVC() let vc = TestToastVC()
@ -54,6 +56,35 @@ class ViewController: BaseListVC {
} }
} }
vm.addSection(title: "更多") { (sec) in
sec.addRow(title: "查看在线文档", subtitle: "https://xaoxuu.com/wiki/prohud/") {
Guard.push("license") { (vc) in
//
vc.isFullScreen = true
//
vc.vm.add(title: "ProHUD").snp.makeConstraints { (mk) in
mk.height.equalTo(44)
}
//
let web = WKWebView.init(frame: .zero)
web.layer.masksToBounds = true
web.layer.cornerRadius = ProHUD.shared.config.guard.buttonCornerRadius
web.scrollView.showsHorizontalScrollIndicator = false
if let url = URL(string: "https://xaoxuu.com/wiki/prohud/") {
web.load(URLRequest(url: url))
}
vc.textStack.addArrangedSubview(web)
web.snp.makeConstraints { (mk) in
mk.leading.trailing.equalToSuperview()
}
//
vc.vm.add(action: .default, title: "关闭") { [weak vc] in
vc?.pop()
}
}
}
}
} }
} }