Skip to content

Commit

Permalink
Add addresses for donation
Browse files Browse the repository at this point in the history
  • Loading branch information
esen committed Aug 16, 2023
1 parent c5baa2a commit f828d01
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 2 deletions.
14 changes: 14 additions & 0 deletions UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2332,6 +2332,8 @@
D05F132F2A31FE0D00C3193F /* AddTronTokenBlockchainService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D05F132D2A31FE0D00C3193F /* AddTronTokenBlockchainService.swift */; };
D06669022A31B559004B048D /* TronRecipientAddressViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06669012A31B559004B048D /* TronRecipientAddressViewModel.swift */; };
D06669032A31B559004B048D /* TronRecipientAddressViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06669012A31B559004B048D /* TronRecipientAddressViewModel.swift */; };
D06F756F2A8BA35F00184227 /* DonateAddressViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06F756E2A8BA35F00184227 /* DonateAddressViewController.swift */; };
D06F75702A8BA35F00184227 /* DonateAddressViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06F756E2A8BA35F00184227 /* DonateAddressViewController.swift */; };
D07157DB2A2DD968006F141F /* SendTronModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = D07157DA2A2DD968006F141F /* SendTronModule.swift */; };
D07157DC2A2DD968006F141F /* SendTronModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = D07157DA2A2DD968006F141F /* SendTronModule.swift */; };
D07157DE2A2DDA09006F141F /* SendTronService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D07157DD2A2DDA09006F141F /* SendTronService.swift */; };
Expand Down Expand Up @@ -3797,6 +3799,7 @@
D05E96B82A2A1113002CCD71 /* WatchTronService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WatchTronService.swift; sourceTree = "<group>"; };
D05F132D2A31FE0D00C3193F /* AddTronTokenBlockchainService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddTronTokenBlockchainService.swift; sourceTree = "<group>"; };
D06669012A31B559004B048D /* TronRecipientAddressViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TronRecipientAddressViewModel.swift; sourceTree = "<group>"; };
D06F756E2A8BA35F00184227 /* DonateAddressViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DonateAddressViewController.swift; sourceTree = "<group>"; };
D07157DA2A2DD968006F141F /* SendTronModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendTronModule.swift; sourceTree = "<group>"; };
D07157DD2A2DDA09006F141F /* SendTronService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendTronService.swift; sourceTree = "<group>"; };
D07157E02A2DDA17006F141F /* SendTronViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendTronViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5052,6 +5055,7 @@
11B3563CCEF5817CCA5A0C6A /* Appearance */,
1A5648A0CFE0BED4703D9794 /* Privacy */,
11B35C3CD4FFDE56E8E30B80 /* BlockchainSettings */,
D06F756D2A8BA33000184227 /* Donate */,
);
path = Settings;
sourceTree = "<group>";
Expand Down Expand Up @@ -7251,6 +7255,14 @@
path = Evm;
sourceTree = "<group>";
};
D06F756D2A8BA33000184227 /* Donate */ = {
isa = PBXGroup;
children = (
D06F756E2A8BA35F00184227 /* DonateAddressViewController.swift */,
);
path = Donate;
sourceTree = "<group>";
};
D07157D72A2DD7A8006F141F /* SendTron */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -8249,6 +8261,7 @@
2FA5D4C4D13E610DA6009C48 /* CoinOverviewViewModel.swift in Sources */,
D05E969E2A2627AF002CCD71 /* TronContractCallTransactionRecord.swift in Sources */,
2FA5D72F396BC5D16C228112 /* CoinOverviewService.swift in Sources */,
D06F75702A8BA35F00184227 /* DonateAddressViewController.swift in Sources */,
2FA5DF327EC188AC29719179 /* CoinOverviewModule.swift in Sources */,
2FA5D0F37E1B46988A88DB29 /* CoinOverviewViewController.swift in Sources */,
11B35CD199C820EC89FBB546 /* MarketListViewModel.swift in Sources */,
Expand Down Expand Up @@ -9494,6 +9507,7 @@
D05E969A2A26278D002CCD71 /* TronApproveTransactionRecord.swift in Sources */,
2FA5D40FA7CAC1BA01C0B373 /* CoinOverviewViewModel.swift in Sources */,
2FA5DBE42827FF3D114DBF4B /* CoinOverviewService.swift in Sources */,
D06F756F2A8BA35F00184227 /* DonateAddressViewController.swift in Sources */,
2FA5DF4BB73C12C8DDF42599 /* CoinOverviewModule.swift in Sources */,
D05E969D2A2627AF002CCD71 /* TronContractCallTransactionRecord.swift in Sources */,
2FA5DF596B5EE00090E050D9 /* CoinOverviewViewController.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"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.
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ class ChartCell: UITableViewCell {
chartSecondaryTitleLabel.isHidden = false
chartSecondaryValueLabel.isHidden = false
chartSecondaryTitleLabel.attributedText = top
chartSecondaryTitleLabel.lineBreakMode = .byTruncatingTail
chartSecondaryValueLabel.attributedText = bottom
chartSecondaryValueLabel.lineBreakMode = .byTruncatingTail
chartSecondaryDiffLabel.isHidden = true
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import UIKit
import ActionSheet
import ThemeKit
import SectionsTableView
import ComponentKit
import MarketKit

class DonateAddressViewController: ThemeViewController {
typealias ViewItem = (String, BlockchainType, String)
private let viewItems: [ViewItem]

private let tableView = SectionsTableView(style: .grouped)

override init() {
viewItems = [
ViewItem("Bitcoin Address", .bitcoin, "bc1qw5tw4cnyt0vxts70ntdzxesn2zzz97t6r29pjj"),
ViewItem("Ethereum Address", .ethereum, "0x8a2Bec907827F496752c3F24F960B3cddc5D311B"),
ViewItem("BNB Smart Chain Address", .binanceSmartChain, "0x8a2Bec907827F496752c3F24F960B3cddc5D311B")
]

super.init()
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func viewDidLoad() {
super.viewDidLoad()

title = "settings.donate.title".localized
navigationItem.largeTitleDisplayMode = .never
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "button.done".localized, style: .plain, target: self, action: #selector(onTapDoneButton))
navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)

view.addSubview(tableView)
tableView.snp.makeConstraints { maker in
maker.left.right.bottom.equalToSuperview()
maker.top.equalToSuperview().offset(CGFloat.margin24)
}

tableView.registerCell(forClass: MarkdownHeader1Cell.self)

tableView.sectionDataSource = self
tableView.separatorStyle = .none
tableView.backgroundColor = .clear

tableView.buildSections()
}

@objc private func onTapDoneButton() {
dismiss(animated: true)
}

}

extension DonateAddressViewController: SectionsDataSource {

func buildSections() -> [SectionProtocol] {
viewItems.enumerated().map { index, viewItem -> SectionProtocol in
Section(
id: "section-id-\(index)",
headerState: tableView.sectionHeader(text: viewItem.0),
footerState: .margin(height: .margin24),
rows: [
CellBuilderNew.row(
rootElement: .hStack([
.image32 { (component: ImageComponent) -> () in
component.setImage(
urlString: viewItem.1.imageUrl,
placeholder: UIImage(named: viewItem.1.placeholderImageName(tokenProtocol: .native))
)
},
.text { component in
component.font = .subhead2
component.textColor = .themeLeah
component.text = viewItem.2
component.textAlignment = .right
component.numberOfLines = 0
},
.secondaryCircleButton { component in
component.button.set(image: UIImage(named: "copy_20"))
component.onTap = {
CopyHelper.copyAndNotify(value: viewItem.2)
}
}
]),
tableView: tableView,
id: "donate-address-\(index)",
hash: "donate-address-hash-\(index)",
height: .heightCell56,
bind: { cell in
cell.set(backgroundStyle: .lawrence, isFirst: true, isLast: true)
}
)
]
)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class MainSettingsViewController: ThemeViewController {
tableView.separatorStyle = .none
tableView.backgroundColor = .clear

tableView.registerCell(forClass: PlaceholderCell.self)

view.addSubview(tableView)
tableView.snp.makeConstraints { maker in
maker.edges.equalToSuperview()
Expand Down Expand Up @@ -196,6 +198,10 @@ class MainSettingsViewController: ThemeViewController {
]))
}

@objc private func onDonateTapped() {
present(ThemeNavigationController(rootViewController: DonateAddressViewController()), animated: true)
}

private var accountRows: [RowProtocol] {
[
StaticRow(
Expand Down Expand Up @@ -336,6 +342,26 @@ class MainSettingsViewController: ThemeViewController {
]
}

private var donateRows: [RowProtocol] {
[
Row<PlaceholderCell>(
id: "donate",
autoDeselect: true,
dynamicHeight: { containerWidth in PlaceholderCell.height(text: "settings.donate.description".localized) },
bind: { cell, _ in
cell.set(backgroundStyle: .lawrence, isFirst: true, isLast: true)
cell.bind(
icon: UIImage(named: "heart_48")?.withTintColor(.themeJacob),
text: "settings.donate.description".localized,
buttonTitle: "settings.donate.title".localized,
buttonStyle: .yellow,
onTapButton: { [weak self] in self?.onDonateTapped() }
)
}
)
]
}

private var footerRows: [RowProtocol] {
[
StaticRow(
Expand Down Expand Up @@ -367,6 +393,7 @@ extension MainSettingsViewController: SectionsDataSource {
Section(id: "experimental", headerState: .margin(height: .margin32), rows: experimentalRows),
Section(id: "knowledge", headerState: .margin(height: .margin32), rows: knowledgeRows),
Section(id: "about", headerState: .margin(height: .margin32), rows: aboutRows),
Section(id: "donate", headerState: .margin(height: .margin32), rows: donateRows),
Section(id: "footer", headerState: .margin(height: .margin32), footerState: .margin(height: .margin32), rows: footerRows)
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class PlaceholderCell: BaseThemeCell {
private static let verticalPadding: CGFloat = .margin32
private static let iconWrapperSize: CGFloat = 100
private static let contentWidth: CGFloat = 264
private static let textFont: UIFont = .subhead2
private static let textFont: UIFont = .headline2

private let iconImageView = UIImageView()
private let label = UILabel()
Expand Down Expand Up @@ -39,7 +39,7 @@ class PlaceholderCell: BaseThemeCell {
label.numberOfLines = 0
label.textAlignment = .center
label.font = Self.textFont
label.textColor = .themeGray
label.textColor = .themeLeah

wrapperView.addSubview(button)
button.snp.makeConstraints { maker in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,8 @@ Go to Settings - > %@ and allow access to the camera.";
"settings.faq" = "FAQ";
"settings.theme" = "Theme";
"settings.info_subtitle" = "decentralized app";
"settings.donate.description" = "Together, with your support, we can make this app even better!";
"settings.donate.title" = "Donate";

// Settings -> Base Currency

Expand Down

0 comments on commit f828d01

Please sign in to comment.