ProductView.h 5.29 KB
Newer Older
1
//
2
//  ProductView.h
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
//  Mobile Buy SDK
//
//  Created by Shopify.
//  Copyright (c) 2015 Shopify Inc. All rights reserved.
//
//  Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
//
//  The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
//

@import UIKit;
28 29 30 31 32
@import Buy;
@class ActionableFooterView;
@class GradientView;
@class ProductViewHeader;
@class HeaderBackgroundView;
33 34 35 36

/**
 *  The BUYProductViewController's main view, containing everything needed to display the UI for the product
 */
37
@interface ProductView : UIView
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

/**
 *  The table view containg the product's image(s) in the tableHeaderView, title, price, 
 *  description and variant options
 */
@property (nonatomic, strong) UITableView *tableView;

/**
 *  The product view includes a blurred product image as the background. The table view's background 
 *  is clear for this reason. This view ensures the bottom part of the table view is always opaque and only
 *  the background of the product image(s) shows a blurred product image.
 */
@property (nonatomic, strong) UIView *stickyFooterView;

/**
 *  A constraint that managed the height for the stickyFooterView
 */
@property (nonatomic, strong) NSLayoutConstraint *footerHeightLayoutConstraint;

/**
 *  A constraint that managed the offset for the stickyFooterView based on the current scroll offset
 */
@property (nonatomic, strong) NSLayoutConstraint *footerOffsetLayoutConstraint;

/**
 *  The tableHeaderView containting the product image(s) (if available)
 */
65 66
@property (nonatomic, strong) ProductViewHeader *productViewHeader;
@property (nonatomic, strong) HeaderBackgroundView *backgroundImageView;
67 68 69 70

/**
 *  The footer view containing the Checkout button, and - if enabled - Apple Pay button.
 */
71
@property (nonatomic, strong) ActionableFooterView *productViewFooter;
72 73 74 75 76

/**
 *  A gradient view that sits at the top of the product images (if available).
 *  This view is invisible when the navigation bar is visible.
 */
77
@property (nonatomic, strong) GradientView *topGradientView;
78 79 80 81 82 83 84 85 86

/**
 *  Helps determine logic for setting up product images in the BUYProductViewController
 */
@property (nonatomic, assign) BOOL hasSetVariantOnCollectionView;

/**
 *  Initializer for the product view using a rect, product to display and theme
 *
87
 *  @param rect              The rect is needed for the UICollectionView in the ProductViewHeader to setup the cell's bounds
88 89 90 91
 *  @param product           The product to display in the product view. Only used in the initializer to
 *  @param theme             The theme for the product view
 *  @param showApplePaySetup Show Apple Pay button with 'Set Up Apple Pay' text as determined by the presenter
 *
92
 *  @return An instance of the ProductView
93
 */
94
- (instancetype)initWithFrame:(CGRect)rect product:(BUYProduct*)product shouldShowApplePaySetup:(BOOL)showApplePaySetup;
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120

/**
 *  The BUYProductViewController is the UITableViewDelegate, so it receives the UIScrollView delegate method calls. 
 *  This method allows for forward-handling of these calls to update the product images and other UI elements accordingly.
 *
 *  @param scrollView The UIScrollView being scrolled in the BUYProductViewController
 */
- (void)scrollViewDidScroll:(UIScrollView *)scrollView;

/**
 *  Updates the blurred product image behind the table view when the product image change.
 *
 *  @param images An array of product images.
 */
- (void)updateBackgroundImage:(NSArray *)images;

/**
 *  An toast error view above the checkout button(s) to use for display of an error when creating a checkout for Apple Pay.
 *
 *  @param errorMessage The error message to display.
 */
- (void)showErrorWithMessage:(NSString*)errorMessage;

/**
 *  The inset for the table view and scroll indicator, allowing for custom insets.
 *
121
 *  @param edgeInsets           The edge inset to set for the table view.
122 123 124 125
 *  @param appendToCurrentInset A flag that allows for adding the edge insets to the current edgeinsets of the table view.
 */
- (void)setInsets:(UIEdgeInsets)edgeInsets appendToCurrentInset:(BOOL)appendToCurrentInset;

126 127 128 129 130 131 132 133
/**
 *  Sets the top inset specifically for when the product view is pushed into a navigation controller stack
 *  instead of presented modally.
 *
 *  @param topInset The inset to use for insetting the product view inside the container.
 */
- (void)setTopInset:(CGFloat)topInset;

134 135
- (void)setShowsProductImageBackground:(BOOL)showsProductImageBackground UI_APPEARANCE_SELECTOR;

136
@end