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

remodeling 更新 #1

Open
wants to merge 38 commits into
base: remodeling
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e01b8c3
Hide home indicator
Sep 13, 2017
f922314
Version bump
Sep 13, 2017
aadddb8
Account for iPhone X
Oct 4, 2017
a327ae2
Merge pull request #68 from bufferapp/task/nudge-close-button
Oct 4, 2017
b725cd2
Spec bump
Oct 4, 2017
e5dbb4a
Fix pod spec
Oct 4, 2017
948f475
Ability to disable long press to share
Oct 5, 2017
446f397
Completion handler for backloading, constants file
Oct 5, 2017
dc1211f
Merge pull request #69 from bufferapp/task/oss-tweaks
Oct 5, 2017
ad1d191
Spec bump
Oct 5, 2017
a2501dc
Merge remote-tracking branch 'bufferapp/master'
Oct 20, 2017
8aa3dea
Implemented Live Photo feature
Oct 20, 2017
9052794
Hook into scrollview for percent complete
Jan 12, 2018
fb01df2
Parallax view, correct coding style for pragma marks
Jan 16, 2018
923f051
First go parallax effect
Jan 16, 2018
7a7b990
Fix hidden state of parallax view
Jan 16, 2018
48818db
Merge pull request #72 from bufferapp/task/parallax
Jan 16, 2018
d1e5122
Spec bump
Jan 16, 2018
e3d11a4
Don't change destination view frame
Apr 30, 2018
e334ab9
Spec bump
Apr 30, 2018
088df98
Updates to master + tweaks
May 1, 2018
505e73f
Support for Live Photo finished up
May 2, 2018
bea65f8
Show a few Live Photos
May 2, 2018
102d192
Merge pull request #73 from bufferapp/pr/70
May 2, 2018
d40642f
Added Live Photo mention
May 2, 2018
89c5968
Spec bump
May 2, 2018
a734382
Fix presented view's bounds being changed on rotation
May 2, 2018
e42699b
Spec bump
May 2, 2018
9c4415f
Added in Live Photo as image source
May 2, 2018
4f56ee1
Expose dismiss methods for public use
danielgindi Jul 1, 2018
59f73af
Added `setImageSource` accessor to dynamically reinitialize with new …
danielgindi Jul 1, 2018
10969fc
Expose currentIndex property
danielgindi Jul 1, 2018
c8ffe03
Minor tweaks
Jul 16, 2018
eeaef4f
Merge pull request #75 from danielgindi/master
Jul 16, 2018
8c36375
Spec bump
Jul 16, 2018
fcc28fe
Rolled our own progress indicator
Aug 22, 2018
f42ccf5
Spec bump
Aug 22, 2018
d90ff70
Merge from bufferapp/master and fix conflict
culumn Jan 15, 2019
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
6 changes: 4 additions & 2 deletions BFRImageViewController/BFRBackLoadedImageSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

typedef void(^onHiResDownloadComplete)(UIImage * _Nullable, NSError * _Nullable);

/*! This class allows you to show an image that you already have available initially, while loading a higher fidelity version in the background which will replace the lower fidelity one. This class assumes that the new image will have the same aspect ratio as the old one. */
@interface BFRBackLoadedImageSource : NSObject

/*! The image that is available for use right away. */
@property (strong, nonatomic, readonly, nonnull) UIImage *image;

/*! This is called on the main thread when the higher resolution image is finished loading. */
@property (copy) void (^ _Nonnull onHighResImageLoaded)(UIImage * _Nullable highResImage);
/*! This is called on the main thread when the higher resolution image is finished loading. Assign to this if you wish to do any specific logic when the download completes. NOTE: Do not attempt to assign the image to any @c BFRImageContainerViewController, this is done for you. Use this block soley for any other business logic you might have to carry out. */
@property (copy) onHiResDownloadComplete _Nullable onCompletion;

/*! Use initWithInitialImage:hiResURL instead. */
- (instancetype _Nullable)init NS_UNAVAILABLE;
Expand Down
21 changes: 14 additions & 7 deletions BFRImageViewController/BFRBackLoadedImageSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import "BFRBackLoadedImageSource.h"
#import "BFRImageViewerConstants.h"
#import <UIKit/UIKit.h>
#import <PINRemoteImage/PINRemoteImage.h>
#import <PINRemoteImage/PINImageView+PINRemoteImage.h>
Expand All @@ -24,6 +25,7 @@ @interface BFRBackLoadedImageSource()
@implementation BFRBackLoadedImageSource

#pragma mark - Initializers

- (instancetype)initWithInitialImage:(UIImage *)image hiResURL:(NSURL *)url {
self = [super init];

Expand All @@ -38,18 +40,23 @@ - (instancetype)initWithInitialImage:(UIImage *)image hiResURL:(NSURL *)url {
}

#pragma mark - Backloading

- (void)loadHighFidelityImage {
[[PINRemoteImageManager sharedImageManager] downloadImageWithURL:self.url options:PINRemoteImageManagerDisallowAlternateRepresentations progressDownload:nil completion:^(PINRemoteImageManagerResult * _Nonnull result) {
dispatch_async(dispatch_get_main_queue(), ^{
if (result.image) {
if (self.onHighResImageLoaded != nil) {
dispatch_async(dispatch_get_main_queue(), ^ {
self.onHighResImageLoaded(result.image);
});
if (self.onCompletion != nil) {
if (result.image) {
self.onCompletion(result.image, nil);
} else {
NSLog(@"BFRImageViewer: Unable to load high resolution photo via backloading.");
NSError *downloadError = [NSError errorWithDomain:HI_RES_IMG_ERROR_DOMAIN
code:HI_RES_IMG_ERROR_CODE
userInfo:@{NSLocalizedFailureReasonErrorKey:[NSString stringWithFormat:@"Failed to download an image for high resolution url %@", self.url.absoluteString]}];
self.onCompletion(nil, downloadError);
}
} else {
NSLog(@"BFRImageViewer: Unable to load high resolution photo via backloading.");
}

[[NSNotificationCenter defaultCenter] postNotificationName:NOTE_HI_RES_IMG_DOWNLOADED object:result.image];
});
}];
}
Expand Down
31 changes: 24 additions & 7 deletions BFRImageViewController/BFRImageContainerViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,41 @@

#import <UIKit/UIKit.h>

typedef NS_ENUM(NSUInteger, BFRImageAssetType) {
BFRImageAssetTypeImage,
BFRImageAssetTypeRemoteImage,
BFRImageAssetTypeGIF,
BFRImageAssetTypeLivePhoto,
BFRImageAssetTypeUnknown
};

/*! This class holds an image to view, if you need an image viewer alloc @C BFRImageViewController instead. This class isn't meant to instanitated outside of it. */
@interface BFRImageContainerViewController : UIViewController

/*! Source of the image, which should either be @c NSURL or @c UIIimage. */
@property (strong, nonatomic, nonnull) id imgSrc;
@property(strong, nonatomic, nonnull) id imgSrc;

/*! The type of asset that is being represented by the given @p imgSrc. */
@property(nonatomic, assign) BFRImageAssetType assetType;

/*! This will determine whether to change certain behaviors for 3D touch considerations based on its value. */
@property (nonatomic, getter=isBeingUsedFor3DTouch) BOOL usedFor3DTouch;
@property(nonatomic, getter=isBeingUsedFor3DTouch) BOOL usedFor3DTouch;

/*! A helper integer to simplify using this view controller inside a @c UIPagerViewController when swiping between views. */
@property (nonatomic, assign) NSUInteger pageIndex;
@property(nonatomic, assign) NSUInteger pageIndex;

/*! Assigning YES to this property will make the background transparent. */
@property (nonatomic, getter=isUsingTransparentBackground) BOOL useTransparentBackground;
/*! Assigning YES to this property will make the background transparent. You typically don't set this property yourself, instead, the value is derived from the containing @c BFRImageViewController instance. */
@property(nonatomic, getter=isUsingTransparentBackground) BOOL useTransparentBackground;

/*! Assigning YES to this property will disable long pressing media to present the activity view controller. You typically don't set this property yourself, instead, the value is derived from the containing @c BFRImageViewController instance. */
@property(nonatomic, getter=shouldDisableSharingLongPress) BOOL disableSharingLongPress;

/*! If there is more than one image in the containing @c BFRImageViewController - this property is set to YES to make swiping from image to image easier. */
@property (nonatomic, getter=shouldDisableHorizontalDrag) BOOL disableHorizontalDrag;
@property(nonatomic, getter=shouldDisableHorizontalDrag) BOOL disableHorizontalDrag;

@property(strong, nonatomic, nullable) NSURLSessionConfiguration *configuration;

@property (strong, nonatomic, nullable) NSURLSessionConfiguration *configuration;
/*! Assigning YES to this property will disable autoplay for live photos when it used with 3DTouch peek feature */
@property(nonatomic, getter=shouldDisableAutoplayForLivePhoto) BOOL disableAutoplayForLivePhoto;

@end
Loading