|
@@ -8,9 +8,18 @@
|
|
|
#import "XSTTPersonalPageHeaderViewController.h"
|
|
|
#import "XSTTUIGeneralHeader.h"
|
|
|
#import <JXHCornerView.h>
|
|
|
+#import "XSTTPersonalPageModel.h"
|
|
|
+#import <UIImageView+WebCache.h>
|
|
|
+#import <JXHGeneralTools.h>
|
|
|
+#import "XSTTBusinessManager.h"
|
|
|
+#import "XSTTNotificationDelegateManager.h"
|
|
|
+#import "UIViewController+XSTTNetworkManager.h"
|
|
|
+#import "XSTTBusinessManager.h"
|
|
|
|
|
|
-@interface XSTTPersonalPageHeaderViewController () {
|
|
|
+@interface XSTTPersonalPageHeaderViewController ()<XSTTNotificationDelegate> {
|
|
|
UIImageView *_backgroundImageView;
|
|
|
+ UIButton *_rightButton;
|
|
|
+ bool _isMine;
|
|
|
}
|
|
|
|
|
|
@end
|
|
@@ -18,12 +27,54 @@
|
|
|
@implementation XSTTPersonalPageHeaderViewController
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
+ _isMine = xstt_userId().userIDValue == _xstt_userId.userIDValue;
|
|
|
[super viewDidLoad];
|
|
|
- // Do any additional setup after loading the view.
|
|
|
+ xstt_setNotificationKey(XSTTLoggingNotificationKey);
|
|
|
+}
|
|
|
+
|
|
|
+- (void)dealloc {
|
|
|
+ xstt_removeNotificationKey(XSTTLoggingNotificationKey);
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - XSTTLoggingNotificationKey
|
|
|
+- (void)xstt_loggingStatusChanged:(XSTTLoggingStatus)status {
|
|
|
+ _isMine = xstt_userId().userIDValue == _xstt_userId.userIDValue;
|
|
|
+ if (_rightButton) {
|
|
|
+ [self setRightButton];
|
|
|
+ [_rightButton makeConstraints:^(JXHConstraintMaker *make) {
|
|
|
+ make.size.update((CGSize){self->_isMine ? 84 : 76, 36});
|
|
|
+ }];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#pragma mark - Action
|
|
|
+- (void)rightButtonAction:(UIButton *)sender {
|
|
|
+ if (_isMine) {
|
|
|
+ xstt_needLogin(^{
|
|
|
+ xstt_publishSocialCircleAction(self, nil);
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ xstt_needLogin(^{
|
|
|
+ [self followAction];
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - Network Action
|
|
|
+- (void)followAction {
|
|
|
+ bool isFollow = _xstt_data.xstt_focus.boolValue;
|
|
|
+ [self networkUseMethod:XSTTNetworkMethodPOST loadingTips:isFollow ? @"正在取消关注" : @"正在关注" isLogin:true signKey:XSTTNetworkSignKeyApp url:xstt_appUrl(isFollow ? XSTTURLUnfollow : XSTTURLFollow) urlParameters:nil parameters:^NSDictionary * _Nonnull{
|
|
|
+ if (isFollow) return @{@"unfocusUserId": self->_xstt_userId};
|
|
|
+ return @{@"focusUserId": self->_xstt_userId};
|
|
|
+ } success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
|
|
|
+ self->_xstt_data.xstt_focus = [NSString stringWithFormat:@"%d", !isFollow];
|
|
|
+ self->_rightButton.selected = !isFollow;
|
|
|
+ return @"";
|
|
|
+ } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
|
|
|
+ return isFollow ? @"取消关注失败" : @"关注失败";
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - Overwrite
|
|
|
- (void)setUI {
|
|
|
[super setUI];
|
|
@@ -50,6 +101,16 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+- (void)setRightButton {
|
|
|
+ if (_isMine) {
|
|
|
+ [_rightButton setTitle:@"发布动态" titleColor:xstt_FFFFFF_color(1.f) image:nil backgroundImage:jxh_createImage(xstt_FF5700_color(), (CGSize){10, 10}) state:JXHButtonControlStateNormal];
|
|
|
+ } else {
|
|
|
+ [_rightButton setTitle:@"关注" titleColor:xstt_FFFFFF_color(1.f) image:nil backgroundImage:jxh_createImage(xstt_FF5700_color(), (CGSize){10, 10}) state:JXHButtonControlStateNormal | JXHButtonControlStateHighlighted];
|
|
|
+ [_rightButton setTitle:@"已关注" titleColor:xstt_000000_color(0.4) image:nil backgroundImage:jxh_createImage(xstt_F5F6F9_color(), (CGSize){10, 10}) state:JXHButtonControlStateSelected | JXHButtonControlStateSelectedAndHighlighted];
|
|
|
+ _rightButton.selected = _xstt_data.xstt_focus.boolValue;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
- (void)createContentView {
|
|
|
JXHCornerView *contentView = JXHCornerView.new;
|
|
|
[contentView setCornerWithRadius:12 position:JXHCornerPositionMake(true, true, false, false) backgroundColor:xstt_FFFFFF_color(1.f)];
|
|
@@ -71,15 +132,26 @@
|
|
|
}];
|
|
|
|
|
|
UIImageView *avatar = UIImageView.new;
|
|
|
- avatar.image = jxh_getImage(默认头像);
|
|
|
+ [avatar sd_setImageWithURL:[NSURL URLWithString:_xstt_data.xstt_headImg]];
|
|
|
[avatarBG addSubview:avatar];
|
|
|
- [avatar setLayerCornerRadius:40 clipToBounds:false];
|
|
|
+ [avatar setLayerCornerRadius:40 clipToBounds:true];
|
|
|
[avatar makeConstraints:^(JXHConstraintMaker *make) {
|
|
|
make.center.equalTo(0);
|
|
|
make.size.equalTo(80);
|
|
|
}];
|
|
|
|
|
|
- UILabel *name = [UILabel convenienceWithFont:xstt_mediumFont(19) text:@"和酒做朋友" textColor:xstt_000000_color(0.87)];
|
|
|
+ _rightButton = [UIButton convenienceWithFont:xstt_semiboldFont(14) target:self action:@selector(rightButtonAction:)];
|
|
|
+ [self setRightButton];
|
|
|
+ [_rightButton setLayerCornerRadius:18 clipToBounds:true];
|
|
|
+ [contentView addSubview:_rightButton];
|
|
|
+ [_rightButton makeConstraints:^(JXHConstraintMaker *make) {
|
|
|
+ make.trailing.equalTo(-16);
|
|
|
+ make.top.equalTo(16);
|
|
|
+ make.size.equalTo((CGSize){self->_isMine ? 84 : 76, 36});
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+ UILabel *name = [UILabel convenienceWithFont:xstt_mediumFont(19) text:_xstt_data.xstt_nickName textColor:xstt_000000_color(0.87)];
|
|
|
[contentView addSubview:name];
|
|
|
[name makeConstraints:^(JXHConstraintMaker *make) {
|
|
|
make.leading.equalTo(XSTTMargin);
|
|
@@ -87,10 +159,10 @@
|
|
|
make.trailing.lessThanOrEqualTo(-XSTTMargin);
|
|
|
}];
|
|
|
|
|
|
- NSArray *data = @[@"粉丝", @"关注", @"转评赞"];
|
|
|
+ NSArray *data = @[@"粉丝", @"关注", @"转评赞", _xstt_data.xstt_fansNum, _xstt_data.xstt_focusNum, _xstt_data.xstt_commAndLike];
|
|
|
UIView *tempView = nil;
|
|
|
- for (NSInteger i = 0; i < data.count; i ++) {
|
|
|
- UILabel *num = [UILabel convenienceWithFont:xstt_mediumFont(15) text:@"8080" textColor:xstt_000000_color(0.8)];
|
|
|
+ for (NSInteger i = 0; i < data.count / 2; i ++) {
|
|
|
+ UILabel *num = [UILabel convenienceWithFont:xstt_mediumFont(15) text:data[i + 3] textColor:xstt_000000_color(0.8)];
|
|
|
[contentView addSubview:num];
|
|
|
[num makeConstraints:^(JXHConstraintMaker *make) {
|
|
|
if (tempView) {
|
|
@@ -105,11 +177,11 @@
|
|
|
[contentView addSubview:title];
|
|
|
[title makeConstraints:^(JXHConstraintMaker *make) {
|
|
|
make.leading.equalTo(num.trailing).offset(4);
|
|
|
- make.bottom.equalTo(-22);
|
|
|
+ make.centerY.equalTo(num);
|
|
|
}];
|
|
|
|
|
|
tempView = title;
|
|
|
- if (i < data.count - 1) {
|
|
|
+ if (i < data.count / 2 - 1) {
|
|
|
UIView *line = UIView.new;
|
|
|
line.backgroundColor = xstt_000000_color(0.12);
|
|
|
[contentView addSubview:line];
|
|
@@ -128,7 +200,7 @@
|
|
|
_backgroundImageView = UIImageView.new;
|
|
|
_backgroundImageView.backgroundColor = xstt_F7F7F7_color();
|
|
|
_backgroundImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
|
- _backgroundImageView.image = jxh_getImage(默认头像);
|
|
|
+ [_backgroundImageView sd_setImageWithURL:[NSURL URLWithString:_xstt_data.xstt_bg]];
|
|
|
// _backgroundImageView.clipsToBounds = true;
|
|
|
[self.jxh_contentView addSubview:_backgroundImageView];
|
|
|
[_backgroundImageView makeConstraints:^(JXHConstraintMaker *make) {
|