Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove custom back button in VCs #789

Merged
merged 3 commits into from
Sep 11, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Example/Custom Integration (ObjC).xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
);
INFOPLIST_FILE = "Custom Integration (ObjC)/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.stripe.customexample;
PRODUCT_BUNDLE_IDENTIFIER = com.stripe.CustomSDKExample;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -378,7 +378,7 @@
);
INFOPLIST_FILE = "Custom Integration (ObjC)/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.stripe.customexample;
PRODUCT_BUNDLE_IDENTIFIER = com.stripe.CustomSDKExample;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
INFOPLIST_FILE = "Standard Integration (Swift)/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.stripe.standardexample;
PRODUCT_BUNDLE_IDENTIFIER = com.stripe.SimpleSDKExample;
PRODUCT_NAME = "Standard Integration (Swift)";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -439,7 +439,7 @@
INFOPLIST_FILE = "Standard Integration (Swift)/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.stripe.standardexample;
PRODUCT_BUNDLE_IDENTIFIER = com.stripe.SimpleSDKExample;
PRODUCT_NAME = "Standard Integration (Swift)";
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
18 changes: 0 additions & 18 deletions Stripe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,6 @@
04E39F5C1CECFAFD00AF3B96 /* STPPaymentContext+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 04E39F5A1CECFAFD00AF3B96 /* STPPaymentContext+Private.h */; };
04E39F6A1CED48D500AF3B96 /* UIBarButtonItem+Stripe.h in Headers */ = {isa = PBXBuildFile; fileRef = 04E39F681CED48D500AF3B96 /* UIBarButtonItem+Stripe.h */; };
04E39F6B1CED48D500AF3B96 /* UIBarButtonItem+Stripe.m in Sources */ = {isa = PBXBuildFile; fileRef = 04E39F691CED48D500AF3B96 /* UIBarButtonItem+Stripe.m */; };
04E39F6F1CED4C7700AF3B96 /* stp_icon_chevron_left.png in Resources */ = {isa = PBXBuildFile; fileRef = 04E39F6C1CED4C7700AF3B96 /* stp_icon_chevron_left.png */; };
04E39F701CED4C7700AF3B96 /* stp_icon_chevron_left@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 04E39F6D1CED4C7700AF3B96 /* stp_icon_chevron_left@2x.png */; };
04E39F711CED4C7700AF3B96 /* stp_icon_chevron_left@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 04E39F6E1CED4C7700AF3B96 /* stp_icon_chevron_left@3x.png */; };
04EBC7531B7533C300A0E6AE /* STPCardValidationState.h in Headers */ = {isa = PBXBuildFile; fileRef = 04EBC7511B7533C300A0E6AE /* STPCardValidationState.h */; settings = {ATTRIBUTES = (Public, ); }; };
04EBC7561B7533C300A0E6AE /* STPCardValidationState.h in Headers */ = {isa = PBXBuildFile; fileRef = 04EBC7511B7533C300A0E6AE /* STPCardValidationState.h */; settings = {ATTRIBUTES = (Public, ); }; };
04EBC7571B7533C300A0E6AE /* STPCardValidator.h in Headers */ = {isa = PBXBuildFile; fileRef = 04EBC7521B7533C300A0E6AE /* STPCardValidator.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -617,9 +614,6 @@
F1510B591D5A4CC4000731AD /* stp_card_applepay@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 049A3FA41CC8071100F57DE7 /* stp_card_applepay@3x.png */; };
F1510B5B1D5A4CC4000731AD /* stp_icon_add@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 049A3F9D1CC8006800F57DE7 /* stp_icon_add@2x.png */; };
F1510B5C1D5A4CC4000731AD /* stp_icon_add@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 049A3F9E1CC8006800F57DE7 /* stp_icon_add@3x.png */; };
F1510B5D1D5A4CC4000731AD /* stp_icon_chevron_left.png in Resources */ = {isa = PBXBuildFile; fileRef = 04E39F6C1CED4C7700AF3B96 /* stp_icon_chevron_left.png */; };
F1510B5E1D5A4CC4000731AD /* stp_icon_chevron_left@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 04E39F6D1CED4C7700AF3B96 /* stp_icon_chevron_left@2x.png */; };
F1510B5F1D5A4CC4000731AD /* stp_icon_chevron_left@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 04E39F6E1CED4C7700AF3B96 /* stp_icon_chevron_left@3x.png */; };
F1510BA71D5A77F6000731AD /* stp_card_diners_template.png in Resources */ = {isa = PBXBuildFile; fileRef = F1510BA41D5A77F6000731AD /* stp_card_diners_template.png */; };
F1510BAA1D5A77F6000731AD /* stp_card_diners_template@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F1510BA51D5A77F6000731AD /* stp_card_diners_template@2x.png */; };
F1510BAD1D5A77F6000731AD /* stp_card_diners_template@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = F1510BA61D5A77F6000731AD /* stp_card_diners_template@3x.png */; };
Expand Down Expand Up @@ -954,9 +948,6 @@
04E39F5A1CECFAFD00AF3B96 /* STPPaymentContext+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "STPPaymentContext+Private.h"; sourceTree = "<group>"; };
04E39F681CED48D500AF3B96 /* UIBarButtonItem+Stripe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIBarButtonItem+Stripe.h"; sourceTree = "<group>"; };
04E39F691CED48D500AF3B96 /* UIBarButtonItem+Stripe.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIBarButtonItem+Stripe.m"; sourceTree = "<group>"; };
04E39F6C1CED4C7700AF3B96 /* stp_icon_chevron_left.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = stp_icon_chevron_left.png; sourceTree = "<group>"; };
04E39F6D1CED4C7700AF3B96 /* stp_icon_chevron_left@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "stp_icon_chevron_left@2x.png"; sourceTree = "<group>"; };
04E39F6E1CED4C7700AF3B96 /* stp_icon_chevron_left@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "stp_icon_chevron_left@3x.png"; sourceTree = "<group>"; };
04EBC7511B7533C300A0E6AE /* STPCardValidationState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STPCardValidationState.h; path = PublicHeaders/STPCardValidationState.h; sourceTree = "<group>"; };
04EBC7521B7533C300A0E6AE /* STPCardValidator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STPCardValidator.h; path = PublicHeaders/STPCardValidator.h; sourceTree = "<group>"; };
04F213301BCEAB61001D6F22 /* STPFormEncodable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STPFormEncodable.h; path = PublicHeaders/STPFormEncodable.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1330,9 +1321,6 @@
049A3F9C1CC8006800F57DE7 /* stp_icon_add.png */,
049A3F9D1CC8006800F57DE7 /* stp_icon_add@2x.png */,
049A3F9E1CC8006800F57DE7 /* stp_icon_add@3x.png */,
04E39F6C1CED4C7700AF3B96 /* stp_icon_chevron_left.png */,
04E39F6D1CED4C7700AF3B96 /* stp_icon_chevron_left@2x.png */,
04E39F6E1CED4C7700AF3B96 /* stp_icon_chevron_left@3x.png */,
C15993201D8807930047950D /* stp_shipping_form.png */,
C15993211D8807930047950D /* stp_shipping_form@2x.png */,
C15993221D8807930047950D /* stp_shipping_form@3x.png */,
Expand Down Expand Up @@ -2419,13 +2407,11 @@
0438EFC61B741C2800D506CC /* stp_card_jcb@3x.png in Resources */,
0438EFC21B741C2800D506CC /* stp_card_jcb.png in Resources */,
F1C578F11D651AB200912EAE /* stp_card_applepay.png in Resources */,
04E39F6F1CED4C7700AF3B96 /* stp_icon_chevron_left.png in Resources */,
C1300D211EB8D38A0080AF7B /* stp_card_unknown@2x.png in Resources */,
C1300D2D1EB8D3AB0080AF7B /* stp_card_error@2x.png in Resources */,
F1510BC21D5A8146000731AD /* stp_card_jcb_template@2x.png in Resources */,
F1510B1B1D5A4C93000731AD /* stp_card_discover_template@3x.png in Resources */,
0438EFD61B741C2800D506CC /* stp_card_visa@2x.png in Resources */,
04E39F701CED4C7700AF3B96 /* stp_icon_chevron_left@2x.png in Resources */,
F148ABFD1D5E8DF20014FD92 /* stp_card_form_back.png in Resources */,
C11810C21CC7DA290022FB55 /* stp_card_form_front@2x.png in Resources */,
C11810C01CC7DA290022FB55 /* stp_card_form_back@3x.png in Resources */,
Expand Down Expand Up @@ -2462,7 +2448,6 @@
C1300D2E1EB8D3AB0080AF7B /* stp_card_error@3x.png in Resources */,
F148ABE81D5E805A0014FD92 /* Localizable.strings in Resources */,
0438EFB41B741C2800D506CC /* stp_card_cvc_amex@3x.png in Resources */,
04E39F711CED4C7700AF3B96 /* stp_icon_chevron_left@3x.png in Resources */,
C1300D2C1EB8D3AB0080AF7B /* stp_card_error.png in Resources */,
0438EFB81B741C2800D506CC /* stp_card_diners@2x.png in Resources */,
C11810C31CC7DA290022FB55 /* stp_card_form_front@3x.png in Resources */,
Expand Down Expand Up @@ -2500,7 +2485,6 @@
C15993471D8829C00047950D /* stp_shipping_form@3x.png in Resources */,
C1363BB31D76337900EB82B4 /* stp_icon_checkmark@2x.png in Resources */,
F148AC031D5E8DF30014FD92 /* stp_card_form_front@3x.png in Resources */,
F1510B5E1D5A4CC4000731AD /* stp_icon_chevron_left@2x.png in Resources */,
C1B630BD1D1D860100A05285 /* stp_card_amex@3x.png in Resources */,
F1510B101D5A4C93000731AD /* stp_card_amex_template@3x.png in Resources */,
C1B630BE1D1D860100A05285 /* stp_card_cvc.png in Resources */,
Expand All @@ -2518,7 +2502,6 @@
C1B630C31D1D860100A05285 /* stp_card_cvc_amex@3x.png in Resources */,
C1300D311EB8F16B0080AF7B /* stp_card_error_amex@3x.png in Resources */,
C1B630C41D1D860100A05285 /* stp_card_diners.png in Resources */,
F1510B5D1D5A4CC4000731AD /* stp_icon_chevron_left.png in Resources */,
C1B630C51D1D860100A05285 /* stp_card_diners@2x.png in Resources */,
C12057521D676DD400CFBCB8 /* stp_card_jcb_template@3x.png in Resources */,
F1510B1A1D5A4C93000731AD /* stp_card_discover_template@2x.png in Resources */,
Expand Down Expand Up @@ -2560,7 +2543,6 @@
C1300D361EB8F1780080AF7B /* stp_card_unknown@2x.png in Resources */,
F1510B201D5A4C93000731AD /* stp_card_mastercard_template@2x.png in Resources */,
C12057501D676DD400CFBCB8 /* stp_card_jcb_template.png in Resources */,
F1510B5F1D5A4CC4000731AD /* stp_icon_chevron_left@3x.png in Resources */,
C1B630D61D1D860100A05285 /* stp_card_visa.png in Resources */,
C12057511D676DD400CFBCB8 /* stp_card_jcb_template@2x.png in Resources */,
C1B630D71D1D860100A05285 /* stp_card_visa@2x.png in Resources */,
Expand Down
Binary file removed Stripe/Resources/Images/stp_icon_chevron_left.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion Stripe/STPAddCardViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ - (UIResponder *)firstEmptyField {
return nil;
}

- (void)handleBackOrCancelTapped:(__unused id)sender {
- (void)handleCancelTapped:(__unused id)sender {
[self.delegate addCardViewControllerDidCancel:self];
}

Expand Down
13 changes: 11 additions & 2 deletions Stripe/STPCoreViewController+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic) STPTheme *theme;
@property (nonatomic) UIBarButtonItem *cancelItem;
@property (nonatomic) UIBarButtonItem *backItem;

/**
All designated initializers funnel through this method to do their setup
Expand All @@ -39,8 +38,18 @@ NS_ASSUME_NONNULL_BEGIN

@param sender Sender of the target action, if applicable.
*/
- (void)handleBackOrCancelTapped:(nullable id)sender;
- (void)handleCancelTapped:(nullable id)sender;

/**
If you override this and return YES, then your CoreVC implementation will not
create and set up a cancel and instead just use the default
UIViewController back button behavior.

You won't receive calls to `handleCancelTapped` if this is YES.

Defaults to NO.
*/
- (BOOL)useSystemBackButton;

/**
Called in viewDidLoad after doing base implementation, before
Expand Down
27 changes: 12 additions & 15 deletions Stripe/STPCoreViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,14 @@ - (instancetype)initWithTheme:(STPTheme *)theme {

- (void)commonInitWithTheme:(STPTheme *)theme {
_theme = theme;
self.backItem = [UIBarButtonItem stp_backButtonItemWithTitle:STPLocalizedString(@"Back", @"Text for back button")
style:UIBarButtonItemStylePlain
target:self
action:@selector(handleBackOrCancelTapped:)];
self.cancelItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(handleBackOrCancelTapped:)];

self.stp_navigationItemProxy.leftBarButtonItem = self.cancelItem;

if (![self useSystemBackButton]) {
self.cancelItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(handleCancelTapped:)];

self.stp_navigationItemProxy.leftBarButtonItem = self.cancelItem;
}
}

- (void)setTheme:(STPTheme *)theme {
Expand All @@ -84,7 +83,6 @@ - (void)updateAppearance {
STPTheme *navBarTheme = self.navigationController.navigationBar.stp_theme ?: self.theme;
[self.navigationItem.leftBarButtonItem stp_setTheme:navBarTheme];
[self.navigationItem.rightBarButtonItem stp_setTheme:navBarTheme];
[self.backItem stp_setTheme:navBarTheme];
[self.cancelItem stp_setTheme:navBarTheme];

self.view.backgroundColor = self.theme.primaryBackgroundColor;
Expand All @@ -94,10 +92,6 @@ - (void)updateAppearance {

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];

if (![self stp_isAtRootOfNavigationController]) {
self.stp_navigationItemProxy.leftBarButtonItem = self.backItem;
}
}

- (void)viewWillDisappear:(BOOL)animated {
Expand All @@ -112,7 +106,7 @@ - (UIStatusBarStyle)preferredStatusBarStyle {
: UIStatusBarStyleLightContent);
}

- (void)handleBackOrCancelTapped:(__unused id)sender {
- (void)handleCancelTapped:(__unused id)sender {
if ([self stp_isAtRootOfNavigationController]) {
// if we're the root of the navigation controller, we've been presented modally.
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
Expand All @@ -123,5 +117,8 @@ - (void)handleBackOrCancelTapped:(__unused id)sender {
}
}

- (BOOL)useSystemBackButton {
return NO;
}

@end
1 change: 0 additions & 1 deletion Stripe/STPImageLibrary+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface STPImageLibrary (Private)

+ (UIImage *)addIcon;
+ (UIImage *)leftChevronIcon;
+ (UIImage *)checkmarkIcon;
+ (UIImage *)largeCardFrontImage;
+ (UIImage *)largeCardBackImage;
Expand Down
4 changes: 0 additions & 4 deletions Stripe/STPImageLibrary.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ + (UIImage *)addIcon {
return [self safeImageNamed:@"stp_icon_add" templateIfAvailable:YES];
}

+ (UIImage *)leftChevronIcon {
return [self safeImageNamed:@"stp_icon_chevron_left" templateIfAvailable:YES];
}

+ (UIImage *)checkmarkIcon {
return [self safeImageNamed:@"stp_icon_checkmark" templateIfAvailable:YES];
}
Expand Down
2 changes: 1 addition & 1 deletion Stripe/STPPaymentMethodsInternalViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ - (void)updateWithPaymentMethodTuple:(STPPaymentMethodTuple *)tuple {

#pragma mark - Button Handlers

- (void)handleBackOrCancelTapped:(__unused id)sender {
- (void)handleCancelTapped:(__unused id)sender {
[self.delegate internalViewControllerDidCancel];
}

Expand Down
2 changes: 1 addition & 1 deletion Stripe/STPShippingAddressViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ - (void)setLoading:(BOOL)loading {
}
}

- (void)handleBackOrCancelTapped:(__unused id)sender {
- (void)handleCancelTapped:(__unused id)sender {
[self.delegate shippingAddressViewControllerDidCancel:self];
}

Expand Down
4 changes: 4 additions & 0 deletions Stripe/STPShippingMethodsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ - (void)done:(__unused id)sender {
[self.delegate shippingMethodsViewController:self didFinishWithShippingMethod:self.selectedShippingMethod];
}

- (BOOL)useSystemBackButton {
return YES;
}

#pragma mark - UITableView

- (NSInteger)numberOfSectionsInTableView:(__unused UITableView *)tableView {
Expand Down
5 changes: 0 additions & 5 deletions Stripe/UIBarButtonItem+Stripe.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ NS_ASSUME_NONNULL_BEGIN

@interface UIBarButtonItem (Stripe)

+ (instancetype)stp_backButtonItemWithTitle:(NSString *)title
style:(UIBarButtonItemStyle)style
target:(id)target
action:(SEL)action;

- (void)stp_setTheme:(STPTheme *)theme;

@end
Expand Down
16 changes: 0 additions & 16 deletions Stripe/UIBarButtonItem+Stripe.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,6 @@

@implementation UIBarButtonItem (Stripe)

+ (instancetype)stp_backButtonItemWithTitle:(NSString *)title
style:(UIBarButtonItemStyle)style
target:(id)target
action:(SEL)action {
UIBarButtonItem *item = [[self alloc] initWithTitle:title
style:style
target:target
action:action];
UIImage *chevron = [STPImageLibrary leftChevronIcon];
CGFloat yPadding = (30 - chevron.size.height) / 2;
UIImage *paddedChevron = [STPImageLibrary paddedImageWithInsets:UIEdgeInsetsMake(yPadding, 0, yPadding, 30)
forImage:chevron];
[item setBackgroundImage:paddedChevron forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
return item;
}

- (void)stp_setTheme:(STPTheme *)theme {
UIImage *image = [self backgroundImageForState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
if (image) {
Expand Down