Conversation
Image("brave.clipboard") | ||
.resizable() | ||
.aspectRatio(contentMode: .fit) | ||
.frame(width: length, height: length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set a font
on this instead, brave.clipboard
is a custom SF Symbol so no need to make it resizable/aspect-fit/frame modifiers
} | ||
|
||
public func accountsChanged() { | ||
fetchAssetBalance() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think you have to re-fetch asset balance when an account is added/removed as long as the selected account still exists. Maybe add a check here to see if selected account exists in in the keyring.accountInfos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think you have to re-fetch asset balance when an account is added/removed as long as the selected account still exists. Maybe add a check here to see if selected account exists in in the keyring.accountInfos
I wasn't too sure what this protocol is for that's why I fetch the assets there. But after your explanation, i think fetch assets in selectedAccountChanged
is sufficient.
9e2b6dc
to
7680eae
Compare
NSLayoutConstraint.activate([ | ||
imageView.centerYAnchor.constraint(equalTo: view.centerYAnchor), | ||
imageView.centerXAnchor.constraint(equalTo: view.centerXAnchor), | ||
imageView.widthAnchor.constraint(equalToConstant: 200), | ||
imageView.heightAnchor.constraint(equalToConstant: 200), | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use SnapKit instead
private lazy var captureSession: AVCaptureSession = { | ||
let session = AVCaptureSession() | ||
session.sessionPreset = AVCaptureSession.Preset.high | ||
return session | ||
}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private let captureSession = AVCaptureSession().then {
$0.sessionPreset = .high
}
let imageView = UIImageView().then { | ||
$0.image = UIImage(named: "camera-overlay") | ||
$0.contentMode = .center | ||
$0.translatesAutoresizingMaskIntoConstraints = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isAccessibilityElement = false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isAccessibilityElement = false
it's right below at 159 😀
import AVFoundation | ||
import Shared | ||
|
||
struct WalletScannerView: UIViewControllerRepresentable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per conversation: do something like this
struct WalletScannerView: View {
@Binding var address: String
@State private var isErrorPresented: Bool = false
@Environment(\.presentationMode) @Binding private var presentationMode
var simulatorBody: some View {
}
var body: some View {
NavigationView {
#if targetEnvironment(simulator)
Text("Unable to scan on simulator")
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
address = ""
presentationMode.dismiss()
}
}
#else
_WalletScannerView(address: _address)
.ignoresSafeArea()
.alert()
#endif
}
.toolbar {
ToolbarItemGroup(placement: .cancellationAction) {
Text("")
}
}
}
}
guard let readableObject = metadataObject as? AVMetadataMachineReadableCodeObject else { | ||
isFinishScanning = true | ||
isErrorPresented = true | ||
return | ||
} | ||
guard let stringValue = readableObject.stringValue else { | ||
isFinishScanning = true | ||
isErrorPresented = true | ||
return | ||
} | ||
guard isFinishScanning == false else { return } | ||
|
||
found(code: stringValue) | ||
guard stringValue.isAddress else { | ||
isFinishScanning = true | ||
isErrorPresented = true | ||
return | ||
} | ||
|
||
toAddress = stringValue | ||
isFinishScanning = true | ||
dismiss() | ||
} else { | ||
isFinishScanning = true | ||
isErrorPresented = true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can be all combined into a simpler flow
if !isFinishScanning,
let stringValue = (metadataObjects.first as? AVMetadataMachineReadableCodeObject)?.stringValue,
stringValue.isAddress {
address = stringValue
dismiss()
} else {
isErrorPresented = true
}
isFinishScanning = true
Are we treating non-address as errors as well? Are we going to have a special error message for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked other existed scanners they don't have output validation. We can treat it as invalid data to have a popup so that user knows the scan did happen but the data is wrong.
…en fetching/selection/balance. Will need to verify token balance once brave-ios has a bump for a new core framework.
867dcd0
to
2696a97
Compare
Also removes recents commented out stuff
Summary of Changes
This pull request fixes #4273
Submitter Checklist:
NSLocalizableString()
Screenshots:
Reviewer Checklist:
QA/(Yes|No)
bug
/enhancement