mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 15:04:50 +01:00
FIX: Use buttons rather than menu items due to watchOS changes
This commit is contained in:
parent
ba3a4ea2f7
commit
91763d26a7
5 changed files with 62 additions and 35 deletions
|
@ -18,3 +18,8 @@ enum HandOffUserInfoKey: String {
|
|||
case ReceiveOnchain = "address"
|
||||
case Xpub = "xpub"
|
||||
}
|
||||
|
||||
enum HandOffTitle: String {
|
||||
case ReceiveOnchain = "View Address"
|
||||
case Xpub = "View XPUB"
|
||||
}
|
||||
|
|
|
@ -14,7 +14,15 @@ import EFQRCode
|
|||
class ReceiveInterfaceController: WKInterfaceController {
|
||||
|
||||
static let identifier = "ReceiveInterfaceController"
|
||||
private var wallet: Wallet?
|
||||
private var wallet: Wallet? {
|
||||
didSet {
|
||||
if let address = wallet?.receiveAddress {
|
||||
userActivity.userInfo = [HandOffUserInfoKey.ReceiveOnchain.rawValue: address]
|
||||
userActivity.isEligibleForHandoff = true;
|
||||
userActivity.becomeCurrent()
|
||||
}
|
||||
}
|
||||
}
|
||||
private var isRenderingQRCode: Bool?
|
||||
private var receiveMethod: String = "receive"
|
||||
private var interfaceMode: InterfaceMode = .Address
|
||||
|
@ -22,9 +30,12 @@ class ReceiveInterfaceController: WKInterfaceController {
|
|||
@IBOutlet weak var loadingIndicator: WKInterfaceGroup!
|
||||
@IBOutlet weak var imageInterface: WKInterfaceImage!
|
||||
private let userActivity: NSUserActivity = NSUserActivity(activityType: HandoffIdentifier.ReceiveOnchain.rawValue)
|
||||
|
||||
|
||||
override func willActivate() {
|
||||
super.willActivate()
|
||||
userActivity.title = HandOffTitle.ReceiveOnchain.rawValue
|
||||
userActivity.requiredUserInfoKeys = [HandOffUserInfoKey.Xpub.rawValue]
|
||||
userActivity.isEligibleForHandoff = true
|
||||
update(userActivity)
|
||||
}
|
||||
|
||||
|
@ -50,7 +61,6 @@ class ReceiveInterfaceController: WKInterfaceController {
|
|||
content: "lightning:\(invoice)", inputCorrectionLevel: .h, pointShape: .circle) else {
|
||||
return
|
||||
}
|
||||
self?.invalidateUserActivity()
|
||||
let image = UIImage(cgImage: cgImage)
|
||||
self?.loadingIndicator.setHidden(true)
|
||||
self?.imageInterface.setHidden(false)
|
||||
|
@ -70,12 +80,6 @@ class ReceiveInterfaceController: WKInterfaceController {
|
|||
})
|
||||
} else {
|
||||
guard let notificationObject = notification.object as? SpecifyInterfaceController.SpecificQRCodeContent, let walletContext = self?.wallet, !walletContext.receiveAddress.isEmpty, let receiveAddress = self?.wallet?.receiveAddress else { return }
|
||||
self?.userActivity.userInfo = [HandOffUserInfoKey.ReceiveOnchain.rawValue: receiveAddress]
|
||||
self?.userActivity.isEligibleForHandoff = true;
|
||||
self?.userActivity.becomeCurrent()
|
||||
if let userActivity = self?.userActivity {
|
||||
self?.update(userActivity)
|
||||
}
|
||||
|
||||
var address = "bitcoin:\(receiveAddress)"
|
||||
|
||||
|
@ -127,10 +131,6 @@ class ReceiveInterfaceController: WKInterfaceController {
|
|||
addMenuItem(with: .shuffle, title: "Address", action: #selector(toggleViewButtonPressed))
|
||||
}
|
||||
addressLabel.setText(wallet.receiveAddress)
|
||||
userActivity.userInfo = [HandOffUserInfoKey.ReceiveOnchain.rawValue: wallet.receiveAddress]
|
||||
userActivity.isEligibleForHandoff = true;
|
||||
userActivity.becomeCurrent()
|
||||
update(userActivity)
|
||||
}
|
||||
|
||||
override func didAppear() {
|
||||
|
|
|
@ -15,23 +15,29 @@ class ViewQRCodefaceController: WKInterfaceController {
|
|||
static let identifier = "ViewQRCodefaceController"
|
||||
@IBOutlet weak var imageInterface: WKInterfaceImage!
|
||||
@IBOutlet weak var addressLabel: WKInterfaceLabel!
|
||||
var qrcodeData: String?
|
||||
var address: String? {
|
||||
didSet {
|
||||
if let address = address, !address.isEmpty{
|
||||
userActivity.userInfo = [HandOffUserInfoKey.Xpub.rawValue: address]
|
||||
userActivity.becomeCurrent()
|
||||
}
|
||||
}
|
||||
}
|
||||
private var interfaceMode = InterfaceMode.Address
|
||||
private let userActivity: NSUserActivity = NSUserActivity(activityType: HandoffIdentifier.Xpub.rawValue)
|
||||
|
||||
override func awake(withContext context: Any?) {
|
||||
super.awake(withContext: context)
|
||||
userActivity.title = HandOffTitle.Xpub.rawValue
|
||||
userActivity.requiredUserInfoKeys = [HandOffUserInfoKey.Xpub.rawValue]
|
||||
userActivity.isEligibleForHandoff = true
|
||||
guard let passedContext = context as? String else {
|
||||
pop()
|
||||
return
|
||||
}
|
||||
address = passedContext
|
||||
addressLabel.setText(passedContext)
|
||||
|
||||
userActivity.userInfo = [HandOffUserInfoKey.Xpub.rawValue: passedContext]
|
||||
userActivity.isEligibleForHandoff = true
|
||||
userActivity.becomeCurrent()
|
||||
update(userActivity)
|
||||
|
||||
|
||||
DispatchQueue.main.async {
|
||||
guard let cgImage = EFQRCode.generate(
|
||||
content: passedContext) else {
|
||||
|
@ -87,6 +93,7 @@ class ViewQRCodefaceController: WKInterfaceController {
|
|||
super.willActivate()
|
||||
update(userActivity)
|
||||
}
|
||||
|
||||
|
||||
override func didDeactivate() {
|
||||
super.didDeactivate()
|
||||
|
|
|
@ -19,6 +19,7 @@ class WalletDetailsInterfaceController: WKInterfaceController {
|
|||
@IBOutlet weak var createInvoiceButton: WKInterfaceButton!
|
||||
@IBOutlet weak var walletNameLabel: WKInterfaceLabel!
|
||||
@IBOutlet weak var receiveButton: WKInterfaceButton!
|
||||
@IBOutlet weak var viewXPubButton: WKInterfaceButton!
|
||||
@IBOutlet weak var noTransactionsLabel: WKInterfaceLabel!
|
||||
@IBOutlet weak var transactionsTable: WKInterfaceTable!
|
||||
|
||||
|
@ -40,26 +41,25 @@ class WalletDetailsInterfaceController: WKInterfaceController {
|
|||
walletNameLabel.setText(wallet.label)
|
||||
walletBasicsGroup.setBackgroundImageNamed(WalletGradient(rawValue: wallet.type)?.imageString)
|
||||
createInvoiceButton.setHidden(!(wallet.type == WalletGradient.LightningCustodial.rawValue || wallet.type == WalletGradient.LightningLDK.rawValue))
|
||||
receiveButton.setHidden(wallet.receiveAddress.isEmpty)
|
||||
viewXPubButton.setHidden(!((wallet.type != WalletGradient.LightningCustodial.rawValue || wallet.type != WalletGradient.LightningLDK.rawValue) && !(wallet.xpub ?? "").isEmpty))
|
||||
processWalletsTable()
|
||||
addMenuItems()
|
||||
}
|
||||
|
||||
func addMenuItems() {
|
||||
|
||||
@IBAction func toggleBalanceVisibility(_ sender: Any) {
|
||||
guard let wallet = wallet else {
|
||||
return
|
||||
}
|
||||
|
||||
clearAllMenuItems()
|
||||
if (wallet.type != WalletGradient.LightningCustodial.rawValue || wallet.type != WalletGradient.LightningLDK.rawValue) && !(wallet.xpub ?? "").isEmpty {
|
||||
addMenuItem(with: .share, title: "View XPub", action: #selector(viewXPubMenuItemTapped))
|
||||
}
|
||||
|
||||
if wallet.hideBalance {
|
||||
addMenuItem(with: .accept, title: "Show Balance", action: #selector(showBalanceMenuItemTapped))
|
||||
}else{
|
||||
addMenuItem(with: .decline, title: "Hide Balance", action: #selector(hideBalanceMenuItemTapped))
|
||||
showBalanceMenuItemTapped()
|
||||
} else{
|
||||
hideBalanceMenuItemTapped()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@objc func showBalanceMenuItemTapped() {
|
||||
guard let identifier = wallet?.identifier else { return }
|
||||
WatchDataSource.toggleWalletHideBalance(walletIdentifier: identifier, hideBalance: false) { [weak self] _ in
|
||||
|
@ -80,7 +80,7 @@ class WalletDetailsInterfaceController: WKInterfaceController {
|
|||
}
|
||||
}
|
||||
|
||||
@objc func viewXPubMenuItemTapped() {
|
||||
@IBAction func viewXPubMenuItemTapped() {
|
||||
guard let xpub = wallet?.xpub else {
|
||||
return
|
||||
}
|
||||
|
@ -91,7 +91,6 @@ class WalletDetailsInterfaceController: WKInterfaceController {
|
|||
super.willActivate()
|
||||
transactionsTable.setHidden(wallet?.transactions.isEmpty ?? true)
|
||||
noTransactionsLabel.setHidden(!(wallet?.transactions.isEmpty ?? false))
|
||||
receiveButton.setHidden(wallet?.receiveAddress.isEmpty ?? true)
|
||||
}
|
||||
|
||||
@IBAction func receiveMenuItemTapped() {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="18122" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="AgC-eL-Hgc">
|
||||
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="19162" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="AgC-eL-Hgc">
|
||||
<device id="watch44"/>
|
||||
<dependencies>
|
||||
<deployment identifier="watchOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="18022"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="19044"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--BlueWallet-->
|
||||
|
@ -64,6 +64,13 @@
|
|||
</items>
|
||||
</group>
|
||||
</items>
|
||||
<gestureRecognizers>
|
||||
<tapGestureRecognizer id="amo-3m-JJX">
|
||||
<connections>
|
||||
<action selector="toggleBalanceVisibility:" destination="XWa-4i-Abg" id="UIu-9b-ksx"/>
|
||||
</connections>
|
||||
</tapGestureRecognizer>
|
||||
</gestureRecognizers>
|
||||
</group>
|
||||
<button width="1" alignment="left" hidden="YES" title="Receive" id="bPO-h8-ccD">
|
||||
<color key="titleColor" red="0.18431372549019609" green="0.37254901960784315" blue="0.70196078431372544" alpha="1" colorSpace="calibratedRGB"/>
|
||||
|
@ -73,6 +80,14 @@
|
|||
<segue destination="egq-Yw-qK5" kind="push" identifier="ReceiveInterfaceController" id="zEG-Xi-Smb"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button width="1" alignment="left" hidden="YES" title="View XPUB" id="j0O-fq-mwp" userLabel="View XPUB">
|
||||
<color key="titleColor" red="0.1843137255" green="0.37254901959999998" blue="0.70196078429999997" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="backgroundColor" red="0.80000000000000004" green="0.86666666670000003" blue="0.97647058819999999" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<fontDescription key="font" type="system" weight="medium" pointSize="16"/>
|
||||
<connections>
|
||||
<action selector="viewXPubMenuItemTapped" destination="XWa-4i-Abg" id="bmF-2z-gzj"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button width="1" alignment="left" hidden="YES" title="Create Invoice" id="7bc-tt-Pab" userLabel="Create Invoice">
|
||||
<color key="titleColor" red="0.1843137255" green="0.37254901959999998" blue="0.70196078429999997" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="backgroundColor" red="0.80000000000000004" green="0.86666666670000003" blue="0.97647058819999999" alpha="1" colorSpace="calibratedRGB"/>
|
||||
|
@ -128,6 +143,7 @@
|
|||
<outlet property="noTransactionsLabel" destination="pi4-Bk-Jiq" id="zft-Hw-KuZ"/>
|
||||
<outlet property="receiveButton" destination="bPO-h8-ccD" id="xBq-42-9qP"/>
|
||||
<outlet property="transactionsTable" destination="nyQ-lX-DX0" id="N1x-px-s08"/>
|
||||
<outlet property="viewXPubButton" destination="j0O-fq-mwp" id="5YN-ej-Ajr"/>
|
||||
<outlet property="walletBalanceLabel" destination="WTr-jJ-w7L" id="kiU-ZS-2dh"/>
|
||||
<outlet property="walletBasicsGroup" destination="275-K7-Qhe" id="nvB-rn-8Xn"/>
|
||||
<outlet property="walletNameLabel" destination="PQi-JV-aYW" id="dfi-Ai-rOe"/>
|
||||
|
|
Loading…
Add table
Reference in a new issue