123 lines
2.8 KiB
Objective-C
123 lines
2.8 KiB
Objective-C
//
|
|
// User.m
|
|
// BabyAlbum
|
|
//
|
|
// Created by mambaxie on 2021/7/27.
|
|
//
|
|
|
|
#import "User.h"
|
|
|
|
NSString * const AppReviewVipTimeKey = @"AppReviewVipTimeKey";
|
|
NSUInteger const SecurityCodeLength = 6;
|
|
@implementation UserOtherInfo
|
|
|
|
- (BOOL)isVIP {
|
|
return _vip_kind > VIPKindNone;
|
|
}
|
|
|
|
- (void)updateFollowState:(BOOL)isFollow {
|
|
if (isFollow) {
|
|
if (self.relation == RelationTypeFollower) {
|
|
self.relation = RelationTypeFriends;
|
|
} else {
|
|
self.relation = RelationTypeFollowing;
|
|
}
|
|
} else {
|
|
if (self.relation == RelationTypeFriends) {
|
|
self.relation = RelationTypeFollower;
|
|
} else {
|
|
self.relation = RelationTypeNone;
|
|
}
|
|
}
|
|
}
|
|
|
|
- (BOOL)isFollowing {
|
|
return self.relation == RelationTypeFollowing || self.relation == RelationTypeFriends;
|
|
}
|
|
|
|
- (UIImage *)genderImage {
|
|
return [User genderImageWithGenderStr:self.gender_str];
|
|
}
|
|
|
|
|
|
@end
|
|
|
|
@implementation User
|
|
|
|
MJCodingImplementation
|
|
|
|
+ (NSDictionary *)mj_replacedKeyFromPropertyName {
|
|
return @{@"ID": @"id",};
|
|
}
|
|
|
|
- (NSString *)location {
|
|
if (self.province.length && self.city.length && self.district.length) {
|
|
return [NSString stringWithFormat:@"%@-%@-%@", self.province, self.city, self.district];
|
|
}
|
|
return nil;
|
|
}
|
|
|
|
- (BOOL)isSelf {
|
|
return self.ID == [UserService currentUser].ID;
|
|
}
|
|
|
|
- (NSString *)introduce {
|
|
return _introduce.length > 0 ? _introduce : _intro;
|
|
}
|
|
|
|
- (BOOL)isVIP {
|
|
return _vip_kind > VIPKindNone;
|
|
}
|
|
|
|
- (void)updateFollowState:(BOOL)isFollow {
|
|
if (isFollow) {
|
|
if (self.relation == RelationTypeFollower) {
|
|
self.relation = RelationTypeFriends;
|
|
} else {
|
|
self.relation = RelationTypeFollowing;
|
|
}
|
|
} else {
|
|
if (self.relation == RelationTypeFriends) {
|
|
self.relation = RelationTypeFollower;
|
|
} else {
|
|
self.relation = RelationTypeNone;
|
|
}
|
|
}
|
|
}
|
|
|
|
- (BOOL)isFollowing {
|
|
return self.relation == RelationTypeFollowing || self.relation == RelationTypeFriends;
|
|
}
|
|
|
|
- (UIImage *)genderImage {
|
|
return [User genderImageWithGenderStr:self.gender_str];
|
|
}
|
|
|
|
- (UIColor *)genderColor {
|
|
return @{
|
|
@"CD": COLOR_WITH_RGB(0xFFFFFF),
|
|
@"ZN": COLOR_WITH_RGB(0x3DC5FF),
|
|
@"TS": COLOR_WITH_RGB(0xFF4C73)
|
|
}[_gender_str];
|
|
}
|
|
|
|
- (UIColor *)genderBGColor {
|
|
return @{
|
|
@"CD": COLOR_WITH_RGB_A(0xFFFFFF, 0.5),
|
|
@"ZN": COLOR_WITH_RGB_A(0x3DC5FF, 0.5),
|
|
@"TS": COLOR_WITH_RGB_A(0xFF4C73, 0.5)
|
|
}[_gender_str];
|
|
}
|
|
|
|
+ (CGSize)genderSize {
|
|
return CGSizeMake(FIX_SIZE(26), FIX_SIZE(16));
|
|
}
|
|
|
|
+ (UIImage *)genderImageWithGenderStr:(NSString *)genderStr {
|
|
NSString *imgName = [NSString stringWithFormat:@"TH_%@_tag", [genderStr lowercaseString]];
|
|
return ImageNamed(imgName);
|
|
// return ImageNamed([[genderStr lowercaseString] stringByAppendingString:@"_tag"]);
|
|
}
|
|
|
|
@end
|