Commit 75e54603 authored by luyueming's avatar luyueming

update

parent 8b06f494
......@@ -8,7 +8,7 @@ Pod::Spec.new do |s|
s.source = { :git => 'git@git.wanmeizhensuo.com:gengmeiios/GMBase.git', :tag => s.version.to_s }
s.ios.deployment_target = '8.0'
s.source_files = 'GMBase/Classes/**/*'
s.dependency 'GMRefresh'
s.dependency 'GMJSONModel'
s.dependency 'UITableView+FDTemplateLayoutCell', '1.4'
......@@ -18,4 +18,5 @@ Pod::Spec.new do |s|
s.dependency 'GMHud'
s.dependency 'GMKit'
s.dependency 'SDWebImage'
s.dependency 'SnapKit','4.2.0'
end
//
// GMRountClassManager.h
// GMBase
//
// Created by 卢悦明 on 2020/5/12.
//
#import <Foundation/Foundation.h>
@interface GMRountClassManager : NSObject
/// 通过key找到对应的方法,回调想要的值
/// @param key
- (id)getMassge:(NSString *)key;
/// 调用方法
- (void)sendCladdMethod:(NSString *)key;
@end
//
// GMRountClassManager.m
// GMBase
//
// Created by 卢悦明 on 2020/5/12.
//
#import "GMRountClassManager.h"
@implementation GMRountClassManager
@end
//
// GMWelfareServiceObject.h
// GMBase
//
// Created by 卢悦明 on 2020/5/12.
//
#import <GMBase/GMObject.h>
#import "GMWelfareVideObject.h"
typedef NS_ENUM(NSUInteger, GMWelfareDetailServiceType) {
GMWelfareDetailServiceTypeDefault = 1,// 其他(后端也不知道1, 2啥意思, 旗舰店之前客户端没用到)
GMWelfareDetailServiceTypeFlagShip = 3,// 旗舰店(新加类型)
};
NS_ASSUME_NONNULL_BEGIN
@protocol GMWelfareServiceObject @end
@interface GMWelfareServiceObject : GMObject
@property (nonatomic, strong) NSString *serviceId;
@property (nonatomic, strong) NSString *serviceName;
@property (nonatomic, strong) NSString *shortDescription;
@property (nonatomic, strong) NSString *doctorName;
@property (nonatomic, assign) BOOL doctorRecommend;
@property (nonatomic, strong) NSString *pic;
@property (nonatomic, strong) NSString *picSmall;
/** 划线价(7745开始,未选中sku时,会传一个价格区间), 不需要展示的,original_price会传空字符串 */
@property (nonatomic, strong) NSString *originalPrice;
@property (nonatomic, strong) NSString *gengmeiPrice;
@property (nonatomic, strong) NSString *picNum;
@property (nonatomic, assign) NSInteger sellAmount;
@property (nonatomic, strong) NSString *city;
@property (nonatomic, strong) NSString *url;
@property (nonatomic, strong) NSString *specialInfo;
@property (nonatomic, strong) NSString *specialId;
@property (nonatomic, strong) NSString *specialInfoUrl;
@property (nonatomic, assign) NSInteger saleLimit;
@property (nonatomic, strong) NSNumber *commentRate;
@property (nonatomic, strong) NSArray <GMWelfareVideObject> *headerPic;
@property (nonatomic, strong) NSString *distance;
/** 添加提问按钮 的列表问题 从AI过来的时候, 会有这个字段 by add 7.22.0*/
@property (nonatomic, copy) NSString *projectTag;
/** 美购类型, 先判断旗舰店, 否则就是其他 */
@property (nonatomic, assign) GMWelfareDetailServiceType serviceType;
@property (nonatomic, copy) NSString *image;
@end
NS_ASSUME_NONNULL_END
//
// GMWelfareServiceObject.m
// GMBase
//
// Created by 卢悦明 on 2020/5/12.
//
#import "GMWelfareServiceObject.h"
@implementation GMWelfareServiceObject
@end
//
// GMWelfareVideObject.h
// GMBase
//
// Created by 卢悦明 on 2020/5/12.
//
#import <GMBase/GMObject.h>
NS_ASSUME_NONNULL_BEGIN
@protocol GMWelfareVideObject @end
@interface GMWelfareVideObject : GMObject
@property (nonatomic, strong) NSString *pic;
@property (nonatomic, strong) NSString *videoUrl;
@end
NS_ASSUME_NONNULL_END
//
// GMWelfareVideObject.m
// GMBase
//
// Created by 卢悦明 on 2020/5/12.
//
#import "GMWelfareVideObject.h"
@implementation GMWelfareVideObject
@end
//
// GMZoneTagsObject.h
// Gengmei
//
// Created by 卢悦明 on 2020/5/12.
// Copyright © 2020 更美互动信息科技有限公司. All rights reserved.
//
#import <GMBase/GMObject.h>
NS_ASSUME_NONNULL_BEGIN
@protocol GMZoneTagsObject @end
@interface GMZoneTagsObject : GMObject
@property (nonatomic, assign) NSInteger id;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSString *tagType;
/** 是否是新标签 */
@property (nonatomic, assign) BOOL isNew;
@end
NS_ASSUME_NONNULL_END
//
// GMZoneTagsObject.m
// Gengmei
//
// Created by 卢悦明 on 2020/5/12.
// Copyright © 2020 更美互动信息科技有限公司. All rights reserved.
//
#import "GMZoneTagsObject.h"
@implementation GMZoneTagsObject
@end
//
// NSString+CalculateSize.h
// Gengmei
//
// Created by Q14 on 2019/8/27.
// Copyright © 2019 更美互动信息科技有限公司. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface NSString (CalculateSize)
/**
* 计算文字高度,可以处理计算带行间距的
*/
- (CGSize)boundingRectWithSize:(CGSize)size font:(UIFont*)font lineSpacing:(CGFloat)lineSpacing;
/**
* 计算最大行数文字高度,可以处理计算带行间距的
*/
- (CGFloat)boundingRectWithSize:(CGSize)size font:(UIFont*)font lineSpacing:(CGFloat)lineSpacing maxLines:(NSInteger)maxLines;
/**
* 计算是否超过一行 用于给Label 赋值attribute text的时候 超过一行设置lineSpace
*/
- (BOOL)isMoreThanOneLineWithSize:(CGSize)size font:(UIFont *)font lineSpaceing:(CGFloat)lineSpacing;
@end
NS_ASSUME_NONNULL_END
//
// NSString+CalculateSize.m
// Gengmei
//
// Created by Q14 on 2019/8/27.
// Copyright © 2019 更美互动信息科技有限公司. All rights reserved.
//
#import "NSString+CalculateSize.h"
@implementation NSString (CalculateSize)
/**
* 计算文字高度,可以处理计算带行间距的
*/
- (CGSize)boundingRectWithSize:(CGSize)size font:(UIFont*)font lineSpacing:(CGFloat)lineSpacing {
NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:self];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineSpacing = lineSpacing;
[attributeString addAttribute:NSParagraphStyleAttributeName
value:paragraphStyle
range:NSMakeRange(0, self.length)];
[attributeString addAttribute:NSFontAttributeName
value:font
range:NSMakeRange(0, self.length)];
NSStringDrawingOptions options = NSStringDrawingUsesLineFragmentOrigin |
NSStringDrawingUsesFontLeading;
CGRect rect = [attributeString boundingRectWithSize:size
options:options
context:nil];
//文本的高度减去字体高度小于等于行间距,判断为当前只有1行
if ((rect.size.height - font.lineHeight) <= paragraphStyle.lineSpacing) {
if ([self containChinese:self]) { //如果包含中文
rect = CGRectMake(rect.origin.x,
rect.origin.y,
rect.size.width,
rect.size.height-paragraphStyle.lineSpacing);
}
}
return rect.size;
}
//判断如果包含中文
- (BOOL)containChinese:(NSString *)str {
for(int i = 0; i < [str length]; i++) {
int a = [str characterAtIndex:i];
if(a > 0x4e00 && a < 0x9fff) {
return YES;
}
}
return NO;
}
/**
* 计算最大行数文字高度,可以处理计算带行间距的
*/
- (CGFloat)boundingRectWithSize:(CGSize)size font:(UIFont*)font lineSpacing:(CGFloat)lineSpacing maxLines:(NSInteger)maxLines {
if (maxLines <= 0) {
return 0;
}
CGFloat maxHeight = font.lineHeight * maxLines + lineSpacing * (maxLines - 1);
CGSize orginalSize = [self boundingRectWithSize:size
font:font
lineSpacing:lineSpacing];
if (orginalSize.height >= maxHeight) {
return maxHeight;
} else {
return orginalSize.height;
}
}
/**
* 计算是否超过一行 用于给Label 赋值attribute text的时候 超过一行设置lineSpace
*/
- (BOOL)isMoreThanOneLineWithSize:(CGSize)size font:(UIFont *)font lineSpaceing:(CGFloat)lineSpacing {
if ([self boundingRectWithSize:size font:font lineSpacing:lineSpacing].height > font.lineHeight) {
return YES;
} else {
return NO;
}
}
@end
//
// WMTagView.swift
// test
//
// Created by wangyang on 15/12/8.
// Copyright © 2015年 Wanmiechuangyi. All rights reserved.
//
import UIKit
//import GMBaseSwift
/*
高效的,可以在table及collectionView中使用的tagView。
现在用在了日记本卡片中,以保证首页流畅度。其它地方涉及需求时再改动
*/
@objcMembers
class WYTagView: GMView {
/// 在layoutsubview中使用该属性最后设置self的宽度
var maxWidth: CGFloat = Constant.screenWidth
var tapBlock: ((_ index: Int) -> Void)?
var tags: [String] = [] {
didSet {
for (index, view) in self.subviews.enumerated() {
let label = view as! GMLabel
// 如果视图的index超过数据的长度,则隐藏
if index >= tags.count {
label.isHidden = true
} else {
label.isHidden = false
label.text = tags[index]
}
}
}
}
override func layoutSubviews() {
super.layoutSubviews()
// 如果视图的right已经超过最大宽度,则隐藏
for (index, label) in self.subviews.enumerated() where label.frame.maxX > self.maxWidth {
// 经过产品王昕 确认iOS 如果超出显示...
if index > 0 {
label.isHidden = true
} else {
label.width = self.maxWidth
}
}
}
/// 在初始化方法
///
/// - Parameters:
/// - maxWidth: 最大宽度
/// - maxTagCount: 预估的tag label最大个数
/// - tagSpace: tag之间的距离
/// - customLabelUI: 自定义tag label的UI
convenience init(maxWidth: CGFloat, maxTagCount: Int, tagSpace: CGFloat, customLabelUI: ((GMLabel) -> Void)?) {
self.init()
self.maxWidth = maxWidth
// self不剪切,以显示全部的Label内容。见下面label.centerY的约束
clipsToBounds = false
var preLabel: UIView! = nil
for i in 0..<maxTagCount {
let label = GMLabel(frame: CGRect(x: 0, y: 0, width: self.bounds.size.width, height: self.bounds.size.height))
label.textColor = UIColor.mainVisual
label.font = UIFont.gmFont(13)
label.backgroundColor = UIColor.clear
label.layer.masksToBounds = true
addSubview(label)
label.snp.makeConstraints({ (make) in
if i == 0 {
make.left.equalTo(0)
} else {
make.left.equalTo(preLabel.snp.right).offset(tagSpace)
}
make.centerY.equalToSuperview()
})
preLabel = label
customLabelUI?(label)
}
// 点击手势:注意,是加在self上的,而不是每个label一个
let tap = UITapGestureRecognizer(target: self, action: #selector(WYTagView.tapAction(_:)))
addGestureRecognizer(tap)
}
@objc private func tapAction(_ tap: UITapGestureRecognizer) {
// 因为 pointInside:withEvent已经保证了是点击了tagView,那么剩下只需要判断点击的x是在哪个label范围就行了。
// 所以强制生成一个CGPoint(x: point.x, y: 0),只计算x范围
let point = tap.location(in: self)
for (i, view) in self.subviews.enumerated() {
if view.frame.minX < point.x && view.frame.maxX > point.x {
tapBlock?(i)
break
}
}
}
/// 为tag增加一点热区,主要是y方向,并且只在点击到了subview,才算作命中
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
if gm_point(inside: point, with: event) {
for view in self.subviews {
// 视图没有被隐藏,并且在视图的范围内
if !view.isHidden &&
view.frame.minX < point.x && view.frame.maxX > point.x {
return true
}
}
return false
} else {
return false
}
}
}
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