feat: update wallet punch point and report success
This commit is contained in:
@ -38,9 +38,9 @@ enum HomeCollectionLayoutBuilder {
|
||||
let section = sectionIndex < sections.count ? sections[sectionIndex] : .commonApps
|
||||
switch section {
|
||||
case .workStatus:
|
||||
return fullWidthSection(height: AppSpacing.formRowHeight)
|
||||
return fullWidthSection(height: 84)
|
||||
case .locationReport:
|
||||
return fullWidthSection(height: 100)
|
||||
return fullWidthSection(height: 132)
|
||||
case .quickActions:
|
||||
return fullWidthSection(height: 72)
|
||||
case .store:
|
||||
|
||||
@ -186,7 +186,7 @@ final class HomeViewController: BaseViewController {
|
||||
Task { await self.viewModel.manualReportLocation(api: self.homeAPI) }
|
||||
}
|
||||
cell.apply(
|
||||
address: self.viewModel.locationInfoText,
|
||||
address: HomeViewModel.locationReportPromptText,
|
||||
isReporting: self.viewModel.isLocationReporting
|
||||
)
|
||||
return cell
|
||||
@ -266,8 +266,6 @@ final class HomeViewController: BaseViewController {
|
||||
|
||||
applyViewModel()
|
||||
await evaluateDialogsWithDelay()
|
||||
await viewModel.refreshLocationInfo()
|
||||
applyViewModel()
|
||||
}
|
||||
|
||||
private func evaluateDialogsWithDelay() async {
|
||||
|
||||
@ -11,47 +11,80 @@ final class HomeLocationReportCardView: UIView {
|
||||
|
||||
var onReportTap: (() -> Void)?
|
||||
|
||||
private let titleStackView = UIStackView()
|
||||
private let titleIconView = UIImageView(image: UIImage(systemName: "arrow.up.square.fill"))
|
||||
private let titleLabel = UILabel()
|
||||
private let addressLabel = UILabel()
|
||||
private let reportButtonContainer = UIView()
|
||||
private let reportButton = UIButton(type: .system)
|
||||
private let reportGradientLayer = CAGradientLayer()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
backgroundColor = AppColor.cardBackground
|
||||
layer.cornerRadius = AppRadius.md
|
||||
clipsToBounds = true
|
||||
|
||||
titleLabel.text = "位置上报"
|
||||
titleLabel.font = .app(.title)
|
||||
titleStackView.axis = .horizontal
|
||||
titleStackView.alignment = .center
|
||||
titleStackView.spacing = AppSpacing.xs
|
||||
|
||||
titleIconView.tintColor = AppColor.primary
|
||||
titleIconView.contentMode = .scaleAspectFit
|
||||
|
||||
titleLabel.text = "立即上报"
|
||||
titleLabel.font = .systemFont(ofSize: 22, weight: .bold)
|
||||
titleLabel.textColor = AppColor.textPrimary
|
||||
|
||||
addressLabel.font = .app(.body)
|
||||
addressLabel.textColor = AppColor.textSecondary
|
||||
addressLabel.font = .systemFont(ofSize: 15, weight: .regular)
|
||||
addressLabel.textColor = AppColor.textTertiary
|
||||
addressLabel.numberOfLines = 2
|
||||
|
||||
reportButton.setTitle("立即上报", for: .normal)
|
||||
reportButton.setTitleColor(.white, for: .normal)
|
||||
reportButton.backgroundColor = AppColor.primary
|
||||
reportButton.layer.cornerRadius = AppRadius.sm
|
||||
reportButton.titleLabel?.font = .app(.bodyMedium)
|
||||
reportButton.contentEdgeInsets = UIEdgeInsets(top: AppSpacing.xs, left: 14, bottom: AppSpacing.xs, right: 14)
|
||||
reportGradientLayer.colors = [AppColor.primary.cgColor, UIColor(hex: 0x5CA8FF).cgColor]
|
||||
reportGradientLayer.startPoint = CGPoint(x: 0.5, y: 0)
|
||||
reportGradientLayer.endPoint = CGPoint(x: 0.5, y: 1)
|
||||
reportButtonContainer.layer.insertSublayer(reportGradientLayer, at: 0)
|
||||
reportButtonContainer.layer.cornerRadius = 46
|
||||
reportButtonContainer.clipsToBounds = true
|
||||
|
||||
reportButton.backgroundColor = .clear
|
||||
reportButton.tintColor = .white
|
||||
reportButton.setImage(UIImage(systemName: "hand.tap.fill"), for: .normal)
|
||||
reportButton.setPreferredSymbolConfiguration(
|
||||
UIImage.SymbolConfiguration(pointSize: 38, weight: .semibold),
|
||||
forImageIn: .normal
|
||||
)
|
||||
reportButton.imageView?.contentMode = .scaleAspectFit
|
||||
reportButton.addTarget(self, action: #selector(reportTapped), for: .touchUpInside)
|
||||
reportButton.accessibilityLabel = "上报位置"
|
||||
|
||||
addSubview(titleLabel)
|
||||
titleStackView.addArrangedSubview(titleIconView)
|
||||
titleStackView.addArrangedSubview(titleLabel)
|
||||
addSubview(titleStackView)
|
||||
addSubview(addressLabel)
|
||||
addSubview(reportButton)
|
||||
addSubview(reportButtonContainer)
|
||||
reportButtonContainer.addSubview(reportButton)
|
||||
|
||||
titleLabel.snp.makeConstraints { make in
|
||||
make.top.leading.equalToSuperview().offset(AppSpacing.screenHorizontalInset)
|
||||
titleIconView.snp.makeConstraints { make in
|
||||
make.width.height.equalTo(25)
|
||||
}
|
||||
titleStackView.snp.makeConstraints { make in
|
||||
make.leading.equalToSuperview().offset(15)
|
||||
make.top.equalToSuperview().offset(15)
|
||||
make.trailing.lessThanOrEqualTo(reportButtonContainer.snp.leading).offset(-AppSpacing.sm)
|
||||
}
|
||||
addressLabel.snp.makeConstraints { make in
|
||||
make.top.equalTo(titleLabel.snp.bottom).offset(AppSpacing.xs)
|
||||
make.leading.equalToSuperview().offset(AppSpacing.screenHorizontalInset)
|
||||
make.bottom.equalToSuperview().offset(-AppSpacing.screenHorizontalInset)
|
||||
make.trailing.lessThanOrEqualTo(reportButton.snp.leading).offset(-AppSpacing.sm)
|
||||
make.top.equalTo(titleStackView.snp.bottom).offset(AppSpacing.xxs)
|
||||
make.leading.equalTo(titleStackView)
|
||||
make.trailing.lessThanOrEqualTo(reportButtonContainer.snp.leading).offset(-AppSpacing.sm)
|
||||
}
|
||||
reportButtonContainer.snp.makeConstraints { make in
|
||||
make.trailing.equalToSuperview().offset(-15)
|
||||
make.centerY.equalToSuperview()
|
||||
make.width.height.equalTo(92)
|
||||
}
|
||||
reportButton.snp.makeConstraints { make in
|
||||
make.trailing.equalToSuperview().offset(-AppSpacing.screenHorizontalInset)
|
||||
make.centerY.equalToSuperview()
|
||||
make.edges.equalToSuperview()
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,10 +93,19 @@ final class HomeLocationReportCardView: UIView {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
reportGradientLayer.frame = reportButtonContainer.bounds
|
||||
reportGradientLayer.cornerRadius = reportButtonContainer.bounds.width / 2
|
||||
}
|
||||
|
||||
func apply(address: String, isReporting: Bool) {
|
||||
addressLabel.text = address
|
||||
reportButton.isEnabled = !isReporting
|
||||
reportButton.alpha = isReporting ? 0.6 : 1
|
||||
reportButton.alpha = 1
|
||||
reportGradientLayer.colors = isReporting
|
||||
? [UIColor(hex: 0xC9CED6).cgColor, UIColor(hex: 0xD9DDE4).cgColor]
|
||||
: [AppColor.primary.cgColor, UIColor(hex: 0x5CA8FF).cgColor]
|
||||
}
|
||||
|
||||
@objc private func reportTapped() { onReportTap?() }
|
||||
|
||||
@ -12,7 +12,10 @@ final class HomeWorkStatusCardView: UIView {
|
||||
var onOnlineTap: (() -> Void)?
|
||||
var onReminderTap: (() -> Void)?
|
||||
|
||||
private let contentStackView = UIStackView()
|
||||
private let onlineButton = UIButton(type: .system)
|
||||
private let countdownStackView = UIStackView()
|
||||
private let countdownIconView = UIImageView(image: UIImage(systemName: "clock"))
|
||||
private let countdownLabel = UILabel()
|
||||
private let reminderButton = UIButton(type: .system)
|
||||
|
||||
@ -20,36 +23,57 @@ final class HomeWorkStatusCardView: UIView {
|
||||
super.init(frame: frame)
|
||||
backgroundColor = AppColor.cardBackground
|
||||
layer.cornerRadius = AppRadius.md
|
||||
clipsToBounds = true
|
||||
|
||||
contentStackView.axis = .horizontal
|
||||
contentStackView.alignment = .center
|
||||
contentStackView.distribution = .equalSpacing
|
||||
contentStackView.spacing = AppSpacing.sm
|
||||
|
||||
onlineButton.titleLabel?.font = .app(.captionMedium)
|
||||
onlineButton.layer.cornerRadius = AppRadius.xs
|
||||
onlineButton.contentEdgeInsets = UIEdgeInsets(top: 6, left: 12, bottom: 6, right: 12)
|
||||
onlineButton.addTarget(self, action: #selector(onlineTapped), for: .touchUpInside)
|
||||
|
||||
countdownStackView.axis = .horizontal
|
||||
countdownStackView.alignment = .center
|
||||
countdownStackView.spacing = 6
|
||||
countdownIconView.tintColor = AppColor.primary
|
||||
countdownIconView.contentMode = .scaleAspectFit
|
||||
countdownIconView.setContentCompressionResistancePriority(.required, for: .horizontal)
|
||||
|
||||
countdownLabel.font = .app(.subtitle)
|
||||
countdownLabel.textColor = AppColor.primary
|
||||
countdownLabel.adjustsFontSizeToFitWidth = true
|
||||
countdownLabel.minimumScaleFactor = 0.85
|
||||
countdownLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
|
||||
|
||||
reminderButton.titleLabel?.font = .app(.subtitle)
|
||||
reminderButton.setTitleColor(AppColor.primary, for: .normal)
|
||||
reminderButton.tintColor = AppColor.primary
|
||||
reminderButton.setImage(UIImage(systemName: "bell.fill"), for: .normal)
|
||||
reminderButton.semanticContentAttribute = .forceLeftToRight
|
||||
reminderButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 6)
|
||||
reminderButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 6, bottom: 0, right: -6)
|
||||
reminderButton.titleLabel?.adjustsFontSizeToFitWidth = true
|
||||
reminderButton.titleLabel?.minimumScaleFactor = 0.8
|
||||
reminderButton.addTarget(self, action: #selector(reminderTapped), for: .touchUpInside)
|
||||
|
||||
addSubview(onlineButton)
|
||||
addSubview(countdownLabel)
|
||||
addSubview(reminderButton)
|
||||
countdownStackView.addArrangedSubview(countdownIconView)
|
||||
countdownStackView.addArrangedSubview(countdownLabel)
|
||||
contentStackView.addArrangedSubview(onlineButton)
|
||||
contentStackView.addArrangedSubview(countdownStackView)
|
||||
contentStackView.addArrangedSubview(reminderButton)
|
||||
addSubview(contentStackView)
|
||||
|
||||
onlineButton.snp.makeConstraints { make in
|
||||
make.leading.equalToSuperview().offset(AppSpacing.screenHorizontalInset)
|
||||
make.centerY.equalToSuperview()
|
||||
contentStackView.snp.makeConstraints { make in
|
||||
make.edges.equalToSuperview().inset(15)
|
||||
}
|
||||
countdownLabel.snp.makeConstraints { make in
|
||||
make.center.equalToSuperview()
|
||||
}
|
||||
reminderButton.snp.makeConstraints { make in
|
||||
make.trailing.equalToSuperview().offset(-AppSpacing.screenHorizontalInset)
|
||||
make.centerY.equalToSuperview()
|
||||
countdownIconView.snp.makeConstraints { make in
|
||||
make.width.height.equalTo(15)
|
||||
}
|
||||
snp.makeConstraints { make in
|
||||
make.height.equalTo(AppSpacing.formRowHeight)
|
||||
make.height.equalTo(84)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user