Add icon to "donate with credit/debit card" button

This commit is contained in:
Evan Hahn 2022-11-22 12:25:18 -06:00
parent 21f2a36125
commit 0e79b75029
No known key found for this signature in database
5 changed files with 247 additions and 2 deletions

View File

@ -1262,6 +1262,7 @@
F94D130628C1667600B2C478 /* DatabaseRecoveryTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F94D130528C1667600B2C478 /* DatabaseRecoveryTest.swift */; };
F95427E6286E042200314EDA /* BadgeGiftingThanksSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = F95427E5286E042200314EDA /* BadgeGiftingThanksSheet.swift */; };
F963164B291AE06C00218FB7 /* OWSScrubbingLogFormatterTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F963164A291AE06C00218FB7 /* OWSScrubbingLogFormatterTest.swift */; };
F963F816292D1B5B007DBBBD /* UIButton+SignalUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = F963F815292D1B5B007DBBBD /* UIButton+SignalUI.swift */; };
F969C2CF2922DD6F00E19786 /* OWSDisappearingMessageFinderTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F969C2CE2922DD6F00E19786 /* OWSDisappearingMessageFinderTest.swift */; };
F96A534328A1AE7C003262D4 /* OutgoingGroupUpdateMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = F96A534228A1AE7B003262D4 /* OutgoingGroupUpdateMessage.swift */; };
F96B66A92912B88B004FFFAA /* DonateViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F96B66A02912B88A004FFFAA /* DonateViewController.swift */; };
@ -3632,6 +3633,7 @@
F94D130528C1667600B2C478 /* DatabaseRecoveryTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabaseRecoveryTest.swift; sourceTree = "<group>"; };
F95427E5286E042200314EDA /* BadgeGiftingThanksSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeGiftingThanksSheet.swift; sourceTree = "<group>"; };
F963164A291AE06C00218FB7 /* OWSScrubbingLogFormatterTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OWSScrubbingLogFormatterTest.swift; sourceTree = "<group>"; };
F963F815292D1B5B007DBBBD /* UIButton+SignalUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIButton+SignalUI.swift"; sourceTree = "<group>"; };
F965C5B87BFDF8F86556C04C /* Pods-SignalNSE.profiling.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SignalNSE.profiling.xcconfig"; path = "Pods/Target Support Files/Pods-SignalNSE/Pods-SignalNSE.profiling.xcconfig"; sourceTree = "<group>"; };
F969C2CE2922DD6F00E19786 /* OWSDisappearingMessageFinderTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OWSDisappearingMessageFinderTest.swift; sourceTree = "<group>"; };
F96A534228A1AE7B003262D4 /* OutgoingGroupUpdateMessage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OutgoingGroupUpdateMessage.swift; sourceTree = "<group>"; };
@ -5191,6 +5193,7 @@
34A954E9271B4FB000B05242 /* Categories */ = {
isa = PBXGroup;
children = (
F963F815292D1B5B007DBBBD /* UIButton+SignalUI.swift */,
34A954F4271B4FB000B05242 /* UIFont+OWS.h */,
34A954F1271B4FB000B05242 /* UIFont+OWS.m */,
76E54D68290B4E7800D03BA8 /* UIFont+TextStyle.swift */,
@ -9920,6 +9923,7 @@
3402AA9B271D9E180084CBAE /* TooltipView.swift in Sources */,
88C980D427F3AD2C009750C0 /* TSMessage+SignalUI.swift in Sources */,
8803C2F628B02FDB00183D2B /* TSOutgoingMessage+AttachmentMultisend.swift in Sources */,
F963F816292D1B5B007DBBBD /* UIButton+SignalUI.swift in Sources */,
34A954FC271B4FB000B05242 /* UIFont+OWS.m in Sources */,
76E54D69290B4E7800D03BA8 /* UIFont+TextStyle.swift in Sources */,
500FB6182915B86D00257951 /* UITableView+ReusableCell.swift in Sources */,

View File

@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "card-32.pdf"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,175 @@
%PDF-1.7
1 0 obj
<< /ExtGState << /E2 << /ca 0.400000 >>
/E1 << /ca 0.110000 >>
>> >>
endobj
2 0 obj
<< /Length 3 0 R >>
stream
/DeviceRGB CS
/DeviceRGB cs
q
1.000000 0.000000 -0.000000 1.000000 0.000000 5.000000 cm
0.984314 0.988235 0.996078 scn
0.000000 18.631578 m
0.000000 20.491905 1.508094 22.000000 3.368421 22.000000 c
28.631578 22.000000 l
30.491905 22.000000 32.000000 20.491907 32.000000 18.631578 c
32.000000 3.368422 l
32.000000 1.508095 30.491907 0.000000 28.631578 0.000000 c
3.368422 0.000000 l
1.508094 0.000000 0.000000 1.508093 0.000000 3.368422 c
0.000000 18.631578 l
h
f
n
Q
q
/E1 gs
1.000000 0.000000 -0.000000 1.000000 0.000000 5.000000 cm
0.313726 0.403922 0.623529 scn
0.000000 18.631578 m
0.000000 20.491905 1.508094 22.000000 3.368421 22.000000 c
28.631578 22.000000 l
30.491905 22.000000 32.000000 20.491907 32.000000 18.631578 c
32.000000 3.368422 l
32.000000 1.508095 30.491907 0.000000 28.631578 0.000000 c
3.368422 0.000000 l
1.508094 0.000000 0.000000 1.508093 0.000000 3.368422 c
0.000000 18.631578 l
h
f
n
Q
q
/E2 gs
1.000000 0.000000 -0.000000 1.000000 21.894928 17.222168 cm
0.345098 0.376471 0.443137 scn
0.000000 5.676389 m
0.000000 6.141471 0.377023 6.518494 0.842105 6.518494 c
5.894737 6.518494 l
6.359819 6.518494 6.736842 6.141470 6.736842 5.676388 c
6.736842 0.842080 l
6.736842 0.376998 6.359819 -0.000025 5.894737 -0.000025 c
0.842105 -0.000025 l
0.377023 -0.000025 0.000000 0.376998 0.000000 0.842081 c
0.000000 5.676389 l
h
f
n
Q
q
1.000000 0.000000 -0.000000 1.000000 3.368530 9.888916 cm
0.631373 0.674510 0.768627 scn
0.000000 0.814763 m
0.000000 1.264773 0.364805 1.629578 0.814815 1.629578 c
4.237816 1.629578 l
4.687826 1.629578 5.052631 1.264773 5.052631 0.814763 c
5.052631 0.814763 l
5.052631 0.364753 4.687826 -0.000052 4.237816 -0.000052 c
0.814816 -0.000052 l
0.364806 -0.000052 0.000000 0.364753 0.000000 0.814763 c
0.000000 0.814763 l
h
f
n
Q
q
1.000000 0.000000 -0.000000 1.000000 10.105103 9.888916 cm
0.631373 0.674510 0.768627 scn
0.000000 0.814763 m
0.000000 1.264773 0.364805 1.629578 0.814815 1.629578 c
4.237816 1.629578 l
4.687826 1.629578 5.052631 1.264773 5.052631 0.814763 c
5.052631 0.814763 l
5.052631 0.364753 4.687826 -0.000052 4.237816 -0.000052 c
0.814816 -0.000052 l
0.364806 -0.000052 0.000000 0.364753 0.000000 0.814763 c
0.000000 0.814763 l
h
f
n
Q
q
1.000000 0.000000 -0.000000 1.000000 16.841705 9.888916 cm
0.631373 0.674510 0.768627 scn
0.000000 0.814763 m
0.000000 1.264773 0.364805 1.629578 0.814815 1.629578 c
4.237816 1.629578 l
4.687826 1.629578 5.052631 1.264773 5.052631 0.814763 c
5.052631 0.814763 l
5.052631 0.364753 4.687826 -0.000052 4.237816 -0.000052 c
0.814816 -0.000052 l
0.364806 -0.000052 0.000000 0.364753 0.000000 0.814763 c
0.000000 0.814763 l
h
f
n
Q
q
1.000000 0.000000 -0.000000 1.000000 23.579193 9.888916 cm
0.631373 0.674510 0.768627 scn
0.000000 0.814763 m
0.000000 1.264773 0.364805 1.629578 0.814815 1.629578 c
4.237816 1.629578 l
4.687826 1.629578 5.052631 1.264773 5.052631 0.814763 c
5.052631 0.814763 l
5.052631 0.364753 4.687826 -0.000052 4.237816 -0.000052 c
0.814816 -0.000052 l
0.364806 -0.000052 0.000000 0.364753 0.000000 0.814763 c
0.000000 0.814763 l
h
f
n
Q
endstream
endobj
3 0 obj
3062
endobj
4 0 obj
<< /Annots []
/Type /Page
/MediaBox [ 0.000000 0.000000 32.000000 32.000000 ]
/Resources 1 0 R
/Contents 2 0 R
/Parent 5 0 R
>>
endobj
5 0 obj
<< /Kids [ 4 0 R ]
/Count 1
/Type /Pages
>>
endobj
6 0 obj
<< /Pages 5 0 R
/Type /Catalog
>>
endobj
xref
0 7
0000000000 65535 f
0000000010 00000 n
0000000132 00000 n
0000003250 00000 n
0000003273 00000 n
0000003446 00000 n
0000003520 00000 n
trailer
<< /ID [ (some) (id) ]
/Root 6 0 R
/Size 7
>>
startxref
3579
%%EOF

View File

@ -164,13 +164,22 @@ class DonateChoosePaymentMethodSheet: OWSTableSheetViewController {
"DONATE_CHOOSE_CREDIT_OR_DEBIT_CARD_AS_PAYMENT_METHOD",
comment: "When users make donations, they can choose which payment method they want to use. This is the text on the button that lets them choose to pay with credit or debit card."
)
// TODO(donations) Add an icon on this button.
let creditOrDebitCardButton = OWSButton(title: title) { [weak self] in
guard let self else { return }
self.didChoosePaymentMethod(self, .creditOrDebitCard)
}
creditOrDebitCardButton.layer.cornerRadius = 8
guard let image = UIImage(named: "credit-or-debit-card") else {
owsFail("Card asset not found")
}
creditOrDebitCardButton.setImage(image, for: .normal)
creditOrDebitCardButton.setPaddingBetweenImageAndText(
to: 8,
isRightToLeft: CurrentAppContext().isRTL
)
creditOrDebitCardButton.layer.cornerRadius = 12
creditOrDebitCardButton.backgroundColor = .ows_accentBlue
creditOrDebitCardButton.dimsWhenHighlighted = true
creditOrDebitCardButton.titleLabel?.font = UIFont.ows_dynamicTypeBody.ows_semibold
paymentMethodButtons.append(creditOrDebitCardButton)
}

View File

@ -0,0 +1,45 @@
//
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
import Foundation
import UIKit
import CoreFoundation
public extension UIButton {
/// Add spacing between a button's image and its title.
///
/// Modified from [this project][0], licensed under the MIT License.
///
/// [0]: https://github.com/noahsark769/NGUIButtonInsetsExample
func setPaddingBetweenImageAndText(to padding: CGFloat, isRightToLeft: Bool) {
if isRightToLeft {
contentEdgeInsets = .init(
top: contentEdgeInsets.top,
left: padding,
bottom: contentEdgeInsets.bottom,
right: contentEdgeInsets.right
)
titleEdgeInsets = .init(
top: titleEdgeInsets.top,
left: -padding,
bottom: titleEdgeInsets.bottom,
right: padding
)
} else {
contentEdgeInsets = .init(
top: contentEdgeInsets.top,
left: contentEdgeInsets.left,
bottom: contentEdgeInsets.bottom,
right: padding
)
titleEdgeInsets = .init(
top: titleEdgeInsets.top,
left: padding,
bottom: titleEdgeInsets.bottom,
right: -padding
)
}
}
}