Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(voting): cancel username request #631

Merged
merged 14 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DashPay/Presentation/Home/Views/DWDPWelcomeView.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

#import "DWDPWelcomeView.h"

#import "DWShadowView.h"
#import "DWUIKit.h"
#import "UIView+DWAnimations.h"
#import "dashwallet-Swift.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#import "DWEditProfileBaseCell.h"

#import "DWShadowView.h"
#import "DWUIKit.h"
#import "dashwallet-Swift.h"


NS_ASSUME_NONNULL_BEGIN
Expand Down
148 changes: 148 additions & 0 deletions DashPay/Presentation/Profile/UserProfile/DPWelcomeMenuView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
//
// Created by Andrew Podkovyrin
// Copyright © 2020 Dash Core Group. All rights reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import UIKit

enum DPWelcomState {
case none
case voting
}

@objc(DWDPWelcomeMenuView)
class DPWelcomeMenuView: UIView {
private let prefs = VotingPrefs.shared

private let titleLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.textColor = .dw_label()
label.numberOfLines = 1
label.adjustsFontForContentSizeCategory = true
label.font = .dw_mediumFont(ofSize: 15)
label.text = NSLocalizedString("Join DashPay", comment: "")

return label
}()

private let subtitleLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.textColor = .dw_tertiaryText()
label.numberOfLines = 1
label.adjustsFontForContentSizeCategory = true
label.font = .dw_regularFont(ofSize: 12)
label.text = NSLocalizedString("Request your username", comment: "")

return label
}()

override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
setupView()
}

@objc
func refreshState() {
changeState(state: prefs.requestedUsernameId != nil ? .voting : .none, username: prefs.requestedUsername)
}

private func setupView() {
backgroundColor = UIColor.clear

let shadowView = ShadowView(frame: .zero)
shadowView.translatesAutoresizingMaskIntoConstraints = false
shadowView.insetsLayoutMarginsFromSafeArea = true
addSubview(shadowView)

let contentView = UIView()
contentView.translatesAutoresizingMaskIntoConstraints = false
contentView.backgroundColor = .dw_background()
contentView.layer.cornerRadius = 8.0
contentView.layer.masksToBounds = true
shadowView.addSubview(contentView)

let imageView = UIImageView(image: UIImage(named: "dp_user_generic"))
imageView.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(imageView)

contentView.addSubview(titleLabel)
contentView.addSubview(subtitleLabel)

let chevronView = UIImageView(image: UIImage(named: "greyarrow"))
chevronView.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(chevronView)

let padding: CGFloat = 20.0
let horizontalPadding: CGFloat = 12

NSLayoutConstraint.activate([
contentView.heightAnchor.constraint(equalToConstant: 68),

shadowView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: padding),
shadowView.topAnchor.constraint(equalTo: topAnchor),
shadowView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -padding),
shadowView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),

contentView.leadingAnchor.constraint(equalTo: shadowView.leadingAnchor),
contentView.topAnchor.constraint(equalTo: shadowView.topAnchor),
contentView.trailingAnchor.constraint(equalTo: shadowView.trailingAnchor),
bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: 12),

imageView.heightAnchor.constraint(equalToConstant: 34),
imageView.widthAnchor.constraint(equalToConstant: 34),
imageView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 15),
imageView.centerYAnchor.constraint(equalTo: contentView.centerYAnchor),

titleLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 20),
titleLabel.leadingAnchor.constraint(equalTo: imageView.trailingAnchor, constant: horizontalPadding),

contentView.trailingAnchor.constraint(equalTo: titleLabel.trailingAnchor, constant: horizontalPadding),

subtitleLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 2),
subtitleLabel.leadingAnchor.constraint(equalTo: imageView.trailingAnchor, constant: horizontalPadding),

chevronView.heightAnchor.constraint(equalToConstant: 16),
chevronView.widthAnchor.constraint(equalToConstant: 9),
chevronView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -25),
chevronView.centerYAnchor.constraint(equalTo: contentView.centerYAnchor)
])

refreshState()
}

private func changeState(state: DPWelcomState, username: String?) {
switch state {
case .none:
titleLabel.text = NSLocalizedString("Join DashPay", comment: "")
subtitleLabel.text = NSLocalizedString("Request your username", comment: "")
case .voting:
titleLabel.text = username ?? ""
let startDate = Date(timeIntervalSince1970: VotingConstants.votingStartTime)
let endDate = Date(timeIntervalSince1970: VotingConstants.votingEndTime)
let startDateStr = DWDateFormatter.sharedInstance.dateOnly(from: startDate)
let endDateStr = DWDateFormatter.sharedInstance.dateOnly(from: endDate)
let votingPeriod = "\(startDateStr) - \(endDateStr)"
subtitleLabel.text = String.localizedStringWithFormat(NSLocalizedString("Requested · Voting: %@", comment: ""), votingPeriod)
}
}
}

28 changes: 0 additions & 28 deletions DashPay/Presentation/Profile/UserProfile/DWDPWelcomeMenuView.h

This file was deleted.

126 changes: 0 additions & 126 deletions DashPay/Presentation/Profile/UserProfile/DWDPWelcomeMenuView.m

This file was deleted.

Loading