Skip to content

Commit

Permalink
feat: what is voting on Menu & contacts screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Syn-McJ committed Oct 23, 2024
1 parent b2783c5 commit 29805c7
Show file tree
Hide file tree
Showing 72 changed files with 1,638 additions and 75 deletions.
2 changes: 1 addition & 1 deletion DashSyncCurrentCommit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1b5af0dbe136f129e590264f5b446b4471b175b1
09eee81df1a1a89cdcd77dd8965edb1f78b2eb84
6 changes: 6 additions & 0 deletions DashWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,8 @@
75CDD7872C08D61300F433D2 /* DashAmount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CDD7852C08D61300F433D2 /* DashAmount.swift */; };
75CED09E2ACFD0ED0095F10C /* CoinbaseDepositRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CED09D2ACFD0ED0095F10C /* CoinbaseDepositRequest.swift */; };
75CED0A02ACFED200095F10C /* CoinbaseDepositResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CED09F2ACFED200095F10C /* CoinbaseDepositResponse.swift */; };
75D5D5332CC928630049ED7B /* UIHostingController+DashWallet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D5D5322CC9285B0049ED7B /* UIHostingController+DashWallet.swift */; };
75D5D5342CC928630049ED7B /* UIHostingController+DashWallet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D5D5322CC9285B0049ED7B /* UIHostingController+DashWallet.swift */; };
75D5F3CE191EC270004AB296 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 75D5F3CD191EC270004AB296 /* main.m */; };
75D6561C2B07935000D1A902 /* WelcomeToDashpayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75D6561B2B07935000D1A902 /* WelcomeToDashpayViewController.swift */; };
75D6561D2B07936100D1A902 /* UsernameRequests.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 75D656192B0792F500D1A902 /* UsernameRequests.storyboard */; };
Expand Down Expand Up @@ -2522,6 +2524,7 @@
75CE50B51B5216F100DBC18C /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = DashWalletTests/Info.plist; sourceTree = SOURCE_ROOT; };
75CED09D2ACFD0ED0095F10C /* CoinbaseDepositRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoinbaseDepositRequest.swift; sourceTree = "<group>"; };
75CED09F2ACFED200095F10C /* CoinbaseDepositResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoinbaseDepositResponse.swift; sourceTree = "<group>"; };
75D5D5322CC9285B0049ED7B /* UIHostingController+DashWallet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIHostingController+DashWallet.swift"; sourceTree = "<group>"; };
75D5F3BE191EC270004AB296 /* dashwallet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = dashwallet.app; sourceTree = BUILT_PRODUCTS_DIR; };
75D5F3C9191EC270004AB296 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
75D5F3CD191EC270004AB296 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5010,6 +5013,7 @@
47E4B7B6292F85E800CE0EB6 /* Numbers+Dash.swift */,
47EE171629560DC200BA1986 /* ErrorPresentable.swift */,
47CDEECD294A3CF2008AE06D /* UIViewController+DashWallet.swift */,
75D5D5322CC9285B0049ED7B /* UIHostingController+DashWallet.swift */,
47EE17182959CDC200BA1986 /* ColorizedText.swift */,
4730586D295AB3BD004641DA /* UIDevice+Compatibility.swift */,
4730586F295AD62B004641DA /* NavigationBarAppearanceCustomizable.swift */,
Expand Down Expand Up @@ -8541,6 +8545,7 @@
477F50102950A55A003C7508 /* Coinbase+Error.swift in Sources */,
2A63003F2327B4BB00827825 /* DWPaymentOutput+DWView.m in Sources */,
750CED602C94BFD7000FB837 /* SettingsViewModel.swift in Sources */,
75D5D5342CC928630049ED7B /* UIHostingController+DashWallet.swift in Sources */,
2ACD53EE234C9D8E00650AD3 /* UIView+DWRecursiveSubview.m in Sources */,
11860923297598B400279FCC /* AddressStatus.swift in Sources */,
C91E919729FBACE6003E7883 /* ExtendedPublicKeysModel.swift in Sources */,
Expand Down Expand Up @@ -9537,6 +9542,7 @@
C9D2C7CA2A320AA000D15901 /* DWModalDismissalAnimation.m in Sources */,
C9D2C7CB2A320AA000D15901 /* (null) in Sources */,
C9D2C7CD2A320AA000D15901 /* UIViewController+DashWallet.swift in Sources */,
75D5D5332CC928630049ED7B /* UIHostingController+DashWallet.swift in Sources */,
C9D2C7CE2A320AA000D15901 /* CrowdNodeCell.swift in Sources */,
751B61C62ADFFD0A00D1C2EF /* IntegrationViewController+Coinbase.swift in Sources */,
C9D2C7CF2A320AA000D15901 /* MerchantListLocationOffCell.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"images" : [
{
"filename" : "passphrase.png",
"filename" : "icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "passphrase@2x.png",
"filename" : "icon@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "passphrase@3x.png",
"filename" : "icon@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
Expand Down
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "voting.blocked.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "feature.list.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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.
32 changes: 32 additions & 0 deletions DashWallet/Sources/Categories/UIHostingController+DashWallet.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// Created by Andrei Ashikhmin
// Copyright © 2024 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 SwiftUI

extension UIHostingController {
func setDetent(_ detent: CGFloat) {
if #available(iOS 16.0, *) {
if let sheet = self.sheetPresentationController {
let fitId = UISheetPresentationController.Detent.Identifier("fit")
let fitDetent = UISheetPresentationController.Detent.custom(identifier: fitId) { _ in
detent
}
sheet.detents = [fitDetent]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,31 +130,40 @@ class ContactsPlaceholderViewController: ActionButtonViewController {
let controller = CoinJoinLevelsViewController.controller(isFullScreen: true)
self.present(controller, animated: true, completion: nil)
}, negativeAction: {
let controller = DashPaySetupFlowController(dashPayModel: self.dashPayModel,
invitationURL: nil,
definedUsername: nil)
controller.modalPresentationStyle = .fullScreen
self.present(controller, animated: true, completion: nil)
if UsernamePrefs.shared.joinDashPayInfoShown {
self.navigateToCreateUsername()
} else {
UsernamePrefs.shared.joinDashPayInfoShown = true
self.showDashPayInfo()
}
}
)
let hostingController = UIHostingController(rootView: swiftUIView)
hostingController.setDetent(250)

if #available(iOS 16.0, *) {
if let sheet = hostingController.sheetPresentationController {
let fitId = UISheetPresentationController.Detent.Identifier("fit")
let fitDetent = UISheetPresentationController.Detent.custom(identifier: fitId) { _ in
250
}
sheet.detents = [fitDetent]
}
present(hostingController, animated: true, completion: nil)
}

private func showDashPayInfo() {
let swiftUIView = JoinDashPayInfoDialog() {
self.navigateToCreateUsername()
}

let hostingController = UIHostingController(rootView: swiftUIView)
hostingController.setDetent(600)
present(hostingController, animated: true, completion: nil)
}

@objc func update() {
actionButton?.isEnabled = dashPayReady.shouldShowCreateUserNameButton()
}

private func navigateToCreateUsername() {
let controller = DashPaySetupFlowController(dashPayModel: self.dashPayModel,
invitationURL: nil,
definedUsername: nil)
controller.modalPresentationStyle = .fullScreen
self.present(controller, animated: true, completion: nil)
}
}

// MARK: - Notification Names
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ import SwiftUI

public struct JoinDashPayInfoDialog: View {
@Environment(\.presentationMode) private var presentationMode
var action: () -> Void

public var body: some View {
BottomSheet(showBackButton: Binding<Bool>.constant(false)) {
JoinDashPayScreen()
JoinDashPayScreen {
presentationMode.wrappedValue.dismiss()
action()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import SwiftUI
public struct JoinDashPayScreen: View {
@StateObject private var viewModel = RequestUsernameViewModel.shared
@State private var navigateToVotingInfo = false
var action: () -> Void

public var body: some View {
ZStack {
Expand All @@ -43,7 +44,7 @@ public struct JoinDashPayScreen: View {
)

NavigationLink(
destination: VotingInfoScreen().navigationBarHidden(true),
destination: VotingInfoScreen(action: action).navigationBarHidden(true),
isActive: $navigateToVotingInfo
) {
EmptyView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,26 @@
import SwiftUI

public struct VotingInfoScreen: View {
var action: () -> Void

public var body: some View {
TextIntro(
buttonLabel: NSLocalizedString("Continue", comment: ""),
action: { }, // TODO: navlink
inProgress: .constant(false),
topText: {
FeatureTopText(
title: NSLocalizedString("What is username voting?", comment: "Usernames"),
text: NSLocalizedString("The Dash network has to vote to approve some usernames before they are created", comment: "Usernames")
)
},
features: {[
FeatureSingleItem(iconName: .custom("username.letter"), title: NSLocalizedString("Voting is only required in some cases", comment: "Usernames"), description: NSLocalizedString("Any username that has a number 2-9, is more than 20 characters or that has a hyphen will be automatically approved", comment: "Usernames")),
FeatureSingleItem(iconName: .custom("friends.add"), title: NSLocalizedString("Some usernames can be blocked", comment: "Usernames"), description: NSLocalizedString("If enough of the network feels that a username is inappropriate, they can block it", comment: "Usernames")),
FeatureSingleItem(iconName: .custom("profile.personalized"), title: NSLocalizedString("In case your request is not approved", comment: "Usernames"), description: NSLocalizedString("Pay now and if not approved, you can create a different name without paying again", comment: "Usernames")),
FeatureSingleItem(iconName: .custom("profile.personalized"), title: NSLocalizedString("Keep your passphrase safe", comment: "Usernames"), description: NSLocalizedString("In case you lose your passphrase you will lose your right to your requested username.", comment: "Usernames"))
]}
)
ZStack {
TextIntro(
buttonLabel: NSLocalizedString("Continue", comment: ""),
action: action,
inProgress: .constant(false),
topText: {
FeatureTopText(
title: NSLocalizedString("What is username voting?", comment: "Usernames"),
text: NSLocalizedString("The Dash network has to vote to approve some usernames before they are created", comment: "Usernames")
)
},
features: {[
FeatureSingleItem(iconName: .custom("voting.list"), title: NSLocalizedString("Voting is only required in some cases", comment: "Usernames"), description: NSLocalizedString("Any username that has a number 2-9, is more than 20 characters or that has a hyphen will be automatically approved", comment: "Usernames")),
FeatureSingleItem(iconName: .custom("voting.blocked"), title: NSLocalizedString("Some usernames can be blocked", comment: "Usernames"), description: NSLocalizedString("If enough of the network feels that a username is inappropriate, they can block it", comment: "Usernames")),
FeatureSingleItem(iconName: .custom("icon.passphrase"), title: NSLocalizedString("Keep your passphrase safe", comment: "Usernames"), description: NSLocalizedString("In case you lose your passphrase you will lose your right to your requested username.", comment: "Usernames"))
]}
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import UIKit

protocol DWDashPaySetupFlowControllerDelegate: AnyObject {
protocol DashPaySetupFlowControllerDelegate: AnyObject {
func dashPaySetupFlowController(_ controller: DashPaySetupFlowController, didConfirmUsername username: String)
}

Expand All @@ -27,7 +27,7 @@ class DashPaySetupFlowController: UIViewController, NavigationFullscreenable, DW
private(set) var dashPayModel: DWDashPayProtocol
private(set) var invitationURL: URL?
private(set) var definedUsername: String?
weak var confirmationDelegate: DWDashPaySetupFlowControllerDelegate?
weak var confirmationDelegate: DashPaySetupFlowControllerDelegate?
private var headerHeightConstraint: NSLayoutConstraint!
private var containerController: DWContainerViewController!
private var createUsernameViewController: DWCreateUsernameViewController!
Expand Down Expand Up @@ -55,7 +55,7 @@ class DashPaySetupFlowController: UIViewController, NavigationFullscreenable, DW
super.init(nibName: nil, bundle: nil)
}

init(confirmationDelegate: DWDashPaySetupFlowControllerDelegate) {
init(confirmationDelegate: DashPaySetupFlowControllerDelegate) {
self.dashPayModel = DWDashPaySetupModel()
self.confirmationDelegate = confirmationDelegate
super.init(nibName: nil, bundle: nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ final class RequestUsernameViewController: UIViewController {
return label
}()

static func controller() -> RequestUsernameViewController {
RequestUsernameViewController()
static func controller(isFullScreen: Bool = false) -> RequestUsernameViewController {
let vc = RequestUsernameViewController()
vc.modalPresentationStyle = isFullScreen ? .fullScreen : .formSheet
return vc
}

override func viewDidLoad() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22155" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23094" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22131"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23084"/>
<capability name="Image references" minToolsVersion="12.0"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
Expand Down Expand Up @@ -854,11 +854,11 @@
<image name="dashpay.welcome" width="80.333335876464844" height="80"/>
<image name="friends.add" width="27.666666030883789" height="18"/>
<image name="icon.clock" width="50" height="50"/>
<image name="icon.passphrase" width="26" height="22"/>
<image name="icon.passphrase" width="24" height="20.666666030883789"/>
<image name="icon.voting" width="48.333332061767578" height="43.666667938232422"/>
<image name="not.approved" width="28" height="21"/>
<image name="profile.personalized" width="28" height="22"/>
<image name="square.and.arrow.up" catalog="system" width="108" height="128"/>
<image name="square.and.arrow.up" catalog="system" width="110" height="128"/>
<image name="username.create" width="23.333333969116211" height="24"/>
<namedColor name="BackgroundColor">
<color red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand All @@ -870,7 +870,7 @@
<color red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="Label">
<color red="0.094117647058823528" green="0.10980392156862745" blue="0.12156862745098039" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.098039215686274508" green="0.10980392156862745" blue="0.12156862745098039" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="QuaternaryFillColor">
<color red="0.4392156862745098" green="0.4392156862745098" blue="0.44705882352941179" alpha="0.070000000298023224" colorSpace="custom" customColorSpace="sRGB"/>
Expand Down
7 changes: 6 additions & 1 deletion DashWallet/Sources/UI/Home/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,16 @@ extension HomeViewController: RootEditProfileViewControllerDelegate {
// MARK: - HomeViewDelegate

extension HomeViewController: HomeViewDelegate {
func homeViewShowCoinJoin(_ homeView: HomeView?) {
func homeViewShowCoinJoin() {
let controller = CoinJoinLevelsViewController.controller(isFullScreen: true)
present(controller, animated: true, completion: nil)
}

func homeViewRequestUsername() {
let action = ShortcutAction(type: .createUsername)
performAction(for: action, sender: nil)
}

func homeView(_ homeView: HomeView, showTxFilter sender: UIView) {
showTxFilter(withSender: sender, displayModeProvider: model, shouldShowRewards: true)
}
Expand Down
Loading

0 comments on commit 29805c7

Please sign in to comment.