<commit_before>//
//  SSPullToRefreshView.h
//  SSPullToRefresh
//
//  Created by <NAME> on 4/9/12.
//  Copyright (c) 2012 <NAME>. All rights reserved.
//

//
// Example usage:
// 
// - (void)viewDidLoad {
//    [super viewDidLoad];
//    self.pullToRefreshView = [[SSPullToRefreshView alloc] initWithScrollView:self.tableView delegate:self];
// }
// 
// - (void)viewDidUnload {
//    [super viewDidUnload];
//    self.pullToRefreshView = nil;
// }
// 
// - (void)refresh {
//    [self.pullToRefreshView startLoading];
//    // Load data...
//    [self.pullToRefreshView finishLoading];
// }
// 
// - (void)pullToRefreshViewDidStartLoading:(SSPullToRefreshView *)view {
//    [self refresh];
// }
//

#import <UIKit/UIKit.h>

typedef enum {
	/// Most will say "Pull to refresh" in this state
	SSPullToRefreshViewStateNormal,

	/// Most will say "Release to refresh" in this state
	SSPullToRefreshViewStateReady,

	/// The view is loading
	SSPullToRefreshViewStateLoading,

	/// The view has finished loading and is animating
	SSPullToRefreshViewStateClosing
} SSPullToRefreshViewState;

@protocol SSPullToRefreshViewDelegate;
@protocol SSPullToRefreshContentView;

@interface SSPullToRefreshView : UIView

/**
 The content view displayed when the `scrollView` is pulled down. By default this is an instance of `SSPullToRefreshDefaultContentView`.
 
 @see SSPullToRefreshContentView
 */
@property (nonatomic, strong) UIView<SSPullToRefreshContentView> *contentView;

/**
 If you need to update the scroll view's content inset while it contains a pull to refresh view, you should set the
 `defaultContentInset` on the pull to refresh view and it will forward it to the scroll view taking into account the
 pull to refresh view's position.
 */
@property (nonatomic, assign) UIEdgeInsets defaultContentInset;

/**
 The height of the fully expanded content view. The default is `70.0`.
 
 The `contentView`'s `sizeThatFits:` will be respected when displayed but does not effect the expanded height. You can use this
 to draw outside of the expanded area. If you don't implement `sizeThatFits:` it will automatically display at the default size.
 
 @see expanded
 */
@property (nonatomic, assign) CGFloat expandedHeight;

/**
 A boolean indicating if the pull to refresh view is expanded.
 
 @see expandedHeight
 @see startLoadingAndExpand:
 */
@property (nonatomic, assign, readonly, getter = isExpanded) BOOL expanded;

/**
 The scroll view containing the pull to refresh view. This is automatically set with `initWithScrollView:delegate:`.
 
 @see initWithScrollView:delegate:
 */
@property (nonatomic, assign, readonly) UIScrollView *scrollView;

/**
 The delegate is sent messages when the pull to refresh view starts loading. This is automatically set with `initWithScrollView:delegate:`.
 
 @see initWithScrollView:delegate:
 @see SSPullToRefreshViewDelegate
 */
@property (nonatomic, assign) id<SSPullToRefreshViewDelegate> delegate;

/**
 The state of the pull to refresh view.
 
 @see startLoading
 @see startLoadingAndExpand:
 @see finishLoading
 @see SSPullToRefreshViewState
 */
@property (nonatomic, assign, readonly) SSPullToRefreshViewState state;

/**
 All you need to do to add this view to your scroll view is call this method (passing in the scroll view). That's it.
 You don't have to add it as subview or anything else. The rest is magic.
 
 You should only initalize with this method and never move it to another scroll view during its lifetime.
 */
- (id)initWithScrollView:(UIScrollView *)scrollView delegate:(id<SSPullToRefreshViewDelegate>)delegate;

/**
 Call this method when you start loading. If you trigger loading another way besides pulling to refresh, call this
 method so the pull to refresh view will be in sync with the loading status. By default, it will not expand the view
 so it loads quietly out of view.
 */
- (void)startLoading;

/**
 Call this method when you start loading. If you trigger loading another way besides pulling to refresh, call this<commit_msg>Use weak delegate. I feel like there was a reason I didn't do this before, but I can't remember.<commit_after>//
//  SSPullToRefreshView.h
//  SSPullToRefresh
//
//  Created by <NAME> on 4/9/12.
//  Copyright (c) 2012 <NAME>. All rights reserved.
//

//
// Example usage:
// 
// - (void)viewDidLoad {
//    [super viewDidLoad];
//    self.pullToRefreshView = [[SSPullToRefreshView alloc] initWithScrollView:self.tableView delegate:self];
// }
// 
// - (void)viewDidUnload {
//    [super viewDidUnload];
//    self.pullToRefreshView = nil;
// }
// 
// - (void)refresh {
//    [self.pullToRefreshView startLoading];
//    // Load data...
//    [self.pullToRefreshView finishLoading];
// }
// 
// - (void)pullToRefreshViewDidStartLoading:(SSPullToRefreshView *)view {
//    [self refresh];
// }
//

#import <UIKit/UIKit.h>

typedef enum {
	/// Most will say "Pull to refresh" in this state
	SSPullToRefreshViewStateNormal,

	/// Most will say "Release to refresh" in this state
	SSPullToRefreshViewStateReady,

	/// The view is loading
	SSPullToRefreshViewStateLoading,

	/// The view has finished loading and is animating
	SSPullToRefreshViewStateClosing
} SSPullToRefreshViewState;

@protocol SSPullToRefreshViewDelegate;
@protocol SSPullToRefreshContentView;

@interface SSPullToRefreshView : UIView

/**
 The content view displayed when the `scrollView` is pulled down. By default this is an instance of `SSPullToRefreshDefaultContentView`.
 
 @see SSPullToRefreshContentView
 */
@property (nonatomic, strong) UIView<SSPullToRefreshContentView> *contentView;

/**
 If you need to update the scroll view's content inset while it contains a pull to refresh view, you should set the
 `defaultContentInset` on the pull to refresh view and it will forward it to the scroll view taking into account the
 pull to refresh view's position.
 */
@property (nonatomic, assign) UIEdgeInsets defaultContentInset;

/**
 The height of the fully expanded content view. The default is `70.0`.
 
 The `contentView`'s `sizeThatFits:` will be respected when displayed but does not effect the expanded height. You can use this
 to draw outside of the expanded area. If you don't implement `sizeThatFits:` it will automatically display at the default size.
 
 @see expanded
 */
@property (nonatomic, assign) CGFloat expandedHeight;

/**
 A boolean indicating if the pull to refresh view is expanded.
 
 @see expandedHeight
 @see startLoadingAndExpand:
 */
@property (nonatomic, assign, readonly, getter = isExpanded) BOOL expanded;

/**
 The scroll view containing the pull to refresh view. This is automatically set with `initWithScrollView:delegate:`.
 
 @see initWithScrollView:delegate:
 */
@property (nonatomic, assign, readonly) UIScrollView *scrollView;

/**
 The delegate is sent messages when the pull to refresh view starts loading. This is automatically set with `initWithScrollView:delegate:`.
 
 @see initWithScrollView:delegate:
 @see SSPullToRefreshViewDelegate
 */
@property (nonatomic, weak) id<SSPullToRefreshViewDelegate> delegate;

/**
 The state of the pull to refresh view.
 
 @see startLoading
 @see startLoadingAndExpand:
 @see finishLoading
 @see SSPullToRefreshViewState
 */
@property (nonatomic, assign, readonly) SSPullToRefreshViewState state;

/**
 All you need to do to add this view to your scroll view is call this method (passing in the scroll view). That's it.
 You don't have to add it as subview or anything else. The rest is magic.
 
 You should only initalize with this method and never move it to another scroll view during its lifetime.
 */
- (id)initWithScrollView:(UIScrollView *)scrollView delegate:(id<SSPullToRefreshViewDelegate>)delegate;

/**
 Call this method when you start loading. If you trigger loading another way besides pulling to refresh, call this
 method so the pull to refresh view will be in sync with the loading status. By default, it will not expand the view
 so it loads quietly out of view.
 */
- (void)startLoading;

/**
 Call this method when you start loading. If you trigger loading another way besides pulling to refresh, call this
{'fraction_non_alphanumeric': 0.08874860750092833, 'fraction_numerical': 0.002723109295704914, 'mean_word_length': 4.1761691223574635, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4400393', 'n_tokens_mistral': 2337, 'n_tokens_neox': 2208, 'n_words': 911}