Skip to content

Commit

Permalink
Merge branch 'feature/ui_updates' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	Kukai Mobile.xcodeproj/project.pbxproj
#	Kukai Mobile/Info.plist

- updates to fix garbage collection issue
- improvements to WC2
  • Loading branch information
simonmcl committed Nov 30, 2023
2 parents 2d4656a + 51c151b commit abb720d
Show file tree
Hide file tree
Showing 22 changed files with 360 additions and 118 deletions.
8 changes: 4 additions & 4 deletions Kukai Mobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2336,7 +2336,7 @@
CODE_SIGN_ENTITLEMENTS = "Kukai Mobile/Kukai Mobile.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 208;
CURRENT_PROJECT_VERSION = 209;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = TK7KK2VPJP;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = TK7KK2VPJP;
Expand Down Expand Up @@ -2376,7 +2376,7 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 208;
CURRENT_PROJECT_VERSION = 209;
DEVELOPMENT_TEAM = TK7KK2VPJP;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = TK7KK2VPJP;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -2559,7 +2559,7 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 208;
CURRENT_PROJECT_VERSION = 209;
DEVELOPMENT_TEAM = TK7KK2VPJP;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = TK7KK2VPJP;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -2699,7 +2699,7 @@
repositoryURL = "https://github.com/WalletConnect/WalletConnectSwiftV2";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.9.1;
minimumVersion = 1.9.9;
};
};
C07A2DEE2AEA76BF00550E32 /* XCRemoteSwiftPackageReference "Starscream" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/WalletConnect/WalletConnectSwiftV2",
"state" : {
"revision" : "f7ffc7910871b1cc3e4194e5bf1c7f9b5bd65e03",
"version" : "1.9.1"
"revision" : "58d2b49eeac5cf94432e2647b9107577c156a25c",
"version" : "1.9.9"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions Kukai Mobile/Controls/ThemeManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public class ThemeManager {

// Gradient
"gradBgFull-1": UIColor("#FFFFFF"),
"gradBgFull-2": UIColor("#F5F6FF"),
"gradBgFull-2": UIColor("#E9EAF2"),
"gradBgFull-3": UIColor("#E9EAF2"),
"gradModal-1": UIColor("#FFFFFF"),
"gradModal-2": UIColor("#EEEFF7"),
Expand Down Expand Up @@ -408,7 +408,7 @@ public class ThemeManager {

// Gradient
"gradBgFull-1": UIColor("#1B1C2B"),
"gradBgFull-2": UIColor("#0E0F17"),
"gradBgFull-2": UIColor("#12121C"),
"gradBgFull-3": UIColor("#0A0A0F"),
"gradModal-1": UIColor("#1B1C2B"),
"gradModal-2": UIColor("#1B1C2B"),
Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/Extensions/String+extensions_shared.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import UIKit
extension String {

func truncateTezosAddress() -> String {
return "\(self.prefix(6))...\(self.suffix(4))"
return "\(self.prefix(7))...\(self.suffix(4))"
}
}
4 changes: 2 additions & 2 deletions Kukai Mobile/Extensions/UIView+gradients.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ extension UIView {
UIColor.colorNamed("gradBgFull-2").cgColor,
UIColor.colorNamed("gradBgFull-3").cgColor,
],
locations: [0.01, 0.23, 0.66],
degress: cssDegreesToIOS(169.5))
locations: [0.01, 0.34, 0.74],
degress: cssDegreesToIOS(170))
}

func addGradientBackgroundModal() -> CAGradientLayer {
Expand Down
6 changes: 4 additions & 2 deletions Kukai Mobile/Extensions/UIViewController+extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ extension UIViewController {

// MARK: - UIAlertViewController Utils

func windowError(withTitle: String, description: String, autoDismiss: TimeInterval? = 3) {
UIApplication.shared.currentWindow?.displayError(title: withTitle, description: description, autoDismiss: autoDismiss)
func windowError(withTitle: String, description: String, autoDismiss: TimeInterval? = 10) {
if let sceneDelgate = (self.view.window?.windowScene?.delegate as? SceneDelegate) {
sceneDelgate.window?.displayError(title: withTitle, description: description, autoDismiss: autoDismiss)
}
}

func alert(errorWithMessage message: String) {
Expand Down
1 change: 1 addition & 0 deletions Kukai Mobile/Extensions/UIWindow+extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extension UIWindow {
UIWindow.errorView.addSubview(UIWindow.errorViewImage)

UIWindow.errorViewTitleLabel.text = "Error"
UIWindow.errorViewTitleLabel.accessibilityIdentifier = "window-error-title"
UIWindow.errorViewTitleLabel.numberOfLines = 1
UIWindow.errorViewTitleLabel.font = UIFont.custom(ofType: .bold, andSize: 14)
UIWindow.errorViewTitleLabel.textColor = .colorNamed("Txt0")
Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>208</string>
<string>209</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ class CollectibleDetailAVCell: UICollectionViewCell {
private var isPlaybackReady = false
private var isPlaying = false
private var imageView: UIImageView? = nil
private var playbackLikelyToKeepUpContext = 0
private var playbackRateContext = 0
private weak var playerController: CustomAVPlayerViewController? = nil

private var airPlayName: String = ""
private var airPlayArtist: String = ""
private var airPlayAlbum: String = ""
private var hasSetupNowPlaying = false

private var playbackWillKeepUpObserver: NSKeyValueObservation? = nil
private var rateObserver: NSKeyValueObservation? = nil
private var commandCentreTargetStop: Any? = nil
private var commandCentreTargetToggle: Any? = nil
private var commandCentreTargetPlay: Any? = nil
Expand Down Expand Up @@ -57,10 +58,35 @@ class CollectibleDetailAVCell: UICollectionViewCell {
placeholderView.addSubview(avplayerController.view)
avplayerController.view.frame = placeholderView.bounds
avplayerController.view.backgroundColor = .clear
avplayerController.player?.addObserver(self, forKeyPath: "currentItem.playbackLikelyToKeepUp", options: .new, context: &playbackLikelyToKeepUpContext)
avplayerController.player?.addObserver(self, forKeyPath: "rate", options: .new, context: &playbackRateContext)
avplayerController.updatesNowPlayingInfoCenter = false

self.playbackWillKeepUpObserver = avplayerController.player?.observe(\.currentItem?.isPlaybackLikelyToKeepUp, changeHandler: { [weak self] player, change in
if player.currentItem?.isPlaybackLikelyToKeepUp == true {
self?.isPlaybackReady = true

if self?.isAudio == false {
self?.mediaActivityView.stopAnimating()
self?.mediaActivityView.isHidden = true
self?.playerController?.player?.play()

} else {
self?.checkAudioImageStatus()
}
}
})

self.rateObserver = avplayerController.player?.observe(\.rate, changeHandler: { [weak self] player, change in
if player.rate == 0.0 {
self?.updateNowPlaying(isPause: true)

} else if self?.hasSetupNowPlaying == true {
self?.updateNowPlaying(isPause: false)

} else {
self?.setupNowPlaying()
}
})


// if allowsExternalPlayback set to false, during airplay via the command centre, iOS correctly picks up that its a song and shows the album artwork + title + album
// With this setup, videos however do not cast to the external device
Expand Down Expand Up @@ -110,37 +136,12 @@ class CollectibleDetailAVCell: UICollectionViewCell {
setup = true
}

override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if context == &playbackLikelyToKeepUpContext {
if self.playerController?.player?.currentItem?.isPlaybackLikelyToKeepUp == true {
isPlaybackReady = true

if !isAudio {
mediaActivityView.stopAnimating()
mediaActivityView.isHidden = true
self.playerController?.player?.play()


} else {
checkAudioImageStatus()
}
}
} else if context == &playbackRateContext, let playRate = playerController?.player?.rate {
if playRate == 0.0 {
updateNowPlaying(isPause: true)

} else if hasSetupNowPlaying {
updateNowPlaying(isPause: false)

} else {
setupNowPlaying()
}
}
}

deinit {
playerController?.player?.removeObserver(self, forKeyPath: "currentItem.playbackLikelyToKeepUp", context: &playbackLikelyToKeepUpContext)
playerController?.player?.removeObserver(self, forKeyPath: "rate", context: &playbackRateContext)
playbackWillKeepUpObserver?.invalidate()
playbackWillKeepUpObserver = nil

rateObserver?.invalidate()
rateObserver = nil

clearCommandCenterCommands()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class WalletConnectSignViewController: UIViewController, BottomSheetCustomFixedP

self.hideLoadingModal(completion: { [weak self] in
TransactionService.shared.resetWalletConnectState()
HomeTabBarController.recordWalletConnectOperationAsComplete()
self?.presentingViewController?.dismiss(animated: true)
})

Expand Down Expand Up @@ -105,6 +106,7 @@ class WalletConnectSignViewController: UIViewController, BottomSheetCustomFixedP
try WalletConnectService.reject(topic: request.topic, requestId: request.id)
self.hideLoadingModal(completion: { [weak self] in
TransactionService.shared.resetWalletConnectState()
HomeTabBarController.recordWalletConnectOperationAsComplete()
self?.presentingViewController?.dismiss(animated: true)
})

Expand Down
13 changes: 12 additions & 1 deletion Kukai Mobile/Modules/Home/HomeTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,12 @@ extension HomeTabBarController: WalletConnectServiceDelegate {
self.showLoadingView()
}

public static func recordWalletConnectOperationAsComplete() {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
WalletConnectService.shared.requestDidComplete = true
}
}

public func processedOperations(ofType: WalletConnectOperationType) {
self.loadingViewHideActivity()

Expand All @@ -512,7 +518,11 @@ extension HomeTabBarController: WalletConnectServiceDelegate {
}

public func error(message: String?, error: Error?) {
self.hideLoadingView()
Logger.app.error("WC2 error message: \(message) - error: \(error)")

self.hideLoadingView {
WalletConnectService.shared.requestDidComplete = true
}

if let m = message {
var message = "\(m)"
Expand Down Expand Up @@ -597,6 +607,7 @@ extension HomeTabBarController: UISheetPresentationControllerDelegate {
self.hideLoadingView()
self.windowError(withTitle: "error".localized(), description: error.localizedDescription)
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ class SendCollectibleConfirmViewController: UIViewController, SlideButtonDelegat
}

@IBAction func closeTapped(_ sender: Any) {
self.dismissBottomSheet()
if isWalletConnectOp {
walletConnectRespondOnReject()
} else {
self.dismissBottomSheet()
}
}

private func selectedOperationsAndFees() -> [KukaiCoreSwift.Operation] {
Expand Down Expand Up @@ -264,6 +268,7 @@ class SendCollectibleConfirmViewController: UIViewController, SlideButtonDelegat
func dismissAndReturn() {
if isWalletConnectOp {
TransactionService.shared.resetWalletConnectState()
HomeTabBarController.recordWalletConnectOperationAsComplete()
} else {
TransactionService.shared.resetAllState()
}
Expand Down Expand Up @@ -338,6 +343,7 @@ class SendCollectibleConfirmViewController: UIViewController, SlideButtonDelegat
do {
try await Sign.instance.respond(topic: request.topic, requestId: request.id, response: .error(.init(code: 0, message: "")))
try? await Sign.instance.extend(topic: request.topic)
self.didSend = true
self.dismissAndReturn()

} catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,17 @@ class SendContractConfirmViewController: UIViewController, SlideButtonDelegate,
}

@IBAction func closeTapped(_ sender: Any) {
self.dismissBottomSheet()
if isWalletConnectOp {
walletConnectRespondOnReject()
} else {
self.dismissBottomSheet()
}
}

func dismissAndReturn() {
if isWalletConnectOp {
TransactionService.shared.resetWalletConnectState()
HomeTabBarController.recordWalletConnectOperationAsComplete()
} else {
TransactionService.shared.resetAllState()
}
Expand Down Expand Up @@ -347,6 +352,7 @@ class SendContractConfirmViewController: UIViewController, SlideButtonDelegate,
do {
try await Sign.instance.respond(topic: request.topic, requestId: request.id, response: .error(.init(code: 0, message: "")))
try? await Sign.instance.extend(topic: request.topic)
self.didSend = true
self.dismissAndReturn()

} catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,17 @@ class SendTokenConfirmViewController: UIViewController, SlideButtonDelegate, Edi
}

@IBAction func closeTapped(_ sender: Any) {
self.dismissBottomSheet()
if isWalletConnectOp {
walletConnectRespondOnReject()
} else {
self.dismissBottomSheet()
}
}

func dismissAndReturn() {
if isWalletConnectOp {
TransactionService.shared.resetWalletConnectState()
HomeTabBarController.recordWalletConnectOperationAsComplete()
} else {
TransactionService.shared.resetAllState()
}
Expand Down Expand Up @@ -380,6 +385,7 @@ class SendTokenConfirmViewController: UIViewController, SlideButtonDelegate, Edi
do {
try await Sign.instance.respond(topic: request.topic, requestId: request.id, response: .error(.init(code: 0, message: "")))
try? await Sign.instance.extend(topic: request.topic)
self.didSend = true
self.dismissAndReturn()

} catch {
Expand Down
18 changes: 10 additions & 8 deletions Kukai Mobile/Modules/Side Menu/WalletConnectViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,7 @@ class WalletConnectViewController: UIViewController, BottomSheetContainerDelegat
}

func bottomSheetDataChanged() {
viewModel.refresh(animate: true)
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

viewModel.refresh(animate: true)

self.showLoadingView()

// Change account for the given pairing
if let pairing = pairingToChangeAccount {
Expand All @@ -79,17 +72,26 @@ class WalletConnectViewController: UIViewController, BottomSheetContainerDelegat
Task {
do {
try await Sign.instance.update(topic: existingSession.topic, namespaces: newNamespaces)
viewModel.refresh(animate: true)
self.hideLoadingView()

} catch {
DispatchQueue.main.async { [weak self] in
self?.pairingToChangeAccount = nil
self?.hideLoadingModal()
self?.windowError(withTitle: "error".localized(), description: error.localizedDescription)
}
}
}
}
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

viewModel.refresh(animate: true)
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "accounts", let wcSelectedAddress = sender as? String, let vc = segue.destination as? AccountsContainerViewController {
vc.addressToMarkAsSelected = wcSelectedAddress
Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/Modules/Stake/StakeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class StakeViewModel: ViewModel, UITableViewDiffableDataSourceHandler {
return
}

var filteredResults = res.filter { baker in
let filteredResults = res.filter { baker in
if baker.address == currentDelegate?.address {
currentBaker = baker
return false
Expand Down
Loading

0 comments on commit abb720d

Please sign in to comment.