Skip to content

Commit

Permalink
Merge branch 'feature/bug_fixes' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmcl committed Jan 23, 2024
2 parents 9fcda26 + 6005602 commit c960c15
Show file tree
Hide file tree
Showing 15 changed files with 290 additions and 74 deletions.
4 changes: 4 additions & 0 deletions Kukai Mobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
C003AEB42B470D6E00AEC4A8 /* SendAbstractConfirmViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003AEB32B470D6E00AEC4A8 /* SendAbstractConfirmViewController.swift */; };
C003CECB27FDE9C900F64B4C /* CloudKitService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CECA27FDE9C900F64B4C /* CloudKitService.swift */; };
C003CECD27FDED5D00F64B4C /* CKRecord+extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003CECC27FDED5D00F64B4C /* CKRecord+extensions.swift */; };
C005B6D22B5FDEE3006E265F /* OnrampViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C005B6D12B5FDEE3006E265F /* OnrampViewModel.swift */; };
C005BA322822D3DC00D8369D /* AddWalletViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C005BA312822D3DC00D8369D /* AddWalletViewController.swift */; };
C006176A29DB33C8005A1330 /* WalletCreatedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C006176929DB33C8005A1330 /* WalletCreatedViewController.swift */; };
C0081FD627D8FE2300F7FEFF /* ActivityViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0081FD527D8FE2300F7FEFF /* ActivityViewController.swift */; };
Expand Down Expand Up @@ -425,6 +426,7 @@
C003AEB32B470D6E00AEC4A8 /* SendAbstractConfirmViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendAbstractConfirmViewController.swift; sourceTree = "<group>"; };
C003CECA27FDE9C900F64B4C /* CloudKitService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudKitService.swift; sourceTree = "<group>"; };
C003CECC27FDED5D00F64B4C /* CKRecord+extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CKRecord+extensions.swift"; sourceTree = "<group>"; };
C005B6D12B5FDEE3006E265F /* OnrampViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnrampViewModel.swift; sourceTree = "<group>"; };
C005BA312822D3DC00D8369D /* AddWalletViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddWalletViewController.swift; sourceTree = "<group>"; };
C006176929DB33C8005A1330 /* WalletCreatedViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletCreatedViewController.swift; sourceTree = "<group>"; };
C0081FD527D8FE2300F7FEFF /* ActivityViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1471,6 +1473,7 @@
C06E0D60287C3E28007A580B /* WalletConnectViewModel.swift */,
C055EF1D2A2F95310031CB5F /* ShowQRViewController.swift */,
C0172A072A98EC6400163179 /* OnrampViewController.swift */,
C005B6D12B5FDEE3006E265F /* OnrampViewModel.swift */,
);
path = "Side Menu";
sourceTree = "<group>";
Expand Down Expand Up @@ -1923,6 +1926,7 @@
C0FBC88F292C12CE00B29921 /* HiddenTokensBalancesViewController.swift in Sources */,
C001D5B22A027F410089EC7A /* CollectionDetailsViewModel.swift in Sources */,
C0AC1D3E2771E5AB002F66C0 /* BottomSheetLargeSegue.swift in Sources */,
C005B6D22B5FDEE3006E265F /* OnrampViewModel.swift in Sources */,
C07FC40927C538A90056FA47 /* ImageHeadingCell.swift in Sources */,
C05B0A332A03FAC9005AA803 /* CollectiblesCollectionHeaderMediumCell.swift in Sources */,
C065AF0F2AB09C270061CC64 /* SideMenuBackupViewController.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"location" : "https://github.com/kukai-wallet/kukai-core-swift",
"state" : {
"branch" : "develop",
"revision" : "6a7d1f937117de5d88b9a936e74c64084a56be2b"
"revision" : "30b765ac3c40815d01c726a9aeed8c583d4dc073"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ extension EnterAddressComponent: AddressTypeDelegate {
sendToIcon.image = AddressTypeViewController.imageFor(addressType: type)
addressTypeButton.setTitle("Google", for: .normal)
textField.placeholder = "Enter Google Account"
textField.validator = GmailValidator()
textField.validator = EmailValidator()

case .reddit:
sendToIcon.image = AddressTypeViewController.imageFor(addressType: type)
Expand All @@ -330,7 +330,7 @@ extension EnterAddressComponent: AddressTypeDelegate {
sendToIcon.image = AddressTypeViewController.imageFor(addressType: type)
addressTypeButton.setTitle("Email", for: .normal)
textField.placeholder = "Enter email address"
textField.validator = NoWhiteSpaceStringValidator()
textField.validator = EmailValidator()
}

if !textField.revalidateTextfield() {
Expand Down
2 changes: 2 additions & 0 deletions Kukai Mobile/Localization/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@
"error-wc2-unrecoverable"="An unknown error occured with the connection. This operation can't continue. Please check the other application and try agian";
"error-wc2-cant-continue"="Unable to continue with this request due to system error";
"error-beacon-not-supported"="Beacon QRCodes are not supported, only Wallet Connect. Please make sure you are using the kukai option. If you are, please contact the dApp support team and ask them to update their beacon version";
"error-collectible-media-generic"="Unable to play media at this time, please try again later";
"error-onramp-generic"="Unable to access this provider at this time, please try again later";
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
//

import UIKit
import SDWebImage

class CollectiblesCollectionItemLargeWithTextCell: UICollectionViewCell, UITableViewCellImageDownloading {

@IBOutlet weak var iconView: UIImageView!
@IBOutlet weak var iconView: SDAnimatedImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var quantityView: UIView!
@IBOutlet weak var quantityLabel: UILabel!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import UIKit
import AVKit
import KukaiCoreSwift
import MediaPlayer
import OSLog

class CollectibleDetailAVCell: UICollectionViewCell {

Expand All @@ -30,6 +31,7 @@ class CollectibleDetailAVCell: UICollectionViewCell {

private var playbackWillKeepUpObserver: NSKeyValueObservation? = nil
private var rateObserver: NSKeyValueObservation? = nil
private var errorObserver: NSKeyValueObservation? = nil
private var commandCentreTargetStop: Any? = nil
private var commandCentreTargetToggle: Any? = nil
private var commandCentreTargetPlay: Any? = nil
Expand Down Expand Up @@ -87,6 +89,30 @@ class CollectibleDetailAVCell: UICollectionViewCell {
}
})

self.errorObserver = avplayerController.player?.currentItem?.observe(\.status, changeHandler: { [weak self] item, change in
switch item.status {
case .readyToPlay:
// Handled elsewhere
break

case .failed:
self?.mediaActivityView.stopAnimating()
self?.mediaActivityView.isHidden = true
self?.parentViewController()?.windowError(withTitle: "error".localized(), description: "error-collectible-media-generic".localized())
Logger.app.error("AVPlayer - Error: \(String(describing: item.error)), Message: \(String(describing: item.error?.localizedDescription))")

case .unknown:
self?.mediaActivityView.stopAnimating()
self?.mediaActivityView.isHidden = true
Logger.app.error("AVPlayer - unknown: \(String(describing: item.error)), Message: \(String(describing: item.error?.localizedDescription))")

@unknown default:
self?.mediaActivityView.stopAnimating()
self?.mediaActivityView.isHidden = true
Logger.app.error("AVPlayer - default/unknown: \(String(describing: item.error)), Message: \(String(describing: item.error?.localizedDescription))")
}
})


// 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 @@ -137,6 +163,9 @@ class CollectibleDetailAVCell: UICollectionViewCell {
rateObserver?.invalidate()
rateObserver = nil

errorObserver?.invalidate()
errorObserver = nil

clearCommandCenterCommands()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

import UIKit
import KukaiCoreSwift
import SDWebImage

class CollectibleDetailImageCell: UICollectionViewCell {

@IBOutlet weak var activityIndicator: UIActivityIndicatorView!
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var imageView: SDAnimatedImageView!
@IBOutlet weak var aspectRatioConstraint: NSLayoutConstraint!

public var setup = false
Expand All @@ -33,7 +34,9 @@ class CollectibleDetailImageCell: UICollectionViewCell {

// Load image if not only perfroming collectionview layout logic
if !layoutOnly {
MediaProxyService.load(url: mediaContent.mediaURL, to: imageView, withCacheType: .temporary, fallback: UIImage.unknownThumb())
MediaProxyService.load(url: mediaContent.mediaURL, to: imageView, withCacheType: .temporary, fallback: UIImage.unknownThumb()) { [weak self] _ in
self?.activityIndicator.isHidden = true
}
}

setup = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class CollectiblesCollectionCell: UICollectionViewCell, UITableViewCellImageDown
func setupImages(imageURLs: [URL?]) {

// Images 1-4 display if urls present

emptyStyle(forImageView: collectionImage1)
if imageURLs.count > 0 {
MediaProxyService.load(url: imageURLs[0], to: collectionImage1, withCacheType: .temporary, fallback: UIImage.unknownGroup()) { [weak self] imageSize in
Expand Down
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.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.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="dark"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand Down Expand Up @@ -45,7 +45,7 @@
<stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" translatesAutoresizingMaskIntoConstraints="NO" id="x9w-7P-wqQ">
<rect key="frame" x="34" y="38" width="312" height="54"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="oVn-03-8AL">
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="oVn-03-8AL" customClass="SDAnimatedImageView">
<rect key="frame" x="0.0" y="0.0" width="54" height="54"/>
<constraints>
<constraint firstAttribute="height" constant="54" id="b5Q-HK-VQH"/>
Expand All @@ -58,7 +58,7 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="qY9-6u-j5M">
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="qY9-6u-j5M" customClass="SDAnimatedImageView">
<rect key="frame" x="64.666666666666671" y="0.0" width="54" height="54"/>
<constraints>
<constraint firstAttribute="width" constant="54" id="68M-9B-iup"/>
Expand All @@ -71,7 +71,7 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="gp8-aW-hwb">
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="gp8-aW-hwb" customClass="SDAnimatedImageView">
<rect key="frame" x="129" y="0.0" width="54" height="54"/>
<constraints>
<constraint firstAttribute="height" constant="54" id="NBa-rr-ebF"/>
Expand All @@ -84,7 +84,7 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="S5j-UX-nSW">
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="S5j-UX-nSW" customClass="SDAnimatedImageView">
<rect key="frame" x="193.66666666666666" y="0.0" width="54" height="54"/>
<constraints>
<constraint firstAttribute="height" constant="54" id="fsp-4v-jzE"/>
Expand All @@ -100,7 +100,7 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="pza-1s-sun">
<rect key="frame" x="258" y="0.0" width="54" height="54"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="WYm-E6-XuL">
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="WYm-E6-XuL" customClass="SDAnimatedImageView">
<rect key="frame" x="0.0" y="0.0" width="54" height="54"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="maskToBounds" value="YES"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
//

import UIKit
import SDWebImage

class CollectiblesCollectionLargeCell: UICollectionViewCell {

@IBOutlet weak var iconView: UIImageView!
@IBOutlet weak var iconView: SDAnimatedImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet var quantityView: UIView!
@IBOutlet var quantityLabel: UILabel!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
//

import UIKit
import SDWebImage

class CollectiblesCollectionSinglePageCell: UICollectionViewCell {

@IBOutlet weak var iconView: UIImageView!
@IBOutlet weak var iconView: SDAnimatedImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var subTitleLabel: UILabel!
@IBOutlet weak var buttonView: UIView!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
//

import UIKit
import SDWebImage

class SearchResultCell: UICollectionViewCell {

@IBOutlet weak var iconView: UIImageView!
@IBOutlet weak var iconView: SDAnimatedImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var quantityView: UIView!
@IBOutlet weak var quantityLabel: UILabel!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,42 +220,41 @@ class CollectiblesDetailsViewModel: ViewModel, UICollectionViewDiffableDataSourc
section1Content.append(self.descriptionData)
self.currentSnapshot.appendItems(section1Content, toSection: 0)

ds.apply(self.currentSnapshot, animatingDifferences: animate)
self.state = .success(nil)


// If unbale to determine contentn type, we need to do a network request to find it
if response.needsMediaTypeVerification {
self.mediaContentForFailedOfflineFetch(forNFT: self.nft) { [weak self] mediaContent in
ds.apply(self.currentSnapshot, animatingDifferences: animate) {

// If unbale to determine content type, we need to do a network request to find it
if response.needsMediaTypeVerification {
self.mediaContentForFailedOfflineFetch(forNFT: self.nft) { [weak self] mediaContent in

if let newMediaContent = mediaContent {
self?.replace(existingMediaContent: response.mediaContent, with: newMediaContent)
} else {
// Unbale to determine type and unable to locate URL, or fetch packet from URL. Default to missing image palceholder
let blankMediaContent = MediaContent(isImage: true, isThumbnail: false, mediaURL: nil, mediaURL2: nil, width: 100, height: 100)
self?.replace(existingMediaContent: response.mediaContent, with: blankMediaContent)
}
}
}

// If we don't have the full image cached, download it and replace the thumbnail with the real thing
else if response.needsToDownloadFullImage {
let newURL = MediaProxyService.url(fromUri: self.nft?.displayURI, ofFormat: MediaProxyService.Format.large.rawFormat())
let isDualURL = (response.mediaContent.mediaURL2 != nil)

if let newMediaContent = mediaContent {
MediaProxyService.cacheImage(url: newURL) { [weak self] size in
let mediaURL1 = isDualURL ? response.mediaContent.mediaURL : newURL
let mediaURL2 = isDualURL ? newURL : nil
let width = Double(size?.width ?? 300)
let height = Double(size?.height ?? 300)
let newMediaContent = MediaContent(isImage: response.mediaContent.isImage, isThumbnail: false, mediaURL: mediaURL1, mediaURL2: mediaURL2, width: width, height: height)
self?.replace(existingMediaContent: response.mediaContent, with: newMediaContent)
} else {
// Unbale to determine type and unable to locate URL, or fetch packet from URL. Default to missing image palceholder
let blankMediaContent = MediaContent(isImage: true, isThumbnail: false, mediaURL: nil, mediaURL2: nil, width: 100, height: 100)
self?.replace(existingMediaContent: response.mediaContent, with: blankMediaContent)
}
}
}

// If we don't have the full image cached, download it and replace the thumbnail with the real thing
else if response.needsToDownloadFullImage {
let newURL = MediaProxyService.url(fromUri: self.nft?.displayURI, ofFormat: MediaProxyService.Format.large.rawFormat())
let isDualURL = (response.mediaContent.mediaURL2 != nil)

MediaProxyService.cacheImage(url: newURL) { [weak self] size in
let mediaURL1 = isDualURL ? response.mediaContent.mediaURL : newURL
let mediaURL2 = isDualURL ? newURL : nil
let width = Double(size?.width ?? 300)
let height = Double(size?.height ?? 300)
let newMediaContent = MediaContent(isImage: response.mediaContent.isImage, isThumbnail: false, mediaURL: mediaURL1, mediaURL2: mediaURL2, width: width, height: height)
self?.replace(existingMediaContent: response.mediaContent, with: newMediaContent)
}
}
self.state = .success(nil)
}

ds.apply(self.currentSnapshot, animatingDifferences: animate)


// Load remote data after UI
let address = DependencyManager.shared.selectedWalletAddress ?? ""
Expand Down
Loading

0 comments on commit c960c15

Please sign in to comment.