Skip to content

Commit

Permalink
Merge branch 'develop' into fix/topper-default-amount
Browse files Browse the repository at this point in the history
  • Loading branch information
Syn-McJ committed Mar 12, 2024
2 parents 89eef0f + ab8df5e commit a675fab
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 147 deletions.
66 changes: 33 additions & 33 deletions DashWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

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="22505" 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="22504"/>
<capability name="Image references" minToolsVersion="12.0"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
Expand All @@ -27,10 +27,10 @@
</objects>
<point key="canvasLocation" x="86" y="19"/>
</scene>
<!--Portal View Controller-->
<!--Buy Sell Portal View Controller-->
<scene sceneID="Kt1-k3-mw8">
<objects>
<viewController storyboardIdentifier="PortalViewController" extendedLayoutIncludesOpaqueBars="YES" automaticallyAdjustsScrollViewInsets="NO" id="cHp-03-Ty7" customClass="PortalViewController" customModule="dashwallet" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="BuySellPortalViewController" extendedLayoutIncludesOpaqueBars="YES" automaticallyAdjustsScrollViewInsets="NO" id="cHp-03-Ty7" customClass="BuySellPortalViewController" customModule="dashpay" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="RUx-ea-6cO">
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand All @@ -51,7 +51,7 @@
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="ItemCell" id="afa-Qk-ycb" customClass="PortalServiceItemCell" customModule="dashwallet" customModuleProvider="target">
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="ItemCell" id="afa-Qk-ycb" customClass="BuySellServiceItemCell" customModule="dashpay" customModuleProvider="target">
<rect key="frame" x="-6" y="0.0" width="375" height="136"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<collectionViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="lZc-h4-7QQ">
Expand All @@ -74,13 +74,13 @@
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="SLz-yN-ubG">
<rect key="frame" x="61" y="12.333333333333332" width="271" height="33.666666666666671"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aRV-gu-l15">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aRV-gu-l15">
<rect key="frame" x="0.0" y="0.0" width="271" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="u1c-jJ-dxu">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="u1c-jJ-dxu">
<rect key="frame" x="0.0" y="18" width="271" height="15.666666666666664"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
<color key="textColor" systemColor="secondaryLabelColor"/>
Expand Down Expand Up @@ -156,7 +156,7 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4zT-uz-wGV">
<rect key="frame" x="0.0" y="94" width="375" height="42"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3If-PG-jDq" customClass="HairlineView" customModule="dashwallet" customModuleProvider="target">
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3If-PG-jDq" customClass="HairlineView" customModule="dashpay" customModuleProvider="target">
<rect key="frame" x="15" y="0.0" width="360" height="1"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
Expand Down Expand Up @@ -334,7 +334,7 @@
<!--Integration View Controller-->
<scene sceneID="gvg-0p-Zf5">
<objects>
<viewController storyboardIdentifier="IntegrationViewController" id="TWU-3l-B31" customClass="IntegrationViewController" customModule="dashwallet" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="IntegrationViewController" id="TWU-3l-B31" customClass="IntegrationViewController" customModule="dashpay" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" id="CHp-sf-hjx">
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand All @@ -348,7 +348,7 @@
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ufR-Iq-OaE" customClass="BalanceView" customModule="dashwallet" customModuleProvider="target">
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ufR-Iq-OaE" customClass="BalanceView" customModule="dashpay" customModuleProvider="target">
<rect key="frame" x="0.0" y="19.333333333333343" width="240" height="62"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
Expand Down Expand Up @@ -424,7 +424,7 @@
<constraint firstAttribute="height" constant="186" id="0DF-0y-iVk"/>
</constraints>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="ItemCell" rowHeight="62" id="Spx-UT-stf" customClass="ItemCell" customModule="dashwallet" customModuleProvider="target">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="ItemCell" rowHeight="62" id="Spx-UT-stf" customClass="ItemCell" customModule="dashpay" customModuleProvider="target">
<rect key="frame" x="0.0" y="50" width="361" height="62"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Spx-UT-stf" id="W8e-x2-CDx">
Expand Down Expand Up @@ -633,13 +633,13 @@
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="secondaryLabelColor">
<color red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemGreenColor">
<color red="0.20392156859999999" green="0.78039215689999997" blue="0.34901960780000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.20392156862745098" green="0.7803921568627451" blue="0.34901960784313724" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ import AuthenticationServices
import SwiftUI
import UIKit

// MARK: - PortalViewController
// MARK: - BuySellPortalViewController

@objc
final class PortalViewController: UIViewController {
final class BuySellPortalViewController: UIViewController {
@IBOutlet var subtitleLabel: UILabel!
@IBOutlet var collectionView: UICollectionView!
@IBOutlet var networkStatusView: UIView!
@IBOutlet var closeButton: UIBarButtonItem!

private var dataSource: UICollectionViewDiffableDataSource<PortalModel.Section, ServiceItem>!
private var currentSnapshot: NSDiffableDataSourceSnapshot<PortalModel.Section, ServiceItem>!
private var dataSource: UICollectionViewDiffableDataSource<BuySellPortalModel.Section, ServiceItem>!
private var currentSnapshot: NSDiffableDataSourceSnapshot<BuySellPortalModel.Section, ServiceItem>!

private var model = PortalModel()
private var model = BuySellPortalModel()
private var hasNetwork: Bool { model.networkStatus == .online }
private let topperViewModel = TopperViewModel.shared

Expand Down Expand Up @@ -111,20 +111,20 @@ final class PortalViewController: UIViewController {
}

@objc
class func controller() -> PortalViewController {
vc(PortalViewController.self, from: sb("BuySellPortal"))
class func controller() -> BuySellPortalViewController {
vc(BuySellPortalViewController.self, from: sb("BuySellPortal"))
}
}

// MARK: PortalModelDelegate

extension PortalViewController: PortalModelDelegate {
extension BuySellPortalViewController: BuySellPortalModelDelegate {
func serviceItemsDidChange() {
collectionView.reloadSections([0])
}
}

extension PortalViewController {
extension BuySellPortalViewController {
private func createLayout() -> UICollectionViewLayout {
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(64))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
Expand Down Expand Up @@ -155,15 +155,15 @@ extension PortalViewController {

// MARK: UICollectionViewDelegate, UICollectionViewDataSource

extension PortalViewController: UICollectionViewDelegate, UICollectionViewDataSource {
extension BuySellPortalViewController: UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
model.items.count
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let item = model.items[indexPath.item]

let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ItemCell", for: indexPath) as! PortalServiceItemCell
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ItemCell", for: indexPath) as! BuySellServiceItemCell
cell.update(with: item, isEnabled: hasNetwork)
return cell
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ enum Service: CaseIterable {
case topper
}

// MARK: - PortalModel.Section
// MARK: - BuySellPortalModel.Section

extension PortalModel {
extension BuySellPortalModel {
enum Section: Int {
case main
}
Expand Down Expand Up @@ -76,19 +76,19 @@ extension Service {
}
}

// MARK: - PortalModelDelegate
// MARK: - BuySellPortalModelDelegate

protocol PortalModelDelegate: AnyObject {
protocol BuySellPortalModelDelegate: AnyObject {
func serviceItemsDidChange();
}

// MARK: - PortalModel
// MARK: - BuySellPortalModel

class PortalModel: NetworkReachabilityHandling {
class BuySellPortalModel: NetworkReachabilityHandling {
var networkStatusDidChange: ((NetworkStatus) -> ())?
internal var reachabilityObserver: Any!

weak var delegate: PortalModelDelegate?
weak var delegate: BuySellPortalModelDelegate?

var items: [ServiceItem] = [] {
didSet {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,58 +24,40 @@ protocol ServiceDataProvider {
func refresh()
}

// MARK: - MookServiceDataProvider

class MookServiceDataProvider: ServiceDataProvider {
func listenForData(handler: @escaping (([ServiceItem]) -> Void)) {
handler([.init(status: .authorized, service: .uphold), .init(status: .idle, service: .coinbase)])
}

func refresh() { }
}

// MARK: - ServiceDataProviderImpl

class ServiceDataProviderImpl: ServiceDataProvider {
private var handler: (([ServiceItem]) -> Void)?

private var upholdDataSource: ServiceDataSource = UpholdDataSource()
private var coinbaseDataSource: ServiceDataSource = CoinbaseDataSource()

private var items: [ServiceItem] = [
.init(status: .idle, service: .topper) // Topper item doesn't need a data source
]
private var items: [ServiceItem]

init() {
initializeDataSources()
items = [
.init(service: .uphold, dataProvider: UpholdDataSource()),
.init(service: .topper, dataProvider: nil)
]

if CoinbaseDataSource.shouldShow() {
items.insert(.init(service: .coinbase, dataProvider: CoinbaseDataSource()), at: 0)
}

for item in items {
item.didUpdate = { [weak self] in
self?.updateServices()
}
}
}

func listenForData(handler: @escaping (([ServiceItem]) -> Void)) {
self.handler = handler
}

func refresh() {
upholdDataSource.refresh()
coinbaseDataSource.refresh()
}

private func initializeDataSources() {
upholdDataSource.serviceDidUpdate = { [weak self] item in
self?.updateService(with: item)
}

coinbaseDataSource.serviceDidUpdate = { [weak self] item in
self?.updateService(with: item)
for item in items {
item.refresh()
}
}

private func updateService(with item: ServiceItem) {
if let idx = items.firstIndex(where: { $0.service == item.service }) {
items[idx] = item
} else {
items.append(item)
}

private func updateServices() {
let sortedItems = items
.sorted(by: { $0.usageCount > $1.usageCount })
.sorted(by: { $0.isInUse && !$1.isInUse })
Expand Down
Loading

0 comments on commit a675fab

Please sign in to comment.