Skip to content

Commit

Permalink
Merge branch 'feat/voting-changes' into feat/usernames-final-result
Browse files Browse the repository at this point in the history
  • Loading branch information
Syn-McJ committed Feb 4, 2025
2 parents 9de999e + 351bb33 commit 9c2947b
Show file tree
Hide file tree
Showing 61 changed files with 1,953 additions and 1,147 deletions.
2 changes: 1 addition & 1 deletion DashSyncCurrentCommit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d92d814f3f9a3d40126a9359b578831d8eb97293
60ac6c26f8391fed4e59d07b6439642976e45d88
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"images" : [
{
"filename" : "Vector.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Vector@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Vector@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ + (NSString *)transactionURLFormat {

+ (NSString *)logoutURLString {
return @"https://uphold.com/";

}

@end
Expand Down
44 changes: 29 additions & 15 deletions DashWallet/Sources/Models/Voting/VotingFiltersModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,19 @@ struct VotingFilters: Equatable {
enum FilterBy {
case all
case approved
case notApproved
case notVoted
case hasBlockVotes

var localizedString: String {
switch self {
case .all:
return NSLocalizedString("All", comment: "Voting")
case .approved:
return NSLocalizedString("I have approved", comment: "Voting")
case .notApproved:
return NSLocalizedString("I have not approved", comment: "Voting")
case .notVoted:
return NSLocalizedString("I have not voted", comment: "Voting")
case .hasBlockVotes:
return NSLocalizedString("Has blocked votes", comment: "Voting")
}
}
}
Expand All @@ -63,7 +66,7 @@ struct VotingFilters: Equatable {
var onlyDuplicates: Bool?
var onlyWithLinks: Bool?

static let defaultFilters = VotingFilters(sortBy: .datesDesc, filterBy: .notApproved, onlyDuplicates: true, onlyWithLinks: false)
static let defaultFilters = VotingFilters(sortBy: .datesDesc, filterBy: .notVoted, onlyDuplicates: true, onlyWithLinks: false)

var localizedDescription: String? {
var string: [String] = []
Expand Down Expand Up @@ -107,8 +110,10 @@ extension VotingFilters {
set.insert(.typeAll)
case .approved:
set.insert(.typeApproved)
case .notApproved:
set.insert(.typeNotApproved)
case .notVoted:
set.insert(.typeNotVoted)
case .hasBlockVotes:
set.insert(.typeHasBlockVotes)
}
}

Expand All @@ -133,7 +138,8 @@ enum VotingFilterItem: String {
case votesDesc
case typeAll
case typeApproved
case typeNotApproved
case typeNotVoted
case typeHasBlockVotes
case onlyDuplicates
case onlyRequestsWithLinks
case reset
Expand All @@ -149,11 +155,13 @@ enum VotingFilterItem: String {
case .votesDesc:
return [.dateAsc, .dateDesc, .votesAsc]
case .typeAll:
return [.typeApproved, .typeNotApproved]
return [.typeApproved, .typeNotVoted, .typeHasBlockVotes]
case .typeApproved:
return [.typeAll, .typeNotApproved]
case .typeNotApproved:
return [.typeApproved, .typeAll]
return [.typeAll, .typeNotVoted, .typeHasBlockVotes]
case .typeNotVoted:
return [.typeApproved, .typeAll, .typeHasBlockVotes]
case .typeHasBlockVotes:
return [.typeApproved, .typeAll, .typeNotVoted]
default:
return []
}
Expand Down Expand Up @@ -184,8 +192,10 @@ enum VotingFilterItem: String {
return NSLocalizedString("All", comment: "Voting")
case .typeApproved:
return NSLocalizedString("I have approved", comment: "Voting")
case .typeNotApproved:
return NSLocalizedString("I have not approved", comment: "Voting")
case .typeNotVoted:
return NSLocalizedString("I have not voted", comment: "Voting")
case .typeHasBlockVotes:
return NSLocalizedString("Has blocked votes", comment: "Voting")
case .reset:
return NSLocalizedString("Reset Filters", comment: "")
case .onlyDuplicates:
Expand Down Expand Up @@ -273,8 +283,12 @@ extension VotingFiltersModel {
filters.filterBy = .approved
}

if selected.contains(.typeNotApproved) {
filters.filterBy = .notApproved
if selected.contains(.typeNotVoted) {
filters.filterBy = .notVoted
}

if selected.contains(.typeHasBlockVotes) {
filters.filterBy = .hasBlockVotes
}

if selected.contains(.onlyDuplicates) {
Expand Down
70 changes: 43 additions & 27 deletions DashWallet/Sources/UI/DashPay/Voting/Cells/GroupedRequestCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,16 @@ final class GroupedRequestCell: UITableViewCell {
return label
}()

private let chevron: UIImageView = {
let image = UIImageView(image: UIImage(systemName: "chevron.down"))
image.contentMode = .scaleAspectFill
image.tintColor = .dw_label()
image.translatesAutoresizingMaskIntoConstraints = false
return image
private let chevronButton: UIButton = {
let button = UIButton()
button.translatesAutoresizingMaskIntoConstraints = false
let image = UIImage(systemName: "chevron.down")!.withConfiguration(UIImage.SymbolConfiguration(scale: .small))
button.setImage(image, for: .normal)
button.tintColor = .dw_label()
button.backgroundColor = .dw_secondaryBackground()
button.layer.cornerRadius = 7
button.isUserInteractionEnabled = false
return button
}()

private let container: UIStackView = {
Expand All @@ -86,14 +90,25 @@ final class GroupedRequestCell: UITableViewCell {
tableView.register(UsernameRequestCell.self, forCellReuseIdentifier: UsernameRequestCell.description())
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.tableFooterView = UIView(frame: .zero)
tableView.backgroundColor = .dw_background()
return tableView
}()

private let blockButton: VoteButton = {
let button = VoteButton()
button.selectedBackgroundColor = .dw_red()
button.buttonText = NSLocalizedString("Block", comment: "Voting")
button.value = 0
private let blockButton: UIButton = {
let button = UIButton(type: .system)
button.translatesAutoresizingMaskIntoConstraints = false
button.setTitle("0", for: .normal)
let image = UIImage(named: "icon_thumbs_up")!
button.setImage(image.withRenderingMode(.alwaysTemplate), for: .normal)
button.imageView?.transform = CGAffineTransform(rotationAngle: .pi)
button.tintColor = .dw_label()
button.backgroundColor = .dw_secondaryBackground()
button.layer.cornerRadius = 7
button.semanticContentAttribute = .forceRightToLeft
button.contentHorizontalAlignment = .center
button.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 6)
button.imageEdgeInsets = UIEdgeInsets(top: 0, left: 6, bottom: 0, right: 0)

return button
}()
}
Expand All @@ -103,10 +118,9 @@ private extension GroupedRequestCell {
toggleArea.addTarget(self, action: #selector(expandOrCollapse), for: .touchUpInside)
toggleArea.addSubview(username)
toggleArea.addSubview(requestsAmount)
toggleArea.addSubview(chevron)
toggleArea.addSubview(chevronButton)

toggleArea.addSubview(blockButton)
blockButton.isUserInteractionEnabled = true
blockButton.addTarget(self, action: #selector(blockButtonTapped), for: .touchUpInside)

container.addArrangedSubview(toggleArea)
Expand Down Expand Up @@ -134,22 +148,21 @@ private extension GroupedRequestCell {
requestsAmount.leadingAnchor.constraint(equalTo: username.trailingAnchor, constant: 6),
requestsAmount.bottomAnchor.constraint(equalTo: username.bottomAnchor),

chevron.heightAnchor.constraint(equalToConstant: 14),
chevron.widthAnchor.constraint(equalToConstant: 14),
chevron.topAnchor.constraint(equalTo: username.topAnchor),
chevron.trailingAnchor.constraint(equalTo: toggleArea.trailingAnchor, constant: -15),
chevron.bottomAnchor.constraint(equalTo: username.bottomAnchor),
chevronButton.heightAnchor.constraint(equalToConstant: 30),
chevronButton.widthAnchor.constraint(equalToConstant: 70),
chevronButton.centerYAnchor.constraint(equalTo: username.centerYAnchor),
chevronButton.trailingAnchor.constraint(equalTo: toggleArea.trailingAnchor, constant: -10),

containerHeightConstraint,
container.topAnchor.constraint(equalTo: contentView.topAnchor),
container.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 20),
container.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -20),
container.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -15),

blockButton.heightAnchor.constraint(equalToConstant: 35),
blockButton.widthAnchor.constraint(equalToConstant: 65),
blockButton.heightAnchor.constraint(equalToConstant: 30),
blockButton.widthAnchor.constraint(equalToConstant: 70),
blockButton.centerYAnchor.constraint(equalTo: username.centerYAnchor),
blockButton.trailingAnchor.constraint(equalTo: chevron.leadingAnchor, constant: -8)
blockButton.trailingAnchor.constraint(equalTo: chevronButton.leadingAnchor, constant: -10),
])
}

Expand All @@ -167,11 +180,11 @@ private extension GroupedRequestCell {
self.container.setNeedsLayout()
self.onHeightChanged?()

UIView.transition(with: container,
UIView.transition(with: chevronButton.imageView ?? chevronButton,
duration: 0.3,
options: .curveEaseInOut) { [weak self] in
let transform = expand ? CGAffineTransform(rotationAngle: CGFloat.pi) : CGAffineTransform.identity
self?.chevron.transform = transform
self?.chevronButton.imageView?.transform = transform
}
}

Expand All @@ -193,9 +206,9 @@ extension GroupedRequestCell {

let blockVotes = model.last?.blockVotes ?? 0
let isBlocked = blockVotes > 0
blockButton.isSelected = isBlocked
blockButton.value = blockVotes
blockButton.buttonText = isBlocked ? NSLocalizedString("Unblock", comment: "Voting") : NSLocalizedString("Block", comment: "Voting")
blockButton.backgroundColor = isBlocked ? .dw_red() : .dw_secondaryBackground()
blockButton.tintColor = isBlocked ? .white : .dw_label()
blockButton.setTitle("\(blockVotes)", for: .normal)
}

private func updateInnerTableViewHeight() {
Expand Down Expand Up @@ -246,5 +259,8 @@ extension GroupedRequestCell: UITableViewDelegate {
let request = model[indexPath.row]
onRequestSelected?(request)
}

func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,37 @@ final class UsernameRequestCell: UITableViewCell {
return label
}()

private let approveButton: VoteButton = {
let button = VoteButton()
button.selectedBackgroundColor = .dw_dashBlue()
button.buttonText = NSLocalizedString("Approve", comment: "Voting")
button.value = 0
private let approveButton: UIButton = {
let button = UIButton(type: .system)
button.translatesAutoresizingMaskIntoConstraints = false
button.setTitle("0", for: .normal)
button.setImage(UIImage(named: "icon_thumbs_up")!, for: .normal)
button.tintColor = .dw_label()
button.backgroundColor = .dw_secondaryBackground()
button.layer.cornerRadius = 7
button.semanticContentAttribute = .forceRightToLeft
button.contentHorizontalAlignment = .center
button.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 6)
button.imageEdgeInsets = UIEdgeInsets(top: 0, left: 6, bottom: 0, right: 0)

return button
}()

private let blockButton: VoteButton = {
let button = VoteButton()
button.selectedBackgroundColor = .dw_red()
button.buttonText = NSLocalizedString("Block", comment: "Voting")
button.value = 0
private let blockButton: UIButton = {
let button = UIButton(type: .system)
button.translatesAutoresizingMaskIntoConstraints = false
button.setTitle("0", for: .normal)
let image = UIImage(named: "icon_thumbs_up")!
button.setImage(image.withRenderingMode(.alwaysTemplate), for: .normal)
button.imageView?.transform = CGAffineTransform(rotationAngle: .pi)
button.tintColor = .dw_label()
button.backgroundColor = .dw_secondaryBackground()
button.layer.cornerRadius = 7
button.semanticContentAttribute = .forceRightToLeft
button.contentHorizontalAlignment = .center
button.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 6)
button.imageEdgeInsets = UIEdgeInsets(top: 0, left: 6, bottom: 0, right: 0)

return button
}()

Expand Down Expand Up @@ -117,15 +135,15 @@ private extension UsernameRequestCell {
linkLabel.trailingAnchor.constraint(equalTo: containerView.trailingAnchor),
linkLabel.bottomAnchor.constraint(equalTo: containerView.bottomAnchor, constant: -8),

approveButton.heightAnchor.constraint(equalToConstant: 35),
approveButton.widthAnchor.constraint(greaterThanOrEqualToConstant: 65),
approveButton.heightAnchor.constraint(equalToConstant: 30),
approveButton.widthAnchor.constraint(greaterThanOrEqualToConstant: 70),
approveButton.centerYAnchor.constraint(equalTo: containerView.centerYAnchor),
approveButton.trailingAnchor.constraint(equalTo: containerView.trailingAnchor, constant: -8),
approveButton.trailingAnchor.constraint(equalTo: containerView.trailingAnchor, constant: -10),

blockButton.heightAnchor.constraint(equalToConstant: 35),
blockButton.widthAnchor.constraint(greaterThanOrEqualToConstant: 65),
blockButton.heightAnchor.constraint(equalToConstant: 30),
blockButton.widthAnchor.constraint(greaterThanOrEqualToConstant: 70),
blockButton.centerYAnchor.constraint(equalTo: containerView.centerYAnchor),
blockButton.trailingAnchor.constraint(equalTo: approveButton.leadingAnchor, constant: -8)
blockButton.trailingAnchor.constraint(equalTo: approveButton.leadingAnchor, constant: -10)
])
}
}
Expand All @@ -142,7 +160,7 @@ extension UsernameRequestCell {
if isInGroup {
containerView.backgroundColor = .clear
containerView.layer.cornerRadius = 10
contentView.backgroundColor = .clear
contentView.backgroundColor = .dw_background()

containerView.layer.borderWidth = 0.5
containerView.layer.borderColor = UIColor.dw_separatorLine().cgColor
Expand Down Expand Up @@ -205,11 +223,11 @@ extension UsernameRequestCell {
self.username.text = model.username
self.username.isHidden = false
self.dateCreated.isHidden = true
self.blockButton.value = model.blockVotes
self.approveButton.value = model.votes
self.blockButton.setTitle("\(model.blockVotes)", for: .normal)
self.blockButton.isHidden = false
}

self.approveButton.setTitle("\(model.votes)", for: .normal)
let attachment = NSTextAttachment()
attachment.image = UIImage(named: "link.badge")?.withRenderingMode(.alwaysTemplate)
attachment.bounds = CGRect(x: 0, y: -3, width: 14, height: 14)
Expand All @@ -219,19 +237,23 @@ extension UsernameRequestCell {
linkLabel.isHidden = model.link == nil

if model.isApproved {
approveButton.isSelected = true
approveButton.buttonText = NSLocalizedString("Approvals", comment: "Voting")
approveButton.backgroundColor = .dw_dashBlue()
approveButton.tintColor = .white
} else if model.votes > 0 {
approveButton.backgroundColor = .dw_dashBlue().withAlphaComponent(0.05)
approveButton.tintColor = .dw_dashBlue()
} else {
approveButton.isSelected = false
approveButton.buttonText = NSLocalizedString("Approve", comment: "Voting")
approveButton.backgroundColor = .dw_secondaryBackground()
approveButton.tintColor = .dw_label()
}

if model.blockVotes > 0 {
blockButton.isSelected = true
blockButton.buttonText = NSLocalizedString("Unblock", comment: "Voting")
blockButton.backgroundColor = .dw_red()
blockButton.tintColor = .white
} else {
blockButton.isSelected = false
blockButton.buttonText = NSLocalizedString("Block", comment: "Voting")
blockButton.backgroundColor = .dw_secondaryBackground()
blockButton.tintColor = .dw_label()
}
// TODO: pink block button
}
}
Loading

0 comments on commit 9c2947b

Please sign in to comment.