mirror of https://github.com/xaoxuu/ProHUD
支持设置网络图标
This commit is contained in:
parent
8992349953
commit
e64976bb08
|
@ -3,7 +3,7 @@
|
||||||
archiveVersion = 1;
|
archiveVersion = 1;
|
||||||
classes = {
|
classes = {
|
||||||
};
|
};
|
||||||
objectVersion = 55;
|
objectVersion = 60;
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
@ -11,6 +11,8 @@
|
||||||
CD6537C128C35E1C00A5981B /* ListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6537C028C35E1C00A5981B /* ListVC.swift */; };
|
CD6537C128C35E1C00A5981B /* ListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6537C028C35E1C00A5981B /* ListVC.swift */; };
|
||||||
CD6537C328C35E6200A5981B /* ToastVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6537C228C35E6200A5981B /* ToastVC.swift */; };
|
CD6537C328C35E6200A5981B /* ToastVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6537C228C35E6200A5981B /* ToastVC.swift */; };
|
||||||
CD6537C528C35F2C00A5981B /* SheetVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6537C428C35F2C00A5981B /* SheetVC.swift */; };
|
CD6537C528C35F2C00A5981B /* SheetVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6537C428C35F2C00A5981B /* SheetVC.swift */; };
|
||||||
|
CD6AE8A32A7CC1BA0044E53D /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = CD6AE8A22A7CC1BA0044E53D /* SnapKit */; };
|
||||||
|
CD6AE8A62A7CC1C70044E53D /* Inspire in Frameworks */ = {isa = PBXBuildFile; productRef = CD6AE8A52A7CC1C70044E53D /* Inspire */; };
|
||||||
CD8EEF3B28BC5C7200E660EA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD8EEF3A28BC5C7200E660EA /* AppDelegate.swift */; };
|
CD8EEF3B28BC5C7200E660EA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD8EEF3A28BC5C7200E660EA /* AppDelegate.swift */; };
|
||||||
CD8EEF3D28BC5C7200E660EA /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD8EEF3C28BC5C7200E660EA /* SceneDelegate.swift */; };
|
CD8EEF3D28BC5C7200E660EA /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD8EEF3C28BC5C7200E660EA /* SceneDelegate.swift */; };
|
||||||
CD8EEF4228BC5C7200E660EA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CD8EEF4028BC5C7200E660EA /* Main.storyboard */; };
|
CD8EEF4228BC5C7200E660EA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CD8EEF4028BC5C7200E660EA /* Main.storyboard */; };
|
||||||
|
@ -45,7 +47,9 @@
|
||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
CD6AE8A62A7CC1C70044E53D /* Inspire in Frameworks */,
|
||||||
CDB6A2A228BC5F4600DEC80D /* ProHUD in Frameworks */,
|
CDB6A2A228BC5F4600DEC80D /* ProHUD in Frameworks */,
|
||||||
|
CD6AE8A32A7CC1BA0044E53D /* SnapKit in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -123,6 +127,8 @@
|
||||||
name = PHDemo;
|
name = PHDemo;
|
||||||
packageProductDependencies = (
|
packageProductDependencies = (
|
||||||
CDB6A2A128BC5F4600DEC80D /* ProHUD */,
|
CDB6A2A128BC5F4600DEC80D /* ProHUD */,
|
||||||
|
CD6AE8A22A7CC1BA0044E53D /* SnapKit */,
|
||||||
|
CD6AE8A52A7CC1C70044E53D /* Inspire */,
|
||||||
);
|
);
|
||||||
productName = PHDemo;
|
productName = PHDemo;
|
||||||
productReference = CD8EEF3728BC5C7200E660EA /* PHDemo.app */;
|
productReference = CD8EEF3728BC5C7200E660EA /* PHDemo.app */;
|
||||||
|
@ -152,6 +158,10 @@
|
||||||
Base,
|
Base,
|
||||||
);
|
);
|
||||||
mainGroup = CD8EEF2E28BC5C7200E660EA;
|
mainGroup = CD8EEF2E28BC5C7200E660EA;
|
||||||
|
packageReferences = (
|
||||||
|
CD6AE8A12A7CC1BA0044E53D /* XCLocalSwiftPackageReference "../../SnapKit" */,
|
||||||
|
CD6AE8A42A7CC1C70044E53D /* XCLocalSwiftPackageReference "../../Inspire" */,
|
||||||
|
);
|
||||||
productRefGroup = CD8EEF3828BC5C7200E660EA /* Products */;
|
productRefGroup = CD8EEF3828BC5C7200E660EA /* Products */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
projectRoot = "";
|
projectRoot = "";
|
||||||
|
@ -408,7 +418,26 @@
|
||||||
};
|
};
|
||||||
/* End XCConfigurationList section */
|
/* End XCConfigurationList section */
|
||||||
|
|
||||||
|
/* Begin XCLocalSwiftPackageReference section */
|
||||||
|
CD6AE8A12A7CC1BA0044E53D /* XCLocalSwiftPackageReference "../../SnapKit" */ = {
|
||||||
|
isa = XCLocalSwiftPackageReference;
|
||||||
|
relativePath = ../../SnapKit;
|
||||||
|
};
|
||||||
|
CD6AE8A42A7CC1C70044E53D /* XCLocalSwiftPackageReference "../../Inspire" */ = {
|
||||||
|
isa = XCLocalSwiftPackageReference;
|
||||||
|
relativePath = ../../Inspire;
|
||||||
|
};
|
||||||
|
/* End XCLocalSwiftPackageReference section */
|
||||||
|
|
||||||
/* Begin XCSwiftPackageProductDependency section */
|
/* Begin XCSwiftPackageProductDependency section */
|
||||||
|
CD6AE8A22A7CC1BA0044E53D /* SnapKit */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
productName = SnapKit;
|
||||||
|
};
|
||||||
|
CD6AE8A52A7CC1C70044E53D /* Inspire */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
productName = Inspire;
|
||||||
|
};
|
||||||
CDB6A2A128BC5F4600DEC80D /* ProHUD */ = {
|
CDB6A2A128BC5F4600DEC80D /* ProHUD */ = {
|
||||||
isa = XCSwiftPackageProductDependency;
|
isa = XCSwiftPackageProductDependency;
|
||||||
productName = ProHUD;
|
productName = ProHUD;
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
{
|
|
||||||
"pins" : [
|
|
||||||
{
|
|
||||||
"identity" : "inspire",
|
|
||||||
"kind" : "remoteSourceControl",
|
|
||||||
"location" : "https://github.com/xaoxuu/Inspire.git",
|
|
||||||
"state" : {
|
|
||||||
"revision" : "10d5a17ee24c8a66da9a3971c62c1d161d2a4cd2",
|
|
||||||
"version" : "3.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identity" : "snapkit",
|
|
||||||
"kind" : "remoteSourceControl",
|
|
||||||
"location" : "https://github.com/SnapKit/SnapKit.git",
|
|
||||||
"state" : {
|
|
||||||
"revision" : "f222cbdf325885926566172f6f5f06af95473158",
|
|
||||||
"version" : "5.6.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version" : 2
|
|
||||||
}
|
|
|
@ -46,6 +46,9 @@ class ToastVC: ListVC {
|
||||||
mask.backgroundColor = .clear
|
mask.backgroundColor = .clear
|
||||||
mask.effect = UIBlurEffect(style: .systemChromeMaterial)
|
mask.effect = UIBlurEffect(style: .systemChromeMaterial)
|
||||||
}
|
}
|
||||||
|
// config.customWebImage { imageView, imageURL in
|
||||||
|
// imageView.backgroundColor = .red
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
list.add(title: "默认布局") { section in
|
list.add(title: "默认布局") { section in
|
||||||
|
@ -85,6 +88,9 @@ class ToastVC: ListVC {
|
||||||
section.add(title: "图标 + 一段长文本") {
|
section.add(title: "图标 + 一段长文本") {
|
||||||
Toast(.note.message(message)).push()
|
Toast(.note.message(message)).push()
|
||||||
}
|
}
|
||||||
|
section.add(title: "网络图标 + 一段文本") {
|
||||||
|
Toast(.message("这是网络图标").icon(.init(string: "https://xaoxuu.com/assets/xaoxuu/avatar/rect-256@2x.png"))).push()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.add(title: "事件管理") { section in
|
list.add(title: "事件管理") { section in
|
||||||
|
|
|
@ -141,8 +141,11 @@ extension Alert {
|
||||||
// 移除进度
|
// 移除进度
|
||||||
progressView?.removeFromSuperview()
|
progressView?.removeFromSuperview()
|
||||||
|
|
||||||
if vm.icon != nil {
|
if vm.icon != nil || vm.iconURL != nil {
|
||||||
imageView.image = vm.icon
|
imageView.image = vm.icon
|
||||||
|
if let iconURL = vm.iconURL {
|
||||||
|
config.customWebImage?(imageView, iconURL)
|
||||||
|
}
|
||||||
if imageView.superview == nil {
|
if imageView.superview == nil {
|
||||||
contentStack.insertArrangedSubview(imageView, at: 0)
|
contentStack.insertArrangedSubview(imageView, at: 0)
|
||||||
imageView.snp.remakeConstraints { (mk) in
|
imageView.snp.remakeConstraints { (mk) in
|
||||||
|
|
|
@ -180,6 +180,23 @@ public class Configuration: NSObject {
|
||||||
|
|
||||||
// MARK: 自定义
|
// MARK: 自定义
|
||||||
|
|
||||||
|
/// 网络图标
|
||||||
|
var customWebImage: ((_ imageView: UIImageView, _ imageURL: URL) -> Void)? = { imgv, url in
|
||||||
|
DispatchQueue.global().async {
|
||||||
|
URLSession.shared.dataTask(with: .init(url: url)) { data, resp, err in
|
||||||
|
guard let data = data else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
imgv.image = UIImage(data: data)
|
||||||
|
}
|
||||||
|
}.resume()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public func customWebImage(handler: @escaping (_ imageView: UIImageView, _ imageURL: URL) -> Void) {
|
||||||
|
customWebImage = handler
|
||||||
|
}
|
||||||
|
|
||||||
var customReloadData: ((_ vc: Controller) -> Bool)?
|
var customReloadData: ((_ vc: Controller) -> Bool)?
|
||||||
|
|
||||||
/// 自定义刷新规则( ⚠️ 自定义此函数之后,整个容器将不再走默认布局规则,可实现完全自定义)
|
/// 自定义刷新规则( ⚠️ 自定义此函数之后,整个容器将不再走默认布局规则,可实现完全自定义)
|
||||||
|
|
|
@ -12,6 +12,7 @@ open class ViewModel: NSObject {
|
||||||
|
|
||||||
/// 图标
|
/// 图标
|
||||||
open var icon: UIImage?
|
open var icon: UIImage?
|
||||||
|
var iconURL: URL?
|
||||||
|
|
||||||
/// 图标旋转动画
|
/// 图标旋转动画
|
||||||
open var rotation: Rotation?
|
open var rotation: Rotation?
|
||||||
|
@ -66,6 +67,12 @@ public extension ViewModel {
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func icon(_ imageURL: URL?) -> ViewModel {
|
||||||
|
self.iconURL = imageURL
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func title(_ text: String?) -> ViewModel {
|
func title(_ text: String?) -> ViewModel {
|
||||||
self.title = text
|
self.title = text
|
||||||
return self
|
return self
|
||||||
|
|
|
@ -25,7 +25,7 @@ extension Toast: DefaultLayout {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if vm.icon != nil {
|
if vm.icon != nil || vm.iconURL != nil {
|
||||||
if imageView.superview == nil {
|
if imageView.superview == nil {
|
||||||
infoStack.insertArrangedSubview(imageView, at: 0)
|
infoStack.insertArrangedSubview(imageView, at: 0)
|
||||||
imageView.snp.makeConstraints { make in
|
imageView.snp.makeConstraints { make in
|
||||||
|
@ -70,7 +70,6 @@ extension Toast: DefaultLayout {
|
||||||
bodyLabel.removeFromSuperview()
|
bodyLabel.removeFromSuperview()
|
||||||
}
|
}
|
||||||
// 设置数据
|
// 设置数据
|
||||||
imageView.image = vm.icon
|
|
||||||
titleLabel.text = vm.title
|
titleLabel.text = vm.title
|
||||||
bodyLabel.text = vm.message
|
bodyLabel.text = vm.message
|
||||||
view.layoutIfNeeded()
|
view.layoutIfNeeded()
|
||||||
|
@ -133,6 +132,9 @@ extension Toast {
|
||||||
progressView?.removeFromSuperview()
|
progressView?.removeFromSuperview()
|
||||||
|
|
||||||
imageView.image = vm.icon
|
imageView.image = vm.icon
|
||||||
|
if let iconURL = vm.iconURL {
|
||||||
|
config.customWebImage?(imageView, iconURL)
|
||||||
|
}
|
||||||
if let rotation = vm.rotation {
|
if let rotation = vm.rotation {
|
||||||
startRotate(rotation)
|
startRotate(rotation)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue