Skip to content

Commit

Permalink
Merge branch 'feature/pre_beta' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmcl committed May 3, 2024
2 parents 272c30e + a24b9b4 commit 3bdc24f
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 52 deletions.
4 changes: 2 additions & 2 deletions Kukai Mobile/Extensions/UIImageView+extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extension UIImageView {
self.tintColor = color
}

func addTokenIcon(token: Token?) {
func addTokenIcon(token: Token?, fallbackToAvatar: Bool = true) {
guard let token = token else {
self.image = UIImage.unknownToken()
return
Expand All @@ -25,7 +25,7 @@ extension UIImageView {
self.image = UIImage.tezosToken().resizedImage(size: CGSize(width: self.frame.width+2, height: self.frame.height+2))
} else {
var tokenURL = token.thumbnailURL
if tokenURL == nil, let address = token.tokenContractAddress {
if fallbackToAvatar, tokenURL == nil, let address = token.tokenContractAddress {
tokenURL = TzKTClient.avatarURL(forToken: address)
}

Expand Down
12 changes: 6 additions & 6 deletions Kukai Mobile/Modules/Account/Account.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="249" verticalHuggingPriority="251" horizontalCompressionResistancePriority="1000" text="&lt;balance&gt;" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sSc-km-vdB">
<rect key="frame" x="98" y="2" width="271" height="24"/>
<rect key="frame" x="112" y="2" width="257" height="24"/>
<fontDescription key="fontDescription" name="Figtree-Bold" family="Figtree" pointSize="20"/>
<color key="textColor" name="Txt2"/>
<nil key="highlightedColor"/>
Expand All @@ -285,7 +285,7 @@
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" semanticContentAttribute="forceRightToLeft" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cTx-cl-SFJ" customClass="CustomisableButton" customModule="Kukai_Mobile" customModuleProvider="target">
<rect key="frame" x="16" y="-2" width="66" height="32"/>
<rect key="frame" x="16" y="4" width="80" height="20"/>
<fontDescription key="fontDescription" name="Figtree-Medium" family="Figtree" pointSize="16"/>
<color key="tintColor" name="Txt10"/>
<inset key="imageEdgeInsets" minX="17" minY="0.0" maxX="4" maxY="0.0"/>
Expand Down Expand Up @@ -1828,10 +1828,10 @@ The estimate uses exchange data that might not be up to date and does not take i
<size key="intrinsicContentSize" width="78" height="31"/>
</designable>
<designable name="405-zw-M1R">
<size key="intrinsicContentSize" width="30" height="34"/>
<size key="intrinsicContentSize" width="26" height="26"/>
</designable>
<designable name="5Pu-Vc-J65">
<size key="intrinsicContentSize" width="24" height="14"/>
<size key="intrinsicContentSize" width="54" height="44"/>
</designable>
<designable name="EKG-xY-HYO">
<size key="intrinsicContentSize" width="73" height="34"/>
Expand All @@ -1840,10 +1840,10 @@ The estimate uses exchange data that might not be up to date and does not take i
<size key="intrinsicContentSize" width="117" height="34"/>
</designable>
<designable name="cTx-cl-SFJ">
<size key="intrinsicContentSize" width="66" height="32"/>
<size key="intrinsicContentSize" width="80" height="20"/>
</designable>
<designable name="dQs-Hg-Uq3">
<size key="intrinsicContentSize" width="24" height="14"/>
<size key="intrinsicContentSize" width="56" height="46"/>
</designable>
<designable name="mc4-MV-VSh">
<size key="intrinsicContentSize" width="83.333333333333329" height="31"/>
Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/Modules/Activity/Cells/ActivityItemCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class ActivityItemCell: UITableViewCell, UITableViewCellContainerView, UITableVi
} else {

// Icon and title
iconView.addTokenIcon(token: data.primaryToken)
iconView.addTokenIcon(token: data.primaryToken, fallbackToAvatar: false)
titleLabel.text = title(forToken: data.primaryToken)

if data.primaryToken?.tokenType == .nonfungible {
Expand Down
8 changes: 4 additions & 4 deletions Kukai Mobile/Modules/Collectibles/Collectibles.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -642,16 +642,16 @@
</scenes>
<designables>
<designable name="3EA-cA-JgY">
<size key="intrinsicContentSize" width="24" height="14"/>
<size key="intrinsicContentSize" width="50" height="40"/>
</designable>
<designable name="RJp-GD-j8b">
<size key="intrinsicContentSize" width="24" height="14"/>
<size key="intrinsicContentSize" width="44" height="34"/>
</designable>
<designable name="oJi-ls-hKZ">
<size key="intrinsicContentSize" width="24" height="14"/>
<size key="intrinsicContentSize" width="54" height="44"/>
</designable>
<designable name="yxl-v0-paf">
<size key="intrinsicContentSize" width="24" height="14"/>
<size key="intrinsicContentSize" width="54" height="44"/>
</designable>
</designables>
<inferredMetricsTieBreakers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class CollectiblesCollectionsViewModel: ViewModel, UICollectionViewDiffableDataS
let groupURL = MediaProxyService.url(fromUri: nftGroup.thumbnailURL, ofFormat: MediaProxyService.Format.icon.rawFormat())
self.imageURLsForCollectionGroups.append(groupURL)

let urls = visibleNfts.compactMap({ MediaProxyService.smallURL(forNFT: $0) })
let urls = visibleNfts.map({ MediaProxyService.smallURL(forNFT: $0) })
self.imageURLsForCollectibles.append(urls)
self.nftCollectionTotalCounts.append(totalCount)
}
Expand Down
27 changes: 6 additions & 21 deletions Kukai Mobile/Modules/Home/HomeTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class HomeTabBarController: UITabBarController, UITabBarControllerDelegat

DispatchQueue.global(qos: .background).async {
DependencyManager.shared.balanceService.loadCache(address: address)
self?.reconnectWalletConnectIfNeeded()
//self?.reconnectWalletConnectIfNeeded()

DispatchQueue.main.async {
DependencyManager.shared.addressLoaded = address
Expand All @@ -89,7 +89,7 @@ public class HomeTabBarController: UITabBarController, UITabBarControllerDelegat

DispatchQueue.global(qos: .background).async {
DependencyManager.shared.balanceService.loadCache(address: address)
self?.reconnectWalletConnectIfNeeded()
//self?.reconnectWalletConnectIfNeeded()

DispatchQueue.main.async {

Expand Down Expand Up @@ -125,7 +125,7 @@ public class HomeTabBarController: UITabBarController, UITabBarControllerDelegat
.dropFirst()
.sink { [weak self] address in

self?.reconnectWalletConnectIfNeeded()
//self?.reconnectWalletConnectIfNeeded()

if DependencyManager.shared.appUpdateService.isRequiredUpdate {
self?.displayUpdateRequired()
Expand All @@ -147,7 +147,7 @@ public class HomeTabBarController: UITabBarController, UITabBarControllerDelegat
DependencyManager.shared.balanceService.$addressErrored
.dropFirst()
.sink { [weak self] obj in
self?.reconnectWalletConnectIfNeeded()
//self?.reconnectWalletConnectIfNeeded()

if let obj = obj, obj.address == DependencyManager.shared.selectedWalletAddress {

Expand All @@ -161,12 +161,6 @@ public class HomeTabBarController: UITabBarController, UITabBarControllerDelegat
}
}.store(in: &bag)

(UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate)?.$dismissedPrivacyProtectionWindow
.dropFirst()
.sink { [weak self] _ in
self?.displayDisconnectedToastIfNeeded()
}.store(in: &bag)

NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification).sink { [weak self] _ in
AccountViewModel.reconnectAccountActivityListenerIfNeeded()
self?.supressAutoRefreshError = true
Expand Down Expand Up @@ -486,8 +480,6 @@ extension HomeTabBarController: WalletConnectServiceDelegate {
self.walletConnectActivity.color = ThemeManager.shared.currentInterfaceStyle() == .dark ? .white : .black
self.walletConnectActivity.startAnimating()

displayDisconnectedToastIfNeeded()

} else {
self.scanButton.isEnabled = true
self.scanButton.setImage(UIImage(named: "ScanQR"), for: .normal)
Expand All @@ -496,26 +488,19 @@ extension HomeTabBarController: WalletConnectServiceDelegate {
}
}

public func displayDisconnectedToastIfNeeded() {
if !WalletConnectService.shared.isConnected &&
(UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate)?.privacyProtectionWindowVisible == false &&
self.navigationController?.viewControllers.last is HomeTabBarController
{
Toast.shared.show(withMessage: "Reconnecting...", attachedTo: self.scanButton, onTop: false)
}
}

public func walletConnectSocketFailedToReconnect3Times() {
DispatchQueue.main.async {
self.windowError(withTitle: "error".localized(), description: "error-wc2-reconnect".localized())
}
}

/*
public func reconnectWalletConnectIfNeeded() {
if !WalletConnectService.shared.isConnected {
WalletConnectService.shared.reconnect()
}
}
*/

public func pairRequested() {
if self.presentedViewController == nil {
Expand Down
16 changes: 8 additions & 8 deletions Kukai Mobile/Modules/Stake/Stake.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Delegating" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bUC-oz-6FD">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Delegate To Baker" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bUC-oz-6FD">
<rect key="frame" x="20" y="72" width="374" height="24"/>
<fontDescription key="fontDescription" name="Figtree-Bold" family="Figtree" pointSize="20"/>
<color key="textColor" name="Txt2"/>
Expand Down Expand Up @@ -913,11 +913,11 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7hn-85-4wP">
<rect key="frame" x="174" y="0.0" width="126" height="28"/>
<rect key="frame" x="174" y="0.0" width="113" height="28"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
<button opaque="NO" contentMode="scaleToFill" semanticContentAttribute="forceRightToLeft" horizontalHuggingPriority="750" horizontalCompressionResistancePriority="1000" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bHS-8y-RgK" customClass="CustomisableButton" customModule="Kukai_Mobile" customModuleProvider="target">
<rect key="frame" x="306" y="0.0" width="76" height="28"/>
<rect key="frame" x="293" y="0.0" width="89" height="28"/>
<color key="backgroundColor" name="BtnSec1"/>
<constraints>
<constraint firstAttribute="height" constant="28" id="8qr-Tv-CLk"/>
Expand Down Expand Up @@ -1109,22 +1109,22 @@ Bakers validate and participate in Tezos governance. By delegating to a Baker, y
</scenes>
<designables>
<designable name="NRS-kv-8Vb">
<size key="intrinsicContentSize" width="30" height="34"/>
<size key="intrinsicContentSize" width="18" height="22"/>
</designable>
<designable name="VYs-9f-ae4">
<size key="intrinsicContentSize" width="24" height="14"/>
<size key="intrinsicContentSize" width="44" height="34"/>
</designable>
<designable name="bHS-8y-RgK">
<size key="intrinsicContentSize" width="76" height="17"/>
<size key="intrinsicContentSize" width="89" height="17"/>
</designable>
<designable name="fCN-GU-Gc8">
<size key="intrinsicContentSize" width="30" height="34"/>
<size key="intrinsicContentSize" width="12" height="22"/>
</designable>
<designable name="isB-kD-FJg">
<size key="intrinsicContentSize" width="107" height="38"/>
</designable>
<designable name="vd8-mr-vOW">
<size key="intrinsicContentSize" width="30" height="34"/>
<size key="intrinsicContentSize" width="18" height="22"/>
</designable>
</designables>
<resources>
Expand Down
4 changes: 2 additions & 2 deletions Kukai Mobile/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

func sceneWillEnterForeground(_ scene: UIScene) {

WalletConnectService.shared.connect()
//WalletConnectService.shared.connect()

// Check system colors set correctly from beginning
ThemeManager.shared.updateSystemInterfaceStyle()
Expand All @@ -67,7 +67,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

func sceneDidEnterBackground(_ scene: UIScene) {

WalletConnectService.shared.disconnect()
//WalletConnectService.shared.disconnect()

// When entering background, cover the screen in a new window containing a nav controller and the login flow
// They will auto trigger themselves based on `viewDidAppear` methods
Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/Services/TransactionService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public class TransactionService {
return (image: image, title: "AppleID", subtitle: metadata.address.truncateTezosAddress())

case .twitter:
let image = UIImage(named: "Social_Twitter_color")?.resizedImage(size: imageSize) ?? UIImage()
let image = UIImage(named: "Social_Twitter_color")?.resizedImage(size: imageSize)?.withTintColor(.colorNamed("Txt2")) ?? UIImage()
return (image: image, title: metadata.socialUsername ?? metadata.socialUserId ?? "", subtitle: metadata.address.truncateTezosAddress())

case .google:
Expand Down
17 changes: 11 additions & 6 deletions Kukai Mobile/Services/WalletConnectService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public class WalletConnectService {
redirect: AppMetadata.Redirect(native: "kukai://", universal: nil))

private var pairingTimer: Timer? = nil
private var isReconnecting = false
private var isManualDisconnection = true
//private var isReconnecting = false
//private var isManualDisconnection = true

@Published public var requestDidComplete: Bool = false
@Published public var pairsAndSessionsUpdated: Bool = false
Expand All @@ -103,7 +103,7 @@ public class WalletConnectService {
public func setup() {

// Objects and metadata
Networking.configure(groupIdentifier: "group.app.kukai.mobile", projectId: WalletConnectService.projectId, socketFactory: DefaultSocketFactory(), socketConnectionType: .manual)
Networking.configure(groupIdentifier: "group.app.kukai.mobile", projectId: WalletConnectService.projectId, socketFactory: DefaultSocketFactory(), socketConnectionType: .automatic)
Pair.configure(metadata: WalletConnectService.metadata)
//Sign.configure(crypto: WC2CryptoProvider())

Expand All @@ -119,18 +119,23 @@ public class WalletConnectService {
if status == .disconnected {
self?.isConnected = false

/*
if self?.isManualDisconnection == false && self?.isReconnecting == false {
WalletConnectService.shared.reconnect()

} else if self?.isManualDisconnection == true {
self?.isManualDisconnection = false
}
*/

} else {
self?.isConnected = true

/*
if let uri = self?.deepLinkPairingToConnect {
self?.pairClient(uri: uri)
}
*/
}

}.store(in: &bag)
Expand Down Expand Up @@ -214,13 +219,12 @@ public class WalletConnectService {

hasBeenSetup = true

/*
if let uri = deepLinkPairingToConnect {
pairClient(uri: uri)
}
*/
}

/*
public func connect() {
if !hasBeenSetup { return }
Logger.app.info("WC2 - Connection status: calling connect()")
Expand Down Expand Up @@ -281,7 +285,7 @@ public class WalletConnectService {
self.delegate?.walletConnectSocketFailedToReconnect3Times()
}
}

*/



Expand Down Expand Up @@ -693,6 +697,7 @@ public class WalletConnectService {
do {
let _ = try await Sign.instance.approve(proposalId: proposal.id, namespaces: namespaces, sessionProperties: sessionProperties)
Logger.app.info("WC approveCurrentProposal success")
WalletConnectService.shared.pairsAndSessionsUpdated = true
completion?(true, nil)

} catch (let error) {
Expand Down

0 comments on commit 3bdc24f

Please sign in to comment.