| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- //
- // LNNoMoreDataView.swift
- // Lanu
- //
- // Created by OneeChan on 2025/12/29.
- //
- import Foundation
- import UIKit
- import SnapKit
- class LNNoMoreDataView: UIView {
- private let stackView = UIStackView()
- let imageView = UIImageView()
- let tipsLabel = UILabel()
-
- override init(frame: CGRect) {
- super.init(frame: frame)
-
- setupViews()
- }
-
- func showNetworkError() {
- imageView.image = .icNoDataNetworkError
- tipsLabel.text = .init(key: "A00004")
- isHidden = false
- }
-
- func showNoData(icon: UIImage = .icNoDataEmpty,
- tips: String = .init(key: "A00005")) {
- imageView.image = icon
- tipsLabel.text = tips
- isHidden = false
- }
-
- func addActionView(_ view: UIView) {
- stackView.addArrangedSubview(view)
- }
-
- func hide() {
- isHidden = true
- }
-
- required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
- extension LNNoMoreDataView {
- private func setupViews() {
- isHidden = true
-
- snp.makeConstraints { make in
- make.width.lessThanOrEqualTo(260)
- }
-
- stackView.axis = .vertical
- stackView.spacing = 24
- stackView.alignment = .center
- addSubview(stackView)
- stackView.snp.makeConstraints { make in
- make.edges.equalToSuperview()
- }
-
- let emptyView = UIView()
- stackView.addArrangedSubview(emptyView)
-
- emptyView.addSubview(imageView)
- imageView.snp.makeConstraints { make in
- make.centerX.equalToSuperview()
- make.top.equalToSuperview()
- make.width.height.equalTo(0).priority(.low)
- }
-
- tipsLabel.font = .body_s
- tipsLabel.textColor = .text_2
- tipsLabel.numberOfLines = 0
- tipsLabel.textAlignment = .center
- emptyView.addSubview(tipsLabel)
- tipsLabel.snp.makeConstraints { make in
- make.horizontalEdges.equalToSuperview()
- make.top.equalTo(imageView.snp.bottom).offset(14)
- make.bottom.equalToSuperview()
- }
- }
- }
|