123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- //
- // ASGeneratorErrorView.swift
- // AICalendarWallpaper
- //
- // Created by 100Years on 2025/5/26.
- //
- class ASGeneratorErrorView: AIBaseView {
-
- var style:ASGeneratorView.Style = .generalError{
- didSet{
- debugPrint("ASGeneratorErrorView style = \(style)")
- switch style {
- case .sensitiveError:
- sensitiveErrorView()
- case .netWorkError:
- netWorkErrorView()
- default:
- generalErrorView()
- }
- }
- }
- var isUploadImage:Bool = true
- lazy var cusStackView: UIStackView = {
- let cusStackView = UIStackView()
- cusStackView.axis = .vertical
- cusStackView.distribution = .fill
- cusStackView.alignment = .center
- return cusStackView
- }()
-
- lazy var errorImageView: UIImageView = {
- let errorImageView = UIImageView.createImageView(imageName: "yellow_warning")
- return errorImageView
- }()
-
- lazy var textLabel: UILabel = {
- let textLabel = UILabel.createLabel(font: .font(size: 14),textColor: .white,textAlignment: .center,numberOfLines: 0)
- return textLabel
- }()
-
- lazy var submitBtn: UIButton = {
- let textColor = "#B48EFF".uiColor
- let btn = UIButton.createBtn(title: "Generate in the background".localized,font: .font(size: 16),titleColor: textColor,corner: 24)
- btn.layer.borderColor = textColor.cgColor
- btn.layer.borderWidth = 1.0
- btn.titleLabel?.adjustsFontSizeToFitWidth = true
- return btn
- }()
-
- override func setupViews() {
-
- contentView.addSubview(cusStackView)
- cusStackView.snp.makeConstraints { make in
- make.edges.equalToSuperview()
- }
-
- cusStackView.addArrangedSubview(errorImageView)
- errorImageView.snp.makeConstraints { make in
- make.top.equalTo(0)
- make.width.height.equalTo(56)
- }
-
- cusStackView.addSpacing(length: 12.0)
-
- cusStackView.addArrangedSubview(textLabel)
- textLabel.snp.makeConstraints { make in
- make.leading.equalTo(24)
- make.trailing.equalTo(-24)
- }
-
- cusStackView.addSpacing(length: 28.0)
-
- cusStackView.addArrangedSubview(submitBtn)
- submitBtn.snp.makeConstraints { make in
- make.width.equalTo(250)
- make.height.equalTo(48)
- make.bottom.equalTo(0)
- }
- }
- }
- extension ASGeneratorErrorView {
- func sensitiveErrorView() {
- submitBtn.setTitle(isUploadImage ? "Reselect photos".localized : "Got it".localized, for: .normal)
- // errorImageView.image = UIImage(named: "yellow_warning")
- errorImageView.image = .generationFailed
- errorImageView.snp.updateConstraints { make in
- make.width.height.equalTo(56)
- }
- textLabel.text = "Your photo may contain nudity, gore or violence that does not comply with the health policy, please replace the photo and try again.".localized
-
- }
-
- func generalErrorView() {
- submitBtn.setTitle("Got it".localized, for: .normal)
- errorImageView.image = .generationFailed
-
- errorImageView.snp.updateConstraints { make in
- make.width.height.equalTo(120)
- }
-
- textLabel.text = "Sorry there was a slight problem with the image processing, please try again later.".localized
- }
-
-
- func netWorkErrorView() {
- submitBtn.setTitle("Try Again".localized, for: .normal)
- errorImageView.image = UIImage(named: "network_error")
-
- errorImageView.snp.updateConstraints { make in
- make.width.height.equalTo(120)
- }
-
- textLabel.text = "No network, please check your network and try again.".localized
- }
- }
|