Commit 61bb4ef8 authored by 井庆林's avatar 井庆林

创建

parents
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-Spotlight-40.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-60.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-Small@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-Small@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-Spotlight-40@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-Spotlight-40@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-60@3x.png",
"scale" : "3x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "iTunesArtwork@2x.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
//
// ALDownloadViewController.h
// GMAlpha
//
// Created by Jing on 2018/12/6.
// Copyright © 2018 Gengmei. All rights reserved.
//
@interface ALDownloadDemoViewController : WMBaseViewController
@end
//
// ALDownloadViewController.m
// GMAlpha
//
// Created by Jing on 2018/12/6.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import "ALDownloadDemoViewController.h"
#import "ALDownloadManager.h"
@interface ALDownloadDemoViewController ()
@end
@implementation ALDownloadDemoViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSString *url = @"http://phvf6wllb.bkt.clouddn.com/yangmi.obj";
NSString *folderName = @"obj";
NSString *documentPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:folderName];
NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL isDirectory = YES;
if (![fileManager fileExistsAtPath:documentPath isDirectory:&isDirectory]) {
[fileManager createDirectoryAtPath:documentPath withIntermediateDirectories:YES attributes:nil error:nil];
}
[ALDownloadManager downloadTaskWithURL:url path:documentPath completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
NSString *fileName = [fileManager displayNameAtPath:filePath.absoluteString];
}];
}
@end
//
// ALFaceFittingViewController.h
// GMAlpha
//
// Created by Jing on 2018/11/26.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ALFaceFittingViewController : WMBaseViewController
- (void)reloadFaceFitting;
@end
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>鼻子</key>
<array>
<string>鼻梁</string>
<string>鼻宽</string>
</array>
<key>眼部</key>
<array>
<string>内眼角</string>
<string>外眼角</string>
<!-- <string>祛眼袋</string>-->
<!-- <string>平行双眼皮</string>-->
<!-- <string>扇形双眼皮</string>-->
<!-- <string>新月双眼皮</string>-->
<!-- <string>欧式双眼皮</string>-->
</array>
<key>嘴部</key>
<array>
<string>微笑</string>
<string>上嘴唇</string>
<string>下嘴唇</string>
</array>
<key>脸颊</key>
<array>
<string>v型脸</string>
<string>前额</string>
<string>苹果肌</string>
<string>凸下巴</string>
<string>凹下巴</string>
</array>
<key>美白</key>
<array>
<!-- <string>美白</string>-->
<!-- <string>平滑</string>-->
</array>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>鼻子</key>
<array>
<dict>
<key>name</key>
<string>鼻梁</string>
<key>tag</key>
<string>NOSE_BRIDGE</string>
<key>value</key>
<string>50</string>
</dict>
<dict>
<key>name</key>
<string>鼻宽</string>
<key>tag</key>
<string>NOSE_FAT</string>
<key>value</key>
<string>50</string>
</dict>
</array>
<key>眼部</key>
<array>
<dict>
<key>name</key>
<string>内眼角</string>
<key>tag</key>
<string>MEDIAL_CANTHUS</string>
<key>value</key>
<string>50</string>
</dict>
<dict>
<key>name</key>
<string>外眼角</string>
<key>tag</key>
<string>EXTERNAL_CANTHUS</string>
<key>value</key>
<string>50</string>
</dict>
<dict>
<key>name</key>
<string>祛眼袋</string>
<key>tag</key>
<string>SMOOTH_POUCH</string>
<key>value</key>
<string>50</string>
</dict>
<dict>
<key>name</key>
<string>平行双眼皮</string>
<key>tag</key>
<string>PARALLEL_EYELID</string>
<key>value</key>
<string>50</string>
</dict>
<dict>
<key>name</key>
<string>扇形双眼皮</string>
<key>tag</key>
<string>FAN_EYELID</string>
<key>value</key>
<string>50</string>
</dict>
<dict>
<key>name</key>
<string>新月双眼皮</string>
<key>tag</key>
<string>MOON_EYELID</string>
<key>value</key>
<string>50</string>
</dict>
<dict>
<key>name</key>
<string>欧式双眼皮</string>
<key>tag</key>
<string>WESTERN_EYELID</string>
<key>value</key>
<string>50</string>
</dict>
</array>
<key>嘴部</key>
<array>
<dict>
<key>name</key>
<string>微笑</string>
<key>tag</key>
<string>LIPS_SMILE</string>
<key>value</key>
<string>50</string>
</dict>
<dict>
<key>name</key>
<string>上嘴唇</string>
<key>tag</key>
<string>LIPS_UP</string>
<key>value</key>
<string>50</string>
</dict>
<dict>
<key>name</key>
<string>下嘴唇</string>
<key>tag</key>
<string>LIPS_DOWN</string>
<key>value</key>
<string>50</string>
</dict>
</array>
<key>脸颊</key>
<array>
<dict>
<key>name</key>
<string>v型脸</string>
<key>tag</key>
<string>VFACE</string>
<key>value</key>
<string>50</string>
</dict>
<dict>
<key>name</key>
<string>前额</string>
<key>tag</key>
<string>FOREHEAD</string>
<key>value</key>
<string>50</string>
</dict>
<dict>
<key>name</key>
<string>苹果肌</string>
<key>tag</key>
<string>APPLE_MUSCLE</string>
<key>value</key>
<string>50</string>
</dict>
<dict>
<key>name</key>
<string>凸下巴</string>
<key>tag</key>
<string>UP_CHIN</string>
<key>value</key>
<string>50</string>
</dict>
<dict>
<key>name</key>
<string>凹下巴</string>
<key>tag</key>
<string>DOWN_CHIN</string>
<key>value</key>
<string>50</string>
</dict>
</array>
<key>美白</key>
<array>
<dict>
<key>name</key>
<string>美白</string>
<key>tag</key>
<string>WHITENING</string>
<key>value</key>
<string>50</string>
</dict>
<dict>
<key>name</key>
<string>平滑</string>
<key>tag</key>
<string>SMOOTH_UV</string>
<key>value</key>
<string>50</string>
</dict>
</array>
</dict>
</plist>
//
// ALFaceStarModel.h
// GMAlpha
//
// Created by Jing on 2018/11/26.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface ALFaceStarModel : GMObject
@property (nonatomic, copy) NSString *id;
@property (nonatomic, copy) NSString *starUrl;
@property (nonatomic, copy) NSString *starModelUrl;
@property (nonatomic, copy) NSString *starUv;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *similarScore;
@property (nonatomic, assign) BOOL isLock;
@end
//
// ALFaceStarModel.m
// GMAlpha
//
// Created by Jing on 2018/11/26.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import "ALFaceStarModel.h"
@implementation ALFaceStarModel
@end
//
// ALBreakpointDownloading.h
// GMAlpha
//
// Created by Jing on 2018/11/28.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef NSURL * (^ALDownloadManagerDestination)(NSURL *targetPath, NSURLResponse *response);
typedef void (^ALDownloadmanagerProgress)(NSProgress *downloadProgress);
typedef void(^ALDownloadManagerCompletion)(NSURLResponse * _Nullable response, NSURL * _Nullable filePath, NSError * _Nullable error);
@interface ALDownloadManager : GMObject
+ (void)downloadTaskWithURL:(NSString *)url path:(NSString *)path completionHandler:(ALDownloadManagerCompletion)completionHandler;
@end
NS_ASSUME_NONNULL_END
This diff is collapsed.
//
// ALFaceFittingAPI.h
// GMAlpha
//
// Created by Jing on 2018/11/28.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "GMNetworking-Swift.h"
NS_ASSUME_NONNULL_BEGIN
typedef void(^ALFaceFittingDownloadStarCompletion)(NSString * _Nullable filePath);
@interface ALFaceFittingAPI : GMObject
+ (void)fetchFaceFittingDataWithCompletion:(nullable void (^)(GMResponseOC *responseObject))completion;
+ (void)fetchStarListWithParameters:(NSDictionary *)parameters completion:(nullable void (^)(GMResponseOC *responseObject))completion;
+ (void)fetchStarFittingObjWithUrl:(NSString *)url starId:(NSString *)starId;
+ (void)fetchStarFittingObjWithUrl:(NSString *)url starId:(NSString *)starId completion:(nullable ALFaceFittingDownloadStarCompletion)completion;
+ (void)storeObjWithFilePath:(NSString *)filePath key:(NSString *)key completion:(nullable void (^)(GMResponseOC * responseObject))completion;
+ (void)unlockStarNeedShareWithParameters:(NSDictionary *)parameters completion:(void (^)(GMResponseOC * _Nonnull responseObject))completion;
+ (void)unlockStarWithParameters:(NSDictionary *)parameters completion:(nullable void (^)(GMResponseOC * responseObject))completion;
+ (nullable NSString *)fetchStarFittingObjPathWithUrl:(NSString *)url starId:(NSString *)starId completion:(nullable ALFaceFittingDownloadStarCompletion)completion;
+ (nullable NSString *)fetchStarFittingUvPathWithUrl:(NSString *)url starId:(NSString *)starId completion:(nullable ALFaceFittingDownloadStarCompletion)completion;
@end
NS_ASSUME_NONNULL_END
This diff is collapsed.
//
// ALFaceFittingManager.h
// GMAlpha
//
// Created by Jing on 2018/12/7.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface ALFaceFittingManager : NSObject
@property (nonatomic, assign) BOOL isNeedRequest;
+ (instancetype)shareInstance;
@end
//
// ALFaceFittingManager.m
// GMAlpha
//
// Created by Jing on 2018/12/7.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import "ALFaceFittingManager.h"
#import "ALFaceFittingViewController.h"
#import "ALScanFaceCompleteViewController.h"
#import "ALFaceFittingAPI.h"
#import "ALScanManager.h"
static ALFaceFittingManager *_manager;
static NSString *ALIS_NEED_REQUEST_KEY = @"ALIsNeedRequestKey";
@implementation ALFaceFittingManager
+ (instancetype)shareInstance {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_manager = [[ALFaceFittingManager alloc] init];
});
return _manager;
}
- (instancetype)init {
if (self = [super init]) {
_isNeedRequest = [[GMCache fetchObjectAtDocumentPathWithkey:ALIS_NEED_REQUEST_KEY] boolValue];
}
return self;
}
- (void)setIsNeedRequest:(BOOL)isNeedRequest {
_isNeedRequest = isNeedRequest;
if (isNeedRequest) [self p_requestData];
else [GMCache removeObjectAtDocumentPathWithkey:ALIS_NEED_REQUEST_KEY];
}
- (void)p_requestData {
if (!_isNeedRequest) return;
NSMutableDictionary *parameters = [NSMutableDictionary new];
[parameters setValue:[ALScanManager shareInstance].fittingId forKey:@"id"];
[ALFaceFittingAPI fetchStarListWithParameters:parameters completion:^(GMResponseOC *responseObject) {
if (responseObject.isSuccess) {
NSDictionary *stars = responseObject.data[@"stars"];
NSArray *maleStar = stars[@"male"];
NSArray *femaleStar = stars[@"female"];
if (maleStar.count > 0 || femaleStar.count > 0) [self p_hasData];
else [self p_reRequestData];
} else {
[self p_reRequestData];
}
}];
}
- (void)p_hasData {
UIViewController *vc = AppDelegate.visibleController;
if ([vc isKindOfClass:[ALFaceFittingViewController class]]) {
ALFaceFittingViewController *faceFittingVC = (ALFaceFittingViewController *)vc;
[faceFittingVC reloadFaceFitting];
} if ([vc isKindOfClass:[ALScanFaceCompleteViewController class]]) {
} else {
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"是" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
ALFaceFittingViewController *toVC = [[ALFaceFittingViewController alloc] init];
[vc.navigationController pushViewController:toVC animated:YES];
}];
UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"否" style:UIAlertActionStyleCancel handler:nil];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:@"人脸拟合成功,是否查看" preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:action1];
[alertController addAction:action2];
[vc presentViewController:alertController animated:YES completion:nil];
}
self.isNeedRequest = NO;
}
- (void)p_reRequestData {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(30 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self p_requestData];
});
}
@end
//
// ALFaceAlertView.h
// GMAlpha
//
// Created by Jing on 2018/11/28.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import "GMPopupBgView.h"
@interface ALFaceAlertView : GMPopupBgView
typedef void (^ALFaceAlertViewClickBlock)(ALFaceAlertView *alertView, NSInteger buttonIndex);
@property (nonatomic, assign) BOOL isShare;
@property (nonatomic, copy) ALFaceAlertViewClickBlock clickBlock;
@end
//
// ALFaceAlertView.m
// GMAlpha
//
// Created by Jing on 2018/11/28.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import "ALFaceAlertView.h"
@interface ALFaceAlertView ()
@property (nonatomic, strong) GMImageView *imageView;
@property (nonatomic, strong) GMLabel *titleLabel;
@property (nonatomic, strong) GMLabel *messageLabel;
@property (nonatomic, strong) GMLabel *messageNumLabel;
@property (nonatomic, strong) GMButton *cancelButton;
@property (nonatomic, strong) GMButton *shareWeChatButton;
@property (nonatomic, strong) GMButton *shareFriendsButton;
@end
@implementation ALFaceAlertView
- (void)setup {
[super setup];
self.container.layer.cornerRadius = 5;
self.container.layer.masksToBounds = YES;
self.animationType = GMPopupAnimationTypeSpringScaleFromCenter;
[self.container mas_remakeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(285);
make.height.mas_equalTo(280);
make.center.equalTo(self);
}];
_imageView = [[GMImageView alloc] initWithImage:[UIImage imageNamed:@"faceDescContent"]];
[self.container addSubview:_imageView];
[_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.container);
}];
_cancelButton = [GMButton buttonWithType:UIButtonTypeCustom];
[_cancelButton setBackgroundImage:[UIImage imageNamed:@"faceAlertCancel"] forState:UIControlStateNormal];
[_cancelButton addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside];
[self.container addSubview:_cancelButton];
[_cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.top.mas_equalTo(12);
make.right.mas_equalTo(-12);
}];
}
- (void)setIsShare:(BOOL)isShare {
_isShare = isShare;
if (isShare) {
[self.container mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(255);
make.height.mas_equalTo(270);
}];
self.imageView.image = [UIImage imageNamed:@"faceShareContent"];
[self shareFriendsButton];
[self shareWeChatButton];
}
}
- (void)clickAction:(GMButton *)button {
if (button == _cancelButton) {
if (_clickBlock) _clickBlock(self, 0);
[self hide];
} else if (button == _shareWeChatButton) {
if (_clickBlock) _clickBlock(self, 1);
} else if (button == _shareFriendsButton) {
if (_clickBlock) _clickBlock(self, 2);
}
}
- (GMButton *)shareFriendsButton {
if (!_shareFriendsButton) {
_shareFriendsButton = [GMButton buttonWithTitle:@"分享到朋友圈" backgroundColor:RGBCOLOR_HEX(0x0093FF) titleFontSize:16 titleColor:UIColor.whiteColor];
_shareFriendsButton.layer.cornerRadius = 18;
_shareFriendsButton.layer.masksToBounds = YES;
[_shareFriendsButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 5)];
[_shareFriendsButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 5, 0, 0)];
[_shareFriendsButton setImage:[UIImage imageNamed:@"faceShareFriends"] forState:UIControlStateNormal];
[_shareFriendsButton addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside];
[self.container addSubview:_shareFriendsButton];
[_shareFriendsButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(200);
make.height.mas_equalTo(36);
make.centerX.equalTo(self.container);
make.bottom.mas_equalTo(-28);
}];
}
return _shareFriendsButton;
}
- (GMButton *)shareWeChatButton {
if (!_shareWeChatButton) {
_shareWeChatButton = [GMButton buttonWithTitle:@"分享到微信" backgroundColor:RGBCOLOR_HEX(0x0093FF) titleFontSize:16 titleColor:UIColor.whiteColor];
_shareWeChatButton.layer.cornerRadius = 18;
_shareWeChatButton.layer.masksToBounds = YES;
[_shareWeChatButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 5)];
[_shareWeChatButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 5, 0, 0)];
[_shareWeChatButton setImage:[UIImage imageNamed:@"faceShareWeChat"] forState:UIControlStateNormal];
[_shareWeChatButton addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside];
[self.container addSubview:_shareWeChatButton];
[_shareWeChatButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(200);
make.height.mas_equalTo(36);
make.centerX.equalTo(self.container);
make.bottom.equalTo(self.shareFriendsButton.mas_top).offset(-16);
}];
}
return _shareFriendsButton;
}
@end
//
// ALFaceFittingBottomView.h
// GMAlpha
//
// Created by Jing on 2018/11/26.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import <UIKit/UIKit.h>
@class ALFaceFittingModifyView, ALFaceStarModel;
@protocol ALFaceFittingModifyViewDelegate <NSObject>
@required
/** 第一次点击明星,要去拟合*/
- (void)faceFittingModifyView:(ALFaceFittingModifyView *)view willModeifyDetails:(ALFaceStarModel *)star filePath:(NSString *)filePath UVPath:(NSString *)uvPath;
/** 第二次点击明星,进行拟合 */
- (void)faceFittingModifyView:(ALFaceFittingModifyView *)view modifyStarDetails:(ALFaceStarModel *)star;
/** 点击具体部位,调整局部细节 */
- (void)faceFittingModifyView:(ALFaceFittingModifyView *)view modifyStarDetail:(ALFaceStarModel *)star indexPath:(NSIndexPath *)indexPath;
/** 进行局部调整slider */
- (void)faceFittingModifyView:(ALFaceFittingModifyView *)view modifyDetailIndexPath:(NSIndexPath *)indexPath value:(NSInteger)value;
/** 拟合完成,点击底部完成或取消 */
- (void)faceFittingModifyView:(ALFaceFittingModifyView *)view modifyDetialsFinish:(BOOL)isFinish values:(NSArray *)values;
/** 切换男女 */
- (void)faceFittingModifyView:(ALFaceFittingModifyView *)view selettStarListIsFemale:(BOOL)isFemale;
/** 点击未解锁明星,进行解锁 */
- (void)faceFittingModifyView:(ALFaceFittingModifyView *)view unlockStar:(ALFaceStarModel *)star;
/** 点击添加明星 */
- (void)faceFittingModifyView:(ALFaceFittingModifyView *)view addStar:(BOOL)isFemale;
@end
@interface ALFaceFittingModifyView : UIView
@property (nonatomic, weak) id<ALFaceFittingModifyViewDelegate> delegate;
@property (nonatomic, strong) NSArray <ALFaceStarModel *>*starArray;
@property (nonatomic, strong) ALFaceStarModel *modifyStarModel;
@property (nonatomic, assign, readonly) BOOL isFemale;
@end
This diff is collapsed.
//
// ALFaceFittingView.h
// GMAlpha
//
// Created by Jing on 2018/11/26.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import <UIKit/UIKit.h>
#include "SDKHelper.h"
@class ALFaceFittingView;
@protocol ALFaceFittingViewDelegate <NSObject>
@required
- (void)rescanInFaceFittingView:(ALFaceFittingView *)view;
- (void)fittingInFaceFittingView:(ALFaceFittingView *)view;
- (void)gridInFaceFittingView:(ALFaceFittingView *)view;
@end
@interface ALFaceFittingView : UIView
@property (nonatomic, strong) SDKHelper *sdkHelper;
@property (nonatomic, weak) id<ALFaceFittingViewDelegate> delegate;
- (void)reloadData;
// 点击去拟合
- (void)modifyDetails;
//将要去修改
- (void)willModifyDetailsAtFilePath:(NSString *)filePath starUV:(NSString *)starUV;
- (void)refreshObj:(NSString *)goalObjPath startUv:(NSString *)goalStarUV;
@property (nonatomic, assign) BOOL isGrid;
@end
//
// ALFaceFittingView.m
// GMAlpha
//
// Created by Jing on 2018/11/26.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import "ALFaceFittingView.h"
#import "UIColor+GMTheme.h"
#import <SceneKit/SceneKit.h>
#import "FileUtils.h"
#include "OBJView.h"
#import "ALMatchingModel.h"
#import "ALScanManager.h"
@interface ALFaceFittingView ()<SDKHelperDelegate>
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UIView *view;
@property (nonatomic, strong) GMButton *rescanButton;
@property (nonatomic, strong) GMButton *fittingButton;
@property (nonatomic, strong) GMButton *gridButton;
@property (nonatomic, strong) GMButton *selectedButton;
@property (nonatomic, strong) OBJView *objView;
//当前模型数据
@property (nonatomic, strong) ALMatchingModel *model;
@property (nonatomic, strong) NSString *goalObjPath;
@property (nonatomic, strong) NSString *goalStarUV;
@end
@implementation ALFaceFittingView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self p_setup];
ALMatchingModel *myModle = [self getMy3DHeadSourceModel];
[self.objView loadMyOBjModel:myModle];
}
return self;
}
//加载自己的模型
- (ALMatchingModel *)getMy3DHeadSourceModel {
ALMatchingModel *model = [[ALMatchingModel alloc] init];
if (ALScanManager.shareInstance.isScan3D) {
//加载3d下文件
model.sourceOBJFile = [ALScanManager.shareInstance.show3DInfo getOBJFile]; //存本地
model.sourceMeshFile = [ALScanManager.shareInstance.show3DInfo getMeshFile]; //存本地
} else {
//加载2d下文件
model.sourceOBJFile = [ALScanManager.shareInstance.show2DPathInfo getOBJFile];
model.sourceMeshFile = [ALScanManager.shareInstance.show2DPathInfo getMeshFile]; //存本地
}
return model;
}
- (void)reloadData {
[_objView reload];
}
- (void)refreshObj:(NSString *)goalObjPath startUv:(NSString *)goalStarUV {
_model = [self getMy3DHeadSourceModel];
if ([goalObjPath isNonEmpty] && [goalObjPath isNonEmpty]) {
_goalObjPath = goalObjPath;
_goalStarUV = goalStarUV;
_model.goalOBJFile = [NSString stringWithFormat:@"%@/%@", [FileUtils getBasePath], goalObjPath];
_model.goalMeshFile = [NSString stringWithFormat:@"%@/%@", [FileUtils getBasePath], goalStarUV];
_sdkHelper = [[SDKHelper alloc] initWithOBJView:self.objView andModel:_model andSliderPanel:nil];
} else {
[AppDelegate.visibleController toast:@"获取目标模型失败"];
}
}
//拟合数据
- (void)modifyDetails { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.sdkHelper testEvlo];
});
}
- (void)willModifyDetailsAtFilePath:(NSString *)filePath starUV:(NSString *)starUV {
if (![filePath isNonEmpty] || ![starUV isNonEmpty]) {
[AppDelegate.visibleController toast:@"正在下载..."];
return;
}
[self refreshObj:filePath startUv:starUV];
}
- (BOOL)isGrid {
return _selectedButton == _gridButton;
}
- (void)p_rescan {
if ([_delegate respondsToSelector:@selector(rescanInFaceFittingView:)])
[_delegate rescanInFaceFittingView:self];
}
- (void)p_fitting {
if (_selectedButton == _fittingButton) return;
self.selectedButton = _fittingButton;
[self reloadData];
if ([_delegate respondsToSelector:@selector(fittingInFaceFittingView:)])
[_delegate fittingInFaceFittingView:self];
}
//需要知道网格脸以及目标模型
- (void)p_grid {
if (_selectedButton == _gridButton) return;
self.selectedButton = _gridButton;
ALMatchingModel *model = [self getMy3DHeadSourceModel];
if ([model.sourceOBJFile isNonEmpty] && [self.goalObjPath isNonEmpty]) {
NSString *goalObj = [NSString stringWithFormat:@"%@/%@", [FileUtils getBasePath], self.goalObjPath];
SCNNode *myNode;
if (ALScanManager.shareInstance.isScan3D) {
myNode = [_sdkHelper getMy3DNode];
myNode.geometry.firstMaterial.lightingModelName = SCNLightingModelBlinn;
myNode.geometry.firstMaterial.diffuse.contents = model.sourceMeshFile;
myNode.geometry.firstMaterial.transparency = 0.5;
}
[self.objView reloadWithMyModel:model andStarObj:goalObj and3DNode:myNode];
} else {
[AppDelegate.visibleController toast:@"模型不存在"];
}
if ([_delegate respondsToSelector:@selector(gridInFaceFittingView:)])
[_delegate gridInFaceFittingView:self];
}
- (void)setSelectedButton:(GMButton *)button {
_selectedButton.selected = NO;
button.selected = YES;
_selectedButton = button;
}
- (void)p_setup {
_imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"faceFittingNormal"]];
[self addSubview:_imageView];
[_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
_view = [UIView new];
[self addSubview:_view];
[_view mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
_objView = [[OBJView alloc] initWithFrame:CGRectMake(0, 0, MAINSCREEN_WIDTH, MAINSCREEN_WIDTH)];
[_view addSubview:_objView];
_rescanButton = [GMButton buttonWithTitle:@"重新扫描" backgroundColor:UIColor.blackColor titleFontSize:14 titleColor:UIColor.whiteColor];
[_rescanButton addTarget:self action:@selector(p_rescan) forControlEvents:UIControlEventTouchUpInside];
[_view addSubview:_rescanButton];
[_rescanButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(68);
make.height.mas_equalTo(26);
make.left.mas_equalTo(15);
make.bottom.mas_equalTo(-15);
}];
_gridButton = [GMButton buttonWithType:UIButtonTypeCustom];
_gridButton.hidden = YES;
[_gridButton setBackgroundColor:UIColor.darkGrayColor forState:UIControlStateNormal];
[_gridButton setBackgroundColor:UIColor.blackColor forState:UIControlStateSelected];
[_gridButton setImage:[UIImage imageNamed:@"faceGrid"] forState:UIControlStateNormal];
[_gridButton addTarget:self action:@selector(p_grid) forControlEvents:UIControlEventTouchUpInside];
[_view addSubview:_gridButton];
[_gridButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(37);
make.height.mas_equalTo(33);
make.right.bottom.mas_equalTo(-15);
}];
_fittingButton = [GMButton buttonWithType:UIButtonTypeCustom];
_fittingButton.hidden = YES;
[_fittingButton setBackgroundColor:UIColor.darkGrayColor forState:UIControlStateNormal];
[_fittingButton setBackgroundColor:UIColor.blackColor forState:UIControlStateSelected];
[_fittingButton setImage:[UIImage imageNamed:@"faceFitting"] forState:UIControlStateNormal];
[_fittingButton addTarget:self action:@selector(p_fitting) forControlEvents:UIControlEventTouchUpInside];
self.selectedButton = _fittingButton;
[_view addSubview:_fittingButton];
[_fittingButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(37);
make.height.mas_equalTo(33);
make.right.mas_equalTo(self.gridButton.mas_left);
make.bottom.mas_equalTo(self.gridButton);
}];
}
#pragma mark - SDKHelperDelegate
-(void)analyzeObjFinish {
//分析初始化 数据完毕
[AppDelegate.visibleController hideLoading];
}
@end
//
// ALFaceModifyDetailsView.h
// GMAlpha
//
// Created by Jing on 2018/11/26.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ALFaceModifyDetailsView : UIView
@property (nonatomic, assign) NSInteger value;
- (void)resetValue;
@end
//
// ALFaceModifyDetailsView.m
// GMAlpha
//
// Created by Jing on 2018/11/26.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import "ALFaceModifyDetailsView.h"
@interface ALFaceModifyDetailsView ()
@property (nonatomic, strong) UISlider *slider;
@property (nonatomic, strong) UIButton *sliderValueButton;
@property (nonatomic, strong) UIButton *cancelButton;
@end
@implementation ALFaceModifyDetailsView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self p_setup];
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
_cancelButton.enabled = _slider.value != 50;
[_sliderValueButton setTitle:@(_value).stringValue forState:UIControlStateDisabled];
[_sliderValueButton mas_updateConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.slider).mas_offset((275 / 2) * (self.slider.value - 50) / 50.);
}];
}
- (void)resetValue {
_slider.value = 50;
_value = _slider.value;
[self setNeedsLayout];
}
- (void)p_cancelClick {
_slider.value = 50;
[self p_sliderChangeValue:_slider];
}
- (void)p_sliderChangeValue:(UISlider *)slider {
NSInteger value = @(slider.value).integerValue;
self.value = value;
[self setNeedsLayout];
}
- (void)p_setup {
_slider = [[UISlider alloc] init];
[_slider setThumbImage:[UIImage imageNamed:@"faceModifyProgressTrack"] forState:UIControlStateNormal];
_slider.minimumValue = 0;
_slider.maximumValue = 100;
_slider.minimumTrackTintColor = RGBCOLOR_HEX(0x0093FF);
_slider.maximumTrackTintColor = RGBCOLOR_HEX(0xCCCCCC);
_slider.value = 50;
_value = _slider.value;
[_slider addTarget:self action:@selector(p_sliderChangeValue:) forControlEvents:UIControlEventValueChanged];
[self addSubview:_slider];
[_slider mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_offset(275);
make.top.mas_offset(85);
make.left.mas_offset(30);
make.height.mas_offset(16);
}];
_sliderValueButton = [GMButton buttonWithTitle:@"50" backgroundColor:UIColor.clearColor titleFontSize:14 titleColor:UIColor.whiteColor];
[_sliderValueButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 4, 0)];
[_sliderValueButton setBackgroundImage:[UIImage imageNamed:@"faceModifyProgress"] forState:UIControlStateDisabled];
_sliderValueButton.enabled = NO;
[self addSubview:_sliderValueButton];
[_sliderValueButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_offset(23.5);
make.height.mas_offset(26.7);
make.bottom.equalTo(self.slider.mas_top).mas_offset(-10);
make.centerX.equalTo(self.slider).mas_offset(0);
}];
_cancelButton = [GMButton buttonWithType:UIButtonTypeCustom];
[_cancelButton setBackgroundImage:[UIImage imageNamed:@"faceModifyCancelNormal"] forState:UIControlStateNormal];
[_cancelButton setBackgroundImage:[UIImage imageNamed:@"faceModifyCancelDisabled"] forState:UIControlStateDisabled];
[_cancelButton addTarget:self action:@selector(p_cancelClick) forControlEvents:UIControlEventTouchUpInside];
_cancelButton.enabled = NO;
[self addSubview:_cancelButton];
[_cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(26);
make.centerY.equalTo(self.slider);
make.right.mas_equalTo(-22);
}];
}
@end
//
// ALFaceStarCollectionViewCell.h
// GMAlpha
//
// Created by Jing on 2018/11/26.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "ALFaceStarModel.h"
@interface ALFaceStarCollectionViewCell : GMCollectionViewCell
@property (nonatomic, strong) ALFaceStarModel *model;
- (void)addCell;
- (void)modifyDetails;
- (BOOL)willModify;
@end
//
// ALFaceStarCollectionViewCell.m
// GMAlpha
//
// Created by Jing on 2018/11/26.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import "ALFaceStarCollectionViewCell.h"
#import <GMKit/UIColor+GMTheme.h>
@interface ALFaceStarCollectionViewCell ()
@property (nonatomic, strong) UIImageView *starImageView;
@property (nonatomic, strong) UIImageView *editImageView;
@property (nonatomic, strong) UIImageView *lockImageView;
@property (nonatomic, strong) GMLabel *nameLabel;
@property (nonatomic, strong) GMLabel *similarityLabel;
@end
@implementation ALFaceStarCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self p_setup];
}
return self;
}
- (void)setModel:(ALFaceStarModel *)model {
_model = model;
_editImageView.hidden = YES;
_nameLabel.hidden = NO;
_lockImageView.hidden = !model.isLock;
_similarityLabel.hidden = model.isLock;
_nameLabel.text = model.name;
[_starImageView sd_setImageWithURL:[NSURL URLWithString:model.starUrl] placeholderImage:[UIImage imageNamed:@"faceEditNormal"]];
if (!model.isLock) {
_similarityLabel.text = [NSString stringWithFormat:@"%@%%相似", model.similarScore];
}
}
- (void)addCell {
_starImageView.image = [UIImage imageNamed:@"faceFittingAddStar"];
_nameLabel.hidden = _lockImageView.hidden = _similarityLabel.hidden = YES;
}
- (void)modifyDetails {
_editImageView.hidden = !_editImageView.hidden;
}
- (BOOL)willModify {
return !_editImageView.hidden;
}
- (void)p_setup {
_starImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@""]];
_starImageView.layer.cornerRadius = 45;
_starImageView.layer.masksToBounds = YES;
[self.contentView addSubview:_starImageView];
[_starImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(90);
make.height.mas_equalTo(90);
make.top.equalTo(self.contentView);
make.centerX.equalTo(self.contentView);
}];
_editImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"faceEdit"]];
_editImageView.hidden = YES;
[self.contentView addSubview:_editImageView];
[_editImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.starImageView);
}];
_lockImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"faceFittingUnlockStar"]];
_lockImageView.hidden = YES;
[self.contentView addSubview:_lockImageView];
[_lockImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(25);
make.bottom.right.mas_equalTo(self.starImageView);
}];
_nameLabel = [GMLabel labelWithTextColor:UIColor.auxiliaryTextLight fontSize:12];
[self.contentView addSubview:_nameLabel];
[_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.starImageView.mas_bottom).offset(6);
make.centerX.equalTo(self.editImageView);
make.height.mas_equalTo(12);
}];
_similarityLabel = [GMLabel labelWithTextColor:UIColor.auxiliaryTextLight fontSize:10];
[self.contentView addSubview:_similarityLabel];
[_similarityLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.nameLabel.mas_bottom).offset(3);
make.centerX.equalTo(self.editImageView);
make.height.mas_equalTo(10);
}];
}
@end
//
// ALFaceSDK.h
// GMAlpha
//
// Created by zhouLiang on 2018/11/29.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface ALFaceSDK : GMObject
/**
* 获取UV图的定时器
*/
@property (nonatomic, strong) NSTimer *timer;
/**
* 客户端数据上传
* url : /api/v1/face/upload
* raw_similar_data : 用户相似度的数据,二进制流数据(文件)
* pre_uv_url : 生成uv图片的URL(文件)
* faceId : 拟合ID
* raw_pic : 用户普通图片(文件)
* create_uv : 是否生成uv图片(int) 此参数2D传-->1 3D传-->0
*/
- (void)faceUploadRaw_similar_data:(NSString *)raw_similar_data pre_uv_url:(NSString *)pre_uv_url create_uv:(NSInteger)create_uv successBlock:(HttpSuccessBlock)successBlock failBlock:(HttpFailedBlock)failBlock;
/**
* 获取uv图
* url : /api/v1/face/get_uv
* faceId : 拟合ID
*/
- (void)faceUploadSuccessBlock:(HttpSuccessBlock)successBlock failBlock:(HttpFailedBlock)failBlock;
+ (void)downloadURL:(NSString *)downloadURL storePath:(NSString *)storePath progress:(void (^)(NSProgress *downloadProgress))progress destination:(void (^)(NSURL *targetPath))destination failure:(void(^)(NSError *error))faliure;
@end
//
// ALFaceSDK.m
// GMAlpha
//
// Created by zhouLiang on 2018/11/29.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import "ALFaceSDK.h"
#import "ALUpLoadManager.h"
#import "ALDownloadManager.h"
#import "ALFaceFittingAPI.h"
@implementation ALFaceSDK
/**
* 客户端数据上传
* url : /api/v1/face/upload
* raw_similar_data : 用户相似度的数据,二进制流数据(文件)
* faceId : 拟合ID
* raw_pic : 用户普通图片(文件)
* create_uv : 是否生成uv图片(int) 此参数2D传-->1 3D传-->0
*/
- (void)faceUploadRaw_similar_data:(NSString *)raw_similar_data pre_uv_url:(NSString *)pre_uv_url create_uv:(NSInteger)create_uv successBlock:(HttpSuccessBlock)successBlock failBlock:(HttpFailedBlock)failBlock
{
NSString *fittingId = [ALScanManager.shareInstance.fittingTempId isNonEmpty] ? ALScanManager.shareInstance.fittingTempId : ALScanManager.shareInstance.fittingId;
NSDictionary *params = @{
@"raw_similar_data":raw_similar_data,
@"id":SafeString(fittingId),
@"create_uv":@(create_uv),
@"pre_uv_url":pre_uv_url
};
[GMNetworking requestOCWithApi:API_FACE_UPLOAD method:GMHTTPMethodPost parameters:params completion:^(GMResponseOC *responseObject) {
if (responseObject.isSuccess) {
successBlock(responseObject);
ALScanManager.shareInstance.fittingId = responseObject.data[@"id"];
ALScanManager.shareInstance.fittingTempId = nil;
[ALScanManager.shareInstance savePathInfo];
} else {
failBlock(responseObject.message);
}
}];
}
/**
* 获取uv图
* url : /api/v1/face/get_uv
* faceId : 拟合ID
*/
- (void)faceUploadSuccessBlock:(HttpSuccessBlock)successBlock failBlock:(HttpFailedBlock)failBlock
{
NSLog(@"%@",[GMLoginManager shareInstance].user);
NSDictionary *params = @{@"id":SafeString(ALScanManager.shareInstance.fittingId),
};
[GMNetworking requestOCWithApi:API_FACE_GET_UV method:GMHTTPMethodGet parameters:params completion:^(GMResponseOC *responseObject) {
if (responseObject.isSuccess) {
successBlock(responseObject);
} else {
failBlock(responseObject.message);
}
}];
}
+ (void)fetchOutPutTxtWithUrl:(NSString *)url sotrePath:(NSString *)sotrePath completion:(ALFaceFittingDownloadStarCompletion)completion {
;
[ALDownloadManager downloadTaskWithURL:url path:sotrePath completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
if (!error ) {
NSString *path = filePath.absoluteString;
if (completion) {
[GMCache storeObjectAtDocumentPathWithkey:@"output" object:path];
completion(sotrePath);
};
} else if (completion) completion(nil);
}];
}
//全路径带名字的
+ (void)downloadURL:(NSString *)downloadURL storePath:(NSString *)storePath progress:(void (^)(NSProgress *downloadProgress))progress destination:(void (^)(NSURL *targetPath))destination failure:(void(^)(NSError *error))faliure{
//1.创建管理者
AFHTTPSessionManager *manage = [AFHTTPSessionManager manager];
//2.下载文件
/*
第一个参数:请求对象
第二个参数:下载进度
第三个参数:block回调,需要返回一个url地址,用来告诉AFN下载文件的目标地址
targetPath:AFN内部下载文件存储的地址,tmp文件夹下
response:请求的响应头
返回值:文件应该剪切到什么地方
第四个参数:block回调,当文件下载完成之后调用
response:响应头
filePath:文件存储在沙盒的地址 == 第三个参数中block的返回值
error:错误信息
*/
//2.1 创建请求对象
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString: downloadURL]];
NSURLSessionDownloadTask *downloadTask = [manage downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) {//进度
if (downloadProgress) {
progress(downloadProgress);
}
} destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
NSURL *filePathUrl = [NSURL fileURLWithPath:storePath];
return filePathUrl;
} completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nonnull filePath, NSError * _Nonnull error) {
if (error) {
faliure(error);
}
if(filePath){
destination(filePath);
}
}];
//3.启动任务
[downloadTask resume];
}
@end
测试上传文件
\ No newline at end of file
//
// ALRecommendUserObject.h
// GMAlpha
//
// Created by Mikasa on 2018/11/7.
// Copyright © 2018 Gengmei. All rights reserved.
//
// 推荐关注用户Object
@interface ALRecommendUserObject : GMObject
@property (nonatomic, copy) NSString *imageUrl;
@end
//
// ALRecommendUserObject.m
// GMAlpha
//
// Created by Mikasa on 2018/11/7.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import "ALRecommendUserObject.h"
@implementation ALRecommendUserObject
@end
//
// ALRecommendFollowUserCell.h
// GMAlpha
//
// Created by Mikasa on 2018/11/7.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import "ALTopicCardObject.h"
#define kItemWidth ((MAINSCREEN_WIDTH - 15 - 20) / 2.5)
@protocol ALRecommendFollowUserCellDelegate;
@interface ALRecommendFollowUserCell : GMCollectionViewCell
@property (nonatomic, strong) ALTopicCardRecommentObject *userObject;
@property (nonatomic, strong) NSIndexPath *indexPath;
@property (nonatomic, weak) id<ALRecommendFollowUserCellDelegate> delegate;
/** 点击关注用户 */
@property (nonatomic, copy) void(^didClickFollowUserBlock)();
@end
@protocol ALRecommendFollowUserCellDelegate <NSObject>
- (void)cell:(ALRecommendFollowUserCell *)view clickedIconAtIndexPath:(NSIndexPath *)indexPath;
/**
触发了关注事件
@param view self
@param indexPath indexPath
@param voteString 取值(@"do", @"undo"), do:关注, undo:取消关注
*/
- (void)cell:(ALRecommendFollowUserCell *)view clickedFollowAtIndexPath:(NSIndexPath *)indexPath voteString:(NSString *)voteString;
@end
//
// ALRecommendFollowUserCell.m
// GMAlpha
//
// Created by Mikasa on 2018/11/7.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import "ALRecommendFollowUserCell.h"
#import "ALPersonViewController.h"
@interface ALRecommendFollowUserCell ()
@property (nonatomic, strong) GMLabel *nameLabel;// 名称
@property (nonatomic, strong) GMLabel *followTipsLabel;// 她也关注
@property (nonatomic, strong) UIButton *followButton;// 关注按钮
@property (nonatomic, strong) GMImageView *iconImageView;// 头像
@end
@implementation ALRecommendFollowUserCell
- (void)setup {
self.layer.cornerRadius = 5;
self.layer.masksToBounds = YES;
self.backgroundColor = [UIColor whiteColor];
__weak __typeof(self)weakSelf = self;
// 头像
CGFloat imageWidth = kItemWidth - 60;
CGFloat imageHeight = imageWidth;
GMImageView *iconImageView = [[GMImageView alloc] initWithFrame:CGRectMake(30, 20, imageWidth, imageHeight)];
iconImageView.image = [UIImage imageNamed:@"user_setter_default_icon_new"];
iconImageView.layer.cornerRadius = imageHeight/2;
iconImageView.layer.masksToBounds = YES;
iconImageView.userInteractionEnabled = YES;
UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(iconImageViewClickMethod)];
[iconImageView addGestureRecognizer:gesture];
[self.contentView addSubview:iconImageView];
self.iconImageView = iconImageView;
[_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(weakSelf.mas_centerX);
make.width.height.mas_equalTo(imageWidth);
make.top.mas_equalTo(10);
}];
// 名称
GMLabel *nameLabel = [GMLabel labelWithTextColor:UIColor.headlineText
fontSize:14];
nameLabel.font = [UIFont gmBoldFont:14];
nameLabel.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:nameLabel];
self.nameLabel = nameLabel;
[_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(_iconImageView.mas_bottom).offset(15);
make.left.right.mas_equalTo(0);
make.height.mas_equalTo(14);
}];
// 也关注
GMLabel *followTipsLabel = [GMLabel labelWithTextColor:UIColor.auxiliaryTextLight
fontSize:11];
followTipsLabel.textAlignment = NSTextAlignmentCenter;
followTipsLabel.text = @"她也关注";
[self.contentView addSubview:followTipsLabel];
self.followTipsLabel = followTipsLabel;
[_followTipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(0);
make.top.mas_equalTo(_nameLabel.mas_bottom).offset(5);
make.height.mas_equalTo(11);
}];
// 关注按钮
UIButton *followButton = [[UIButton alloc] init];
self.followButton = followButton;
followButton.backgroundColor = RGBCOLOR_HEX(0x0093FF);
followButton.layer.cornerRadius = 14;
followButton.layer.masksToBounds = YES;
[followButton setBackgroundImage:[UIImage imageWithColor:RGBCOLOR_HEX(0x0093FF)] forState:UIControlStateNormal];
[followButton setBackgroundImage:[UIImage imageWithColor:RGBCOLOR_HEX(0xCCCCCC)] forState:UIControlStateSelected];
[followButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
[followButton setTitleColor:UIColor.auxiliaryTextLight forState:UIControlStateSelected];
followButton.titleLabel.font = [UIFont gmFont:14];
[followButton setTitle:@"关注" forState:UIControlStateNormal];
[followButton setTitle:@"已关注" forState:UIControlStateSelected];
// followButton.layer.borderColor = RGBCOLOR_HEX(0x0093FF).CGColor;
// followButton.layer.borderWidth = ONE_PIXEL;
// followButton.layer.cornerRadius = 12 * ONE_PIXEL;
// followButton.layer.masksToBounds = YES;
[followButton addTarget:self action:@selector(followButtonClick:) forControlEvents:UIControlEventTouchUpInside];
[followButton sizeToFit];
[self.contentView addSubview:followButton];
[_followButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.followTipsLabel.mas_bottom).offset(10);
make.centerX.mas_equalTo(weakSelf.mas_centerX);
make.width.mas_equalTo(118);
make.height.mas_equalTo(28);
}];
}
- (void)setUserObject:(ALTopicCardRecommentObject *)userObject {
_userObject = userObject;
UIImage *defIcon = [UIImage imageNamed:@"user_setter_default_icon_new"];
NSURL *iconUrl = [NSURL URLWithString:userObject.icon];
[self.iconImageView sd_setImageWithURL:iconUrl placeholderImage:defIcon];
self.nameLabel.text = userObject.name;
self.followTipsLabel.text = userObject.desc;
self.followButton.selected = userObject.isFollow;
// if (userObject.isFollow == YES)
// {
// self.followButton.layer.borderColor = UIColor.auxiliaryTextLight.CGColor;
// }
// else
// {
// self.followButton.layer.borderColor = [UIColor clearColor].CGColor;
// }
}
#pragma mark - private method
- (void)followButtonClick:(UIButton *)sender {
//用户权限
if ([[GMLoginManager shareInstance] showLoginViewIfNeeded]) {
return;
}
NSString *voteString = @"do";
if (self.followButton.isSelected) {//已关注状态,只发送取消关注请求
self.followButton.selected = NO;
self.userObject.isFollow = NO;
[self requestCancelFollowAuthor];
voteString = @"undo";
}else {
[[NSNotificationCenter defaultCenter] postNotificationName:OTHERPERSON_ATTENTION_PERSON object:[NSString stringWithFormat:@"%zd",self.userObject.id]];
self.followButton.selected = YES;
self.userObject.isFollow = YES;
[self requestAddFollowAuthor];
voteString = @"do";
}
if ([self.delegate respondsToSelector:@selector(cell:clickedFollowAtIndexPath:voteString:)]) {
[self.delegate cell:self clickedFollowAtIndexPath:self.indexPath voteString:voteString];
}
}
#pragma mark - clickMethod
- (void)iconImageViewClickMethod
{
[[NSNotificationCenter defaultCenter] postNotificationName:OTHERPERSON_CLICK_PERSONAVATAR object:[NSString stringWithFormat:@"%ld",(long)self.userObject.id]];
ALPersonViewController *toVc = [[ALPersonViewController alloc] initWithUserId:self.userObject.id];
[AppDelegate.visibleController.navigationController pushViewController:toVc animated:YES];
if ([self.delegate respondsToSelector:@selector(cell:clickedIconAtIndexPath:)]) {
[self.delegate cell:self clickedIconAtIndexPath:self.indexPath];
}
}
#pragma mark - 网络
/** rq 关注<作者> */
- (void)requestAddFollowAuthor
{
NSDictionary *params = @{
@"type": @"1",
@"id": @(self.userObject.id)
};
[GMNetworking requestOCWithApi:API_V1_FOLLOW method:GMHTTPMethodPost parameters:params completion:^(GMResponseOC * response) {
}];
}
/** rq 取消关注<作者> */
- (void)requestCancelFollowAuthor
{
NSDictionary *params = @{
@"type": @"1",
@"id": @(self.userObject.id)
};
[GMNetworking requestOCWithApi:API_V1_CANCEL_FOLLOW method:GMHTTPMethodPost parameters:params completion:^(GMResponseOC * response) {
}];
}
@end
//
// ALRecommendUserView.h
// GMAlpha
//
// Created by Mikasa on 2018/11/7.
// Copyright © 2018 Gengmei. All rights reserved.
//
@protocol ALRecommendUserViewDelegate;
@interface ALRecommendUserView : GMView
@property (nonatomic, strong) NSArray *recommendUserArray;
@property (nonatomic, assign) CGFloat recommendUserViewHeight;
@property (nonatomic, weak) id<ALRecommendUserViewDelegate> delegate;
+ (CGFloat)recommendUserViewHeight;
@end
@protocol ALRecommendUserViewDelegate <NSObject>
- (void)recommendView:(ALRecommendUserView *)view clickedIconAtIndexPath:(NSIndexPath *)indexPath;
/**
触发 关注 事件
@param view self
@param indexPath cell的位置indexPath
@param voteString 取值范围(@"do", @"undo"), 用于埋点,do:关注,undo:取消关注
*/
- (void)recommendView:(ALRecommendUserView *)view clickedFollowAtIndexPath:(NSIndexPath *)indexPath voteString:(NSString *)voteString;
@end
//
// ALRecommendUserView.m
// GMAlpha
//
// Created by Mikasa on 2018/11/7.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import "ALRecommendUserView.h"
#import "ALRecommendFollowUserCell.h"
#import "ALTopicCardObject.h"
@interface ALRecommendUserView()<UICollectionViewDelegate, UICollectionViewDataSource, ALRecommendFollowUserCellDelegate>
@property (nonatomic, strong) GMLabel *recommendTitleLabel;
@property (nonatomic, strong) GMCollectionView *collection;
@end
static CGFloat kItemHeight;
@implementation ALRecommendUserView
- (void)setup {
[super setup];
self.recommendUserArray = @[];
self.backgroundColor = UIColor.background;
// 248
// 标题
GMLabel *recommendTitleLabel = [GMLabel labelWithTextColor:UIColor.headlineText fontSize:18];
recommendTitleLabel.frame = CGRectMake(15, 0, MAINSCREEN_WIDTH - 30, 42);
recommendTitleLabel.text = @"推荐关注";
recommendTitleLabel.font = [UIFont gmBoldFont:18];
[self addSubview:recommendTitleLabel];
self.recommendTitleLabel = recommendTitleLabel;
[_recommendTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(15);
make.right.mas_equalTo(-15);
make.top.mas_equalTo(0);
make.height.mas_equalTo(42);
}];
// 添加推荐关注人列表(103)
UICollectionViewFlowLayout *layout = [UICollectionViewFlowLayout new];
CGFloat itemWidth = kItemWidth;
CGFloat itemHeight = ceilf((kItemWidth * 190) / 140);
layout.itemSize = CGSizeMake(itemWidth, itemHeight);
layout.minimumInteritemSpacing = 10;
layout.minimumLineSpacing = 10;
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
_collection = [[GMCollectionView alloc] initWithFrame:CGRectMake(0, 0, MAINSCREEN_WIDTH - 30, 190) collectionViewLayout:layout];
[self addSubview:_collection];
_collection.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_collection.showsHorizontalScrollIndicator = NO;
_collection.dataSource = self;
_collection.delegate = self;
_collection.allowsSelection = YES;
_collection.allowsMultipleSelection = NO;
_collection.contentInset = UIEdgeInsetsMake(0, 15, 0, 15);
_collection.backgroundColor = [UIColor clearColor];
[_collection registerCell:[ALRecommendFollowUserCell class]];
[_collection mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(0);
make.right.mas_equalTo(0);
make.height.mas_equalTo(itemHeight);
make.bottom.mas_equalTo(-16);
}];
_recommendUserViewHeight = itemHeight + 42 + 16;
kItemHeight = _recommendUserViewHeight;
}
+ (CGFloat)recommendUserViewHeight
{
return kItemHeight;
}
- (void)setRecommendUserArray:(NSArray *)recommendUserArray {
_recommendUserArray = recommendUserArray;
[self.collection reloadData];
}
#pragma mark - UICollectionViewDataSource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.recommendUserArray.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
ALRecommendFollowUserCell *cell = [collectionView dequeueCell:[ALRecommendFollowUserCell class] forIndexPath:indexPath];
cell.indexPath = indexPath;
cell.delegate = self;
ALTopicCardRecommentObject *userObj = self.recommendUserArray[indexPath.row];
cell.userObject = userObj;
return cell;
}
#pragma mark - UICollectionViewDelegate
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
// 跳转查看用户详情 (内部直接跳转)
// ALRecommendUserObject *userObject = self.recommendUserArray[indexPath.row];
/*
if (self.didClickFollowUserDetailBlock) {
self.didClickFollowUserDetailBlock();
}*/
}
#pragma mark - ALRecommendFollowUserCellDelegate
- (void)cell:(ALRecommendFollowUserCell *)view clickedIconAtIndexPath:(NSIndexPath *)indexPath {
if ([self.delegate respondsToSelector:@selector(recommendView:clickedIconAtIndexPath:)]) {
[self.delegate recommendView:self clickedIconAtIndexPath:indexPath];
}
}
/**
触发了关注事件
@param view self
@param indexPath indexPath
@param voteString 取值(@"do", @"undo"), do:关注, undo:取消关注
*/
- (void)cell:(ALRecommendFollowUserCell *)view clickedFollowAtIndexPath:(NSIndexPath *)indexPath voteString:(NSString *)voteString {
if ([self.delegate respondsToSelector:@selector(recommendView:clickedFollowAtIndexPath:voteString:)]) {
[self.delegate recommendView:self clickedFollowAtIndexPath:indexPath voteString:voteString];
}
}
@end
//
// GMPlayerControlView.h
// Gengmei
//
// Created by 朱璇 on 2018/9/4.
// Copyright © 2018年 更美互动信息科技有限公司. All rights reserved.
//
@protocol GMPlayerControlViewDelegate <NSObject>
/**
* 点击播放按钮
*/
- (void)didClickPlayerBtn:(GMButton *)sender;
/**
* 开始触摸
*/
- (void)touchesBeganWithPoint:(CGPoint)point;
/**
* 结束触摸
*/
- (void)touchesEndWithPoint:(CGPoint)point;
/**
* 移动手指
*/
- (void)touchesMoveWithPoint:(CGPoint)point;
@end
@interface GMPlayerControlView : GMView
@property (nonatomic, assign) id <GMPlayerControlViewDelegate> touchDelegate;
@property (nonatomic, strong) GMButton *bigPlayerBtn;
@property (nonatomic, strong) GMView *coverView; // 暂停时遮罩
@end
//
// GMPlayerControlView.m
// Gengmei
//
// Created by 朱璇 on 2018/9/4.
// Copyright © 2018年 更美互动信息科技有限公司. All rights reserved.
//
#import "GMPlayerControlView.h"
@implementation GMPlayerControlView
- (instancetype)init {
if (self == [super init]) {
_bigPlayerBtn = [[GMButton alloc] init];
_bigPlayerBtn.hidden = YES;
[_bigPlayerBtn setImage:[UIImage imageNamed:@"diary_video_cover"] forState:UIControlStateNormal];
[_bigPlayerBtn addTarget:self action:@selector(playVideo:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:_bigPlayerBtn];
_coverView = [GMView new];
_coverView.hidden = YES;
_coverView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:.4];
[self addSubview:_coverView];
[self sendSubviewToBack:_coverView];
[_bigPlayerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self);
make.width.mas_equalTo(MAINSCREEN_WIDTH - 100);
make.height.mas_equalTo(MAINSCREEN_HEIGHT - 300);
}];
[_coverView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
}
return self;
}
// 播放
-(void)playVideo:(GMButton *)sender {
if ([self.touchDelegate respondsToSelector:@selector(didClickPlayerBtn:)]) {
[self.touchDelegate didClickPlayerBtn:sender];
}
}
//触摸开始
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
//获取触摸开始的坐标
UITouch *touch = [touches anyObject];
CGPoint currentP = [touch locationInView:self];
[self.touchDelegate touchesBeganWithPoint:currentP];
}
//触摸结束
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[super touchesEnded:touches withEvent:event];
UITouch *touch = [touches anyObject];
CGPoint currentP = [touch locationInView:self];
[self.touchDelegate touchesEndWithPoint:currentP];
}
//移动
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint currentP = [touch locationInView:self];
[self.touchDelegate touchesMoveWithPoint:currentP];
}
@end
//
// GMPlayerView.h
// Gengmei
//
// Created by 翟国钧 on 2016/12/13.
// Copyright © 2016年 更美互动信息科技有限公司. All rights reserved.
//
#import <AVFoundation/AVFoundation.h>
#import <AVFoundation/AVFoundation.h>
#import "GMVideoObject.h"
typedef NS_ENUM(NSUInteger, TouchDirection) {
TouchDirectionLeftOrRight,
TouchDirectionUpOrDown,
TouchDirectionNone
};
// class: 音量、亮度
@interface GMPlayerVolumeAndBrightView : GMView
@property (nonatomic, strong) UIProgressView *progressView;
-(instancetype)initWithFrame:(CGRect)frame title:(NSString *)title image:(UIImage *)image;
@end
// class: 快进、快退
@interface GMPlayerFastSpeedView : GMView
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) GMImageView *imageView;
@end
NS_ASSUME_NONNULL_BEGIN
@interface GMPlayerView : UIView
/**
被播放的video。
*/
@property (nonatomic, strong, nullable) GMVideoObject *video;
/**
被播放的topic id。
如果不需要记录播放次数,请使用initNoTopicId初始化GMPlayerView。另外可以参考 addViewNumber 方法
*/
@property (nonatomic, copy, nullable) NSString *topicId;
/**
播放的页面来源。
如果不需要记录播放次数,请使用initNoTopicId初始化GMPlayerView。另外可以参考 addViewNumber 方法
*/
@property (nonatomic, copy, nullable) NSString *from;
@property (nonatomic, copy, nullable) void (^closePlayBack)(void);
- (instancetype)init;
/**
如果不需要记录播放次数,请使用initNoTopicId初始化GMPlayerView。另外可以参考 addViewNumber 方法
*/
- (instancetype)initNoTopicId;
/**
播放视频,并按照指定rect位置开始动画。如果无法给出rect,就传递CGRectZero
*/
- (void)play:(NSString *)url animationRect:(CGRect)rect;
// 卡片上自动播放视频的时候用这个方法
- (void)play:(NSString *)videoUrl backView:(UIView *)backView;
- (void)stop;
@end
NS_ASSUME_NONNULL_END
This diff is collapsed.
//
// GMVIdeoBottomVIew.h
// Gengmei
//
// Created by Terminator on 2016/11/18.
// Copyright © 2016年 更美互动信息科技有限公司. All rights reserved.
//
@protocol GMVideoBottomViewDelegate <NSObject>
// 全屏
- (void)didClickEnterFullScreen;
// 退出全屏
- (void)didClickExitFullScreen;
@end
@interface GMVideoBottomView : GMView
@property (nonatomic, assign)id <GMVideoBottomViewDelegate>delegate;
//播放按钮
@property (nonatomic, strong) GMButton *playButton;
//进度条
@property (nonatomic, strong) UISlider *processSlider;
//播放时间
@property (nonatomic, strong) GMLabel *playerTime;
//总时长
@property (nonatomic, strong) GMLabel *totalTime;
// 全屏,退出全屏
@property (nonatomic, strong) GMButton *enterFullScreenButton;
@property (nonatomic, strong) GMButton *exitfullScreenButton;
// 背景
@property (nonatomic, strong) GMImageView *backgroundView;
- (void)enterFullScreen:(BOOL)isFull;
@end
//
// GMVIdeoBottomVIew.m
// Gengmei
//
// Created by Terminator on 2016/11/18.
// Copyright © 2016年 更美互动信息科技有限公司. All rights reserved.
//
#import "GMVideoBottomView.h"
@implementation GMVideoBottomView
- (void)setup {
[super setup];
_backgroundView = [[GMImageView alloc] initWithImage:[UIImage imageNamed:@"player_bottomBackview"]];
_backgroundView.userInteractionEnabled = YES;
[self addSubview:_backgroundView];
_playButton = [GMButton buttonWithType:UIButtonTypeCustom];
[_playButton setBackgroundColor:[UIColor clearColor] forState:UIControlStateNormal];
[_playButton setImage:[UIImage imageNamed:@"player"] forState:UIControlStateSelected];
[_playButton setImage:[UIImage imageNamed:@"pause"] forState:UIControlStateNormal];
[_backgroundView addSubview:_playButton];
_playerTime = [[GMLabel alloc] init];
_playerTime.font = [UIFont gmFont:11];
_playerTime.textColor = [UIColor whiteColor];
_playerTime.textAlignment = NSTextAlignmentCenter;
_playerTime.text = [NSString stringWithFormat:@"00:00"];
[_backgroundView addSubview:_playerTime];
_processSlider = [[UISlider alloc] init];
[_processSlider setThumbImage:[UIImage imageNamed:@"current_slider"] forState:UIControlStateNormal];
_processSlider.maximumTrackTintColor = [RGBCOLOR_HEX(0xffffff) colorWithAlphaComponent:0.6];
_processSlider.minimumTrackTintColor = [UIColor whiteColor];
[_backgroundView addSubview:_processSlider];
_totalTime = [[GMLabel alloc] init];
_totalTime.font = [UIFont gmFont:11];
_totalTime.textColor = [UIColor whiteColor];
_totalTime.text = [NSString stringWithFormat:@"00:00"];
_totalTime.textAlignment = NSTextAlignmentCenter;
[_backgroundView addSubview:_totalTime];
self.enterFullScreenButton = [GMButton buttonWithType:UIButtonTypeCustom];
[self.enterFullScreenButton setImage:[UIImage imageNamed:@"player_fullScreen"] forState:(UIControlStateNormal)];
[self.enterFullScreenButton addTarget:self action:@selector(clickEnterFullScreenButton) forControlEvents:(UIControlEventTouchUpInside)];
[_backgroundView addSubview:self.enterFullScreenButton];
self.exitfullScreenButton = [GMButton buttonWithType:UIButtonTypeCustom];
[self.exitfullScreenButton setImage:[UIImage imageNamed:@"player_exitFullScreen"] forState:(UIControlStateNormal)];
[self.exitfullScreenButton addTarget:self action:@selector(clickExitFullScreenButton) forControlEvents:(UIControlEventTouchUpInside)];
[_backgroundView addSubview:self.exitfullScreenButton];
[_backgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
[_playButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(12);
make.centerY.mas_equalTo(_backgroundView.mas_centerY);
make.height.equalTo(_backgroundView);
make.width.mas_equalTo(30);
}];
[_playerTime mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(_backgroundView.mas_centerY);
make.width.mas_equalTo(32);
make.left.equalTo(self.playButton.mas_right).offset(0);
}];
[_processSlider mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(_playerTime.mas_right).offset(8);
make.height.mas_equalTo(_backgroundView.mas_height);
make.centerY.mas_equalTo(_backgroundView.mas_centerY);
}];
[_totalTime mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(_backgroundView.mas_centerY);
make.width.mas_equalTo(32);
make.left.equalTo(_processSlider.mas_right).offset(8);
}];
[_enterFullScreenButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-14);
make.centerY.mas_equalTo(_backgroundView.mas_centerY);
make.left.equalTo(_totalTime.mas_right).offset(2);
make.height.equalTo(_backgroundView);
make.width.mas_equalTo(30);
}];
}
- (void)enterFullScreen:(BOOL)isFull {
if (isFull) {
[_playButton mas_remakeConstraints:^(MASConstraintMaker *make) {
if ([UIDevice resolutionType] == iPhone58Inches) {
make.left.mas_equalTo(12 + OCNavigationBar.statusBarHeight);
} else {
make.left.mas_equalTo(12);
}
make.centerY.mas_equalTo(_backgroundView.mas_centerY);
make.height.equalTo(_backgroundView);
make.width.mas_equalTo(30);
}];
[_enterFullScreenButton mas_remakeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(0);
make.height.mas_equalTo(0);
}];
[_exitfullScreenButton mas_remakeConstraints:^(MASConstraintMaker *make) {
if ([UIDevice resolutionType] == iPhone58Inches) {
make.right.mas_equalTo(-14 - OCNavigationBar.statusBarHeight);
} else {
make.right.mas_equalTo(-14);
}
make.centerY.mas_equalTo(_backgroundView.mas_centerY);
make.left.equalTo(_totalTime.mas_right).offset(2);
make.height.equalTo(self);
make.width.mas_equalTo(30);
}];
} else {// 竖屏状态
[_playButton mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(12);
make.centerY.mas_equalTo(_backgroundView.mas_centerY);
make.height.equalTo(_backgroundView);
make.width.mas_equalTo(30);
}];
[_enterFullScreenButton mas_remakeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-14);
make.centerY.mas_equalTo(_backgroundView.mas_centerY);
make.left.equalTo(_totalTime.mas_right).offset(2);
make.height.equalTo(self);
make.width.mas_equalTo(30);
}];
[_exitfullScreenButton mas_remakeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(0);
make.height.mas_equalTo(0);
}];
}
}
- (void)clickEnterFullScreenButton {
if ([self.delegate respondsToSelector:@selector(didClickEnterFullScreen)]) {
[self.delegate didClickEnterFullScreen];
}
}
- (void)clickExitFullScreenButton {
if ([self.delegate respondsToSelector:@selector(didClickExitFullScreen)]) {
[self.delegate didClickExitFullScreen];
}
}
@end
//
// GMVideoObject.h
// Gengmei
//
// Created by 朱璇 on 2018/9/5.
// Copyright © 2018年 更美互动信息科技有限公司. All rights reserved.
//
@interface GMVideoObject : GMObject
@property (nonatomic,copy) NSString *pageName;
@property (nonatomic,copy) NSString *tabName;
@property (nonatomic,copy) NSString *cardType;
@property (nonatomic,copy) NSString *businessId;
@property (nonatomic,copy) NSString *tagId;
@property (nonatomic,copy) NSString *topicId;
@property (nonatomic,copy) NSString *videoUrl;
@property (nonatomic,copy) NSString *videoPic;
@end
//
// GMVideoObject.m
// Gengmei
//
// Created by 朱璇 on 2018/9/5.
// Copyright © 2018年 更美互动信息科技有限公司. All rights reserved.
//
#import "GMVideoObject.h"
@implementation GMVideoObject
@end
//
// UIViewController+VideoPlayer.h
// Gengmei
//
// Created by wangyang on 2017/1/6.
// Copyright © 2017年 更美互动信息科技有限公司. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "GMPlayerView.h"
#import "GMVideoObject.h"
@interface UIViewController (VideoPlayer)
@property (nonatomic, copy) NSString * (^videoPlayViewFrom) (void);
@property (nonatomic, strong) GMPlayerView *player;
// 埋点使用
@property (nonatomic, copy) NSString *tabName;
@property (nonatomic, copy) NSString *tagId;
// 是否全屏
@property (nonatomic, assign) BOOL isFullScreen;
- (void)playVideo:(GMVideoObject *)video animationStartRect:(CGRect)rect;
@end
//
// UIViewController+VideoPlayer.m
// Gengmei
//
// Created by wangyang on 2017/1/6.
// Copyright © 2017年 更美互动信息科技有限公司. All rights reserved.
//
#import "UIViewController+VideoPlayer.h"
#import <objc/runtime.h>
@import AFNetworking;
@interface UIViewController ()
@end
@implementation UIViewController (VideoPlayer)
- (NSString *(^)(void))videoPlayViewFrom {
return objc_getAssociatedObject(self, _cmd);
}
- (void)setVideoPlayViewFrom:(NSString *(^)(void))videoPlayViewFrom {
objc_setAssociatedObject(self, @selector(videoPlayViewFrom), videoPlayViewFrom, OBJC_ASSOCIATION_COPY);
}
- (NSString *)tagId {
return objc_getAssociatedObject(self, _cmd);
}
- (void)setTagId:(NSString *)tagId {
objc_setAssociatedObject(self, @selector(tagId), tagId, OBJC_ASSOCIATION_COPY);
}
- (NSString *)tabName {
return objc_getAssociatedObject(self, _cmd);
}
- (void)setTabName:(NSString *)tabName {
objc_setAssociatedObject(self, @selector(tabName), tabName, OBJC_ASSOCIATION_COPY);
}
- (BOOL)isFullScreen {
return [objc_getAssociatedObject(self, _cmd) boolValue];
}
- (void)setIsFullScreen:(BOOL)isFullScreen {
objc_setAssociatedObject(self, @selector(isFullScreen), @(isFullScreen), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (GMPlayerView *)player {
GMPlayerView *_player = objc_getAssociatedObject(self, @selector(player));
if (_player == nil) {
_player = [GMPlayerView new];
objc_setAssociatedObject(self, @selector(player), _player, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
return _player;
}
- (void)setPlayer:(GMPlayerView *)player {
objc_setAssociatedObject(self, @selector(player), player, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (void)playVideo:(GMVideoObject *)video animationStartRect:(CGRect)rect {
if ([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable) {
[self toast:@"网络情况欠佳,请检查网络"];
return;
}
__weak __typeof(self)weakSelf = self;
self.player = [GMPlayerView new];
self.player.closePlayBack = ^{
weakSelf.player = nil;
};
video.pageName = AppDelegate.visibleController.pageName;
video.tabName = self.tabName;
video.tagId = self.tagId;
self.player.video = video;
self.player.topicId = video.topicId;
// self.player.from = self.videoPlayViewFrom();
[self.player play:self.player.video.videoUrl animationRect:rect];
}
@end
//
// ALCreateGroupController.h
// GMAlpha
//
// Created by Q14 on 2018/11/7.
// Copyright © 2018年 Gengmei. All rights reserved.
//
@interface ALCreateGroupController : WMBaseViewController
@end
//
// ALCreateGroupWebNextController.h
// GMAlpha
//
// Created by zhouLiang on 2018/12/3.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import "WMBaseWebViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface ALCreateGroupWebNextController : WMBaseWebViewController
@end
NS_ASSUME_NONNULL_END
//
// ALCreateGroupWebOneController.h
// GMAlpha
//
// Created by zhouLiang on 2018/12/3.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import "WMBaseWebViewController.h"
@interface ALCreateGroupWebOneController : WMBaseWebViewController
@end
//
// ALCreateGroupViewModel.h
// GMAlpha
//
// Created by Q14 on 2018/11/12.
// Copyright © 2018年 Gengmei. All rights reserved.
//
@interface ALCreateGroupViewModel : WMFetchDataViewModel
@end
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment