Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #1674: Add auto-contribute exclusion list table
Browse files Browse the repository at this point in the history
This PR also updates the UI in auto-contribute details, bringing the settings up to top-level, and moving supported sites into its own screen
  • Loading branch information
kylehickinson committed Jan 20, 2020
1 parent 24c14e7 commit 4458361
Show file tree
Hide file tree
Showing 13 changed files with 794 additions and 473 deletions.
14 changes: 12 additions & 2 deletions BraveRewardsUI/Common/PopoverNavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,23 @@ public class PopoverNavigationController: UINavigationController {
}
}

private class Toolbar: UIToolbar {
override var frame: CGRect {
get { return super.frame.with { $0.size.height = 44 } }
set { super.frame = newValue }
}
override var barPosition: UIBarPosition {
return .bottom
}
}

init() {
super.init(navigationBarClass: NavigationBar.self, toolbarClass: nil)
super.init(navigationBarClass: NavigationBar.self, toolbarClass: Toolbar.self)
modalPresentationStyle = .currentContext
}

public override init(rootViewController: UIViewController) {
super.init(navigationBarClass: NavigationBar.self, toolbarClass: nil)
super.init(navigationBarClass: NavigationBar.self, toolbarClass: Toolbar.self)
modalPresentationStyle = .currentContext
viewControllers = [rootViewController]
}
Expand Down
2 changes: 1 addition & 1 deletion BraveRewardsUI/Common/Tables/TableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class TableViewCell: UITableViewCell, TableViewReusable {
if accessoryType == .none {
$0.trailing.equalToSuperview().inset(layoutMargins.right)
} else {
$0.trailing.equalToSuperview()
$0.trailing.equalToSuperview().inset(6)
}
$0.centerY.equalToSuperview()
}
Expand Down
31 changes: 31 additions & 0 deletions BraveRewardsUI/Extensions/BraveLedgerExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,35 @@ private let log = Logger.rewardsLogger

extension BraveLedger {

// MARK: - Auto-Contribute Publisher Helpers

var supportedPublishersFilter: ActivityInfoFilter {
let sort = ActivityInfoFilterOrderPair().then {
$0.propertyName = "percent"
$0.ascending = false
}
let filter = ActivityInfoFilter().then {
$0.id = ""
$0.excluded = .filterAllExceptExcluded
$0.percent = 1 //exclude 0% sites.
$0.orderBy = [sort]
$0.nonVerified = self.allowUnverifiedPublishers
$0.reconcileStamp = self.autoContributeProps.reconcileStamp
}
return filter
}

var excludedPublishersFilter: ActivityInfoFilter {
return ActivityInfoFilter().then {
$0.id = ""
$0.excluded = .filterExcluded
$0.nonVerified = self.allowUnverifiedPublishers
$0.reconcileStamp = self.autoContributeProps.reconcileStamp
}
}

// MARK: - External Wallet Helpers

var walletBalances: [WalletType: Double] {
guard let wallets = balance?.wallets else { return [:] }
var balances: [WalletType: Double] = [:]
Expand All @@ -35,6 +64,8 @@ extension BraveLedger {
return balance?.total ?? 0
}

// MARK: - Balance and Currency Helpers

/// Get the current BAT wallet balance for display
var balanceString: String { return BATValue(balanceTotal).displayString }

Expand Down
4 changes: 4 additions & 0 deletions BraveRewardsUI/Localized Strings/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,5 +290,9 @@ internal extension Strings {
static let userWalletNotificationWalletDisconnectedBody = NSLocalizedString("UserWalletNotificationWalletDisconnectedBody", bundle: .rewardsUI, value: "No worries. This can happen for a variety of security reasons. Reconnecting your wallet will solve this issue.", comment: "The message you receive when your user wallet is unreachable/disconnected")
static let userWalletNotificationNowVerifiedTitle = NSLocalizedString("UserWalletNotificationNowVerifiedTitle", bundle: .rewardsUI, value: "Your wallet is verified!", comment: "The message you receive when your user wallet has been verified")
static let userWalletNotificationNowVerifiedBody = NSLocalizedString("UserWalletNotificationNowVerifiedBody", bundle: .rewardsUI, value: "Congrats! Your %@ wallet was successfully verified and ready to add and withdraw funds.", comment: "The message you receive when your user wallet has been verified (%@ = The user wallet name, such as \"Uphold\")")
static let exclusionListTitle = NSLocalizedString("ExclusionListTitle", bundle: .rewardsUI, value: "Excluded sites", comment: "The title of the screen that shows a list of excluded sites for Auto-Contribute")
static let restoreAllSitesToolbarButtonTitle = NSLocalizedString("ExclusionListRestoreAllButton", bundle: .rewardsUI, value: "Restore All Sites", comment: "The button that restores all excluded publishers while on the Auto-Contribute excluson list")
static let restore = NSLocalizedString("ExclusionListRestore", bundle: .rewardsUI, value: "Restore", comment: "The swipe-to-delete title when restoring a single item in the Auto-Contribute exclusion list")
static let emptyExclusionList = NSLocalizedString("EmptyExclusionList", bundle: .rewardsUI, value: "No publishers excluded", comment: "The copy the user sees when they are viewing an empty Auto-Contribute exclusion list.")
}

3 changes: 3 additions & 0 deletions BraveRewardsUI/RewardsPanelController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class RewardsPanelController: PopoverNavigationController {
navigationBar.tintColor = Colors.blurple400
navigationBar.titleTextAttributes = [.foregroundColor: UIColor.black]

toolbar.appearanceBarTintColor = toolbar.barTintColor
toolbar.tintColor = Colors.blurple400

if #available(iOS 13.0, *) {
overrideUserInterfaceStyle = .light
}
Expand Down
Loading

0 comments on commit 4458361

Please sign in to comment.