|
@@ -21,6 +21,9 @@
|
|
|
#import "XSTTBeerDetailsBuyTipsViewController.h"
|
|
|
#import "XSTTRouteManager.h"
|
|
|
#import "XSTTBeerDetailsRadarMapView.h"
|
|
|
+#import "XSTTPreviewViewController.h"
|
|
|
+#import "UIViewController+XSTTNavigationBar.h"
|
|
|
+#import "UIViewController+XSTTInitialization.h"
|
|
|
|
|
|
@interface XSTTBeerDetailsViewController ()<XSTTBannerViewPorotocol> {
|
|
|
JXHCenterButton *_likeButton;
|
|
@@ -38,6 +41,7 @@
|
|
|
UILabel *_bannerCount;
|
|
|
|
|
|
XSTTBeerDetailsModel *_data;
|
|
|
+ XSTTPreviewViewController *_previewVC;
|
|
|
}
|
|
|
|
|
|
@end
|
|
@@ -46,7 +50,9 @@
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
- self.title = @"详情";
|
|
|
+ self.xstt_isHiddenNavigationBar = true;
|
|
|
+ [self createNavigationBar];
|
|
|
+ self.xstt_titleLabel.text = @"详情";
|
|
|
[self getData];
|
|
|
}
|
|
|
|
|
@@ -99,7 +105,33 @@
|
|
|
}
|
|
|
|
|
|
- (void)bannerView:(XSTTBannerView *)bannerView choseIndex:(NSInteger)choseIndex currentImage:(nullable UIImage *)currentImage {
|
|
|
-
|
|
|
+ if (nil == currentImage) return;
|
|
|
+ CGRect rect = bannerView.frame;
|
|
|
+ CGPoint point = [bannerView convertPoint:CGPointZero toView:xstt_keyWindow()];
|
|
|
+ rect = (CGRect){point, rect.size};
|
|
|
+ XSTTPreviewConfiguration *configuration = XSTTPreviewConfiguration.new;
|
|
|
+ configuration.xstt_images = _data.xstt_imgUrls;
|
|
|
+ configuration.xstt_cornerRadius = 0;
|
|
|
+
|
|
|
+ _previewVC.xstt_getOriginalRect = ^CGRect(NSInteger index) {
|
|
|
+ if (choseIndex == index) {
|
|
|
+ CGFloat bannerScale = rect.size.width / rect.size.height;
|
|
|
+ CGFloat imageScale = currentImage.size.width / currentImage.size.height;
|
|
|
+ if (bannerScale > imageScale) {
|
|
|
+ CGFloat width = rect.size.height * imageScale;
|
|
|
+ CGFloat x = (rect.size.width - width) / 2;
|
|
|
+ return (CGRect){point.x + x, point.y, width, rect.size.height};
|
|
|
+ } else if (bannerScale < imageScale) {
|
|
|
+ CGFloat height = rect.size.width / imageScale;
|
|
|
+ CGFloat y = (rect.size.height - height) / 2;
|
|
|
+ return (CGRect){point.x, point.y + y, rect.size.width, height};
|
|
|
+ } else {
|
|
|
+ return rect;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return CGRectZero;
|
|
|
+ };
|
|
|
+ [_previewVC showWithConfiguration:configuration currentImage:currentImage index:choseIndex];
|
|
|
}
|
|
|
|
|
|
#pragma mark - Network Action
|
|
@@ -131,7 +163,7 @@
|
|
|
|
|
|
#pragma mark - UI
|
|
|
- (void)setupUI {
|
|
|
- self.title = _data.xstt_beerInfo.xstt_beerName;
|
|
|
+ self.xstt_titleLabel.text = _data.xstt_beerInfo.xstt_beerName;
|
|
|
[self createBottomView];
|
|
|
[self createBgView];
|
|
|
[self createBannerView];
|
|
@@ -140,6 +172,15 @@
|
|
|
[self createBreweryView];
|
|
|
[self createParameterView];
|
|
|
[self createTipsView];
|
|
|
+ [self createPreview];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)createPreview {
|
|
|
+ _previewVC = XSTTPreviewViewController.new;
|
|
|
+ _previewVC.xstt_maxPreview = 18;
|
|
|
+ _previewVC.xstt_cancelDismissAnimation = true;
|
|
|
+ [self addChildViewController:_previewVC];
|
|
|
+ [self.view addSubview:_previewVC.view];
|
|
|
}
|
|
|
|
|
|
#define xstt_beerDetailsViewBottomViewHeight 56
|
|
@@ -429,7 +470,7 @@
|
|
|
_bgView = [UIScrollView convenienceWithBackgroundColor:xstt_F7F7F7_color()];
|
|
|
[self.view addSubview:_bgView];
|
|
|
[_bgView makeConstraints:^(JXHConstraintMaker *make) {
|
|
|
- make.top.equalTo(self.view.safetop);
|
|
|
+ make.top.equalTo(self.xstt_navigationBar.bottom);
|
|
|
make.leading.and.trailing.equalTo(0);
|
|
|
make.bottom.equalTo(self.view.safebottom).offset(-xstt_beerDetailsViewBottomViewHeight);
|
|
|
}];
|
|
@@ -449,13 +490,13 @@
|
|
|
make.top.and.leading.and.trailing.equalTo(0);
|
|
|
make.size.equalTo((CGSize){bannerWidth, bannerHeight});
|
|
|
}];
|
|
|
- _banner.xstt_modelData = _data.xstt_imgUrls;
|
|
|
+ _banner.xstt_modelData = _data.xstta_imgModels;
|
|
|
|
|
|
[self createBannerCountView];
|
|
|
}
|
|
|
|
|
|
- (void)createBannerCountView {
|
|
|
- if (_data.xstt_imgUrls.count > 1) {
|
|
|
+ if (_data.xstta_imgModels.count > 1) {
|
|
|
UIView *countView = UIView.new;
|
|
|
countView.backgroundColor = xstt_000000_color(0.6);
|
|
|
[countView setLayerCornerRadius:9 clipToBounds:false];
|
|
@@ -478,7 +519,7 @@
|
|
|
}
|
|
|
|
|
|
- (void)reloadBannerCountView:(NSInteger)index {
|
|
|
- _bannerCount.text = [NSString stringWithFormat:@"%ld/%ld", index + 1, _data.xstt_imgUrls.count];
|
|
|
+ _bannerCount.text = [NSString stringWithFormat:@"%ld/%ld", index + 1, _data.xstta_imgModels.count];
|
|
|
}
|
|
|
|
|
|
- (void)createBottomView {
|