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): request details UI #619

Merged
merged 1 commit into from
Nov 14, 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
16 changes: 10 additions & 6 deletions DashWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@
75E83CF61B5F997A0038FB70 /* coinflip.aiff in Resources */ = {isa = PBXBuildFile; fileRef = 75E83CF51B5F997A0038FB70 /* coinflip.aiff */; };
75F51AAD2ABD8C800057B499 /* IntegrationViewController+Uphold.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F51AAC2ABD8C800057B499 /* IntegrationViewController+Uphold.swift */; };
75F51AAF2ABD8D070057B499 /* IntegrationViewController+Coinbase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F51AAE2ABD8D070057B499 /* IntegrationViewController+Coinbase.swift */; };
75F990822AFD1065006759AB /* UsernameRequestDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F990812AFD1065006759AB /* UsernameRequestDetailsViewController.swift */; };
7EE06A55AFE483FA7824B06E /* libPods-DashWalletTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BEAE29AA65F429DD9EF1A1A7 /* libPods-DashWalletTests.a */; };
A90D08EA4AA9019A2D806A9C /* libPods-dashwallet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 17427514C25A58AB4AEDF999 /* libPods-dashwallet.a */; };
AEC28D84403A194A6C7D8C5A /* libPods-dashpay.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CE89DF632BC53160BB8FBED1 /* libPods-dashpay.a */; };
Expand Down Expand Up @@ -2429,6 +2430,7 @@
75F2E0B61BE2D5F000EAE861 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; };
75F51AAC2ABD8C800057B499 /* IntegrationViewController+Uphold.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "IntegrationViewController+Uphold.swift"; sourceTree = "<group>"; };
75F51AAE2ABD8D070057B499 /* IntegrationViewController+Coinbase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "IntegrationViewController+Coinbase.swift"; sourceTree = "<group>"; };
75F990812AFD1065006759AB /* UsernameRequestDetailsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UsernameRequestDetailsViewController.swift; sourceTree = "<group>"; };
7EEDF75116E60BB9EE9C80FB /* Pods-WatchApp.testnet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WatchApp.testnet.xcconfig"; path = "Pods/Target Support Files/Pods-WatchApp/Pods-WatchApp.testnet.xcconfig"; sourceTree = "<group>"; };
87872BF3D40B38CD0FC246AB /* Pods-DashWalletTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DashWalletTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-DashWalletTests/Pods-DashWalletTests.debug.xcconfig"; sourceTree = "<group>"; };
8A9877BEC5093CED81768D3D /* Pods-TodayExtension.testnet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TodayExtension.testnet.xcconfig"; path = "Pods/Target Support Files/Pods-TodayExtension/Pods-TodayExtension.testnet.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5934,9 +5936,10 @@
children = (
754495DB2AE91AF700492817 /* Cells */,
7502A4862AE401EF00ACDDD3 /* UsernameVotingViewController.swift */,
75A8C1682AE6A1AC0042256E /* VotingViewModel.swift */,
7514E4E72AF233CF00A0466F /* VotingFiltersViewController.swift */,
7514E4EB2AF27E5900A0466F /* VotingHeaderView.swift */,
7514E4E72AF233CF00A0466F /* VotingFiltersViewController.swift */,
75F990812AFD1065006759AB /* UsernameRequestDetailsViewController.swift */,
75A8C1682AE6A1AC0042256E /* VotingViewModel.swift */,
753FDBED2AECF52B0005EEC3 /* UsernameVoting.storyboard */,
753FDBEB2AECF4CC0005EEC3 /* VotingHeaderView.xib */,
);
Expand Down Expand Up @@ -8877,6 +8880,7 @@
C9D2C6BA2A320AA000D15901 /* DWUpholdAccountObject.m in Sources */,
C9D2C6BB2A320AA000D15901 /* DWFormTableViewController.m in Sources */,
C943B34D2A40A4C500AF23C5 /* DWInfoPopupViewController.m in Sources */,
75F990822AFD1065006759AB /* UsernameRequestDetailsViewController.swift in Sources */,
C943B32A2A408CED00AF23C5 /* DWAvatarExternalSourceView.m in Sources */,
C9D2C6BC2A320AA000D15901 /* WalletKeysOverviewModel.swift in Sources */,
C9D2C6BD2A320AA000D15901 /* UIAssembly.swift in Sources */,
Expand Down Expand Up @@ -10477,7 +10481,7 @@
CLIENT_ID = 0c38beb67db0c68191326be347d7ec0abd7d77adb02a79db1abeba343f16a0f7;
CLIENT_SECRET = cc980185754f905e24250f877792817c03540b3d0e0959721df291c816797e59;
CODE_SIGN_ENTITLEMENTS = dashwallet/dashwallet.entitlements;
CURRENT_PROJECT_VERSION = 152;
CURRENT_PROJECT_VERSION = 153;
DEVELOPMENT_TEAM = 44RJ69WHFF;
EXCLUDED_ARCHS = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
Expand Down Expand Up @@ -10613,7 +10617,7 @@
CLIENT_ID = 0c38beb67db0c68191326be347d7ec0abd7d77adb02a79db1abeba343f16a0f7;
CLIENT_SECRET = cc980185754f905e24250f877792817c03540b3d0e0959721df291c816797e59;
CODE_SIGN_ENTITLEMENTS = dashwallet/dashwallet.entitlements;
CURRENT_PROJECT_VERSION = 152;
CURRENT_PROJECT_VERSION = 153;
DEVELOPMENT_TEAM = 44RJ69WHFF;
EXCLUDED_ARCHS = "";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand Down Expand Up @@ -10748,7 +10752,7 @@
CLIENT_ID = 0c38beb67db0c68191326be347d7ec0abd7d77adb02a79db1abeba343f16a0f7;
CLIENT_SECRET = cc980185754f905e24250f877792817c03540b3d0e0959721df291c816797e59;
CODE_SIGN_ENTITLEMENTS = dashwallet/dashwallet.entitlements;
CURRENT_PROJECT_VERSION = 152;
CURRENT_PROJECT_VERSION = 153;
DEVELOPMENT_TEAM = 44RJ69WHFF;
EXCLUDED_ARCHS = "";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand Down Expand Up @@ -10893,7 +10897,7 @@
CLIENT_ID = 0c38beb67db0c68191326be347d7ec0abd7d77adb02a79db1abeba343f16a0f7;
CLIENT_SECRET = cc980185754f905e24250f877792817c03540b3d0e0959721df291c816797e59;
CODE_SIGN_ENTITLEMENTS = dashwallet/dashwallet.entitlements;
CURRENT_PROJECT_VERSION = 152;
CURRENT_PROJECT_VERSION = 153;
DEVELOPMENT_TEAM = 44RJ69WHFF;
EXCLUDED_ARCHS = "";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand Down
2 changes: 1 addition & 1 deletion DashWallet/Sources/UI/Views/UIButton+Dash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class ActionButton: ActivityIndicatorButton {

var container = incoming
container.foregroundColor = foregroundColor
container.font = .title3
container.font = .dw_mediumFont(ofSize: 15)
return container
}
}
Expand Down
16 changes: 7 additions & 9 deletions DashWallet/Sources/UI/Voting/Cells/GroupedRequestCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ import UIKit

let kToogleAreaHeight = CGFloat(50)

protocol HeightChangedDelegate {
func heightChanged()
}

final class GroupedRequestCell: UITableViewCell {
var heightDelegate: HeightChangedDelegate?
var model: [UsernameRequest] = []
private var model: [UsernameRequest] = []
private var dataSource: DataSource! = nil
private var containerHeightConstraint: NSLayoutConstraint!

var onHeightChanged: (() -> ())?
var onRequestSelected: ((UsernameRequest) -> ())?

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
Expand Down Expand Up @@ -148,7 +146,7 @@ private extension GroupedRequestCell {

self.tableView.isHidden = !expand
self.container.setNeedsLayout()
self.heightDelegate?.heightChanged()
self.onHeightChanged?()

UIView.transition(with: container,
duration: 0.3,
Expand All @@ -170,7 +168,7 @@ extension GroupedRequestCell {
self.reloadDataSource(data: model)
}

func updateInnerTableViewHeight() {
private func updateInnerTableViewHeight() {
let contentHeight = tableView.contentSize.height
containerHeightConstraint.constant = contentHeight + kToogleAreaHeight
self.layoutIfNeeded()
Expand Down Expand Up @@ -213,7 +211,7 @@ extension GroupedRequestCell: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: false)
let request = model[indexPath.row]
contentView.dw_showInfoHUD(withText: NSLocalizedString("Selected row with \(request.votes) votes", comment: ""))
onRequestSelected?(request)
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//
// Created by Andrei Ashikhmin
// Copyright © 2023 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 Combine

class UsernameRequestDetailsViewController: UIViewController {
private var cancellableBag = Set<AnyCancellable>()
private var viewModel: VotingViewModel = VotingViewModel.shared
private var request: UsernameRequest!

@IBOutlet var titleLabel: UILabel!
@IBOutlet var subtitleLabel: UILabel!
@IBOutlet var usernameLabel: UILabel!
@IBOutlet var username: UILabel!
@IBOutlet var linkLabel: UILabel!
@IBOutlet var link: UILabel!
@IBOutlet var linkPanel: UIView!
@IBOutlet var identityLabel: UILabel!
@IBOutlet var identity: UILabel!
@IBOutlet var voteButton: ActionButton!

static func controller(with request: UsernameRequest) -> UsernameRequestDetailsViewController {
let vc = vc(UsernameRequestDetailsViewController.self, from: sb("UsernameVoting"))
vc.request = request

return vc
}

override func viewDidLoad() {
super.viewDidLoad()
configureLayout()
}

@IBAction
func voteAction() {
print("vote")
}
}


extension UsernameRequestDetailsViewController {
private func configureLayout() {
titleLabel.text = NSLocalizedString("Request details", comment: "Voting")
subtitleLabel.text = NSLocalizedString("Review the posting below to verify the ownership of this username", comment: "Voting")
usernameLabel.text = NSLocalizedString("Username", comment: "Voting")
linkLabel.text = NSLocalizedString("Link", comment: "Voting")
identityLabel.text = NSLocalizedString("Identity", comment: "Voting")
voteButton.setTitle(NSLocalizedString("Vote to Approve", comment: "Voting"), for: .normal)

username.text = request.username
identity.text = request.identity

if let url = request.link {
link.text = url
linkPanel.isHidden = false
let linkTap = UITapGestureRecognizer(target: self, action: #selector(openLink))
linkPanel.addGestureRecognizer(linkTap)
}
}

@objc
private func openLink() {
if let url = request.link {
UIApplication.shared.open(URL(string: url)!)
}
}
}
Loading