Wallet UI improvements

This commit is contained in:
Ilya Laktyushin 2019-10-01 23:12:42 +03:00
parent 5006d7ddd5
commit 0e81e73a80
3 changed files with 25 additions and 24 deletions

View File

@ -60,7 +60,6 @@ private enum WalletCreateInvoiceScreenEntryTag: ItemListItemTag {
private enum WalletCreateInvoiceScreenEntry: ItemListNodeEntry { private enum WalletCreateInvoiceScreenEntry: ItemListNodeEntry {
case amountHeader(PresentationTheme, String) case amountHeader(PresentationTheme, String)
case amount(PresentationTheme, PresentationStrings, String, String) case amount(PresentationTheme, PresentationStrings, String, String)
case amountInfo(PresentationTheme, String)
case commentHeader(PresentationTheme, String) case commentHeader(PresentationTheme, String)
case comment(PresentationTheme, String, String) case comment(PresentationTheme, String, String)
case addressCode(PresentationTheme, String) case addressCode(PresentationTheme, String)
@ -72,7 +71,7 @@ private enum WalletCreateInvoiceScreenEntry: ItemListNodeEntry {
var section: ItemListSectionId { var section: ItemListSectionId {
switch self { switch self {
case .amountHeader, .amount, .amountInfo: case .amountHeader, .amount:
return WalletCreateInvoiceScreenSection.amount.rawValue return WalletCreateInvoiceScreenSection.amount.rawValue
case .commentHeader, .comment: case .commentHeader, .comment:
return WalletCreateInvoiceScreenSection.comment.rawValue return WalletCreateInvoiceScreenSection.comment.rawValue
@ -87,24 +86,22 @@ private enum WalletCreateInvoiceScreenEntry: ItemListNodeEntry {
return 0 return 0
case .amount: case .amount:
return 1 return 1
case .amountInfo:
return 2
case .commentHeader: case .commentHeader:
return 3 return 2
case .comment: case .comment:
return 4 return 3
case .addressCode: case .addressCode:
return 5 return 4
case .addressHeader: case .addressHeader:
return 6 return 5
case .address: case .address:
return 7 return 6
case .copyAddress: case .copyAddress:
return 8 return 7
case .shareAddressLink: case .shareAddressLink:
return 9 return 8
case .addressInfo: case .addressInfo:
return 10 return 9
} }
} }
@ -122,12 +119,6 @@ private enum WalletCreateInvoiceScreenEntry: ItemListNodeEntry {
} else { } else {
return false return false
} }
case let .amountInfo(lhsTheme, lhsText):
if case let .amountInfo(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
return true
} else {
return false
}
case let .commentHeader(lhsTheme, lhsText): case let .commentHeader(lhsTheme, lhsText):
if case let .commentHeader(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText { if case let .commentHeader(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
return true return true
@ -220,8 +211,6 @@ private enum WalletCreateInvoiceScreenEntry: ItemListNodeEntry {
}, action: { }, action: {
arguments.selectNextInputItem(WalletCreateInvoiceScreenEntryTag.amount) arguments.selectNextInputItem(WalletCreateInvoiceScreenEntryTag.amount)
}) })
case let .amountInfo(theme, text):
return ItemListTextItem(theme: theme, text: .markdown(text), sectionId: self.section)
case let .commentHeader(theme, text): case let .commentHeader(theme, text):
return ItemListSectionHeaderItem(theme: theme, text: text, sectionId: self.section) return ItemListSectionHeaderItem(theme: theme, text: text, sectionId: self.section)
case let .comment(theme, placeholder, value): case let .comment(theme, placeholder, value):
@ -281,7 +270,6 @@ private func walletCreateInvoiceScreenEntries(presentationData: PresentationData
let amount = amountValue(state.amount) let amount = amountValue(state.amount)
entries.append(.amountHeader(presentationData.theme, presentationData.strings.Wallet_Receive_AmountHeader)) entries.append(.amountHeader(presentationData.theme, presentationData.strings.Wallet_Receive_AmountHeader))
entries.append(.amount(presentationData.theme, presentationData.strings, presentationData.strings.Wallet_Receive_AmountText, state.amount ?? "")) entries.append(.amount(presentationData.theme, presentationData.strings, presentationData.strings.Wallet_Receive_AmountText, state.amount ?? ""))
entries.append(.amountInfo(presentationData.theme, presentationData.strings.Wallet_Receive_AmountInfo))
entries.append(.commentHeader(presentationData.theme, presentationData.strings.Wallet_Receive_CommentHeader)) entries.append(.commentHeader(presentationData.theme, presentationData.strings.Wallet_Receive_CommentHeader))
entries.append(.comment(presentationData.theme, presentationData.strings.Wallet_Receive_CommentInfo, state.comment)) entries.append(.comment(presentationData.theme, presentationData.strings.Wallet_Receive_CommentInfo, state.comment))

View File

@ -216,7 +216,6 @@ private final class WalletInfoHeaderNode: ASDisplayNode {
self.headerCornerNode.displaysAsynchronously = false self.headerCornerNode.displaysAsynchronously = false
self.headerCornerNode.displayWithoutProcessing = true self.headerCornerNode.displayWithoutProcessing = true
self.headerCornerNode.image = generateImage(CGSize(width: 20.0, height: 10.0), rotatedContext: { size, context in self.headerCornerNode.image = generateImage(CGSize(width: 20.0, height: 10.0), rotatedContext: { size, context in
context.setFillColor(UIColor.black.cgColor) context.setFillColor(UIColor.black.cgColor)
context.fill(CGRect(origin: CGPoint(), size: size)) context.fill(CGRect(origin: CGPoint(), size: size))
context.setBlendMode(.copy) context.setBlendMode(.copy)

View File

@ -9,6 +9,7 @@ import Display
import Postbox import Postbox
import QrCode import QrCode
import ShareController import ShareController
import AnimationUI
func shareInvoiceQrCode(context: AccountContext, invoice: String) { func shareInvoiceQrCode(context: AccountContext, invoice: String) {
let _ = (qrCode(string: invoice, color: .black, backgroundColor: .white, icon: .custom(UIImage(bundleImageName: "Wallet/QrGem"))) let _ = (qrCode(string: invoice, color: .black, backgroundColor: .white, icon: .custom(UIImage(bundleImageName: "Wallet/QrGem")))
@ -116,6 +117,7 @@ private final class WalletQrViewScreenNode: ViewControllerTracingNode {
private let invoice: String private let invoice: String
private let imageNode: TransformImageNode private let imageNode: TransformImageNode
private let iconNode: AnimatedStickerNode
init(context: AccountContext, presentationData: PresentationData, message: String) { init(context: AccountContext, presentationData: PresentationData, message: String) {
self.presentationData = presentationData self.presentationData = presentationData
@ -125,13 +127,20 @@ private final class WalletQrViewScreenNode: ViewControllerTracingNode {
self.imageNode.clipsToBounds = true self.imageNode.clipsToBounds = true
self.imageNode.cornerRadius = 12.0 self.imageNode.cornerRadius = 12.0
self.iconNode = AnimatedStickerNode()
if let path = getAppBundle().path(forResource: "WalletIntroStatic", ofType: "tgs") {
self.iconNode.setup(account: context.account, resource: .localFile(path), width: 120, height: 120, mode: .direct)
self.iconNode.visibility = true
}
super.init() super.init()
self.backgroundColor = self.presentationData.theme.list.plainBackgroundColor self.backgroundColor = self.presentationData.theme.list.plainBackgroundColor
self.addSubnode(self.imageNode) self.addSubnode(self.imageNode)
self.addSubnode(self.iconNode)
self.imageNode.setSignal(qrCode(string: self.invoice, color: .black, backgroundColor: .white, icon: .custom(UIImage(bundleImageName: "Wallet/QrGem"))), attemptSynchronously: true) self.imageNode.setSignal(qrCode(string: self.invoice, color: .black, backgroundColor: .white, icon: .cutout), attemptSynchronously: true)
} }
func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: ContainedViewLayoutTransition) { func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: ContainedViewLayoutTransition) {
@ -143,6 +152,11 @@ private final class WalletQrViewScreenNode: ViewControllerTracingNode {
let _ = imageApply() let _ = imageApply()
transition.updateFrame(node: self.imageNode, frame: CGRect(origin: CGPoint(x: floor((layout.size.width - imageSize.width) / 2.0), y: floor((layout.size.height - imageSize.height - layout.intrinsicInsets.bottom) / 2.0)), size: imageSize)) let imageFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - imageSize.width) / 2.0), y: floor((layout.size.height - imageSize.height - layout.intrinsicInsets.bottom) / 2.0)), size: imageSize)
transition.updateFrame(node: self.imageNode, frame: imageFrame)
let iconFrame = imageFrame.insetBy(dx: 106.0, dy: 106.0).offsetBy(dx: 0.0, dy: -2.0)
self.iconNode.updateLayout(size: iconFrame.size)
transition.updateFrameAsPositionAndBounds(node: self.iconNode, frame: iconFrame)
} }
} }