diff --git a/YuMi/Appdelegate/AppDelegate.m b/YuMi/Appdelegate/AppDelegate.m index 82fe456a..94408d4a 100644 --- a/YuMi/Appdelegate/AppDelegate.m +++ b/YuMi/Appdelegate/AppDelegate.m @@ -37,7 +37,6 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; [UMConfigure initWithAppkey:@"6434c6dfd64e686139618269" channel:@"yumi_appstore"]; } [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions]; - [FIRApp configure]; return YES; } diff --git a/YuMi/Assets.xcassets/Monents/mine_dynamic.imageset/Contents.json b/YuMi/Assets.xcassets/Monents/mine_dynamic.imageset/Contents.json new file mode 100644 index 00000000..8a5773df --- /dev/null +++ b/YuMi/Assets.xcassets/Monents/mine_dynamic.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "mine_dynamic@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "mine_dynamic@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/YuMi/Assets.xcassets/Monents/mine_dynamic.imageset/mine_dynamic@2x.png b/YuMi/Assets.xcassets/Monents/mine_dynamic.imageset/mine_dynamic@2x.png new file mode 100644 index 00000000..ba002e41 Binary files /dev/null and b/YuMi/Assets.xcassets/Monents/mine_dynamic.imageset/mine_dynamic@2x.png differ diff --git a/YuMi/Assets.xcassets/Monents/mine_dynamic.imageset/mine_dynamic@3x.png b/YuMi/Assets.xcassets/Monents/mine_dynamic.imageset/mine_dynamic@3x.png new file mode 100644 index 00000000..d62d1fb5 Binary files /dev/null and b/YuMi/Assets.xcassets/Monents/mine_dynamic.imageset/mine_dynamic@3x.png differ diff --git a/YuMi/Assets.xcassets/Monents/monents_info_topic_icon.imageset/monents_info_topic_icon@2x.png b/YuMi/Assets.xcassets/Monents/monents_info_topic_icon.imageset/monents_info_topic_icon@2x.png index 688dd76f..669a17e9 100644 Binary files a/YuMi/Assets.xcassets/Monents/monents_info_topic_icon.imageset/monents_info_topic_icon@2x.png and b/YuMi/Assets.xcassets/Monents/monents_info_topic_icon.imageset/monents_info_topic_icon@2x.png differ diff --git a/YuMi/Assets.xcassets/Monents/monents_info_topic_icon.imageset/monents_info_topic_icon@3x.png b/YuMi/Assets.xcassets/Monents/monents_info_topic_icon.imageset/monents_info_topic_icon@3x.png index 3013f4c2..b89f23e0 100644 Binary files a/YuMi/Assets.xcassets/Monents/monents_info_topic_icon.imageset/monents_info_topic_icon@3x.png and b/YuMi/Assets.xcassets/Monents/monents_info_topic_icon.imageset/monents_info_topic_icon@3x.png differ diff --git a/YuMi/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/monents_nav_interavtive_message@2x.png b/YuMi/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/monents_nav_interavtive_message@2x.png index c35b7521..3fba2664 100644 Binary files a/YuMi/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/monents_nav_interavtive_message@2x.png and b/YuMi/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/monents_nav_interavtive_message@2x.png differ diff --git a/YuMi/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/monents_nav_interavtive_message@3x.png b/YuMi/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/monents_nav_interavtive_message@3x.png index 61dfc062..6197d560 100644 Binary files a/YuMi/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/monents_nav_interavtive_message@3x.png and b/YuMi/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/monents_nav_interavtive_message@3x.png differ diff --git a/YuMi/Assets.xcassets/Monents/monents_on_line_bg.imageset/Contents.json b/YuMi/Assets.xcassets/Monents/monents_on_line_bg.imageset/Contents.json new file mode 100644 index 00000000..77998810 --- /dev/null +++ b/YuMi/Assets.xcassets/Monents/monents_on_line_bg.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "monents_on_line_bg@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "monents_on_line_bg@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/YuMi/Assets.xcassets/Monents/monents_on_line_bg.imageset/monents_on_line_bg@2x.png b/YuMi/Assets.xcassets/Monents/monents_on_line_bg.imageset/monents_on_line_bg@2x.png new file mode 100644 index 00000000..9f42cc4c Binary files /dev/null and b/YuMi/Assets.xcassets/Monents/monents_on_line_bg.imageset/monents_on_line_bg@2x.png differ diff --git a/YuMi/Assets.xcassets/Monents/monents_on_line_bg.imageset/monents_on_line_bg@3x.png b/YuMi/Assets.xcassets/Monents/monents_on_line_bg.imageset/monents_on_line_bg@3x.png new file mode 100644 index 00000000..b6383e2c Binary files /dev/null and b/YuMi/Assets.xcassets/Monents/monents_on_line_bg.imageset/monents_on_line_bg@3x.png differ diff --git a/YuMi/Assets.xcassets/Monents/monents_on_line_note.imageset/Contents.json b/YuMi/Assets.xcassets/Monents/monents_on_line_note.imageset/Contents.json new file mode 100644 index 00000000..7aa28d85 --- /dev/null +++ b/YuMi/Assets.xcassets/Monents/monents_on_line_note.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "monents_on_line_note@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "monents_on_line_note@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/YuMi/Assets.xcassets/Monents/monents_on_line_note.imageset/monents_on_line_note@2x.png b/YuMi/Assets.xcassets/Monents/monents_on_line_note.imageset/monents_on_line_note@2x.png new file mode 100644 index 00000000..ff4960d3 Binary files /dev/null and b/YuMi/Assets.xcassets/Monents/monents_on_line_note.imageset/monents_on_line_note@2x.png differ diff --git a/YuMi/Assets.xcassets/Monents/monents_on_line_note.imageset/monents_on_line_note@3x.png b/YuMi/Assets.xcassets/Monents/monents_on_line_note.imageset/monents_on_line_note@3x.png new file mode 100644 index 00000000..38d5cfbd Binary files /dev/null and b/YuMi/Assets.xcassets/Monents/monents_on_line_note.imageset/monents_on_line_note@3x.png differ diff --git a/YuMi/Assets.xcassets/Monents/monents_publish.imageset/monents_publish@2x.png b/YuMi/Assets.xcassets/Monents/monents_publish.imageset/monents_publish@2x.png index a4496b51..f912e35f 100644 Binary files a/YuMi/Assets.xcassets/Monents/monents_publish.imageset/monents_publish@2x.png and b/YuMi/Assets.xcassets/Monents/monents_publish.imageset/monents_publish@2x.png differ diff --git a/YuMi/Assets.xcassets/Monents/monents_publish.imageset/monents_publish@3x.png b/YuMi/Assets.xcassets/Monents/monents_publish.imageset/monents_publish@3x.png index 000f93db..7aa5118c 100644 Binary files a/YuMi/Assets.xcassets/Monents/monents_publish.imageset/monents_publish@3x.png and b/YuMi/Assets.xcassets/Monents/monents_publish.imageset/monents_publish@3x.png differ diff --git a/YuMi/Modules/YMLogin/Presenter/LoginPresenter.m b/YuMi/Modules/YMLogin/Presenter/LoginPresenter.m index a4b6d396..eee4d816 100644 --- a/YuMi/Modules/YMLogin/Presenter/LoginPresenter.m +++ b/YuMi/Modules/YMLogin/Presenter/LoginPresenter.m @@ -32,34 +32,24 @@ - (instancetype)init{ self = [super init]; if(self){ - [FBSDKProfile enableUpdatesOnAccessTokenChange:YES]; + + @weakify(self); [[NSNotificationCenter defaultCenter] addObserverForName:FBSDKProfileDidChangeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock: ^(NSNotification *notification) { - + @strongify(self); if ([FBSDKProfile currentProfile]) { - - //获取当前用户名 [FBSDKProfile loadCurrentProfileWithCompletion: ^(FBSDKProfile *profile, NSError *error) { if (profile) { - ThirdUserInfo * userInfo = [[ThirdUserInfo alloc] init]; - NSString * openid = profile.userID; - NSString * access_token = profile.userID; - NSString * unionid = profile.userID; - userInfo.openid = openid; - userInfo.access_token = access_token; - userInfo.unionid = unionid; - userInfo.userName = profile.name; - userInfo.avatarUrl = profile.imageURL.absoluteString; - [AccountInfoStorage instance].thirdUserInfo = userInfo; + [AccountInfoStorage instance].thirdUserInfo.userName = profile.name; + [AccountInfoStorage instance].thirdUserInfo.avatarUrl = profile.imageURL.absoluteString; [self loginWithThirdPartWithType:ThirdLoginType_FB]; } }]; - } }]; @@ -171,6 +161,8 @@ } -(void)thirdLoginByFBWithPresentingViewController:(UIViewController *)presentingViewController { + [FBSDKProfile enableUpdatesOnAccessTokenChange:YES]; + [FBSDKAccessToken setCurrentAccessToken:nil]; FBSDKLoginManager *manager = [[FBSDKLoginManager alloc] init]; [manager logOut]; [manager logInWithPermissions:@[@"public_profile"] @@ -181,7 +173,11 @@ } else if (result.isCancelled) { [[self getView] showErrorToast:YMLocalizedString(@"LoginPresenter0")]; } else { - NSLog(@"Logged in"); + ThirdUserInfo * userInfo = [[ThirdUserInfo alloc] init]; + userInfo.openid = result.token.userID; + userInfo.access_token = result.token.tokenString; + userInfo.unionid = result.token.userID; + [AccountInfoStorage instance].thirdUserInfo = userInfo; } }]; } diff --git a/YuMi/Modules/YMMine/View/Guild/Api/Api+Guild.m b/YuMi/Modules/YMMine/View/Guild/Api/Api+Guild.m index c5c03378..b33778b3 100644 --- a/YuMi/Modules/YMMine/View/Guild/Api/Api+Guild.m +++ b/YuMi/Modules/YMMine/View/Guild/Api/Api+Guild.m @@ -190,7 +190,6 @@ /// 公会个播收入列表 /// @param completion 完成 /// @param uid 用户的uid -/// @param hallId 公会的id /// @param startTime 开始时间 /// @param endTime 结束时间 + (void)getHallSingleRoomIncomeRecord:(HttpRequestHelperCompletion)completion uid:(NSString *)uid clanId:(NSString *)clanId startTime:(NSString *)startTime endTime:(NSString *)endTime { diff --git a/YuMi/Modules/YMMonents/Api/Api+Monents.h b/YuMi/Modules/YMMonents/Api/Api+Monents.h index 672edbf3..708f9d19 100644 --- a/YuMi/Modules/YMMonents/Api/Api+Monents.h +++ b/YuMi/Modules/YMMonents/Api/Api+Monents.h @@ -167,6 +167,10 @@ NS_ASSUME_NONNULL_BEGIN /// @param completion 完成 /// @param uid uid + (void)monentsUnReadCount:(HttpRequestHelperCompletion)completion uid:(NSString *)uid; +/// 屏蔽 +/// @param completion 完成 +/// @param type type为0 => 屏蔽动态, objId 为 动态id, type为1 => 屏蔽房间, objId 为 用户uid ++ (void)requesstShielding:(HttpRequestHelperCompletion)completion type:(NSString *)type objId:(NSString *)objId; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMonents/Api/Api+Monents.m b/YuMi/Modules/YMMonents/Api/Api+Monents.m index 842c68e0..2bd4ba1e 100644 --- a/YuMi/Modules/YMMonents/Api/Api+Monents.m +++ b/YuMi/Modules/YMMonents/Api/Api+Monents.m @@ -273,5 +273,10 @@ NSString * fang = [NSString stringFromBase64String:@"aW50ZXJhY3RpdmUvdW5yZWFkQ291bnQ="];///interactive/unreadCount [self makeRequest:fang method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, uid, nil]; } - +/// 屏蔽 +/// @param completion 完成 +/// @param type type为0 => 屏蔽动态, objId 为 动态id, type为1 => 屏蔽房间, objId 为 用户uid ++ (void)requesstShielding:(HttpRequestHelperCompletion)completion type:(NSString *)type objId:(NSString *)objId{ + [self makeRequest:[NSString stringWithFormat:@"%@%@%@",@"user/",@"black/",@"add"] method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, type,objId, nil]; +} @end diff --git a/YuMi/Modules/YMMonents/Model/MonentsInfoModel.h b/YuMi/Modules/YMMonents/Model/MonentsInfoModel.h index bdca6aa8..4bf7b511 100644 --- a/YuMi/Modules/YMMonents/Model/MonentsInfoModel.h +++ b/YuMi/Modules/YMMonents/Model/MonentsInfoModel.h @@ -1,19 +1,19 @@ // // MonentsInfoModel.h -// YUMI +// xplan-ios // -// Created by YUMI on 2022/5/11. +// Created by 冯硕 on 2022/5/11. // #import -#import "YUMINNNN.h" + #import "UserVipInfoVo.h" NS_ASSUME_NONNULL_BEGIN typedef NS_ENUM(NSInteger, MonentsContentType) { - ///纯文字的 - MonentsContentType_Text = 0, - ///图片 - MonentsContentType_Picture = 2 + ///纯文字的 + MonentsContentType_Text = 0, + ///图片 + MonentsContentType_Picture = 2 }; @class MonentsPicInfoModel; @interface MonentsInfoModel : NSObject @@ -47,8 +47,10 @@ typedef NS_ENUM(NSInteger, MonentsContentType) { @property (nonatomic,strong) NSString *experLevelPic; ///魅力等级 @property (nonatomic,strong) NSString *charmLevelPic; -///是否置顶 +///广场是否置顶 @property (nonatomic,assign) BOOL squareTop; +///话题是否置顶 +@property (nonatomic,assign) BOOL topicTop; ///贵族信息 @property (nonatomic, strong) UserVipInfoVo *userVipInfoVO; ///发布的内容 diff --git a/YuMi/Modules/YMMonents/Model/MonentsInfoModel.m b/YuMi/Modules/YMMonents/Model/MonentsInfoModel.m index 0fd0bf7b..8d1f9a6f 100644 --- a/YuMi/Modules/YMMonents/Model/MonentsInfoModel.m +++ b/YuMi/Modules/YMMonents/Model/MonentsInfoModel.m @@ -1,8 +1,8 @@ // // MonentsInfoModel.m -// YUMI +// xplan-ios // -// Created by YUMI on 2022/5/11. +// Created by 冯硕 on 2022/5/11. // #import "MonentsInfoModel.h" @@ -10,14 +10,14 @@ @implementation MonentsInfoModel - (instancetype)init { - if (self = [super init]) { - self.isFold = YES; - } - return self; + if (self = [super init]) { + self.isFold = YES; + } + return self; } + (NSDictionary *)objectClassInArray { - return @{@"dynamicResList":MonentsPicInfoModel.class}; + return @{@"dynamicResList":MonentsPicInfoModel.class}; } @end diff --git a/YuMi/Modules/YMMonents/Presenter/XPMonentDetailPresenter.h b/YuMi/Modules/YMMonents/Presenter/XPMonentDetailPresenter.h index 290c1b4f..f86ebfc4 100644 --- a/YuMi/Modules/YMMonents/Presenter/XPMonentDetailPresenter.h +++ b/YuMi/Modules/YMMonents/Presenter/XPMonentDetailPresenter.h @@ -43,6 +43,7 @@ NS_ASSUME_NONNULL_BEGIN /// @param dynamicId 动态的id /// @param content 评论的内容 - (void)commontMonents:(NSString *)dynamicId content:(NSString *)content; +- (void)requesstShieldingWtihType:(NSString *)type objId:(NSString *)objId; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMonents/Presenter/XPMonentDetailPresenter.m b/YuMi/Modules/YMMonents/Presenter/XPMonentDetailPresenter.m index bd39d626..97c4ee19 100644 --- a/YuMi/Modules/YMMonents/Presenter/XPMonentDetailPresenter.m +++ b/YuMi/Modules/YMMonents/Presenter/XPMonentDetailPresenter.m @@ -94,6 +94,11 @@ [[self getView] replyMonentsSuccess]; }] uid:uid dynamicId:dynamicId content:content commentId:commonId]; } +- (void)requesstShieldingWtihType:(NSString *)type objId:(NSString *)objId{ + [Api requesstShielding:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] requesstShieldingSuccess:objId]; + }] type:type objId:objId]; +} diff --git a/YuMi/Modules/YMMonents/Presenter/XPMonentsAttentionPresenter.h b/YuMi/Modules/YMMonents/Presenter/XPMonentsAttentionPresenter.h index 234a3931..c15ab2c8 100644 --- a/YuMi/Modules/YMMonents/Presenter/XPMonentsAttentionPresenter.h +++ b/YuMi/Modules/YMMonents/Presenter/XPMonentsAttentionPresenter.h @@ -28,7 +28,8 @@ NS_ASSUME_NONNULL_BEGIN /// @param dynamicId 动态id /// @param worldId 话题id - (void)deleteMonents:(NSString *)dynamicId worldId:(NSString *)worldId; - +///屏蔽动态 +- (void)requesstShieldingWtihType:(NSString *)type objId:(NSString *)objId; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMonents/Presenter/XPMonentsAttentionPresenter.m b/YuMi/Modules/YMMonents/Presenter/XPMonentsAttentionPresenter.m index d78b88a6..ae6603cc 100644 --- a/YuMi/Modules/YMMonents/Presenter/XPMonentsAttentionPresenter.m +++ b/YuMi/Modules/YMMonents/Presenter/XPMonentsAttentionPresenter.m @@ -52,5 +52,9 @@ } uid:uid dynamicId:dynamicId worldId:worldId]; } - +- (void)requesstShieldingWtihType:(NSString *)type objId:(NSString *)objId{ + [Api requesstShielding:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] requesstShieldingSuccess:objId]; + }] type:type objId:objId]; +} @end diff --git a/YuMi/Modules/YMMonents/Presenter/XPMonentsLatestPresenter.h b/YuMi/Modules/YMMonents/Presenter/XPMonentsLatestPresenter.h index 187a49c7..33d4dfa6 100644 --- a/YuMi/Modules/YMMonents/Presenter/XPMonentsLatestPresenter.h +++ b/YuMi/Modules/YMMonents/Presenter/XPMonentsLatestPresenter.h @@ -28,6 +28,9 @@ NS_ASSUME_NONNULL_BEGIN /// @param dynamicId 动态id /// @param worldId 话题id - (void)deleteMonents:(NSString *)dynamicId worldId:(NSString *)worldId; + +- (void)requesstShieldingWtihType:(NSString *)type objId:(NSString *)objId; + @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMonents/Presenter/XPMonentsLatestPresenter.m b/YuMi/Modules/YMMonents/Presenter/XPMonentsLatestPresenter.m index 7adfa351..432003aa 100644 --- a/YuMi/Modules/YMMonents/Presenter/XPMonentsLatestPresenter.m +++ b/YuMi/Modules/YMMonents/Presenter/XPMonentsLatestPresenter.m @@ -51,5 +51,9 @@ [[self getView] deleteMonentsSuccess:dynamicId]; } uid:uid dynamicId:dynamicId worldId:worldId]; } - +- (void)requesstShieldingWtihType:(NSString *)type objId:(NSString *)objId{ + [Api requesstShielding:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] requesstShieldingSuccess:objId]; + }] type:type objId:objId]; +} @end diff --git a/YuMi/Modules/YMMonents/Presenter/XPMonentsRecommendPresenter.h b/YuMi/Modules/YMMonents/Presenter/XPMonentsRecommendPresenter.h index ed89597c..3927531a 100644 --- a/YuMi/Modules/YMMonents/Presenter/XPMonentsRecommendPresenter.h +++ b/YuMi/Modules/YMMonents/Presenter/XPMonentsRecommendPresenter.h @@ -32,6 +32,9 @@ NS_ASSUME_NONNULL_BEGIN /// @param dynamicId 动态id /// @param worldId 话题id - (void)deleteMonents:(NSString *)dynamicId worldId:(NSString *)worldId; +///屏蔽 +- (void)requesstShieldingWtihType:(NSString *)type objId:(NSString *)objId; + @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMonents/Presenter/XPMonentsRecommendPresenter.m b/YuMi/Modules/YMMonents/Presenter/XPMonentsRecommendPresenter.m index e1683435..73996732 100644 --- a/YuMi/Modules/YMMonents/Presenter/XPMonentsRecommendPresenter.m +++ b/YuMi/Modules/YMMonents/Presenter/XPMonentsRecommendPresenter.m @@ -65,5 +65,9 @@ [[self getView] deleteMonentsSuccess:dynamicId]; } uid:uid dynamicId:dynamicId worldId:worldId]; } - +- (void)requesstShieldingWtihType:(NSString *)type objId:(NSString *)objId{ + [Api requesstShielding:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] requesstShieldingSuccess:objId]; + }] type:type objId:objId]; +} @end diff --git a/YuMi/Modules/YMMonents/Presenter/XPMonentsTopicLatestPresenter.h b/YuMi/Modules/YMMonents/Presenter/XPMonentsTopicLatestPresenter.h index 4ff93272..e63ac131 100644 --- a/YuMi/Modules/YMMonents/Presenter/XPMonentsTopicLatestPresenter.h +++ b/YuMi/Modules/YMMonents/Presenter/XPMonentsTopicLatestPresenter.h @@ -23,6 +23,7 @@ NS_ASSUME_NONNULL_BEGIN /// @param dynamicId 动态id /// @param worldId 话题id - (void)deleteMonents:(NSString *)dynamicId worldId:(NSString *)worldId; +- (void)requesstShieldingWtihType:(NSString *)type objId:(NSString *)objId; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMonents/Presenter/XPMonentsTopicLatestPresenter.m b/YuMi/Modules/YMMonents/Presenter/XPMonentsTopicLatestPresenter.m index 33bd29b0..c2ca0a16 100644 --- a/YuMi/Modules/YMMonents/Presenter/XPMonentsTopicLatestPresenter.m +++ b/YuMi/Modules/YMMonents/Presenter/XPMonentsTopicLatestPresenter.m @@ -44,5 +44,9 @@ [[self getView] deleteMonentsSuccess:dynamicId]; } uid:uid dynamicId:dynamicId worldId:worldId]; } - +- (void)requesstShieldingWtihType:(NSString *)type objId:(NSString *)objId{ + [Api requesstShielding:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] requesstShieldingSuccess:objId]; + }] type:type objId:objId]; +} @end diff --git a/YuMi/Modules/YMMonents/Presenter/XPMonentsTopicRecommendPresenter.h b/YuMi/Modules/YMMonents/Presenter/XPMonentsTopicRecommendPresenter.h index 14a5ccf3..681fd227 100644 --- a/YuMi/Modules/YMMonents/Presenter/XPMonentsTopicRecommendPresenter.h +++ b/YuMi/Modules/YMMonents/Presenter/XPMonentsTopicRecommendPresenter.h @@ -23,6 +23,7 @@ NS_ASSUME_NONNULL_BEGIN /// @param dynamicId 动态id /// @param worldId 话题id - (void)deleteMonents:(NSString *)dynamicId worldId:(NSString *)worldId; +- (void)requesstShieldingWtihType:(NSString *)type objId:(NSString *)objId; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMonents/Presenter/XPMonentsTopicRecommendPresenter.m b/YuMi/Modules/YMMonents/Presenter/XPMonentsTopicRecommendPresenter.m index 47c31995..0452b783 100644 --- a/YuMi/Modules/YMMonents/Presenter/XPMonentsTopicRecommendPresenter.m +++ b/YuMi/Modules/YMMonents/Presenter/XPMonentsTopicRecommendPresenter.m @@ -44,4 +44,9 @@ [[self getView] deleteMonentsSuccess:dynamicId]; } uid:uid dynamicId:dynamicId worldId:worldId]; } +- (void)requesstShieldingWtihType:(NSString *)type objId:(NSString *)objId{ + [Api requesstShielding:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] requesstShieldingSuccess:objId]; + }] type:type objId:objId]; +} @end diff --git a/YuMi/Modules/YMMonents/Protocol/XPMonentsAttentionProtocol.h b/YuMi/Modules/YMMonents/Protocol/XPMonentsAttentionProtocol.h index 1c8926d3..45a52284 100644 --- a/YuMi/Modules/YMMonents/Protocol/XPMonentsAttentionProtocol.h +++ b/YuMi/Modules/YMMonents/Protocol/XPMonentsAttentionProtocol.h @@ -20,6 +20,8 @@ NS_ASSUME_NONNULL_BEGIN ///删除话题成功 - (void)deleteMonentsSuccess:(NSString *)monentsInfo; +///屏蔽 +- (void)requesstShieldingSuccess:(NSString *)monentsInfo; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMonents/Protocol/XPMonentsDetailProtocol.h b/YuMi/Modules/YMMonents/Protocol/XPMonentsDetailProtocol.h index 1864a81f..fd060c71 100644 --- a/YuMi/Modules/YMMonents/Protocol/XPMonentsDetailProtocol.h +++ b/YuMi/Modules/YMMonents/Protocol/XPMonentsDetailProtocol.h @@ -28,6 +28,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)commonMonentsSuccess; ///回复某人评论成功 - (void)replyMonentsSuccess; +///屏蔽 +- (void)requesstShieldingSuccess:(NSString *)monentsInfo; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMonents/Protocol/XPMonentsLatestProtocol.h b/YuMi/Modules/YMMonents/Protocol/XPMonentsLatestProtocol.h index 5c86abd3..122b369d 100644 --- a/YuMi/Modules/YMMonents/Protocol/XPMonentsLatestProtocol.h +++ b/YuMi/Modules/YMMonents/Protocol/XPMonentsLatestProtocol.h @@ -19,6 +19,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status; ///删除话题成功 - (void)deleteMonentsSuccess:(NSString *)monentsInfo; +///屏蔽 +- (void)requesstShieldingSuccess:(NSString *)monentsInfo; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMonents/Protocol/XPMonentsRecommendProtocol.h b/YuMi/Modules/YMMonents/Protocol/XPMonentsRecommendProtocol.h index b2d07919..b24374ae 100644 --- a/YuMi/Modules/YMMonents/Protocol/XPMonentsRecommendProtocol.h +++ b/YuMi/Modules/YMMonents/Protocol/XPMonentsRecommendProtocol.h @@ -22,7 +22,8 @@ NS_ASSUME_NONNULL_BEGIN ///删除话题成功 - (void)deleteMonentsSuccess:(NSString *)monentsInfo; - +///屏蔽 +- (void)requesstShieldingSuccess:(NSString *)monentsInfo; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMonents/Protocol/XPMonentsTopicLatestProtocol.h b/YuMi/Modules/YMMonents/Protocol/XPMonentsTopicLatestProtocol.h index b24ee993..9595c066 100644 --- a/YuMi/Modules/YMMonents/Protocol/XPMonentsTopicLatestProtocol.h +++ b/YuMi/Modules/YMMonents/Protocol/XPMonentsTopicLatestProtocol.h @@ -19,6 +19,8 @@ NS_ASSUME_NONNULL_BEGIN ///删除话题成功 - (void)deleteMonentsSuccess:(NSString *)monentsInfo; +///屏蔽 +- (void)requesstShieldingSuccess:(NSString *)monentsInfo; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMonents/Protocol/XPMonentsTopicRecommendProtocol.h b/YuMi/Modules/YMMonents/Protocol/XPMonentsTopicRecommendProtocol.h index 292c920d..8d32100c 100644 --- a/YuMi/Modules/YMMonents/Protocol/XPMonentsTopicRecommendProtocol.h +++ b/YuMi/Modules/YMMonents/Protocol/XPMonentsTopicRecommendProtocol.h @@ -20,6 +20,8 @@ NS_ASSUME_NONNULL_BEGIN ///删除话题成功 - (void)deleteMonentsSuccess:(NSString *)monentsInfo; +///屏蔽 +- (void)requesstShieldingSuccess:(NSString *)monentsInfo; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMonents/View/Cell/XPMonentsTableViewCell.h b/YuMi/Modules/YMMonents/View/Cell/XPMonentsTableViewCell.h index 6b7f8a09..70482e14 100644 --- a/YuMi/Modules/YMMonents/View/Cell/XPMonentsTableViewCell.h +++ b/YuMi/Modules/YMMonents/View/Cell/XPMonentsTableViewCell.h @@ -30,6 +30,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic,strong) MonentsInfoModel *mineMonentsInfo; @property (nonatomic,strong) MonentsInfoModel *monentsInfo; @property (nonatomic,assign) BOOL isFillet; +@property (nonatomic,assign) BOOL isTopic;///是否是话题页 ///代理 @property (nonatomic,weak) id delegate; diff --git a/YuMi/Modules/YMMonents/View/Cell/XPMonentsTableViewCell.m b/YuMi/Modules/YMMonents/View/Cell/XPMonentsTableViewCell.m index 07007cec..d6c7ee30 100644 --- a/YuMi/Modules/YMMonents/View/Cell/XPMonentsTableViewCell.m +++ b/YuMi/Modules/YMMonents/View/Cell/XPMonentsTableViewCell.m @@ -10,7 +10,6 @@ #import ///Tool - #import "NetImageView.h" #import "XPMonentsLayoutConfig.h" #import "SDPhotoBrowser.h" @@ -83,8 +82,8 @@ - (void)initDynamicSubViewConstraints { [self.backView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(15); - make.right.mas_equalTo(-15); + make.leading.mas_equalTo(15); + make.trailing.mas_equalTo(-15); make.top.bottom.equalTo(self.contentView); }]; @@ -95,8 +94,8 @@ }]; [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(self.backView).offset(12); - make.right.mas_equalTo(self.backView).offset(-12); + make.leading.mas_equalTo(self.backView).offset(12); + make.trailing.mas_equalTo(self.backView).offset(-12); make.top.mas_equalTo(13); }]; @@ -107,14 +106,14 @@ make.width.mas_equalTo(KScreenWidth-30); }]; [self.toolBarView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self.backView); + make.leading.trailing.mas_equalTo(self.backView); make.top.mas_equalTo(self.stackView.mas_bottom).mas_offset(10); make.height.mas_equalTo(18); }]; [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(kGetScaleWidth(1)); - make.left.right.equalTo(self.toolBarView).inset(12); + make.leading.trailing.equalTo(self.toolBarView).inset(12); make.bottom.equalTo(self.contentView); }]; } @@ -139,7 +138,7 @@ }]; [self.userInfoView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.top.mas_equalTo(self.backView); + make.leading.trailing.top.mas_equalTo(self.backView); make.height.mas_equalTo(kMONENTS_USER_INFO_HEIGHT); }]; @@ -148,8 +147,8 @@ }]; [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(self.backView).offset(kMONENTS_CONTENT_LEFT_PADDING); - make.right.mas_equalTo(self.backView).offset(-kMONENTS_CONTENT_RIGHT_PADDING); + make.leading.mas_equalTo(self.backView).offset(kMONENTS_CONTENT_LEFT_PADDING); + make.trailing.mas_equalTo(self.backView).offset(-kMONENTS_CONTENT_RIGHT_PADDING); make.top.mas_equalTo(self.userInfoView.mas_bottom).offset(kMONENTS_CONTENT_SPACAE_HEIGHT); }]; @@ -158,7 +157,7 @@ }]; [self.toolBarView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self.backView); + make.leading.trailing.mas_equalTo(self.backView); make.top.mas_equalTo(self.stackView.mas_bottom); make.height.mas_equalTo(kMONENTS_TOOL_BAR_HEIGHT); }]; @@ -305,6 +304,7 @@ _monentsInfo = monentsInfo; if (_monentsInfo) { self.userInfoView.monentsInfo = _monentsInfo; + self.textView.isTopic = _isTopic; self.textView.monentsInfo = _monentsInfo; self.photoView.dynamicResList = _monentsInfo.dynamicResList; self.topicView.monentsInfo = _monentsInfo; @@ -326,7 +326,7 @@ self.topicView.hidden = monentsInfo.worldId <= 0; - if(_monentsInfo.squareTop && _monentsInfo.content.length == 0){ + if(_monentsInfo.topicTop && _monentsInfo.content.length == 0){ [self.textView mas_updateConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(contentHeight + 20); }]; diff --git a/YuMi/Modules/YMMonents/View/Cell/XPMonentsTopicCollectionViewCell.m b/YuMi/Modules/YMMonents/View/Cell/XPMonentsTopicCollectionViewCell.m index c0510cb3..e2b87837 100644 --- a/YuMi/Modules/YMMonents/View/Cell/XPMonentsTopicCollectionViewCell.m +++ b/YuMi/Modules/YMMonents/View/Cell/XPMonentsTopicCollectionViewCell.m @@ -1,24 +1,23 @@ // -// YMMonentsTopicCollectionViewCell.m -// YUMI +// XPMonentsTopicCollectionViewCell.m +// xplan-ios // -// Created by YUMI on 2022/5/18. +// Created by 冯硕 on 2022/5/18. // #import "XPMonentsTopicCollectionViewCell.h" ///Third #import ///Tool -#import "DJDKMIMOMColor.h" + #import "UIImage+Utils.h" -#import "NetImageView.h" ///Model #import "MonentsTopicModel.h" @interface XPMonentsTopicCollectionViewCell () ///背景 -@property (nonatomic,strong) NetImageView *topicImageView; +//@property (nonatomic,strong) UIImageView *topicImageView; ///显示话题前面的# @property (nonatomic,strong) UIImageView *iconImageView; ///显示话题 @@ -29,73 +28,87 @@ @implementation XPMonentsTopicCollectionViewCell - (instancetype)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; - if (self) { - [self initSubViews]; - [self initSubViewConstraints]; - } - return self; + self = [super initWithFrame:frame]; + if (self) { + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; } #pragma mark - Private Method - (void)initSubViews { - [self.contentView addSubview:self.topicImageView]; - [self.topicImageView addSubview:self.iconImageView]; - [self.topicImageView addSubview:self.topicLabel]; + self.backgroundColor = [UIColor clearColor]; + self.contentView.backgroundColor = [UIColor clearColor]; + [self.contentView addSubview:self.iconImageView]; + [self.contentView addSubview:self.topicLabel]; +// [self.contentView addSubview:self.topicImageView]; +// [self.topicImageView addSubview:self.iconImageView]; +// [self.topicImageView addSubview:self.topicLabel]; } - (void)initSubViewConstraints { - [self.topicImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self.contentView); - }]; - - [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.bottom.mas_equalTo(self.topicImageView); - make.height.mas_equalTo(30); - }]; - - [self.topicLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self.topicImageView).inset(2); - make.bottom.mas_equalTo(self.topicImageView.mas_bottom).offset(-6); - }]; + [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerY.equalTo(self.contentView); + make.left.mas_equalTo(14); + make.width.height.mas_equalTo(10); + }]; + + [self.topicLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerY.right.equalTo(self.contentView); + make.left.equalTo(self.iconImageView.mas_right).mas_offset(5); + make.right.mas_equalTo(-5.5); + }]; + +// [self.topicImageView mas_makeConstraints:^(MASConstraintMaker *make) { +// make.edges.mas_equalTo(self.contentView); +// }]; +// +// [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) { +// make.left.mas_equalTo(self.topicImageView).offset(7); +// make.size.mas_equalTo(CGSizeMake(16, 16)); +// make.centerY.mas_equalTo(self.topicImageView); +// }]; +// +// [self.topicLabel mas_makeConstraints:^(MASConstraintMaker *make) { +// make.left.mas_equalTo(self.iconImageView.mas_right).offset(2); +// make.centerY.mas_equalTo(self.topicImageView); +// }]; } #pragma mark - Getters And Setters - (void)setTopicInfo:(MonentsTopicModel *)topicInfo { - _topicInfo = topicInfo; - if (_topicInfo) { - self.topicLabel.text = [NSString stringWithFormat:@"#%@", _topicInfo.name]; - self.topicImageView.imageUrl = _topicInfo.icon; - } -} - -- (NetImageView *)topicImageView { - if (!_topicImageView) { - NetImageConfig * config = [[NetImageConfig alloc]init]; - config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; - _topicImageView = [[NetImageView alloc] initWithConfig:config]; - _topicImageView.layer.masksToBounds = YES; - _topicImageView.layer.cornerRadius = 12; - _topicImageView.contentMode = UIViewContentModeScaleAspectFill; - } - return _topicImageView; + _topicInfo = topicInfo; + if (_topicInfo) { + self.topicLabel.text = _topicInfo.name; + } } +// +//- (UIImageView *)topicImageView { +// if (!_topicImageView) { +// _topicImageView = [[UIImageView alloc] init]; +// _topicImageView.userInteractionEnabled = YES; +// _topicImageView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFFFCDD), UIColorFromRGB(0xDFF9FF), UIColorFromRGB(0xF4E5FF)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)]; +// _topicImageView.layer.masksToBounds = YES; +// _topicImageView.layer.cornerRadius = 13; +// } +// return _topicImageView; +//} - (UIImageView *)iconImageView { - if (!_iconImageView) { - _iconImageView = [[UIImageView alloc] init]; - _iconImageView.userInteractionEnabled = YES; - _iconImageView.image = [UIImage imageNamed:@"home_room_list_shadow_bg"]; - } - return _iconImageView; + if (!_iconImageView) { + _iconImageView = [[UIImageView alloc] init]; + _iconImageView.userInteractionEnabled = YES; + _iconImageView.image = [UIImage imageNamed:@"monents_info_topic_icon"]; + } + return _iconImageView; } - (UILabel *)topicLabel { - if (!_topicLabel) { - _topicLabel = [[UILabel alloc] init]; - _topicLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightBold]; - _topicLabel.textColor = [UIColor whiteColor]; - _topicLabel.textAlignment = NSTextAlignmentCenter; - } - return _topicLabel; + if (!_topicLabel) { + _topicLabel = [[UILabel alloc] init]; + _topicLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightRegular]; + _topicLabel.textColor = UIColorFromRGB(0x1F1A4E); + } + return _topicLabel; } @end diff --git a/YuMi/Modules/YMMonents/View/SubViews/XPMoentsTopicView.m b/YuMi/Modules/YMMonents/View/SubViews/XPMoentsTopicView.m index 690907d2..468aabfd 100644 --- a/YuMi/Modules/YMMonents/View/SubViews/XPMoentsTopicView.m +++ b/YuMi/Modules/YMMonents/View/SubViews/XPMoentsTopicView.m @@ -1,15 +1,15 @@ // -// YMMoentsTopicView.m -// YUMI +// XPMoentsTopicView.m +// xplan-ios // -// Created by YUMI on 2022/5/12. +// Created by 冯硕 on 2022/5/12. // #import "XPMoentsTopicView.h" ///Third #import ///Tool -#import "DJDKMIMOMColor.h" + #import "UIImage+Utils.h" #import "NSString+Utils.h" ///Model @@ -24,111 +24,97 @@ @property (nonatomic,strong) UIImageView *iconImageView; ///显示话题 @property (nonatomic,strong) UILabel *topicLabel; -///显示时间 -@property (nonatomic,strong) UILabel *timeLabel; + @end @implementation XPMoentsTopicView - (instancetype)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; - if (self) { - [self initSubViews]; - [self initSubViewConstraints]; - } - return self; + self = [super initWithFrame:frame]; + if (self) { + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; } #pragma mark - Private Method - (void)initSubViews { - [self addSubview:self.stackView]; - [self.stackView addArrangedSubview:self.topicImageView]; - [self.stackView addArrangedSubview:self.timeLabel]; - - [self.topicImageView addSubview:self.iconImageView]; - [self.topicImageView addSubview:self.topicLabel]; + [self addSubview:self.stackView]; + [self.stackView addArrangedSubview:self.topicImageView]; + [self.topicImageView addSubview:self.iconImageView]; + [self.topicImageView addSubview:self.topicLabel]; } - (void)initSubViewConstraints { - [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self); - }]; - - [self.topicImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.right.mas_equalTo(self.topicLabel.mas_right).offset(9); - }]; - - [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(self.topicImageView).offset(9); - make.size.mas_equalTo(CGSizeMake(20, 20)); - make.centerY.mas_equalTo(self.topicImageView); - }]; - - [self.topicLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(self.iconImageView.mas_right).offset(4); - make.centerY.mas_equalTo(self.topicImageView); - }]; + [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.top.bottom.mas_equalTo(self); + }]; + + [self.topicImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.right.mas_equalTo(self.topicLabel.mas_right).offset(9); + }]; + + [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.topicImageView); + make.size.mas_equalTo(CGSizeMake(10, 10)); + make.centerY.mas_equalTo(self.topicImageView); + }]; + + [self.topicLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.iconImageView.mas_right).offset(4); + make.centerY.mas_equalTo(self.topicImageView); + }]; } #pragma mark - Getters And Setters - (void)setMonentsInfo:(MonentsInfoModel *)monentsInfo { - _monentsInfo = monentsInfo; - if (_monentsInfo) { - if (_monentsInfo.worldId > 0) { - self.topicImageView.hidden = NO; - self.topicLabel.text = _monentsInfo.worldName; - } else { - self.topicImageView.hidden = YES; - } - self.timeLabel.text = [NSString stringWithTimeStamp:_monentsInfo.publishTime]; - } + _monentsInfo = monentsInfo; + if (_monentsInfo) { + if (_monentsInfo.worldId > 0) { + self.topicLabel.text = _monentsInfo.worldName; + } + } } - (UIStackView *)stackView { - if (!_stackView) { - _stackView = [[UIStackView alloc] init]; - _stackView.axis = UILayoutConstraintAxisHorizontal; - _stackView.distribution = UIStackViewDistributionFill; - _stackView.alignment = UIStackViewAlignmentFill; - _stackView.spacing = 8; - } - return _stackView; + if (!_stackView) { + _stackView = [[UIStackView alloc] init]; + _stackView.axis = UILayoutConstraintAxisHorizontal; + _stackView.distribution = UIStackViewDistributionFill; + _stackView.alignment = UIStackViewAlignmentFill; + _stackView.spacing = 8; + } + return _stackView; } - (UIImageView *)topicImageView { - if (!_topicImageView) { - _topicImageView = [[UIImageView alloc] init]; - _topicImageView.userInteractionEnabled = YES; - _topicImageView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFFFCDD), UIColorFromRGB(0xDFF9FF), UIColorFromRGB(0xF4E5FF)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)]; - _topicImageView.layer.masksToBounds = YES; - _topicImageView.layer.cornerRadius = 8; - } - return _topicImageView; + if (!_topicImageView) { + _topicImageView = [[UIImageView alloc] init]; + _topicImageView.userInteractionEnabled = YES; +// _topicImageView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFFFCDD), UIColorFromRGB(0xDFF9FF), UIColorFromRGB(0xF4E5FF)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)]; + _topicImageView.layer.masksToBounds = YES; + _topicImageView.layer.cornerRadius = 8; + } + return _topicImageView; } - (UIImageView *)iconImageView { - if (!_iconImageView) { - _iconImageView = [[UIImageView alloc] init]; - _iconImageView.userInteractionEnabled = YES; - _iconImageView.image = [UIImage imageNamed:@"monents_info_topic_icon"]; - } - return _iconImageView; + if (!_iconImageView) { + _iconImageView = [[UIImageView alloc] init]; + _iconImageView.userInteractionEnabled = YES; + _iconImageView.image = [UIImage imageNamed:@"monents_info_topic_icon"]; + } + return _iconImageView; } - (UILabel *)topicLabel { - if (!_topicLabel) { - _topicLabel = [[UILabel alloc] init]; - _topicLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightBold]; - _topicLabel.textColor = [DJDKMIMOMColor mainTextColor]; - } - return _topicLabel; + if (!_topicLabel) { + _topicLabel = [[UILabel alloc] init]; + _topicLabel.font = [UIFont systemFontOfSize:11 weight:UIFontWeightRegular]; + _topicLabel.textColor = [DJDKMIMOMColor mainTextColor]; + } + return _topicLabel; } -- (UILabel *)timeLabel { - if (!_timeLabel) { - _timeLabel = [[UILabel alloc] init]; - _timeLabel.font = [UIFont systemFontOfSize:10]; - _timeLabel.textColor = [DJDKMIMOMColor textThirdColor]; - } - return _timeLabel; -} + @end diff --git a/YuMi/Modules/YMMonents/View/SubViews/XPMonentsContentView.h b/YuMi/Modules/YMMonents/View/SubViews/XPMonentsContentView.h index 195d6e52..982feb03 100644 --- a/YuMi/Modules/YMMonents/View/SubViews/XPMonentsContentView.h +++ b/YuMi/Modules/YMMonents/View/SubViews/XPMonentsContentView.h @@ -1,8 +1,8 @@ // -// YMMonentsContentView.h -// YUMI +// XPMonentsContentView.h +// xplan-ios // -// Created by YUMI on 2022/5/13. +// Created by 冯硕 on 2022/5/13. // #import @@ -18,13 +18,11 @@ NS_ASSUME_NONNULL_BEGIN @end @interface XPMonentsContentView : UIView +/// +@property (nonatomic,assign) BOOL isTopic; @property (nonatomic,strong) MonentsInfoModel *monentsInfo; ///代理 @property (nonatomic,weak) id delegate; - -/// 是否是审核UI -@property (nonatomic,assign) BOOL isSimple; - @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMonents/View/SubViews/XPMonentsContentView.m b/YuMi/Modules/YMMonents/View/SubViews/XPMonentsContentView.m index a15e173e..13dd471a 100644 --- a/YuMi/Modules/YMMonents/View/SubViews/XPMonentsContentView.m +++ b/YuMi/Modules/YMMonents/View/SubViews/XPMonentsContentView.m @@ -1,8 +1,8 @@ // -// YMMonentsContentView.m -// YUMI +// XPMonentsContentView.m +// xplan-ios // -// Created by YUMI on 2022/5/13. +// Created by 冯硕 on 2022/5/13. // #import "XPMonentsContentView.h" @@ -10,7 +10,7 @@ #import #import ///Tool -#import "DJDKMIMOMColor.h" + #import "XPMonentsLayoutConfig.h" #import "UIButton+EnlargeTouchArea.h" ///Model @@ -22,152 +22,173 @@ @property (nonatomic,strong) UILabel *contentLabel; ///折叠的按钮 @property (nonatomic,strong) UIButton *foldButton; +///显示时间 +@property (nonatomic,strong) UILabel *timeLabel; @end @implementation XPMonentsContentView - (instancetype)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; - if (self) { - [self initSubViews]; - [self initSubViewConstraints]; - } - return self; + self = [super initWithFrame:frame]; + if (self) { + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; } #pragma mark - Private Method - (void)initSubViews { - [self addSubview:self.stackView]; - [self.stackView addArrangedSubview:self.contentLabel]; - [self.stackView addArrangedSubview:self.foldButton]; + + [self addSubview:self.stackView]; + [self.stackView addArrangedSubview:self.contentLabel]; + [self.stackView addArrangedSubview:self.foldButton]; + [self.stackView addArrangedSubview:self.timeLabel]; } - (void)initSubViewConstraints { - [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self); - }]; - - [self.foldButton mas_makeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(kMONENTS_FOLD_HEIGHT); - }]; + + [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self); + }]; + [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(14); + }]; + [self.foldButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(kMONENTS_FOLD_HEIGHT); + }]; } - (NSAttributedString *)createMonentsContentAttribute { - NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init]; - if (self.monentsInfo.squareTop ) {//动态/广场 - NSTextAttachment * attachment = [[NSTextAttachment alloc] init]; - attachment.bounds = CGRectMake(0, 0, 25 * 1.3, 10 * 1.3); - attachment.image = [UIImage imageNamed:@"monents_info_top"]; - NSAttributedString * starAttribute = [NSMutableAttributedString attributedStringWithAttachment:(NSTextAttachment *)attachment]; - [attributedString insertAttributedString:starAttribute atIndex:0]; - } - [attributedString appendAttributedString:[self creatStrAttrByStr:self.monentsInfo.content attributed:@{NSFontAttributeName : [UIFont systemFontOfSize:15]}]]; - attributedString.yy_lineSpacing = 5; - attributedString.yy_lineBreakMode = NSLineBreakByWordWrapping; - return attributedString; + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init]; + BOOL isTop = NO; + if(self.isTopic && self.monentsInfo.topicTop){ + isTop = YES; + }else{ + if (self.monentsInfo.squareTop ) { + isTop = YES; + } + } + if (isTop) {//动态/广场 + NSTextAttachment * attachment = [[NSTextAttachment alloc] init]; + UIImage *iconImage = [UIImage imageNamed:@"monents_info_top"];; + attachment.bounds = CGRectMake(0, roundf(self.contentLabel.font.capHeight - iconImage.size.height)/2.f, iconImage.size.width, iconImage.size.height); + + attachment.image =iconImage; + NSAttributedString * starAttribute = [NSMutableAttributedString attributedStringWithAttachment:(NSTextAttachment *)attachment]; + [attributedString insertAttributedString:starAttribute atIndex:0]; + //将图片插入到合适的位置 +// [attributedString appendAttributedString:[self creatStrAttrByStr:YMLocalizedString(@"XPMonentsContentView0") attributed:@{NSFontAttributeName : [UIFont systemFontOfSize:15], NSForegroundColorAttributeName: UIColorFromRGB(0xE84C46)}]]; + } + [attributedString appendAttributedString:[self creatStrAttrByStr:self.monentsInfo.content attributed:@{NSFontAttributeName : [UIFont systemFontOfSize:15]}]]; + attributedString.yy_lineSpacing = 5; + attributedString.yy_lineBreakMode = NSLineBreakByWordWrapping; + return attributedString; } - (NSMutableAttributedString *)creatStrAttrByStr:(NSString *)str attributed:(NSDictionary *)attribute{ - if (str.length == 0 || !str) { - str = @" "; - } - NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:str attributes:attribute]; - return attr; + if (str.length == 0 || !str) { + str = @" "; + } + NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:str attributes:attribute]; + return attr; } #pragma mark - Event Response - (void)didClickFoldButton:(UIButton *)sender { - sender.selected = !sender.selected; - self.monentsInfo.isFold = !sender.selected; - if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsContentView:didClickFold:)]) { - [self.delegate xPMonentsContentView:self didClickFold:self.monentsInfo]; - } + sender.selected = !sender.selected; + self.monentsInfo.isFold = !sender.selected; + if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsContentView:didClickFold:)]) { + [self.delegate xPMonentsContentView:self didClickFold:self.monentsInfo]; + } } #pragma mark - Getters And Setters - -- (void)setIsSimple:(BOOL)isSimple { - _isSimple = isSimple; - self.contentLabel.preferredMaxLayoutWidth = isSimple ? kSIMPLE_MONENTS_CONTENT_MAX_WIDTH : kMONENTS_CONTENT_MAX_WIDTH; -} - - (void)setMonentsInfo:(MonentsInfoModel *)monentsInfo { - _monentsInfo = monentsInfo; - if (_monentsInfo) { - self.contentLabel.attributedText = [self createMonentsContentAttribute]; - self.foldButton.selected = !_monentsInfo.isFold; - if (monentsInfo.numberOfText <= 0) { - YYTextContainer *container = [YYTextContainer new]; - container.size = CGSizeMake(self.isSimple ? kSIMPLE_MONENTS_CONTENT_MAX_WIDTH : kMONENTS_CONTENT_MAX_WIDTH, CGFLOAT_MAX); - container.maximumNumberOfRows = 0; - YYTextLayout * layout = [YYTextLayout layoutWithContainer:container text:self.contentLabel.attributedText]; - if (layout.rowCount > 6) { - self.foldButton.hidden = NO; - [self.foldButton mas_remakeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(kMONENTS_FOLD_HEIGHT); - }]; - } else { - self.foldButton.hidden = YES; - [self.foldButton mas_remakeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(0); - }]; - } - } else { - if (monentsInfo.numberOfText > 6) { - self.foldButton.hidden = NO; - [self.foldButton mas_remakeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(kMONENTS_FOLD_HEIGHT); - }]; - } else { - self.foldButton.hidden = YES; - [self.foldButton mas_remakeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(0); - }]; - } - } - } + _monentsInfo = monentsInfo; + if (_monentsInfo) { + self.timeLabel.text = [NSString stringWithTimeStamp:_monentsInfo.publishTime]; + self.contentLabel.attributedText = [self createMonentsContentAttribute]; + self.foldButton.selected = !_monentsInfo.isFold; + if (monentsInfo.numberOfText <= 0) { + YYTextContainer *container = [YYTextContainer new]; + container.size = CGSizeMake(kMONENTS_CONTENT_MAX_WIDTH, CGFLOAT_MAX); + container.maximumNumberOfRows = 0; + YYTextLayout * layout = [YYTextLayout layoutWithContainer:container text:self.contentLabel.attributedText]; + if (layout.rowCount > 6) { + self.foldButton.hidden = NO; + [self.foldButton mas_remakeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(kMONENTS_FOLD_HEIGHT); + }]; + } else { + self.foldButton.hidden = YES; + [self.foldButton mas_remakeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(0); + }]; + } + } else { + if (monentsInfo.numberOfText > 6) { + self.foldButton.hidden = NO; + [self.foldButton mas_remakeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(kMONENTS_FOLD_HEIGHT); + }]; + } else { + self.foldButton.hidden = YES; + [self.foldButton mas_remakeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(0); + }]; + } + } + } } - (UIStackView *)stackView { - if (!_stackView) { - _stackView = [[UIStackView alloc] init]; - _stackView.axis = UILayoutConstraintAxisVertical; - _stackView.distribution = UIStackViewDistributionFill; - _stackView.alignment = UIStackViewAlignmentLeading; - _stackView.spacing = 0; - } - return _stackView; + if (!_stackView) { + _stackView = [[UIStackView alloc] init]; + _stackView.axis = UILayoutConstraintAxisVertical; + _stackView.distribution = UIStackViewDistributionFill; + _stackView.alignment = UIStackViewAlignmentLeading; + _stackView.spacing = 5; + } + return _stackView; } - (UIButton *)foldButton { - if (_foldButton == nil) { - _foldButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_foldButton setTitle:YMLocalizedString(@"XPMonentsContentView0") forState:UIControlStateNormal]; - [_foldButton setTitle:YMLocalizedString(@"XPMonentsContentView1") forState:UIControlStateSelected]; - [_foldButton setTitleColor:UIColorFromRGB(0x34A7FF) forState:UIControlStateNormal]; - [_foldButton setTitleColor:UIColorFromRGB(0x34A7FF) forState:UIControlStateSelected]; - _foldButton.titleLabel.font = [UIFont systemFontOfSize:15]; - _foldButton.hidden = YES; - [_foldButton addTarget:self action:@selector(didClickFoldButton:) forControlEvents:UIControlEventTouchUpInside]; - } - return _foldButton; + if (_foldButton == nil) { + _foldButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_foldButton setTitle:YMLocalizedString(@"XPMonentsContentView1") forState:UIControlStateNormal]; + [_foldButton setTitle:YMLocalizedString(@"XPMonentsContentView2") forState:UIControlStateSelected]; + [_foldButton setTitleColor:UIColorFromRGB(0x34A7FF) forState:UIControlStateNormal]; + [_foldButton setTitleColor:UIColorFromRGB(0x34A7FF) forState:UIControlStateSelected]; + _foldButton.titleLabel.font = [UIFont systemFontOfSize:15]; + _foldButton.hidden = YES; + [_foldButton addTarget:self action:@selector(didClickFoldButton:) forControlEvents:UIControlEventTouchUpInside]; + } + return _foldButton; } - (UILabel *)contentLabel { - if (!_contentLabel) { - _contentLabel = [[UILabel alloc] init]; - _contentLabel.numberOfLines = 0; - _contentLabel.font = [UIFont systemFontOfSize:15]; - _contentLabel.textColor = UIColorRGBAlpha(0x333333, 1); + if (!_contentLabel) { + _contentLabel = [[UILabel alloc] init]; + _contentLabel.numberOfLines = 0; + _contentLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular]; + _contentLabel.textColor = UIColorRGBAlpha(0x1F1A4E, 1); _contentLabel.preferredMaxLayoutWidth = kMONENTS_CONTENT_MAX_WIDTH; - _contentLabel.lineBreakMode = NSLineBreakByWordWrapping; + _contentLabel.lineBreakMode = NSLineBreakByWordWrapping; - } - return _contentLabel; + } + return _contentLabel; +} +- (UILabel *)timeLabel { + if (!_timeLabel) { + _timeLabel = [[UILabel alloc] init]; + _timeLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular]; + _timeLabel.textColor = [DJDKMIMOMColor textThirdColor]; + } + return _timeLabel; } - @end diff --git a/YuMi/Modules/YMMonents/View/SubViews/XPMonentsPhotoView.m b/YuMi/Modules/YMMonents/View/SubViews/XPMonentsPhotoView.m index ba409d47..b06fc652 100644 --- a/YuMi/Modules/YMMonents/View/SubViews/XPMonentsPhotoView.m +++ b/YuMi/Modules/YMMonents/View/SubViews/XPMonentsPhotoView.m @@ -1,18 +1,16 @@ // -// YMMonentsPhotoView.m -// YUMI +// XPMonentsPhotoView.m +// xplan-ios // -// Created by YUMI on 2022/5/12. +// Created by 冯硕 on 2022/5/12. // #import "XPMonentsPhotoView.h" ///Third #import ///Tool -#import "DJDKMIMOMColor.h" #import "NetImageView.h" #import "XPMonentsLayoutConfig.h" -#import "NSArray+Safe.h" ///Model #import "MonentsInfoModel.h" @@ -42,38 +40,38 @@ @implementation XPMonentsPhotoView - (instancetype)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; - if (self) { - [self initSubViews]; - } - return self; + self = [super initWithFrame:frame]; + if (self) { + [self initSubViews]; + } + return self; } #pragma mark - Private Method - (void)initSubViews { - [self addSubview:self.firstImageView]; - [self addSubview:self.secondImageView]; - [self addSubview:self.thirdImageView]; - [self addSubview:self.fourthImageView]; - [self addSubview:self.fifthImageView]; - [self addSubview:self.sixthImageView]; - [self addSubview:self.sevenImageView]; - [self addSubview:self.eighthImageView]; - [self addSubview:self.ninthImageView]; - self.subViewArray = @[self.firstImageView, self.secondImageView, self.thirdImageView, self.fourthImageView, self.fifthImageView, self.sixthImageView, self.sevenImageView, self.eighthImageView, self.ninthImageView]; + [self addSubview:self.firstImageView]; + [self addSubview:self.secondImageView]; + [self addSubview:self.thirdImageView]; + [self addSubview:self.fourthImageView]; + [self addSubview:self.fifthImageView]; + [self addSubview:self.sixthImageView]; + [self addSubview:self.sevenImageView]; + [self addSubview:self.eighthImageView]; + [self addSubview:self.ninthImageView]; + self.subViewArray = @[self.firstImageView, self.secondImageView, self.thirdImageView, self.fourthImageView, self.fifthImageView, self.sixthImageView, self.sevenImageView, self.eighthImageView, self.ninthImageView]; } - (void)hiddenAllImageView { - [self.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - obj.hidden = YES; - }]; + [self.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + obj.hidden = YES; + }]; } #pragma mark - Event Response - (void)tapImageView:(UITapGestureRecognizer *)tap { - NetImageView * imageView = (NetImageView *)tap.view; - if (imageView.imageUrl.length > 0 && self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsPhotoView:didClickImage:)]) { - [self.delegate xPMonentsPhotoView:self didClickImage:imageView.tag - 1001]; - } + NetImageView * imageView = (NetImageView *)tap.view; + if (imageView.imageUrl.length > 0 && self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsPhotoView:didClickImage:)]) { + [self.delegate xPMonentsPhotoView:self didClickImage:imageView.tag - 1001]; + } } @@ -144,222 +142,225 @@ } } + + - (void)setDynamicResList:(NSArray *)dynamicResList { - _dynamicResList = dynamicResList; - [self hiddenAllImageView]; - if (_dynamicResList.count == 0) { - - } else if (_dynamicResList.count == 1) { - self.firstImageView.hidden = NO; - [self.firstImageView mas_remakeConstraints:^(MASConstraintMaker *make) { - make.size.mas_equalTo(CGSizeMake(kMONENTS_PIC_ONE_WIDTH, kMONENTS_PIC_ONE_WIDTH)); - make.left.top.mas_equalTo(self); - }]; - MonentsPicInfoModel * picInfo = [_dynamicResList safeObjectAtIndex1:0]; - self.firstImageView.imageUrl = picInfo.resUrl; - } else if(_dynamicResList.count == 2) { - self.firstImageView.hidden = NO; - CGFloat itemWidth = (kMONENTS_CONTENT_MAX_WIDTH - kMONENTS_PIC_SPACE) / 2; - [self.firstImageView mas_remakeConstraints:^(MASConstraintMaker *make) { - make.size.mas_equalTo(CGSizeMake(itemWidth, itemWidth)); - make.left.top.mas_equalTo(self); - }]; - - MonentsPicInfoModel * picInfo = [_dynamicResList safeObjectAtIndex1:0]; - self.firstImageView.imageUrl = picInfo.resUrl; - - self.secondImageView.hidden = NO; - [self.secondImageView mas_remakeConstraints:^(MASConstraintMaker *make) { - make.size.mas_equalTo(CGSizeMake(itemWidth, itemWidth)); - make.top.mas_equalTo(self); - make.left.mas_equalTo(self.firstImageView.mas_right).offset(kMONENTS_PIC_SPACE); - }]; - - MonentsPicInfoModel * secondPicInfo = [_dynamicResList safeObjectAtIndex1:1]; - self.secondImageView.imageUrl = secondPicInfo.resUrl; - - } else{ - for (int i = 0; i < _dynamicResList.count; i++) { - MonentsPicInfoModel * picInfo = [_dynamicResList safeObjectAtIndex1:i]; - if (i < self.subViewArray.count) { - NetImageView * imageView = [self.subViewArray safeObjectAtIndex1:i]; - imageView.hidden = NO; - imageView.imageUrl = picInfo.resUrl; - } - } - - CGFloat itemWidth = (kMONENTS_CONTENT_MAX_WIDTH - kMONENTS_PIC_SPACE * 2) / 3; - for (int i = 0; i < self.subViewArray.count; i++) { - NSInteger page = i % 3; - NSInteger line = i / 3; - NetImageView * imageView = [self.subViewArray safeObjectAtIndex1:i]; - [imageView mas_remakeConstraints:^(MASConstraintMaker *make) { - make.size.mas_equalTo(CGSizeMake(itemWidth, itemWidth)); - make.left.mas_equalTo(page * (itemWidth + kMONENTS_PIC_SPACE)); - make.top.mas_equalTo(line * (itemWidth + kMONENTS_PIC_SPACE)); - }]; - } - - } + _dynamicResList = dynamicResList; + [self hiddenAllImageView]; + if (_dynamicResList.count == 0) { + + } else if (_dynamicResList.count == 1) { + self.firstImageView.hidden = NO; + [self.firstImageView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(kMONENTS_PIC_ONE_WIDTH, kMONENTS_PIC_ONE_WIDTH)); + make.left.top.mas_equalTo(self); + }]; + MonentsPicInfoModel * picInfo = [_dynamicResList safeObjectAtIndex1:0]; + self.firstImageView.imageUrl = picInfo.resUrl; + } else if(_dynamicResList.count == 2) { + self.firstImageView.hidden = NO; + CGFloat itemWidth = (kMONENTS_CONTENT_MAX_WIDTH - kMONENTS_PIC_SPACE) / 2; + [self.firstImageView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(itemWidth, itemWidth)); + make.left.top.mas_equalTo(self); + }]; + + MonentsPicInfoModel * picInfo = [_dynamicResList safeObjectAtIndex1:0]; + self.firstImageView.imageUrl = picInfo.resUrl; + + self.secondImageView.hidden = NO; + [self.secondImageView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(itemWidth, itemWidth)); + make.top.mas_equalTo(self); + make.left.mas_equalTo(self.firstImageView.mas_right).offset(kMONENTS_PIC_SPACE); + }]; + + MonentsPicInfoModel * secondPicInfo = [_dynamicResList safeObjectAtIndex1:1]; + self.secondImageView.imageUrl = secondPicInfo.resUrl; + + } else{ + for (int i = 0; i < _dynamicResList.count; i++) { + MonentsPicInfoModel * picInfo = [_dynamicResList safeObjectAtIndex1:i]; + if (i < self.subViewArray.count) { + NetImageView * imageView = [self.subViewArray safeObjectAtIndex1:i]; + imageView.hidden = NO; + imageView.imageUrl = picInfo.resUrl; + } + } + + CGFloat itemWidth = (kMONENTS_CONTENT_MAX_WIDTH - kMONENTS_PIC_SPACE * 2) / 3; + for (int i = 0; i < self.subViewArray.count; i++) { + NSInteger page = i % 3; + NSInteger line = i / 3; + NetImageView * imageView = [self.subViewArray safeObjectAtIndex1:i]; + if(imageView == nil)return; + [imageView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(itemWidth, itemWidth)); + make.left.mas_equalTo(page * (itemWidth + kMONENTS_PIC_SPACE)); + make.top.mas_equalTo(line * (itemWidth + kMONENTS_PIC_SPACE)); + }]; + } + + } } - (NetImageView *)firstImageView { - if (!_firstImageView) { - NetImageConfig * config = [[NetImageConfig alloc]init]; - config.imageType = ImageTypeMonentsPhoto; - config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; - _firstImageView = [[NetImageView alloc] initWithConfig:config]; - _firstImageView.layer.masksToBounds = YES; - _firstImageView.layer.cornerRadius = 12; - _firstImageView.contentMode = UIViewContentModeScaleAspectFill; - _firstImageView.tag = 1000 + 1; - _firstImageView.userInteractionEnabled = YES; - UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; - [_firstImageView addGestureRecognizer:tap]; - } - return _firstImageView; + if (!_firstImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.imageType = ImageTypeMonentsPhoto; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _firstImageView = [[NetImageView alloc] initWithConfig:config]; + _firstImageView.layer.masksToBounds = YES; + _firstImageView.layer.cornerRadius = 12; + _firstImageView.contentMode = UIViewContentModeScaleAspectFill; + _firstImageView.tag = 1000 + 1; + _firstImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_firstImageView addGestureRecognizer:tap]; + } + return _firstImageView; } - (NetImageView *)secondImageView { - if (!_secondImageView) { - NetImageConfig * config = [[NetImageConfig alloc]init]; - config.imageType = ImageTypeMonentsPhoto; - config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; - _secondImageView = [[NetImageView alloc] initWithConfig:config]; - _secondImageView.layer.masksToBounds = YES; - _secondImageView.layer.cornerRadius = 12; - _secondImageView.contentMode = UIViewContentModeScaleAspectFill; - _secondImageView.tag = 1000 + 2; - _secondImageView.userInteractionEnabled = YES; - UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; - [_secondImageView addGestureRecognizer:tap]; - } - return _secondImageView; + if (!_secondImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.imageType = ImageTypeMonentsPhoto; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _secondImageView = [[NetImageView alloc] initWithConfig:config]; + _secondImageView.layer.masksToBounds = YES; + _secondImageView.layer.cornerRadius = 12; + _secondImageView.contentMode = UIViewContentModeScaleAspectFill; + _secondImageView.tag = 1000 + 2; + _secondImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_secondImageView addGestureRecognizer:tap]; + } + return _secondImageView; } - (NetImageView *)thirdImageView { - if (!_thirdImageView) { - NetImageConfig * config = [[NetImageConfig alloc]init]; - config.imageType = ImageTypeMonentsPhoto; - config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; - _thirdImageView = [[NetImageView alloc] initWithConfig:config]; - _thirdImageView.layer.masksToBounds = YES; - _thirdImageView.layer.cornerRadius = 12; - _thirdImageView.contentMode = UIViewContentModeScaleAspectFill; - _thirdImageView.tag = 1000 + 3; - _thirdImageView.userInteractionEnabled = YES; - UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; - [_thirdImageView addGestureRecognizer:tap]; - } - return _thirdImageView; + if (!_thirdImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.imageType = ImageTypeMonentsPhoto; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _thirdImageView = [[NetImageView alloc] initWithConfig:config]; + _thirdImageView.layer.masksToBounds = YES; + _thirdImageView.layer.cornerRadius = 12; + _thirdImageView.contentMode = UIViewContentModeScaleAspectFill; + _thirdImageView.tag = 1000 + 3; + _thirdImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_thirdImageView addGestureRecognizer:tap]; + } + return _thirdImageView; } - (NetImageView *)fourthImageView { - if (!_fourthImageView) { - NetImageConfig * config = [[NetImageConfig alloc]init]; - config.imageType = ImageTypeMonentsPhoto; - config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; - _fourthImageView = [[NetImageView alloc] initWithConfig:config]; - _fourthImageView.layer.masksToBounds = YES; - _fourthImageView.layer.cornerRadius = 12; - _fourthImageView.contentMode = UIViewContentModeScaleAspectFill; - _fourthImageView.tag = 1000 + 4; - _fourthImageView.userInteractionEnabled = YES; - UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; - [_fourthImageView addGestureRecognizer:tap]; - - } - return _fourthImageView; + if (!_fourthImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.imageType = ImageTypeMonentsPhoto; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _fourthImageView = [[NetImageView alloc] initWithConfig:config]; + _fourthImageView.layer.masksToBounds = YES; + _fourthImageView.layer.cornerRadius = 12; + _fourthImageView.contentMode = UIViewContentModeScaleAspectFill; + _fourthImageView.tag = 1000 + 4; + _fourthImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_fourthImageView addGestureRecognizer:tap]; + + } + return _fourthImageView; } - (NetImageView *)fifthImageView { - if (!_fifthImageView) { - NetImageConfig * config = [[NetImageConfig alloc]init]; - config.imageType = ImageTypeMonentsPhoto; - config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; - _fifthImageView = [[NetImageView alloc] initWithConfig:config]; - _fifthImageView.layer.masksToBounds = YES; - _fifthImageView.layer.cornerRadius = 12; - _fifthImageView.contentMode = UIViewContentModeScaleAspectFill; - _fifthImageView.tag = 1000 + 5; - _fifthImageView.userInteractionEnabled = YES; - UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; - [_fifthImageView addGestureRecognizer:tap]; - } - return _fifthImageView; + if (!_fifthImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.imageType = ImageTypeMonentsPhoto; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _fifthImageView = [[NetImageView alloc] initWithConfig:config]; + _fifthImageView.layer.masksToBounds = YES; + _fifthImageView.layer.cornerRadius = 12; + _fifthImageView.contentMode = UIViewContentModeScaleAspectFill; + _fifthImageView.tag = 1000 + 5; + _fifthImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_fifthImageView addGestureRecognizer:tap]; + } + return _fifthImageView; } - (NetImageView *)sixthImageView { - if (!_sixthImageView) { - NetImageConfig * config = [[NetImageConfig alloc]init]; - config.imageType = ImageTypeMonentsPhoto; - config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; - _sixthImageView = [[NetImageView alloc] initWithConfig:config]; - _sixthImageView.layer.masksToBounds = YES; - _sixthImageView.layer.cornerRadius = 12; - _sixthImageView.contentMode = UIViewContentModeScaleAspectFill; - _sixthImageView.tag = 1000 + 6; - _sixthImageView.userInteractionEnabled = YES; - UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; - [_sixthImageView addGestureRecognizer:tap]; - } - return _sixthImageView; + if (!_sixthImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.imageType = ImageTypeMonentsPhoto; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _sixthImageView = [[NetImageView alloc] initWithConfig:config]; + _sixthImageView.layer.masksToBounds = YES; + _sixthImageView.layer.cornerRadius = 12; + _sixthImageView.contentMode = UIViewContentModeScaleAspectFill; + _sixthImageView.tag = 1000 + 6; + _sixthImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_sixthImageView addGestureRecognizer:tap]; + } + return _sixthImageView; } - (NetImageView *)sevenImageView { - if (!_sevenImageView) { - NetImageConfig * config = [[NetImageConfig alloc]init]; - config.imageType = ImageTypeMonentsPhoto; - config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; - _sevenImageView = [[NetImageView alloc] initWithConfig:config]; - _sevenImageView.layer.masksToBounds = YES; - _sevenImageView.layer.cornerRadius = 12; - _sevenImageView.contentMode = UIViewContentModeScaleAspectFill; - _sevenImageView.tag = 1000 + 7; - _sevenImageView.userInteractionEnabled = YES; - UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; - [_sevenImageView addGestureRecognizer:tap]; - } - return _sevenImageView; + if (!_sevenImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.imageType = ImageTypeMonentsPhoto; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _sevenImageView = [[NetImageView alloc] initWithConfig:config]; + _sevenImageView.layer.masksToBounds = YES; + _sevenImageView.layer.cornerRadius = 12; + _sevenImageView.contentMode = UIViewContentModeScaleAspectFill; + _sevenImageView.tag = 1000 + 7; + _sevenImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_sevenImageView addGestureRecognizer:tap]; + } + return _sevenImageView; } - (NetImageView *)eighthImageView { - if (!_eighthImageView) { - NetImageConfig * config = [[NetImageConfig alloc]init]; - config.imageType = ImageTypeMonentsPhoto; - config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; - _eighthImageView = [[NetImageView alloc] initWithConfig:config]; - _eighthImageView.layer.masksToBounds = YES; - _eighthImageView.layer.cornerRadius = 12; - _eighthImageView.contentMode = UIViewContentModeScaleAspectFill; - _eighthImageView.tag = 1000 + 8; - _eighthImageView.userInteractionEnabled = YES; - UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; - [_eighthImageView addGestureRecognizer:tap]; - } - return _eighthImageView; + if (!_eighthImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.imageType = ImageTypeMonentsPhoto; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _eighthImageView = [[NetImageView alloc] initWithConfig:config]; + _eighthImageView.layer.masksToBounds = YES; + _eighthImageView.layer.cornerRadius = 12; + _eighthImageView.contentMode = UIViewContentModeScaleAspectFill; + _eighthImageView.tag = 1000 + 8; + _eighthImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_eighthImageView addGestureRecognizer:tap]; + } + return _eighthImageView; } - (NetImageView *)ninthImageView { - if (!_ninthImageView) { - NetImageConfig * config = [[NetImageConfig alloc]init]; - config.imageType = ImageTypeMonentsPhoto; - config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; - _ninthImageView = [[NetImageView alloc] initWithConfig:config]; - _ninthImageView.layer.masksToBounds = YES; - _ninthImageView.layer.cornerRadius = 12; - _ninthImageView.contentMode = UIViewContentModeScaleAspectFill; - _ninthImageView.tag = 1000 + 9; - _ninthImageView.userInteractionEnabled = YES; - UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; - [_ninthImageView addGestureRecognizer:tap]; - } - return _ninthImageView; + if (!_ninthImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.imageType = ImageTypeMonentsPhoto; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _ninthImageView = [[NetImageView alloc] initWithConfig:config]; + _ninthImageView.layer.masksToBounds = YES; + _ninthImageView.layer.cornerRadius = 12; + _ninthImageView.contentMode = UIViewContentModeScaleAspectFill; + _ninthImageView.tag = 1000 + 9; + _ninthImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_ninthImageView addGestureRecognizer:tap]; + } + return _ninthImageView; } diff --git a/YuMi/Modules/YMMonents/View/SubViews/XPMonentsRecommendHeaderView.m b/YuMi/Modules/YMMonents/View/SubViews/XPMonentsRecommendHeaderView.m index fe51c695..293fa112 100644 --- a/YuMi/Modules/YMMonents/View/SubViews/XPMonentsRecommendHeaderView.m +++ b/YuMi/Modules/YMMonents/View/SubViews/XPMonentsRecommendHeaderView.m @@ -1,26 +1,32 @@ // -// YMMonentsRecommendHeaderView.m -// YUMI +// XPMonentsRecommendHeaderView.m +// xplan-ios // -// Created by YUMI on 2022/5/18. +// Created by 冯硕 on 2022/5/18. // #import "XPMonentsRecommendHeaderView.h" ///Third #import -///Tool -#import "DJDKMIMOMColor.h" -#import "NSArray+Safe.h" + ///Model #import "MonentsTopicModel.h" ///View #import "XPMonentsTopicCollectionViewCell.h" -@interface XPMonentsRecommendHeaderView () +@interface XPMonentsRecommendHeaderView () +///背景图 +@property (nonatomic,strong) UIImageView *bgView; + +///titile背景 +@property (nonatomic,strong) UIImageView *titleBgView; + ///显示标题 @property (nonatomic,strong) UILabel *titleLabel; ///显示箭头 -@property (nonatomic,strong) UIButton *arrowButton; +//@property (nonatomic,strong) UIButton *arrowButton; +///列表背景 +@property (nonatomic,strong) UIView *collectionBgView; ///列表 @property (nonatomic,strong) UICollectionView *collectionView; @@ -29,115 +35,182 @@ @implementation XPMonentsRecommendHeaderView - (instancetype)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; - if (self) { - [self initSubViews]; - [self initSubViewConstraints]; - } - return self; + self = [super initWithFrame:frame]; + if (self) { + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; } #pragma mark - Private Method - (void)initSubViews { - self.backgroundColor = [DJDKMIMOMColor appCellBackgroundColor]; - [self addSubview:self.titleLabel]; - [self addSubview:self.arrowButton]; - [self addSubview:self.collectionView]; + self.backgroundColor = [DJDKMIMOMColor appCellBackgroundColor]; + [self addSubview:self.bgView]; + [self.bgView addSubview:self.collectionBgView]; + [self.collectionBgView addSubview:self.collectionView]; + [self.bgView addSubview:self.titleBgView]; + [self.titleBgView addSubview:self.titleLabel]; + } - (void)initSubViewConstraints { - [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(self).offset(15); - make.top.mas_equalTo(self).offset(15); - }]; - - [self.arrowButton mas_makeConstraints:^(MASConstraintMaker *make) { - make.size.mas_equalTo(CGSizeMake(11, 20)); - make.centerY.mas_equalTo(self.titleLabel); - make.right.mas_equalTo(self).offset(-15); - }]; - - [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self); - make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10); - make.height.mas_equalTo(77); - }]; + + [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(16); + make.right.mas_offset(-15); + make.left.mas_offset(15); + make.bottom.mas_equalTo(-20); + }]; +// [self.collectionBgView mas_makeConstraints:^(MASConstraintMaker *make) { +// make.top.mas_equalTo(10); +// make.left.mas_equalTo(10); +// make.right.mas_equalTo(-10); +// make.bottom.mas_equalTo(-10); +// }]; + [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(15); + make.left.right.equalTo(self.collectionBgView); + make.height.mas_equalTo(69); + }]; + [self.titleBgView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.left.equalTo(self.bgView); + make.width.mas_equalTo(74); + make.height.mas_equalTo(21); + }]; + [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.center.equalTo(self.titleBgView); + }]; + +// [self.arrowButton mas_makeConstraints:^(MASConstraintMaker *make) { +// make.size.mas_equalTo(CGSizeMake(11, 20)); +// make.centerY.mas_equalTo(self.titleLabel); +// make.right.mas_equalTo(self).offset(-15); +// }]; + + } #pragma mark - UICollectionViewDelegate And UICollectionViewDatasource - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { - return self.topicList.count; + return self.topicList.count; } -- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { - return CGSizeMake(125, 77); -} +//- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { +// MonentsTopicModel * topicModel = [self.topicList safeObjectWithIndex:indexPath.row]; +// CGFloat itemWidth = [topicModel.name boundingRectWithSize:CGSizeMake(100, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10 weight:UIFontWeightBold]} context:nil].size.width; +// return CGSizeMake(itemWidth +34, 26); +//} - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - XPMonentsTopicCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMonentsTopicCollectionViewCell class]) forIndexPath:indexPath]; - cell.topicInfo = [self.topicList safeObjectAtIndex1:indexPath.row]; - return cell; + XPMonentsTopicCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMonentsTopicCollectionViewCell class]) forIndexPath:indexPath]; + + cell.topicInfo = [self.topicList safeObjectAtIndex1:indexPath.row]; + + return cell; } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { - [collectionView deselectItemAtIndexPath:indexPath animated:YES]; - if (self.topicList.count > 0) { - MonentsTopicModel * topicInfo = [self.topicList safeObjectAtIndex1:indexPath.row]; - if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsRecommendHeaderView:didSelectItem:)]) { - [self.delegate xPMonentsRecommendHeaderView:self didSelectItem:topicInfo]; - } - } + [collectionView deselectItemAtIndexPath:indexPath animated:YES]; + if (self.topicList.count > 0) { + MonentsTopicModel * topicInfo = [self.topicList safeObjectAtIndex1:indexPath.row]; + if(topicInfo == nil)return; + if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsRecommendHeaderView:didSelectItem:)]) { + [self.delegate xPMonentsRecommendHeaderView:self didSelectItem:topicInfo]; + } + } } #pragma mark - Event Response - (void)arrowButtonAction:(UIButton *)sender { - if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsRecommendHeaderView:didClickMoreTopic:)]) { - [self.delegate xPMonentsRecommendHeaderView:self didClickMoreTopic:sender]; - } + if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsRecommendHeaderView:didClickMoreTopic:)]) { + [self.delegate xPMonentsRecommendHeaderView:self didClickMoreTopic:sender]; + } } #pragma mark - Getters And Setters - (void)setTopicList:(NSArray *)topicList { - _topicList = topicList; - [self.collectionView reloadData]; + _topicList = topicList; + [self.collectionView reloadData]; } - (UILabel *)titleLabel { - if (!_titleLabel) { - _titleLabel = [[UILabel alloc] init]; - _titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium]; - _titleLabel.textColor = [DJDKMIMOMColor mainTextColor]; - _titleLabel.text = YMLocalizedString(@"XPMonentsRecommendHeaderView0"); - } - return _titleLabel; + if (!_titleLabel) { + _titleLabel = [[UILabel alloc] init]; + _titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium]; + _titleLabel.textColor = UIColorFromRGB(0x0D344D); + _titleLabel.text = YMLocalizedString(@"XPMonentsRecommendHeaderView0"); + } + return _titleLabel; } -- (UIButton *)arrowButton { - if (!_arrowButton) { - _arrowButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_arrowButton setImage:[UIImage imageNamed:@"room_setting_arrow"] forState:UIControlStateNormal]; - [_arrowButton setImage:[UIImage imageNamed:@"room_setting_arrow"] forState:UIControlStateSelected]; - [_arrowButton addTarget:self action:@selector(arrowButtonAction:) forControlEvents:UIControlEventTouchUpInside]; - } - return _arrowButton; -} +//- (UIButton *)arrowButton { +// if (!_arrowButton) { +// _arrowButton = [UIButton buttonWithType:UIButtonTypeCustom]; +// [_arrowButton setImage:[UIImage imageNamed:@"room_setting_arrow"] forState:UIControlStateNormal]; +// [_arrowButton setImage:[UIImage imageNamed:@"room_setting_arrow"] forState:UIControlStateSelected]; +// [_arrowButton addTarget:self action:@selector(arrowButtonAction:) forControlEvents:UIControlEventTouchUpInside]; +// } +// return _arrowButton; +//} - (UICollectionView *)collectionView{ - if (!_collectionView) { - UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; - layout.sectionInset = UIEdgeInsetsMake(0, 15, 0, 0); - layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; - layout.minimumLineSpacing = 8; - _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; - _collectionView.dataSource = self; - _collectionView.delegate = self; - _collectionView.backgroundColor = [UIColor clearColor]; - _collectionView.showsHorizontalScrollIndicator = NO; - [_collectionView registerClass:[XPMonentsTopicCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPMonentsTopicCollectionViewCell class])]; - } - return _collectionView; + if (!_collectionView) { + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; + layout.sectionInset = UIEdgeInsetsMake(0,0, 0, 0); + layout.itemSize = CGSizeMake((KScreenWidth - 50)/2, 18); + layout.minimumLineSpacing = 0; + layout.minimumInteritemSpacing = 0; + layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; + _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; + _collectionView.dataSource = self; + _collectionView.delegate = self; + _collectionView.backgroundColor = [UIColor clearColor]; + _collectionView.pagingEnabled = YES; + _collectionView.showsHorizontalScrollIndicator = NO; + [_collectionView registerClass:[XPMonentsTopicCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPMonentsTopicCollectionViewCell class])]; + } + return _collectionView; +} +- (UIView *)collectionBgView{ + if (!_collectionBgView){ + + UIView *view = [[UIView alloc] init]; + view.frame = CGRectMake(10,10,KScreenWidth - 50,89); + view.layer.borderWidth = 0.5; + view.layer.borderColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0].CGColor; + + view.layer.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:0.6300].CGColor; + + // blur + UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; + UIVisualEffectView *visualView = [[UIVisualEffectView alloc]initWithEffect:blurEffect]; + visualView.frame = CGRectMake(10,10,KScreenWidth - 50,89); + view.layer.cornerRadius = 8; + _collectionBgView = view; + _collectionView.userInteractionEnabled = YES; + } + return _collectionBgView; +} +- (UIImageView *)bgView{ + if (!_bgView){ + _bgView = [UIImageView new]; + UIImage *image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x9FF4F2),UIColorFromRGB(0x96D6FF)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(KScreenWidth - 30, 109)]; + _bgView.image = image; + [_bgView setCornerWithLeftTopCorner:10 rightTopCorner:10 bottomLeftCorner:10 bottomRightCorner:10 size:CGSizeMake(KScreenWidth - 30, 109)]; + _bgView.userInteractionEnabled = YES; + } + return _bgView; +} +-(UIImageView *)titleBgView{ + if (!_titleBgView){ + _titleBgView = [UIImageView new]; + UIImage *image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x83E8E7),UIColorFromRGB(0x86D4F6)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(74, 21)]; + _titleBgView.image = image; + [_titleBgView setCornerWithLeftTopCorner:10 rightTopCorner:0 bottomLeftCorner:0 bottomRightCorner:10 size:CGSizeMake(74, 21)]; + _titleBgView.userInteractionEnabled = YES; + } + return _titleBgView; } - - @end diff --git a/YuMi/Modules/YMMonents/View/SubViews/XPMonentsUserInfoView.h b/YuMi/Modules/YMMonents/View/SubViews/XPMonentsUserInfoView.h index d8852d15..73ec6f04 100644 --- a/YuMi/Modules/YMMonents/View/SubViews/XPMonentsUserInfoView.h +++ b/YuMi/Modules/YMMonents/View/SubViews/XPMonentsUserInfoView.h @@ -1,8 +1,8 @@ // -// YMMonentsUserInfoView.h -// YUMI +// XPMonentsUserInfoView.h +// xplan-ios // -// Created by YUMI on 2022/5/12. +// Created by 冯硕 on 2022/5/12. // #import @@ -17,6 +17,9 @@ NS_ASSUME_NONNULL_BEGIN ///点击了跟随进房 - (void)xPMonentsUserInfoView:(XPMonentsUserInfoView *)view didClickEnterRoom:(MonentsInfoModel *)monents; +///删除 +- (void)xPMonentsTooBarView:(XPMonentsUserInfoView *)view didClickDelete:(MonentsInfoModel *)monentsInfo; + @end @interface XPMonentsUserInfoView : UIView ///动态信息 diff --git a/YuMi/Modules/YMMonents/View/SubViews/XPMonentsUserInfoView.m b/YuMi/Modules/YMMonents/View/SubViews/XPMonentsUserInfoView.m index 5466f0aa..fe2afe22 100644 --- a/YuMi/Modules/YMMonents/View/SubViews/XPMonentsUserInfoView.m +++ b/YuMi/Modules/YMMonents/View/SubViews/XPMonentsUserInfoView.m @@ -1,21 +1,24 @@ // -// YMMonentsUserInfoView.m -// YUMI +// XPMonentsUserInfoView.m +// xplan-ios // -// Created by YUMI on 2022/5/12. +// Created by 冯硕 on 2022/5/12. // #import "XPMonentsUserInfoView.h" ///Third #import ///Tool -#import "DJDKMIMOMColor.h" + #import "NetImageView.h" #import "SpriteSheetImageManager.h" -#import "YUMIMacroUitls.h" +#import "TTPopup.h" +#import "XPWebViewController.h" +#import "XCCurrentVCStackManager.h" +#import "AccountInfoStorage.h" +#import "UIButton+EnlargeTouchArea.h" ///Model #import "MonentsInfoModel.h" -#import "NSArray+Safe.h" @interface XPMonentsUserInfoView () /// @@ -58,410 +61,436 @@ @property (nonatomic,strong) NetImageView *thirdTagImageView; ///直播中 @property (nonatomic,strong) UIButton *onlineButton; + @end @implementation XPMonentsUserInfoView - (instancetype)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; - if (self) { - [self initSubViews]; - [self initSubViewConstraints]; - } - return self; + self = [super initWithFrame:frame]; + if (self) { + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; } #pragma mark - Private Method - (void)initSubViews { - [self addSubview:self.avatarImageView]; - [self addSubview:self.headWearImageView]; - [self addSubview:self.nickLabel]; - [self addSubview:self.sexImageView]; - [self addSubview:self.tagStackView]; - [self addSubview:self.levelStackView]; - [self addSubview:self.onlineButton]; - - [self.tagStackView addArrangedSubview:self.firstTagImageView]; - [self.tagStackView addArrangedSubview:self.secondTagImageView]; - [self.tagStackView addArrangedSubview:self.thirdTagImageView]; + [self addSubview:self.avatarImageView]; + [self addSubview:self.headWearImageView]; + [self addSubview:self.nickLabel]; + [self addSubview:self.sexImageView]; + [self addSubview:self.tagStackView]; + [self addSubview:self.levelStackView]; + [self addSubview:self.onlineButton]; + + [self.tagStackView addArrangedSubview:self.firstTagImageView]; + [self.tagStackView addArrangedSubview:self.secondTagImageView]; + [self.tagStackView addArrangedSubview:self.thirdTagImageView]; - [self.levelStackView addArrangedSubview:self.nobleImageView]; - [self.levelStackView addArrangedSubview:self.newsUserImageView]; - [self.levelStackView addArrangedSubview:self.officalImageView]; - [self.levelStackView addArrangedSubview:self.experImageView]; - [self.levelStackView addArrangedSubview:self.charmImageView]; - [self.levelStackView addArrangedSubview:self.namePlateView]; - ///铭牌 - [self.namePlateView addSubview:self.nameplateImageView]; - [self.namePlateView addSubview:self.nameplateLabel]; - + [self.levelStackView addArrangedSubview:self.nobleImageView]; + [self.levelStackView addArrangedSubview:self.newsUserImageView]; + [self.levelStackView addArrangedSubview:self.officalImageView]; + [self.levelStackView addArrangedSubview:self.experImageView]; + [self.levelStackView addArrangedSubview:self.charmImageView]; + [self.levelStackView addArrangedSubview:self.namePlateView]; + ///铭牌 + [self.namePlateView addSubview:self.nameplateImageView]; + [self.namePlateView addSubview:self.nameplateLabel]; + } - (void)initSubViewConstraints { - [self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.size.mas_equalTo(CGSizeMake(40, 40)); - make.left.mas_equalTo(self).offset(15); - make.top.mas_equalTo(self).offset(15); - }]; - - [self.headWearImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.center.mas_equalTo(self.avatarImageView); - make.width.mas_equalTo(self.avatarImageView.mas_width).multipliedBy(1.2); - make.height.mas_equalTo(self.headWearImageView.mas_width); - }]; - - [self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(self.avatarImageView.mas_right).offset(12); - make.bottom.mas_equalTo(self.avatarImageView.mas_centerY).offset(-2); - }]; - - [self.sexImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.size.mas_equalTo(CGSizeMake(14, 14)); - make.left.mas_equalTo(self.nickLabel.mas_right).offset(4); - make.centerY.mas_equalTo(self.nickLabel); - }]; - - [self.levelStackView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(self.nickLabel); - make.top.mas_equalTo(self.avatarImageView.mas_centerY).offset(2); - make.height.mas_equalTo(20); - }]; + - [self.nobleImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(20); - }]; - - [self.newsUserImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(20); - }]; - - [self.officalImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(20); - }]; - - [self.experImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(20); - }]; - - [self.charmImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(20); - }]; - - [self.namePlateView mas_makeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(self.nameplateImageView.mas_width); - }]; + [self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(50, 50)); + make.left.mas_equalTo(self).offset(15); + make.centerY.mas_equalTo(self); + }]; + + [self.headWearImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.center.mas_equalTo(self.avatarImageView); + make.width.mas_equalTo(self.avatarImageView.mas_width).multipliedBy(1.2); + make.height.mas_equalTo(self.headWearImageView.mas_width); + }]; - [self.nameplateImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(20); - make.width.mas_equalTo(60); - make.left.top.mas_equalTo(self.namePlateView); - }]; - - [self.nameplateLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.bottom.mas_equalTo(self.nameplateImageView); - make.right.mas_equalTo(self.namePlateView).offset(-2); - }]; - - [self.tagStackView mas_makeConstraints:^(MASConstraintMaker *make) { - make.right.mas_equalTo(self).offset(-15); - make.centerY.mas_equalTo(self.nickLabel); - make.height.mas_equalTo(14); - }]; + + [self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.avatarImageView.mas_right).offset(12); + make.bottom.mas_equalTo(self.avatarImageView.mas_centerY).offset(-2); + }]; + + [self.sexImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(14, 14)); + make.left.mas_equalTo(self.nickLabel.mas_right).offset(4); + make.centerY.mas_equalTo(self.nickLabel); + }]; + + [self.levelStackView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.nickLabel); + make.top.mas_equalTo(self.avatarImageView.mas_centerY).offset(2); + make.height.mas_equalTo(20); + }]; - [self.onlineButton mas_makeConstraints:^(MASConstraintMaker *make) { - make.size.mas_equalTo(CGSizeMake(55, 18)); - make.right.mas_equalTo(self.tagStackView); - make.top.mas_equalTo(self.tagStackView.mas_bottom).offset(4); - }]; - - [self.firstTagImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(28); - }]; - - [self.secondTagImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(self.firstTagImageView); - }]; - - [self.thirdTagImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(self.firstTagImageView); - }]; + [self.nobleImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(20); + }]; + + [self.newsUserImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(20); + }]; + + [self.officalImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(20); + }]; + + [self.experImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(20); + }]; + + [self.charmImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(20); + }]; + + [self.namePlateView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(self.nameplateImageView.mas_width); + }]; + + [self.nameplateImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(20); + make.width.mas_equalTo(60); + make.left.top.mas_equalTo(self.namePlateView); + }]; + + [self.nameplateLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.bottom.mas_equalTo(self.nameplateImageView); + make.right.mas_equalTo(self.namePlateView).offset(-2); + }]; + + [self.tagStackView mas_makeConstraints:^(MASConstraintMaker *make) { + make.right.mas_equalTo(self).offset(-15); + make.centerY.mas_equalTo(self.nickLabel); + make.height.mas_equalTo(14); + }]; + + [self.onlineButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(55, 18)); + make.right.mas_equalTo(-15); + make.top.equalTo(self.tagStackView.mas_bottom).mas_offset(8); + }]; + + [self.firstTagImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(28); + }]; + + [self.secondTagImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(self.firstTagImageView); + }]; + + [self.thirdTagImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(self.firstTagImageView); + }]; } #pragma mark - Event Response - (void)onlineButtonAction:(UIButton *)sender { - if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsUserInfoView:didClickEnterRoom:)]) { - [self.delegate xPMonentsUserInfoView:self didClickEnterRoom:self.monentsInfo]; - } + if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsUserInfoView:didClickEnterRoom:)]) { + [self.delegate xPMonentsUserInfoView:self didClickEnterRoom:self.monentsInfo]; + } } - (void)didTapAvatarGuest { - if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsUserInfoView:didClickAvatar:)]) { - [self.delegate xPMonentsUserInfoView:self didClickAvatar:self.monentsInfo]; - } + if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsUserInfoView:didClickAvatar:)]) { + [self.delegate xPMonentsUserInfoView:self didClickAvatar:self.monentsInfo]; + } } +- (void)reportButtonAction:(UIButton *)sender { + TTActionSheetConfig *action; + if (self.monentsInfo.uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) { + action = [TTActionSheetConfig normalTitle:YMLocalizedString(@"XPMonentsUserInfoView0") clickAction:^{ + if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsTooBarView:didClickDelete:)]) { + [self.delegate xPMonentsTooBarView:self didClickDelete:self.monentsInfo]; + } + }]; + } else { + action = [TTActionSheetConfig normalTitle:YMLocalizedString(@"XPMonentsUserInfoView1") clickAction:^{ + NSString * url= [NSString stringWithFormat:@"%@?reportUid=%@&source=%@", URLWithType(kReportRoomURL),self.monentsInfo.uid, @"WORLDDYNAMIC"]; + XPWebViewController * webVC = [[XPWebViewController alloc] init]; + webVC.url = url; + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES]; + }]; + } + [TTPopup actionSheetWithItems:@[action]]; +} #pragma mark - Getters And Setters - (void)setMonentsInfo:(MonentsInfoModel *)monentsInfo { - _monentsInfo = monentsInfo; - if (_monentsInfo) { - self.avatarImageView.imageUrl = _monentsInfo.avatar; - NSString * nick = _monentsInfo.nick; - if (nick.length > 8) { - nick = [NSString stringWithFormat:@"%@…", [nick substringToIndex:8]]; - } - self.nickLabel.text = nick.length > 0 ? nick : @""; - self.sexImageView.image = _monentsInfo.gender == GenderType_Female ? [UIImage imageNamed:@"common_female"] : [UIImage imageNamed:@"common_male"]; - self.officalImageView.hidden = _monentsInfo.defUser != 2; - self.newsUserImageView.hidden = !_monentsInfo.newUser; - self.nobleImageView.hidden = !_monentsInfo.userVipInfoVO; - if (_monentsInfo.experLevelPic) { - self.experImageView.imageUrl = _monentsInfo.experLevelPic; - } - self.experImageView.hidden = _monentsInfo.experLevelPic.length <= 0; - - if (_monentsInfo.charmLevelPic) { - self.charmImageView.imageUrl = _monentsInfo.charmLevelPic; - } + _monentsInfo = monentsInfo; + if (_monentsInfo) { + self.avatarImageView.imageUrl = _monentsInfo.avatar; + NSString * nick = _monentsInfo.nick; + if (nick.length > 8) { + nick = [NSString stringWithFormat:@"%@…", [nick substringToIndex:8]]; + } + self.nickLabel.text = nick.length > 0 ? nick : @""; + self.sexImageView.image = _monentsInfo.gender == GenderType_Female ? [UIImage imageNamed:@"common_female"] : [UIImage imageNamed:@"common_male"]; + self.officalImageView.hidden = _monentsInfo.defUser != 2; + self.newsUserImageView.hidden = !_monentsInfo.newUser; + self.nobleImageView.hidden = !_monentsInfo.userVipInfoVO; + if (_monentsInfo.experLevelPic) { + self.experImageView.imageUrl = _monentsInfo.experLevelPic; + } + self.experImageView.hidden = _monentsInfo.experLevelPic.length <= 0; + + if (_monentsInfo.charmLevelPic) { + self.charmImageView.imageUrl = _monentsInfo.charmLevelPic; + } - if (_monentsInfo.userVipInfoVO) { - self.nobleImageView.imageUrl = _monentsInfo.userVipInfoVO.vipIcon; - } + if (_monentsInfo.userVipInfoVO) { + self.nobleImageView.imageUrl = _monentsInfo.userVipInfoVO.vipIcon; + } - self.charmImageView.hidden = _monentsInfo.charmLevelPic.length <= 0; - - if (_monentsInfo.nameplateWord.length>0 && _monentsInfo.nameplatePic.length>0) { - self.nameplateImageView.imageUrl = _monentsInfo.nameplatePic; - self.nameplateLabel.text = _monentsInfo.nameplateWord; - self.namePlateView.hidden = NO; - } else { - self.namePlateView.hidden = YES; - } + self.charmImageView.hidden = _monentsInfo.charmLevelPic.length <= 0; + + if (_monentsInfo.nameplateWord.length>0 && _monentsInfo.nameplatePic.length>0) { + self.nameplateImageView.imageUrl = _monentsInfo.nameplatePic; + self.nameplateLabel.text = _monentsInfo.nameplateWord; + self.namePlateView.hidden = NO; + } else { + self.namePlateView.hidden = YES; + } - - NSString * headwearUrl= _monentsInfo.headwearEffect.length > 0 ? _monentsInfo.headwearEffect : _monentsInfo.headwearPic; - self.headWearImageView.hidden = headwearUrl.length <= 0; - if (headwearUrl.length > 0) { - NSURL *url = [NSURL URLWithString:headwearUrl]; - @kWeakify(self); - [self.manager loadSpriteSheetImageWithURL:url completionBlock:^(YYSpriteSheetImage * _Nullable sprit) { - @kStrongify(self); - self.headWearImageView.image = sprit; - } failureBlock:^(NSError * _Nullable error) { - }]; - } - self.firstTagImageView.hidden = YES; - self.secondTagImageView.hidden = YES; - self.thirdTagImageView.hidden = YES; - for (int i = 0; i< _monentsInfo.labelList.count; i++) { - NSString * imageUrl = [_monentsInfo.labelList safeObjectAtIndex1:i]; - if (i < self.tagStackView.subviews.count) { - NetImageView * image = [self.tagStackView.subviews safeObjectAtIndex1:i]; - image.hidden = NO; - image.imageUrl = imageUrl; - } - } - self.onlineButton.hidden = _monentsInfo.inRoomUid.length <= 0; - } + + NSString * headwearUrl= _monentsInfo.headwearEffect.length > 0 ? _monentsInfo.headwearEffect : _monentsInfo.headwearPic; + self.headWearImageView.hidden = headwearUrl.length <= 0; + if (headwearUrl.length > 0) { + NSURL *url = [NSURL URLWithString:headwearUrl]; + @kWeakify(self); + [self.manager loadSpriteSheetImageWithURL:url completionBlock:^(YYSpriteSheetImage * _Nullable sprit) { + @kStrongify(self); + self.headWearImageView.image = sprit; + } failureBlock:^(NSError * _Nullable error) { + }]; + } + self.firstTagImageView.hidden = YES; + self.secondTagImageView.hidden = YES; + self.thirdTagImageView.hidden = YES; + for (int i = 0; i< _monentsInfo.labelList.count; i++) { + NSString * imageUrl = [_monentsInfo.labelList safeObjectAtIndex1:i]; + if (i < self.tagStackView.subviews.count) { + NetImageView * image = [self.tagStackView.subviews safeObjectAtIndex1:i]; + if(image != nil){ + image.hidden = NO; + image.imageUrl = imageUrl; + } + } + } + self.onlineButton.hidden = _monentsInfo.inRoomUid.length <= 0; + } } - (SpriteSheetImageManager *)manager { - if (!_manager) { - _manager = [[SpriteSheetImageManager alloc] init]; - } - return _manager; + if (!_manager) { + _manager = [[SpriteSheetImageManager alloc] init]; + } + return _manager; } - (YYAnimatedImageView *)headWearImageView { - if (!_headWearImageView) { - _headWearImageView = [[YYAnimatedImageView alloc] init]; - _headWearImageView.backgroundColor = [UIColor clearColor]; - _headWearImageView.contentMode = UIViewContentModeScaleAspectFit; - } - return _headWearImageView; + if (!_headWearImageView) { + _headWearImageView = [[YYAnimatedImageView alloc] init]; + _headWearImageView.backgroundColor = [UIColor clearColor]; + _headWearImageView.contentMode = UIViewContentModeScaleAspectFit; + } + return _headWearImageView; } - (NetImageView *)avatarImageView { - if (!_avatarImageView) { - NetImageConfig * config = [[NetImageConfig alloc] init]; - config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; - config.imageType = ImageTypeUserIcon; - _avatarImageView = [[NetImageView alloc] initWithConfig:config]; - _avatarImageView.userInteractionEnabled = YES; - _avatarImageView.layer.masksToBounds = YES; - _avatarImageView.layer.cornerRadius = 20; - _avatarImageView.contentMode = UIViewContentModeScaleAspectFill; - UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapAvatarGuest)]; - [_avatarImageView addGestureRecognizer:tap]; - } - return _avatarImageView; + if (!_avatarImageView) { + NetImageConfig * config = [[NetImageConfig alloc] init]; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + config.imageType = ImageTypeUserIcon; + _avatarImageView = [[NetImageView alloc] initWithConfig:config]; + _avatarImageView.userInteractionEnabled = YES; + _avatarImageView.layer.masksToBounds = YES; + _avatarImageView.layer.cornerRadius = 25; + _avatarImageView.contentMode = UIViewContentModeScaleAspectFill; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapAvatarGuest)]; + [_avatarImageView addGestureRecognizer:tap]; + } + return _avatarImageView; } - (UILabel *)nickLabel { - if (!_nickLabel) { - _nickLabel = [[UILabel alloc] init]; - _nickLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium]; - _nickLabel.textColor = [DJDKMIMOMColor mainTextColor]; - } - return _nickLabel; + if (!_nickLabel) { + _nickLabel = [[UILabel alloc] init]; + _nickLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium]; + _nickLabel.textColor = [DJDKMIMOMColor mainTextColor]; + } + return _nickLabel; } - (UIImageView *)sexImageView { - if (!_sexImageView) { - _sexImageView = [[UIImageView alloc] init]; - _sexImageView.userInteractionEnabled = YES; - } - return _sexImageView; + if (!_sexImageView) { + _sexImageView = [[UIImageView alloc] init]; + _sexImageView.userInteractionEnabled = YES; + } + return _sexImageView; } - (UIStackView *)levelStackView { - if (!_levelStackView) { - _levelStackView = [[UIStackView alloc] init]; - _levelStackView.axis = UILayoutConstraintAxisHorizontal; - _levelStackView.distribution = UIStackViewDistributionFill; - _levelStackView.alignment = UIStackViewAlignmentFill; - _levelStackView.spacing = 2; - } - return _levelStackView; + if (!_levelStackView) { + _levelStackView = [[UIStackView alloc] init]; + _levelStackView.axis = UILayoutConstraintAxisHorizontal; + _levelStackView.distribution = UIStackViewDistributionFill; + _levelStackView.alignment = UIStackViewAlignmentFill; + _levelStackView.spacing = 2; + } + return _levelStackView; } - (NetImageView *)experImageView { - if (!_experImageView) { - NetImageConfig * config = [[NetImageConfig alloc] init]; - config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; - config.imageType = ImageTypeUserCardLevel; - _experImageView = [[NetImageView alloc] initWithConfig:config]; - _experImageView.userInteractionEnabled = YES; - _experImageView.hidden = YES; - _experImageView.contentMode = UIViewContentModeScaleAspectFit; - } - return _experImageView; + if (!_experImageView) { + NetImageConfig * config = [[NetImageConfig alloc] init]; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + config.imageType = ImageTypeUserCardLevel; + _experImageView = [[NetImageView alloc] initWithConfig:config]; + _experImageView.userInteractionEnabled = YES; + _experImageView.hidden = YES; + _experImageView.contentMode = UIViewContentModeScaleAspectFit; + } + return _experImageView; } - (NetImageView *)charmImageView { - if (!_charmImageView) { - NetImageConfig * config = [[NetImageConfig alloc] init]; - config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; - config.imageType = ImageTypeUserCardLevel; - _charmImageView = [[NetImageView alloc] initWithConfig:config]; - _charmImageView.userInteractionEnabled = YES; - _charmImageView.hidden = YES; - _charmImageView.contentMode = UIViewContentModeScaleAspectFit; - } - return _charmImageView; + if (!_charmImageView) { + NetImageConfig * config = [[NetImageConfig alloc] init]; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + config.imageType = ImageTypeUserCardLevel; + _charmImageView = [[NetImageView alloc] initWithConfig:config]; + _charmImageView.userInteractionEnabled = YES; + _charmImageView.hidden = YES; + _charmImageView.contentMode = UIViewContentModeScaleAspectFit; + } + return _charmImageView; } - (NetImageView *)nobleImageView { - if (!_nobleImageView) { - NetImageConfig * config = [[NetImageConfig alloc] init]; - config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; - config.imageType = ImageTypeUserCardLevel; - _nobleImageView = [[NetImageView alloc] initWithConfig:config]; - _nobleImageView.userInteractionEnabled = YES; - _nobleImageView.hidden = YES; - _nobleImageView.contentMode = UIViewContentModeScaleAspectFit; - } - return _nobleImageView; + if (!_nobleImageView) { + NetImageConfig * config = [[NetImageConfig alloc] init]; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + config.imageType = ImageTypeUserCardLevel; + _nobleImageView = [[NetImageView alloc] initWithConfig:config]; + _nobleImageView.userInteractionEnabled = YES; + _nobleImageView.hidden = YES; + _nobleImageView.contentMode = UIViewContentModeScaleAspectFit; + } + return _nobleImageView; } - (UIView *)namePlateView { - if (!_namePlateView) { - _namePlateView = [[UIView alloc] init]; - _namePlateView.backgroundColor = [UIColor clearColor]; - _namePlateView.hidden = YES; - } - return _namePlateView; + if (!_namePlateView) { + _namePlateView = [[UIView alloc] init]; + _namePlateView.backgroundColor = [UIColor clearColor]; + _namePlateView.hidden = YES; + } + return _namePlateView; } - (NetImageView *)nameplateImageView { - if (!_nameplateImageView) { - NetImageConfig * config = [[NetImageConfig alloc] init]; - config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; - config.imageType = ImageTypeUserCardLevel; - _nameplateImageView = [[NetImageView alloc] initWithConfig:config]; - _nameplateImageView.userInteractionEnabled = YES; - _nameplateImageView.contentMode = UIViewContentModeScaleAspectFit; - } - return _nameplateImageView; + if (!_nameplateImageView) { + NetImageConfig * config = [[NetImageConfig alloc] init]; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + config.imageType = ImageTypeUserCardLevel; + _nameplateImageView = [[NetImageView alloc] initWithConfig:config]; + _nameplateImageView.userInteractionEnabled = YES; + _nameplateImageView.contentMode = UIViewContentModeScaleAspectFit; + } + return _nameplateImageView; } - (UILabel *)nameplateLabel { - if (!_nameplateLabel) { - _nameplateLabel = [[UILabel alloc] init]; - _nameplateLabel.font = [UIFont systemFontOfSize:10]; - _nameplateLabel.textAlignment = NSTextAlignmentCenter; - _nameplateLabel.textColor = [UIColor whiteColor]; - } - return _nameplateLabel; + if (!_nameplateLabel) { + _nameplateLabel = [[UILabel alloc] init]; + _nameplateLabel.font = [UIFont systemFontOfSize:10]; + _nameplateLabel.textAlignment = NSTextAlignmentCenter; + _nameplateLabel.textColor = [UIColor whiteColor]; + } + return _nameplateLabel; } - (UIImageView *)newsUserImageView { - if (!_newsUserImageView) { - _newsUserImageView = [[UIImageView alloc] init]; - _newsUserImageView.userInteractionEnabled = YES; - _newsUserImageView.image = [UIImage imageNamed:@"common_new_user"]; - _newsUserImageView.hidden = YES; - } - return _newsUserImageView; + if (!_newsUserImageView) { + _newsUserImageView = [[UIImageView alloc] init]; + _newsUserImageView.userInteractionEnabled = YES; + _newsUserImageView.image = [UIImage imageNamed:@"common_new_user"]; + _newsUserImageView.hidden = YES; + } + return _newsUserImageView; } - (UIImageView *)officalImageView { - if (!_officalImageView) { - _officalImageView = [[UIImageView alloc] init]; - _officalImageView.userInteractionEnabled = YES; - _officalImageView.image = [UIImage imageNamed:@"common_offical"]; - _officalImageView.hidden = YES; - } - return _officalImageView; + if (!_officalImageView) { + _officalImageView = [[UIImageView alloc] init]; + _officalImageView.userInteractionEnabled = YES; + _officalImageView.image = [UIImage imageNamed:@"common_offical"]; + _officalImageView.hidden = YES; + } + return _officalImageView; } - (UIStackView *)tagStackView { - if (!_tagStackView) { - _tagStackView = [[UIStackView alloc] init]; - _tagStackView.axis = UILayoutConstraintAxisHorizontal; - _tagStackView.distribution = UIStackViewDistributionFill; - _tagStackView.alignment = UIStackViewAlignmentFill; - _tagStackView.spacing = 2; - } - return _tagStackView; + if (!_tagStackView) { + _tagStackView = [[UIStackView alloc] init]; + _tagStackView.axis = UILayoutConstraintAxisHorizontal; + _tagStackView.distribution = UIStackViewDistributionFill; + _tagStackView.alignment = UIStackViewAlignmentFill; + _tagStackView.spacing = 2; + } + return _tagStackView; } - (NetImageView *)firstTagImageView { - if (!_firstTagImageView) { - _firstTagImageView = [[NetImageView alloc] init]; - _firstTagImageView.hidden = YES; - } - return _firstTagImageView; + if (!_firstTagImageView) { + _firstTagImageView = [[NetImageView alloc] init]; + _firstTagImageView.hidden = YES; + } + return _firstTagImageView; } - (NetImageView *)secondTagImageView { - if (!_secondTagImageView) { - _secondTagImageView = [[NetImageView alloc] init]; - _secondTagImageView.hidden = YES; - } - return _secondTagImageView; + if (!_secondTagImageView) { + _secondTagImageView = [[NetImageView alloc] init]; + _secondTagImageView.hidden = YES; + } + return _secondTagImageView; } - (NetImageView *)thirdTagImageView { - if (!_thirdTagImageView) { - _thirdTagImageView = [[NetImageView alloc] init]; - _thirdTagImageView.hidden = YES; - } - return _thirdTagImageView; + if (!_thirdTagImageView) { + _thirdTagImageView = [[NetImageView alloc] init]; + _thirdTagImageView.hidden = YES; + } + return _thirdTagImageView; } - (UIButton *)onlineButton { - if (!_onlineButton) { - _onlineButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_onlineButton setTitle:YMLocalizedString(@"XPMonentsUserInfoView0") forState:UIControlStateNormal]; - [_onlineButton setImage:[UIImage imageNamed:@"home_search_user_online"] forState:UIControlStateNormal]; - [_onlineButton setTitleColor:[DJDKMIMOMColor appEmphasizeColor] forState:UIControlStateNormal]; - _onlineButton.backgroundColor = [UIColor clearColor]; - _onlineButton.titleLabel.font = [UIFont systemFontOfSize:10]; - _onlineButton.layer.masksToBounds = YES; - _onlineButton.layer.cornerRadius = 18/2; - _onlineButton.layer.borderColor = [DJDKMIMOMColor appEmphasizeColor].CGColor; - _onlineButton.layer.borderWidth = 1; - [_onlineButton addTarget:self action:@selector(onlineButtonAction:) forControlEvents:UIControlEventTouchUpInside]; - } - return _onlineButton; + if (!_onlineButton) { + _onlineButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_onlineButton setTitle:YMLocalizedString(@"XPMonentsUserInfoView2") forState:UIControlStateNormal]; + [_onlineButton setImage:[UIImage imageNamed:@"monents_on_line_note"] forState:UIControlStateNormal]; + [_onlineButton setTitleColor:[DJDKMIMOMColor appMainColor] forState:UIControlStateNormal]; + _onlineButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 3); + _onlineButton.backgroundColor = [UIColor clearColor]; + _onlineButton.titleLabel.font = [UIFont systemFontOfSize:10]; + _onlineButton.layer.masksToBounds = YES; + _onlineButton.layer.cornerRadius = 18/2; + [_onlineButton setBackgroundImage:[UIImage imageNamed:@"monents_on_line_bg"] forState:UIControlStateNormal]; + [_onlineButton addTarget:self action:@selector(onlineButtonAction:) forControlEvents:UIControlEventTouchUpInside]; + } + return _onlineButton; } + + @end diff --git a/YuMi/Modules/YMMonents/View/XPMonentsAttentionViewController.m b/YuMi/Modules/YMMonents/View/XPMonentsAttentionViewController.m index a5673665..0636d099 100644 --- a/YuMi/Modules/YMMonents/View/XPMonentsAttentionViewController.m +++ b/YuMi/Modules/YMMonents/View/XPMonentsAttentionViewController.m @@ -1,8 +1,8 @@ // -// YMMonentsAttentionViewController.m -// YUMI +// XPMonentsAttentionViewController.m +// xplan-ios // -// Created by YUMI on 2022/5/18. +// Created by 冯硕 on 2022/5/18. // #import "XPMonentsAttentionViewController.h" @@ -10,12 +10,9 @@ #import #import ///Tool -#import "DJDKMIMOMColor.h" -#import "YUMIMacroUitls.h" + #import "XPMonentsLayoutConfig.h" #import "TTPopup.h" -#import "NSArray+Safe.h" -#import "ClientConfig.h" ///Model #import "MonentsListInfoModel.h" ///P @@ -25,8 +22,7 @@ #import "XPMonentsTableViewCell.h" #import "XPMonentsEmptyTableViewCell.h" #import "XPMonentsDetailViewController.h" -#import "XPMomentsSimpleDetailViewController.h" - +UIKIT_EXTERN NSString *kRequestRicket; @interface XPMonentsAttentionViewController () ///列表 @property (nonatomic,strong) UITableView *tableView; @@ -41,242 +37,273 @@ @end @implementation XPMonentsAttentionViewController - +-(void)dealloc{ + [[NSNotificationCenter defaultCenter]removeObserver:self]; +} - (BOOL)isHiddenNavBar { - return YES; + return YES; } - (__kindof id)createPresenter { - return [[XPMonentsAttentionPresenter alloc] init]; + return [[XPMonentsAttentionPresenter alloc] init]; } - (void)viewDidLoad { - [super viewDidLoad]; - [self initHeaderAndFooterRrfresh]; - [self initSubViews]; - [self initSubViewConstraints]; + [super viewDidLoad]; + [self initHeaderAndFooterRrfresh]; + [self initSubViews]; + [self initSubViewConstraints]; } #pragma mark - Private Method - (void)initSubViews { - [self.view addSubview:self.tableView]; + [self.view addSubview:self.tableView]; + [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(requestRicketSuccess:) name:kRequestRicket object:nil]; +} +-(void)requestRicketSuccess:(NSNotification *)not{ + if([not.object isKindOfClass:[NSDictionary class]])return; + BOOL is = [not.object boolValue]; + if(is == YES){ + [self headerRefresh]; + } } + - (void)initSubViewConstraints { - [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self.view); - }]; + [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.view); + }]; } #pragma mark - 下拉刷新 - (void)initHeaderAndFooterRrfresh { - MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)]; - header.stateLabel.font = [UIFont systemFontOfSize:10.0]; - header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0]; - header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; - header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor]; - self.tableView.mj_header = header; - - MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)]; - footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; - footer.stateLabel.font = [UIFont systemFontOfSize:10.0]; - self.tableView.mj_footer = footer; - - [self headerRefresh]; + MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)]; + header.stateLabel.font = [UIFont systemFontOfSize:10.0]; + header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0]; + header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; + header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor]; + self.tableView.mj_header = header; + + MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)]; + footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; + footer.stateLabel.font = [UIFont systemFontOfSize:10.0]; + self.tableView.mj_footer = footer; + + [self headerRefresh]; } #pragma mark - 刷新的fangfa - (void)headerRefresh { - self.page = 1; - [self.presenter getMonentsAttentionListPageSize:20 dynamicId:@"" state:0]; + if([AccountInfoStorage instance].isRequestRicket == YES){ + return; + } + self.page = 1; + [self.presenter getMonentsAttentionListPageSize:20 dynamicId:@"" state:0]; } - (void)footerRefresh { - if (self.hasNoMoreData) { - [self showErrorToast:YMLocalizedString(@"XPMonentsAttentionViewController0")]; - [self.tableView.mj_footer endRefreshing]; - return; - } - self.page++; - [self.presenter getMonentsAttentionListPageSize:20 dynamicId:self.listInfo.nextDynamicId state:1]; + if([AccountInfoStorage instance].isRequestRicket == YES)return; + if (self.hasNoMoreData) { + [self showErrorToast:YMLocalizedString(@"XPMonentsAttentionViewController0")]; + [self.tableView.mj_footer endRefreshing]; + return; + } + self.page++; + [self.presenter getMonentsAttentionListPageSize:20 dynamicId:self.listInfo.nextDynamicId state:1]; } #pragma mark - UITableViewDelegate And UITableViewDataSource - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return self.datasource.count > 0 ? self.datasource.count : 1; + return self.datasource.count > 0 ? self.datasource.count : 1; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - if (self.datasource.count > 0) { - MonentsInfoModel * monentInfo= [self.datasource safeObjectAtIndex1:indexPath.row]; - [XPMonentsLayoutConfig layoutMonentsModel:monentInfo]; - return monentInfo.rowHeight; - } - return KScreenHeight - kNavigationHeight - 49 - kSafeAreaBottomHeight; + if (self.datasource.count > 0) { + MonentsInfoModel * monentInfo= [self.datasource safeObjectAtIndex1:indexPath.row]; + [XPMonentsLayoutConfig layoutMonentsModel:monentInfo]; + if(monentInfo.squareTop && monentInfo.content.length == 0){ + return monentInfo.rowHeight + 20 ; + }else{ + return monentInfo.rowHeight; + } + + } + return KScreenHeight - kNavigationHeight - 49 - kSafeAreaBottomHeight; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - if (self.datasource.count > 0) { - XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; - MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; - cell.delegate = self; - cell.monentsInfo = monentsInfo; - return cell; - } - XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; - return cell; + if (self.datasource.count > 0) { + XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; + MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; + cell.delegate = self; + cell.monentsInfo = monentsInfo; + return cell; + } + XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; + return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - [tableView deselectRowAtIndexPath:indexPath animated:YES]; - if (self.datasource.count > 0) { - MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; - if ([ClientConfig shareConfig].canOpen) { - XPMonentsDetailViewController * detailVC = [[XPMonentsDetailViewController alloc] init]; - detailVC.monentsInfo = monentsInfo; - detailVC.delegate = self; - [self.navigationController pushViewController:detailVC animated:YES]; - }else{ - XPMomentsSimpleDetailViewController * detailVC = [[XPMomentsSimpleDetailViewController alloc] init]; - detailVC.monentsInfo = monentsInfo; - detailVC.delegate = self; - [self.navigationController pushViewController:detailVC animated:YES]; - } - } + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + if (self.datasource.count > 0) { + XPMonentsDetailViewController * detailVC = [[XPMonentsDetailViewController alloc] init]; + MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; + detailVC.monentsInfo = monentsInfo; + detailVC.delegate = self; + [self.navigationController pushViewController:detailVC animated:YES]; + } } #pragma mark - XPMonentsDetailViewControllerDelegate -- (void)xPMonentsDetailViewController:(XPMonentsDetailViewController *)view deleteMonents:(NSString *)dynamicId { - __block MonentsInfoModel * deleteInfo; - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.dynamicId.integerValue == dynamicId.integerValue) { - deleteInfo = obj; - } - }]; +- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicShielding:(MonentsInfoModel *)monentsInfo{ + [self showLoading]; + [self.presenter requesstShieldingWtihType:@"0" objId:monentsInfo.dynamicId]; +} - if (deleteInfo) { - [self.datasource removeObject:deleteInfo]; - [self.tableView reloadData]; - } +- (void)xPMonentsDetailViewController:(XPMonentsDetailViewController *)view deleteMonents:(NSString *)dynamicId { + __block MonentsInfoModel * deleteInfo; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == dynamicId.integerValue) { + deleteInfo = obj; + } + }]; + + if (deleteInfo) { + [self.datasource removeObject:deleteInfo]; + [self.tableView reloadData]; + } } #pragma mark - XPMonentsTableViewCellDelegate - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo { - [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; + [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; } - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicDelete:(MonentsInfoModel *)monentsInfo { - [TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsTopicLatestViewController1") confirmHandler:^{ - [self.presenter deleteMonents:monentsInfo.dynamicId worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; - } cancelHandler:^{ - - }]; + [TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsAttentionViewController1") confirmHandler:^{ + [self.presenter deleteMonents:monentsInfo.dynamicId worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; + } cancelHandler:^{ + + }]; } - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicFold:(MonentsInfoModel *)monentsInfo { - __block MonentsInfoModel * monentsInfos; - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.dynamicId.integerValue == monentsInfo.dynamicId.integerValue) { - monentsInfos = obj; - *stop = YES; - } - }]; - if (monentsInfos) { - NSInteger row = [self.datasource indexOfObject:monentsInfo]; - [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:row inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; - } + __block MonentsInfoModel * monentsInfos; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == monentsInfo.dynamicId.integerValue) { + monentsInfos = obj; + *stop = YES; + } + }]; + if (monentsInfos) { + NSInteger row = [self.datasource indexOfObject:monentsInfo]; + [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:row inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; + } } #pragma mark -JXCategoryListContainerViewDelegate - (UIView *)listView { - return self.view; + return self.view; } #pragma mark - XPMonentsRecommendProtocol - (void)getMonentsAttentionListSuccess:(MonentsListInfoModel *)listInfo state:(int)state { - self.listInfo = listInfo; - if (state == 0) { - [self.datasource removeAllObjects]; - } - if (listInfo.dynamicList.count > 0) { - [self.datasource addObjectsFromArray:listInfo.dynamicList]; - } - - if (state == 0) { - self.hasNoMoreData = NO; - [self.tableView.mj_header endRefreshing]; - } else { - if (listInfo.dynamicList.count > 0) { - self.hasNoMoreData = NO; - } else { - self.hasNoMoreData = YES; - } - [self.tableView.mj_footer endRefreshing]; - } - [self.tableView reloadData]; + self.listInfo = listInfo; + if (state == 0) { + [self.datasource removeAllObjects]; + } + if (listInfo.dynamicList.count > 0) { + [self.datasource addObjectsFromArray:listInfo.dynamicList]; + } + + if (state == 0) { + self.hasNoMoreData = NO; + [self.tableView.mj_header endRefreshing]; + } else { + if (listInfo.dynamicList.count > 0) { + self.hasNoMoreData = NO; + } else { + self.hasNoMoreData = YES; + } + [self.tableView.mj_footer endRefreshing]; + } + [self.tableView reloadData]; } - (void)getMonentsAttentionListFail:(NSString *)msg state:(int)state { - if (state == 0) { - [self.tableView.mj_header endRefreshing]; - } else { - [self.tableView.mj_footer endRefreshing]; - } + if (state == 0) { + [self.tableView.mj_header endRefreshing]; + } else { + [self.tableView.mj_footer endRefreshing]; + } } - (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status { - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if ([obj.dynamicId isEqualToString:dynamicId]) { - if (status) { - obj.isLike += 1; - } else { - obj.isLike -= 1; - } - *stop = YES; - } - }]; - [self.tableView reloadData]; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj.dynamicId isEqualToString:dynamicId]) { + if (status) { + obj.isLike += 1; + } else { + obj.isLike -= 1; + } + *stop = YES; + } + }]; + [self.tableView reloadData]; +} +-(void)requesstShieldingSuccess:(NSString *)monentsInfo{ + [self hideHUD]; + [self showSuccessToast:YMLocalizedString(@"XPMonentsMineViewController2")]; + __block MonentsInfoModel * deleteInfo; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == monentsInfo.integerValue) { + deleteInfo = obj; + } + }]; + + if (deleteInfo) { + [self.datasource removeObject:deleteInfo]; + [self.tableView reloadData]; + } } - - (void)deleteMonentsSuccess:(NSString *)monentsInfo { - [self showSuccessToast:YMLocalizedString(@"XPMonentsAttentionViewController2")]; - __block MonentsInfoModel * deleteInfo; - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.dynamicId.integerValue == monentsInfo.integerValue) { - deleteInfo = obj; - } - }]; - - if (deleteInfo) { - [self.datasource removeObject:deleteInfo]; - [self.tableView reloadData]; - } + [self showSuccessToast:YMLocalizedString(@"XPMonentsAttentionViewController2")]; + __block MonentsInfoModel * deleteInfo; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == monentsInfo.integerValue) { + deleteInfo = obj; + } + }]; + + if (deleteInfo) { + [self.datasource removeObject:deleteInfo]; + [self.tableView reloadData]; + } } #pragma mark - Getters And Setters - (UITableView *)tableView { - if (!_tableView) { - _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; - _tableView.delegate = self; - _tableView.dataSource = self; - _tableView.tableFooterView = [UIView new]; - _tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0); - _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; - _tableView.backgroundColor = [UIColor clearColor]; - if (@available(iOS 11.0, *)) { - _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; - } - [_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; - [_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; - } - return _tableView; + if (!_tableView) { + _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; + _tableView.delegate = self; + _tableView.dataSource = self; + _tableView.tableFooterView = [UIView new]; + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; + _tableView.backgroundColor = [UIColor clearColor]; + if (@available(iOS 11.0, *)) { + _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } + [_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; + [_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; + } + return _tableView; } - (NSMutableArray *)datasource { - if (!_datasource) { - _datasource = [NSMutableArray array]; - } - return _datasource; + if (!_datasource) { + _datasource = [NSMutableArray array]; + } + return _datasource; } @end diff --git a/YuMi/Modules/YMMonents/View/XPMonentsDetailViewController.m b/YuMi/Modules/YMMonents/View/XPMonentsDetailViewController.m index 0ad88897..fb43ec92 100644 --- a/YuMi/Modules/YMMonents/View/XPMonentsDetailViewController.m +++ b/YuMi/Modules/YMMonents/View/XPMonentsDetailViewController.m @@ -1,8 +1,8 @@ // -// YMMonentsDetailViewController.m -// YUMI +// XPMonentsDetailViewController.m +// xplan-ios // -// Created by YUMI on 2022/6/22. +// Created by 冯硕 on 2022/6/22. // #import "XPMonentsDetailViewController.h" @@ -11,12 +11,9 @@ #import ///Tool #import "XPMonentsLayoutConfig.h" -#import "DJDKMIMOMColor.h" #import "QEmotionHelper.h" #import "QKeyboardManager.h" #import "TTPopup.h" -#import "NSArray+Safe.h" -#import "ClientConfig.h" ///Model #import "MonentsInfoModel.h" #import "MonentsCommentModel.h" @@ -29,7 +26,6 @@ #import "QKeyboardManager.h" #import "QEmotionBoardView.h" #import "XPMineUserInfoViewController.h" -#import "XPMineSimpleUserInfoViewController.h" ///P #import "XPMonentDetailPresenter.h" #import "XPMonentsDetailProtocol.h" @@ -50,286 +46,340 @@ @end @implementation XPMonentsDetailViewController - +-(void)dealloc{ + [[NSNotificationCenter defaultCenter]removeObserver:self]; +} - (__kindof id)createPresenter { - return [[XPMonentDetailPresenter alloc] init]; + return [[XPMonentDetailPresenter alloc] init]; } - (void)viewDidLoad { [super viewDidLoad]; - [self initHeaderAndFooterRrfresh]; - [self initSubViews]; - [self initSubViewConstraints]; -} + [self initHeaderAndFooterRrfresh]; + [self initSubViews]; + [self initSubViewConstraints]; + [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(refreshDynamicData:) name:@"kRefreshDynamicData" object:nil]; +} +-(void)refreshDynamicData:(NSNotification *)not{ + NSDictionary *refreshData = not.object; + int type = [refreshData[@"type"] intValue]; + ///type,0=点赞,1=删除,2=屏蔽,3=评论 + switch (type) { + case 0: + { + + BOOL status = [refreshData[@"status"] boolValue]; + NSInteger count = self.monentsInfo.likeCount.integerValue; + NSString *dynamicId = refreshData[@"dynamicId"]; + if([self.monentsInfo.dynamicId isEqualToString:dynamicId]){ + self.monentsInfo.isLike = status; + if (status) { + count += 1; + } else { + count -= 1; + } + self.monentsInfo.likeCount = [NSString stringWithFormat:@"%ld", count]; + [self.tableView reloadData]; + } + break; + } + case 1: + { + + + break; + } + case 2: + { + + break; + } + default: + { + NSString *dynamicId = refreshData[@"dynamicId"]; + if([self.monentsInfo.dynamicId isEqualToString:dynamicId]){ + self.monentsInfo.commentCount = [NSString stringWithFormat:@"%ld",self.monentsInfo.commentCount.integerValue + 1]; + + + [self.tableView reloadData]; + } + + break; + } + } +} #pragma mark - 下拉刷新 - (void)initHeaderAndFooterRrfresh { - MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)]; - header.stateLabel.font = [UIFont systemFontOfSize:10.0]; - header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0]; - header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; - header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor]; - self.tableView.mj_header = header; - - MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)]; - footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; - footer.stateLabel.font = [UIFont systemFontOfSize:10.0]; - self.tableView.mj_footer = footer; - - [self headerRefresh]; + MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)]; + header.stateLabel.font = [UIFont systemFontOfSize:10.0]; + header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0]; + header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; + header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor]; + self.tableView.mj_header = header; + + MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)]; + footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; + footer.stateLabel.font = [UIFont systemFontOfSize:10.0]; + self.tableView.mj_footer = footer; + + [self headerRefresh]; } - (void)headerRefresh { - [self.presenter getMonentsDetail:self.monentsInfo.dynamicId]; - [self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:@"" status:0]; + [self.presenter getMonentsDetail:self.monentsInfo.dynamicId]; + [self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:@"" status:0]; } - (void)footerRefresh { - NSString *timestamp = @""; - if (self.datasource.count > 0) { - MonentsCommentModel * commentInfo = [self.datasource lastObject]; - timestamp = commentInfo.publishTime; - } - [self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:timestamp status:1]; + NSString *timestamp = @""; + if (self.datasource.count > 0) { + MonentsCommentModel * commentInfo = [self.datasource lastObject]; + timestamp = commentInfo.publishTime; + } + [self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:timestamp status:1]; } #pragma mark - Private Method - (void)initInputView { - // 初始化输入工具条,frame可以先这样临时设置,下面的addBottomInputBarView方法会重置输入条frame - // 如果你想要自定义输入条View,请参考TextFieldViewController代码 - _inputBarView = [[QInputBarView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,UIInputBarViewMinHeight)]; - QInputBarViewConfiguration *inputBarViewConfiguration = [QInputBarViewConfiguration defaultInputBarViewConfiguration]; - inputBarViewConfiguration.voiceButtonHidden = YES;//隐藏语音按钮 - inputBarViewConfiguration.extendButtonHidden = YES;//隐藏拓展按钮 - [_inputBarView setupWithConfiguration:inputBarViewConfiguration]; - _inputBarView.delegate = self; + // 初始化输入工具条,frame可以先这样临时设置,下面的addBottomInputBarView方法会重置输入条frame + // 如果你想要自定义输入条View,请参考TextFieldViewController代码 + _inputBarView = [[QInputBarView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,UIInputBarViewMinHeight)]; + QInputBarViewConfiguration *inputBarViewConfiguration = [QInputBarViewConfiguration defaultInputBarViewConfiguration]; + inputBarViewConfiguration.voiceButtonHidden = YES;//隐藏语音按钮 + inputBarViewConfiguration.extendButtonHidden = YES;//隐藏拓展按钮 + [_inputBarView setupWithConfiguration:inputBarViewConfiguration]; + _inputBarView.delegate = self; - //keyboard管理类,用来管理键盘,各大面板的切换 - _keyboardManager = [[QKeyboardManager alloc] initWithViewController:self]; - _keyboardManager.dataSource = self; - //因为addBottomInputBarView方法会立刻触发delegate,所以这里需要先设置delegate - _keyboardManager.delegate = self; - [_keyboardManager addBottomInputBarView:_inputBarView belowViewController:NO]; + //keyboard管理类,用来管理键盘,各大面板的切换 + _keyboardManager = [[QKeyboardManager alloc] initWithViewController:self]; + _keyboardManager.dataSource = self; + //因为addBottomInputBarView方法会立刻触发delegate,所以这里需要先设置delegate + _keyboardManager.delegate = self; + [_keyboardManager addBottomInputBarView:_inputBarView belowViewController:NO]; - //把输入框(如果有的话)绑定给管理类 - [_keyboardManager bindTextView:_inputBarView.inputTextView]; + //把输入框(如果有的话)绑定给管理类 + [_keyboardManager bindTextView:_inputBarView.inputTextView]; } - (void)sendTextMessage:(NSString *)inputText { - if (inputText.length > 0) { - [_keyboardManager hideAllBoardView]; - if (self.commentId && self.commentId.length > 0) { - [self.presenter replayCommon:self.commentId dynamicId:self.monentsInfo.dynamicId content:inputText]; - } else { - [self.presenter commontMonents:self.monentsInfo.dynamicId content:inputText]; - } - self.inputBarView.inputTextView.text = nil; - } else { - [self showErrorToast:YMLocalizedString(@"XPMonentsDetailViewController0")]; - } + if (inputText.length > 0) { + [_keyboardManager hideAllBoardView]; + if (self.commentId && self.commentId.length > 0) { + [self.presenter replayCommon:self.commentId dynamicId:self.monentsInfo.dynamicId content:inputText]; + } else { + [self.presenter commontMonents:self.monentsInfo.dynamicId content:inputText]; + } + self.inputBarView.inputTextView.text = nil; + } else { + [self showErrorToast:YMLocalizedString(@"XPMonentsDetailViewController0")]; + } } - (void)initSubViews { - self.title = YMLocalizedString(@"XPMonentsDetailViewController1"); - [self.view addSubview:self.tableView]; - [self.sectionView addSubview:self.commentLabel]; - [self initInputView]; + self.title = YMLocalizedString(@"XPMonentsDetailViewController1"); + [self.view addSubview:self.tableView]; + [self.sectionView addSubview:self.commentLabel]; + [self initInputView]; } - (void)initSubViewConstraints { - [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.top.mas_equalTo(self.view); - make.bottom.mas_equalTo(self.inputBarView.mas_top); - }]; - - [self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(self.sectionView).offset(15); - make.centerY.mas_equalTo(self.sectionView); - }]; + [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { + make.leading.trailing.top.mas_equalTo(self.view); + make.bottom.mas_equalTo(self.inputBarView.mas_top); + }]; + + [self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.leading.mas_equalTo(self.sectionView).offset(15); + make.centerY.mas_equalTo(self.sectionView); + }]; } #pragma mark - UITableViewDelegate And UITableViewDataSource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 2; + return 2; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - if (section == 0) { - return 1; - } - return self.datasource.count > 0 ? self.datasource.count : 1; + if (section == 0) { + return 1; + } + return self.datasource.count > 0 ? self.datasource.count : 1; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - if (indexPath.section == 0) { - [XPMonentsLayoutConfig layoutMonentsModel:self.monentsInfo]; - return self.monentsInfo.rowHeight; - } else if(indexPath.section == 1) { - if (self.datasource.count > 0) { - MonentsCommentModel * commentInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; - return [XPMonentsLayoutConfig commentCommentRowHeight:commentInfo]; - } else { - return 400; - } - } - return 0; + if (indexPath.section == 0) { + [XPMonentsLayoutConfig layoutMonentsModel:self.monentsInfo]; + + if(self.monentsInfo.squareTop && self.monentsInfo.content.length == 0){ + return self.monentsInfo.rowHeight + 20 ; + }else{ + return self.monentsInfo.rowHeight; + } + } else if(indexPath.section == 1) { + if (self.datasource.count > 0) { + MonentsCommentModel * commentInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; + return [XPMonentsLayoutConfig commentCommentRowHeight:commentInfo]; + } else { + return 400; + } + } + return 0; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { - if (section == 1) { - return 44; - } - return 0.0;; + if (section == 1) { + return 44; + } + return 0.0;; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { - self.commentLabel.text = [NSString stringWithFormat:@"%@(%@)",YMLocalizedString(@"XPMonentsDetailViewController2"),self.monentsInfo.commentCount]; - return self.sectionView; + self.commentLabel.text = [NSString stringWithFormat:YMLocalizedString(@"XPMonentsDetailViewController2"), self.monentsInfo.commentCount]; + return self.sectionView; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { - return 0.0f; + return 0.0f; } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { - return [UIView new]; + return [UIView new]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - if (indexPath.section ==0) { - XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; - cell.delegate = self; - cell.monentsInfo = self.monentsInfo; - return cell; - } else { - if (self.datasource.count > 0) { - XPMonentsCommentTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsCommentTableViewCell class])]; - cell.commentInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; - cell.delegate = self; - return cell; - } else { - XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; - return cell; - } - } + if (indexPath.section ==0) { + XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; + cell.delegate = self; + cell.monentsInfo = self.monentsInfo; + return cell; + } else { + if (self.datasource.count > 0) { + XPMonentsCommentTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsCommentTableViewCell class])]; + cell.commentInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; + cell.delegate = self; + return cell; + } else { + XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; + return cell; + } + } } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - [tableView deselectRowAtIndexPath:indexPath animated:YES]; - if (indexPath.section == 1) { - if (self.datasource.count > 0) { - MonentsCommentModel* monent = [self.datasource safeObjectAtIndex1:indexPath.row]; - self.commentId = monent.commentId; - self.inputBarView.inputTextView.placeholder = [NSString stringWithFormat:@"%@: %@", YMLocalizedString(@"XPMonentsDetailViewController3"),monent.nick]; - [self.inputBarView textViewBecomeFirstResponder]; - } - } + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + if (indexPath.section == 1) { + if (self.datasource.count > 0) { + MonentsCommentModel* monent = [self.datasource safeObjectAtIndex1:indexPath.row]; + self.commentId = monent.commentId; + self.inputBarView.inputTextView.placeholder = [NSString stringWithFormat:YMLocalizedString(@"XPMonentsDetailViewController3"), monent.nick]; + [self.inputBarView textViewBecomeFirstResponder]; + } + } } - (void)scrollViewDidScroll:(UIScrollView *)scrollView { - [_keyboardManager hideAllBoardView]; + [_keyboardManager hideAllBoardView]; } #pragma mark - XPMonentsCommentTableViewCellDelegate +- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicShielding:(MonentsInfoModel *)monentsInfo{ + [self showLoading]; + [self.presenter requesstShieldingWtihType:@"0" objId:monentsInfo.dynamicId]; +} - (void)xPMonentsCommentTableViewCell:(XPMonentsCommentTableViewCell *)view didClickMoreReply:(MonentsCommentModel *)commentInfo { - [self.presenter getMonentsCommentReplyList:self.monentsInfo.dynamicId commentId:commentInfo.commentId timestamp:commentInfo.replyInfo.nextTimestamp]; + [self.presenter getMonentsCommentReplyList:self.monentsInfo.dynamicId commentId:commentInfo.commentId timestamp:commentInfo.replyInfo.nextTimestamp]; } - (void)xPMonentsCommentTableViewCell:(XPMonentsCommentTableViewCell *)view didClickCommon:(MonentsReplyModel *)commentInfo { - if (commentInfo) { - self.commentId = commentInfo.replyId; - self.inputBarView.inputTextView.placeholder = [NSString stringWithFormat:@"%@: %@",YMLocalizedString(@"XPMonentsDetailViewController3"), commentInfo.nick]; - [self.inputBarView textViewBecomeFirstResponder]; - } + if (commentInfo) { + self.commentId = commentInfo.replyId; + self.inputBarView.inputTextView.placeholder = [NSString stringWithFormat:YMLocalizedString(@"XPMonentsDetailViewController4"), commentInfo.nick]; + [self.inputBarView textViewBecomeFirstResponder]; + } } - (void)xPMonentsCommentTableViewCell:(XPMonentsCommentTableViewCell *)view didClickAvatar:(NSString *)commentInfo { - if ([ClientConfig shareConfig].canOpen) { - XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init]; - userInfoVC.uid = commentInfo.integerValue; - [self.navigationController pushViewController:userInfoVC animated:YES]; - }else{ - XPMineSimpleUserInfoViewController * userInfoVC = [[XPMineSimpleUserInfoViewController alloc] init]; - userInfoVC.uid = commentInfo.integerValue; - [self.navigationController pushViewController:userInfoVC animated:YES]; - } + XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init]; + userInfoVC.uid = commentInfo.integerValue; + [self.navigationController pushViewController:userInfoVC animated:YES]; } #pragma mark - XPMonentsTableViewCellDelegate - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo { - [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; + [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; } - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicDelete:(MonentsInfoModel *)monentsInfo { - [TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsDetailViewController5") confirmHandler:^{ - [self.presenter deleteMonents:monentsInfo.dynamicId worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; - } cancelHandler:^{ + [TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsDetailViewController5") confirmHandler:^{ + [self.presenter deleteMonents:monentsInfo.dynamicId worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; + } cancelHandler:^{ - }]; + }]; } - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicCommon:(MonentsInfoModel *)monentsInfo { - if (monentsInfo) { - self.commentId = nil; - self.inputBarView.inputTextView.placeholder = YMLocalizedString(@"XPMonentsDetailViewController6"); - [self.inputBarView textViewBecomeFirstResponder]; - } + if (monentsInfo) { + self.commentId = nil; + self.inputBarView.inputTextView.placeholder = YMLocalizedString(@"XPMonentsDetailViewController6"); + [self.inputBarView textViewBecomeFirstResponder]; + } } - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicFold:(MonentsInfoModel *)monentsInfo { - self.monentsInfo = monentsInfo; - [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone]; + self.monentsInfo = monentsInfo; + [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone]; } #pragma mark - InputBoardDataSource //@return 点加号按钮弹出的拓展面板View,且无需设置frame - (UIView *)keyboardManagerExtendBoardView:(QKeyboardManager *)keyboardManager { - UIView *boardView = [UIView new]; - boardView.backgroundColor = UIColor.blueColor; - return boardView; + UIView *boardView = [UIView new]; + boardView.backgroundColor = UIColor.blueColor; + return boardView; } //@return 点表情按钮弹出的表情面板View,且无需设置frame - (UIView *)keyboardManagerEmotionBoardView:(QKeyboardManager *)keyboardManager { - QEmotionBoardView *emotionView = [[QEmotionBoardView alloc] init]; - QEmotionHelper *faceManager = [QEmotionHelper sharedEmotionHelper]; - emotionView.emotions = faceManager.emotionArray; - emotionView.delegate = self; - if (@available(iOS 11.0, *)) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - emotionView.backgroundColor = [UIColor colorNamed:@"q_input_extend_bg" inBundle:bundle compatibleWithTraitCollection:nil]; - } else { - emotionView.backgroundColor = [UIColor colorWithRed:(246)/255.0f green:(246)/255.0f blue:(246)/255.0f alpha:1]; - } - return emotionView; + QEmotionBoardView *emotionView = [[QEmotionBoardView alloc] init]; + QEmotionHelper *faceManager = [QEmotionHelper sharedEmotionHelper]; + emotionView.emotions = faceManager.emotionArray; + emotionView.delegate = self; + if (@available(iOS 11.0, *)) { + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + emotionView.backgroundColor = [UIColor colorNamed:@"q_input_extend_bg" inBundle:bundle compatibleWithTraitCollection:nil]; + } else { + emotionView.backgroundColor = [UIColor colorWithRed:(246)/255.0f green:(246)/255.0f blue:(246)/255.0f alpha:1]; + } + return emotionView; } //@return 点表情按钮弹出的表情面板View的高度 - (CGFloat)keyboardManagerEmotionBoardHeight:(QKeyboardManager *)keyboardManager { - return 294; + return 294; } //@return 点加号按钮弹出的拓展面板View的高度 - (CGFloat)keyboardManagerExtendBoardHeight:(QKeyboardManager *)keyboardManager { - return 174; + return 174; } - (QInputBarViewConfiguration *)inputBarViewConfiguration { - //输入条配置,子类可以重写 - QInputBarViewConfiguration *inputBarViewConfiguration = [QInputBarViewConfiguration defaultInputBarViewConfiguration]; - inputBarViewConfiguration.voiceButtonHidden = YES;//隐藏语音按钮 - inputBarViewConfiguration.extendButtonHidden = YES;//隐藏拓展按钮 - return inputBarViewConfiguration; + //输入条配置,子类可以重写 + QInputBarViewConfiguration *inputBarViewConfiguration = [QInputBarViewConfiguration defaultInputBarViewConfiguration]; + inputBarViewConfiguration.voiceButtonHidden = YES;//隐藏语音按钮 + inputBarViewConfiguration.extendButtonHidden = YES;//隐藏拓展按钮 + return inputBarViewConfiguration; } //点击表情按钮,切换到表情面板 - (void)inputBarView:(QInputBarView *)inputBarView onEmotionButtonClick:(UIButton *)emotionSwitchButton { - if (emotionSwitchButton.isSelected) { - [_keyboardManager switchToEmotionBoardKeyboard]; - } else { - self.commentId = nil; - _inputBarView.inputTextView.placeholder = YMLocalizedString(@"XPMonentsDetailViewController7"); - [_inputBarView textViewBecomeFirstResponder]; - } + if (emotionSwitchButton.isSelected) { + [_keyboardManager switchToEmotionBoardKeyboard]; + } else { + self.commentId = nil; + _inputBarView.inputTextView.placeholder = YMLocalizedString(@"XPMonentsDetailViewController7"); + [_inputBarView textViewBecomeFirstResponder]; + } } #pragma mark - QEmotionBoardViewDelegate @@ -339,21 +389,21 @@ * @param emotion 被选中的表情对应的`QMUIEmotion`对象 */ - (void)emotionView:(QEmotionBoardView *)emotionView didSelectEmotion:(QEmotion *)emotion atIndex:(NSInteger)index { - //把😊插入到输入栏 - [_inputBarView insertEmotion:emotion.displayName]; + //把😊插入到输入栏 + [_inputBarView insertEmotion:emotion.displayName]; } // 删除按钮的点击事件回调 - (void)emotionViewDidSelectDeleteButton:(QEmotionBoardView *)emotionView { - if (![_inputBarView deleteEmotion]){ - //根据当前的光标,这次点击删除按钮并没有删除表情,那么就删除文字 - [_inputBarView.inputTextView deleteBackward]; - } + if (![_inputBarView deleteEmotion]){ + //根据当前的光标,这次点击删除按钮并没有删除表情,那么就删除文字 + [_inputBarView.inputTextView deleteBackward]; + } } // 发送按钮的点击事件回调 - (void)emotionViewDidSelectSendButton:(QEmotionBoardView *)emotionView { - [self sendTextMessage:[_inputBarView textViewInputNormalText]]; + [self sendTextMessage:[_inputBarView textViewInputNormalText]]; } @@ -363,124 +413,130 @@ * @param inputNormalText :"害~你好啊[微笑]" */ - (void)inputBarView:(QInputBarView *)inputBarView onKeyboardSendClick:(NSString *)inputNormalText { - [self sendTextMessage:inputNormalText]; + [self sendTextMessage:inputNormalText]; } #pragma mark - XPMonentsDetailProtocol - (void)getMonentsDetailSuccess:(MonentsInfoModel *)commentInfo { - self.monentsInfo = commentInfo; - [self.tableView reloadData]; + self.monentsInfo = commentInfo; + [self.tableView reloadData]; } - (void)getMonentsCommentListSuccess:(MonentsCommentListModel *)commentInfo state:(int)state{ - if (state == 0) { - [self.datasource removeAllObjects]; - [self.tableView.mj_header endRefreshing]; - } else { - [self.tableView.mj_footer endRefreshing]; - } - - if (commentInfo.commentList.count > 0) { - [self.datasource addObjectsFromArray:commentInfo.commentList]; - } - [self.tableView reloadData]; + if (state == 0) { + [self.datasource removeAllObjects]; + [self.tableView.mj_header endRefreshing]; + } else { + [self.tableView.mj_footer endRefreshing]; + } + + if (commentInfo.commentList.count > 0) { + [self.datasource addObjectsFromArray:commentInfo.commentList]; + } + [self.tableView reloadData]; } - (void)getMonentsCommentReplyListSuccess:(MonentsCommentReplyModel *)replyInfo commentId:(nonnull NSString *)commentId { - if (commentId) { - __block MonentsCommentModel * commentInfo; - [self.datasource enumerateObjectsUsingBlock:^(MonentsCommentModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if ([obj.commentId isEqualToString:commentId]) { - commentInfo = obj; - *stop = YES; - } - }]; - - if (commentInfo) { - NSMutableArray * replyList= commentInfo.replyInfo.replyList.mutableCopy; - [replyList addObjectsFromArray:replyInfo.replyList]; - commentInfo.replyInfo.replyList = replyList.copy; - commentInfo.replyInfo.leftCount = replyInfo.leftCount; - commentInfo.replyInfo.nextTimestamp = replyInfo.nextTimestamp; - commentInfo.isReloadHeight = YES; - } - [self.tableView reloadData]; - } + if (commentId) { + __block MonentsCommentModel * commentInfo; + [self.datasource enumerateObjectsUsingBlock:^(MonentsCommentModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj.commentId isEqualToString:commentId]) { + commentInfo = obj; + *stop = YES; + } + }]; + + if (commentInfo) { + NSMutableArray * replyList= commentInfo.replyInfo.replyList.mutableCopy; + [replyList addObjectsFromArray:replyInfo.replyList]; + commentInfo.replyInfo.replyList = replyList.copy; + commentInfo.replyInfo.leftCount = replyInfo.leftCount; + commentInfo.replyInfo.nextTimestamp = replyInfo.nextTimestamp; + commentInfo.isReloadHeight = YES; + } + [self.tableView reloadData]; + } } - (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status { - if ([self.monentsInfo.dynamicId isEqualToString:dynamicId]) { - NSInteger count = self.monentsInfo.likeCount.integerValue; - self.monentsInfo.isLike = status; - if (status) { - count += 1; - } else { - count -= 1; - } - self.monentsInfo.likeCount = [NSString stringWithFormat:@"%ld", count]; - [self.tableView reloadData]; - } + if ([self.monentsInfo.dynamicId isEqualToString:dynamicId]) { + + + ///type,0=点赞,1=删除,2=屏蔽,3=评论 + [[NSNotificationCenter defaultCenter]postNotificationName:@"kRefreshDynamicData" object:@{@"dynamicId":dynamicId,@"type":@"0",@"status":@(status)}]; + } } - (void)replyMonentsSuccess { - [self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:@"" status:0]; + [self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:@"" status:0]; + ///type,0=点赞,1=删除,2=屏蔽,3=评论 + [[NSNotificationCenter defaultCenter]postNotificationName:@"kRefreshDynamicData" object:@{@"dynamicId":self.monentsInfo.dynamicId,@"type":@"3"}]; } - (void)commonMonentsSuccess { - [self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:@"" status:0]; + [self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:@"" status:0]; + ///type,0=点赞,1=删除,2=屏蔽,3=评论 + [[NSNotificationCenter defaultCenter]postNotificationName:@"kRefreshDynamicData" object:@{@"dynamicId":self.monentsInfo.dynamicId,@"type":@"3"}]; +} +-(void)requesstShieldingSuccess:(NSString *)monentsInfo{ + [self hideHUD]; + [self showSuccessToast:YMLocalizedString(@"XPMonentsMineViewController2")]; + ///type,0=点赞,1=删除,2=屏蔽,3=评论 + [[NSNotificationCenter defaultCenter]postNotificationName:@"kRefreshDynamicData" object:@{@"dynamicId":monentsInfo,@"type":@"2"}]; + [self.navigationController popViewControllerAnimated:YES]; + } - - (void)deleteMonentsSuccess:(NSString *)monentsInfo { - [self showSuccessToast:YMLocalizedString(@"XPMonentsDetailViewController8")]; - [self.navigationController popViewControllerAnimated:YES]; - if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsDetailViewController:deleteMonents:)]) { - [self.delegate xPMonentsDetailViewController:self deleteMonents:self.monentsInfo.dynamicId]; - } + [self showSuccessToast:YMLocalizedString(@"XPMonentsDetailViewController8")]; + ///type,0=点赞,1=删除,2=屏蔽,3=评论 + [[NSNotificationCenter defaultCenter]postNotificationName:@"kRefreshDynamicData" object:@{@"dynamicId":monentsInfo,@"type":@"1"}]; + [self.navigationController popViewControllerAnimated:YES]; + } #pragma mark - Getters And Setters - (UITableView *)tableView { - if (!_tableView) { - _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]; - _tableView.delegate = self; - _tableView.dataSource = self; - _tableView.tableFooterView = [UIView new]; - _tableView.tableFooterView = [UIView new]; - _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; - _tableView.backgroundColor = [UIColor clearColor]; - if (@available(iOS 11.0, *)) { - _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; - } - [_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; - [_tableView registerClass:[XPMonentsCommentTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsCommentTableViewCell class])]; - [_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; - } - return _tableView; + if (!_tableView) { + _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]; + _tableView.delegate = self; + _tableView.dataSource = self; + _tableView.tableFooterView = [UIView new]; + _tableView.tableFooterView = [UIView new]; + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; + _tableView.backgroundColor = [UIColor clearColor]; + if (@available(iOS 11.0, *)) { + _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } + [_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; + [_tableView registerClass:[XPMonentsCommentTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsCommentTableViewCell class])]; + [_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; + } + return _tableView; } - (UIView *)sectionView { - if (!_sectionView) { - _sectionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 44)]; - _sectionView.backgroundColor = [UIColor clearColor]; - } - return _sectionView; + if (!_sectionView) { + _sectionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 44)]; + _sectionView.backgroundColor = [UIColor clearColor]; + } + return _sectionView; } - (UILabel *)commentLabel { - if (!_commentLabel) { - _commentLabel = [[UILabel alloc] init]; - _commentLabel.font = [UIFont systemFontOfSize:14]; - _commentLabel.textColor = [DJDKMIMOMColor mainTextColor]; - } - return _commentLabel; + if (!_commentLabel) { + _commentLabel = [[UILabel alloc] init]; + _commentLabel.font = [UIFont systemFontOfSize:14]; + _commentLabel.textColor = [DJDKMIMOMColor mainTextColor]; + } + return _commentLabel; } - (NSMutableArray *)datasource { - if (!_datasource) { - _datasource = [NSMutableArray array]; - } - return _datasource; + if (!_datasource) { + _datasource = [NSMutableArray array]; + } + return _datasource; } @end diff --git a/YuMi/Modules/YMMonents/View/XPMonentsLatestViewController.m b/YuMi/Modules/YMMonents/View/XPMonentsLatestViewController.m index 558fd258..ebbd8234 100644 --- a/YuMi/Modules/YMMonents/View/XPMonentsLatestViewController.m +++ b/YuMi/Modules/YMMonents/View/XPMonentsLatestViewController.m @@ -1,8 +1,8 @@ // -// YMMonentsLatestViewController.m -// YUMI +// XPMonentsLatestViewController.m +// xplan-ios // -// Created by YUMI on 2022/5/18. +// Created by 冯硕 on 2022/5/18. // #import "XPMonentsLatestViewController.h" @@ -10,12 +10,8 @@ #import #import ///Tool -#import "DJDKMIMOMColor.h" -#import "YUMIMacroUitls.h" #import "XPMonentsLayoutConfig.h" #import "TTPopup.h" -#import "NSArray+Safe.h" -#import "ClientConfig.h" ///Model #import "MonentsListInfoModel.h" ///P @@ -25,8 +21,7 @@ #import "XPMonentsTableViewCell.h" #import "XPMonentsEmptyTableViewCell.h" #import "XPMonentsDetailViewController.h" -#import "XPMomentsSimpleDetailViewController.h" - +UIKIT_EXTERN NSString *kRequestRicket; @interface XPMonentsLatestViewController () ///列表 @property (nonatomic,strong) UITableView *tableView; @@ -42,248 +37,273 @@ @implementation XPMonentsLatestViewController -- (void)dealloc { - NSLog(@"你阿宁"); +-(void)dealloc{ + [[NSNotificationCenter defaultCenter]removeObserver:self]; } - - (BOOL)isHiddenNavBar { - return YES; + return YES; } - (__kindof id)createPresenter { - return [[XPMonentsLatestPresenter alloc] init]; + return [[XPMonentsLatestPresenter alloc] init]; } - (void)viewDidLoad { - [super viewDidLoad]; - [self initHeaderAndFooterRrfresh]; - [self initSubViews]; - [self initSubViewConstraints]; + [super viewDidLoad]; + [self initHeaderAndFooterRrfresh]; + [self initSubViews]; + [self initSubViewConstraints]; } #pragma mark - Private Method - (void)initSubViews { - [self.view addSubview:self.tableView]; + [self.view addSubview:self.tableView]; } - (void)initSubViewConstraints { - [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self.view); - }]; + [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.view); + }]; + [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(requestRicketSuccess:) name:kRequestRicket object:nil]; +} +-(void)requestRicketSuccess:(NSNotification *)not{ + if([not.object isKindOfClass:[NSDictionary class]])return; + BOOL is = [not.object boolValue]; + if(is == YES){ + [self headerRefresh]; + } } #pragma mark - 下拉刷新 - (void)initHeaderAndFooterRrfresh { - MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)]; - header.stateLabel.font = [UIFont systemFontOfSize:10.0]; - header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0]; - header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; - header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor]; - self.tableView.mj_header = header; - - MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)]; - footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; - footer.stateLabel.font = [UIFont systemFontOfSize:10.0]; - self.tableView.mj_footer = footer; - - [self headerRefresh]; + MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)]; + header.stateLabel.font = [UIFont systemFontOfSize:10.0]; + header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0]; + header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; + header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor]; + self.tableView.mj_header = header; + + MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)]; + footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; + footer.stateLabel.font = [UIFont systemFontOfSize:10.0]; + self.tableView.mj_footer = footer; + + [self headerRefresh]; } #pragma mark - 刷新的fangfa - (void)headerRefresh { - self.page = 1; - [self.presenter getMonentsLatestListPageSize:20 dynamicId:@"" state:0]; + if([AccountInfoStorage instance].isRequestRicket == YES){ + return; + } + self.page = 1; + [self.presenter getMonentsLatestListPageSize:20 dynamicId:@"" state:0]; } - (void)footerRefresh { - if (self.hasNoMoreData) { - [self showErrorToast:YMLocalizedString(@"XPMonentsLatestViewController0")]; - [self.tableView.mj_footer endRefreshing]; - return; - } - self.page++; - [self.presenter getMonentsLatestListPageSize:20 dynamicId:self.listInfo.nextDynamicId state:1]; + if([AccountInfoStorage instance].isRequestRicket == YES)return; + if (self.hasNoMoreData) { + [self showErrorToast:YMLocalizedString(@"XPMonentsLatestViewController0")]; + [self.tableView.mj_footer endRefreshing]; + return; + } + self.page++; + [self.presenter getMonentsLatestListPageSize:20 dynamicId:self.listInfo.nextDynamicId state:1]; } #pragma mark - UITableViewDelegate And UITableViewDataSource - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return self.datasource.count > 0 ? self.datasource.count : 1; + return self.datasource.count > 0 ? self.datasource.count : 1; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - if (self.datasource.count > 0) { - MonentsInfoModel * monentInfo= [self.datasource safeObjectAtIndex1:indexPath.row]; - [XPMonentsLayoutConfig layoutMonentsModel:monentInfo]; - return monentInfo.rowHeight; - } - return KScreenHeight - kNavigationHeight - 49 - kSafeAreaBottomHeight; + if (self.datasource.count > 0) { + MonentsInfoModel * monentInfo= [self.datasource safeObjectAtIndex1:indexPath.row]; + [XPMonentsLayoutConfig layoutMonentsModel:monentInfo]; + if(monentInfo.squareTop && monentInfo.content.length == 0){ + return monentInfo.rowHeight + 20 ; + }else{ + return monentInfo.rowHeight; + } + + } + return KScreenHeight - kNavigationHeight - 49 - kSafeAreaBottomHeight; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - if (self.datasource.count > 0) { - XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; - MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; - cell.monentsInfo = monentsInfo; - cell.delegate = self; - return cell; - } - XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; - return cell; + if (self.datasource.count > 0) { + XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; + MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; + cell.monentsInfo = monentsInfo; + cell.delegate = self; + return cell; + } + XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; + return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - [tableView deselectRowAtIndexPath:indexPath animated:YES]; - if (self.datasource.count > 0) { - MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; - - if ([ClientConfig shareConfig].canOpen) { - XPMonentsDetailViewController * detailVC = [[XPMonentsDetailViewController alloc] init]; - detailVC.monentsInfo = monentsInfo; - detailVC.delegate = self; - [self.navigationController pushViewController:detailVC animated:YES]; - }else{ - XPMomentsSimpleDetailViewController * detailVC = [[XPMomentsSimpleDetailViewController alloc] init]; - detailVC.monentsInfo = monentsInfo; - detailVC.delegate = self; - [self.navigationController pushViewController:detailVC animated:YES]; - } - } + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + if (self.datasource.count > 0) { + XPMonentsDetailViewController * detailVC = [[XPMonentsDetailViewController alloc] init]; + MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; + detailVC.monentsInfo = monentsInfo; + detailVC.delegate = self; + [self.navigationController pushViewController:detailVC animated:YES]; + } } #pragma mark - XPMonentsDetailViewControllerDelegate - (void)xPMonentsDetailViewController:(XPMonentsDetailViewController *)view deleteMonents:(NSString *)dynamicId { - __block MonentsInfoModel * deleteInfo; - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.dynamicId.integerValue == dynamicId.integerValue) { - deleteInfo = obj; - } - }]; - - if (deleteInfo) { - [self.datasource removeObject:deleteInfo]; - [self.tableView reloadData]; - } + __block MonentsInfoModel * deleteInfo; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == dynamicId.integerValue) { + deleteInfo = obj; + } + }]; + + if (deleteInfo) { + [self.datasource removeObject:deleteInfo]; + [self.tableView reloadData]; + } } #pragma mark - XPMonentsTableViewCellDelegate +- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicShielding:(MonentsInfoModel *)monentsInfo{ + [self showLoading]; + [self.presenter requesstShieldingWtihType:@"0" objId:monentsInfo.dynamicId]; +} - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo { - [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; + [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; } - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicDelete:(MonentsInfoModel *)monentsInfo { - [TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsLatestViewController1") confirmHandler:^{ - [self.presenter deleteMonents:monentsInfo.dynamicId worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; - } cancelHandler:^{ - - }]; + [TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsLatestViewController1") confirmHandler:^{ + [self.presenter deleteMonents:monentsInfo.dynamicId worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; + } cancelHandler:^{ + + }]; } - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicFold:(MonentsInfoModel *)monentsInfo { - __block MonentsInfoModel * monentsInfos; - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.dynamicId.integerValue == monentsInfo.dynamicId.integerValue) { - monentsInfos = obj; - *stop = YES; - } - }]; - if (monentsInfos) { - NSInteger row = [self.datasource indexOfObject:monentsInfo]; - [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:row inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; - } + __block MonentsInfoModel * monentsInfos; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == monentsInfo.dynamicId.integerValue) { + monentsInfos = obj; + *stop = YES; + } + }]; + if (monentsInfos) { + NSInteger row = [self.datasource indexOfObject:monentsInfo]; + [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:row inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; + } } #pragma mark -JXCategoryListContainerViewDelegate - (UIView *)listView { - return self.view; + return self.view; } #pragma mark - XPMonentsLatestProtocol - (void)getMonentsLatestListSuccess:(MonentsListInfoModel *)listInfo state:(int)state{ - self.listInfo = listInfo; - if (state == 0) { - [self.datasource removeAllObjects]; - } - if (listInfo.dynamicList.count > 0) { - [self.datasource addObjectsFromArray:listInfo.dynamicList]; - } - - if (state == 0) { - self.hasNoMoreData = NO; - [self.tableView.mj_header endRefreshing]; - } else { - if (listInfo.dynamicList.count > 0) { - self.hasNoMoreData = NO; - } else { - self.hasNoMoreData = YES; - } - [self.tableView.mj_footer endRefreshing]; - } - [self.tableView reloadData]; + self.listInfo = listInfo; + if (state == 0) { + [self.datasource removeAllObjects]; + } + if (listInfo.dynamicList.count > 0) { + [self.datasource addObjectsFromArray:listInfo.dynamicList]; + } + + if (state == 0) { + self.hasNoMoreData = NO; + [self.tableView.mj_header endRefreshing]; + } else { + if (listInfo.dynamicList.count > 0) { + self.hasNoMoreData = NO; + } else { + self.hasNoMoreData = YES; + } + [self.tableView.mj_footer endRefreshing]; + } + [self.tableView reloadData]; } - (void)getMonentsLatestListFail:(NSString *)msg state:(int)state { - if (state == 0) { - [self.tableView.mj_header endRefreshing]; - } else { - [self.tableView.mj_footer endRefreshing]; - } + if (state == 0) { + [self.tableView.mj_header endRefreshing]; + } else { + [self.tableView.mj_footer endRefreshing]; + } } - (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status { - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if ([obj.dynamicId isEqualToString:dynamicId]) { - NSInteger count = obj.likeCount.integerValue; - obj.isLike = status; - if (status) { - count += 1; - } else { - count -= 1; - } - obj.likeCount = [NSString stringWithFormat:@"%ld", count]; - *stop = YES; - } - }]; - [self.tableView reloadData]; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj.dynamicId isEqualToString:dynamicId]) { + NSInteger count = obj.likeCount.integerValue; + obj.isLike = status; + if (status) { + count += 1; + } else { + count -= 1; + } + obj.likeCount = [NSString stringWithFormat:@"%ld", count]; + *stop = YES; + } + }]; + [self.tableView reloadData]; +} +-(void)requesstShieldingSuccess:(NSString *)monentsInfo{ + [self hideHUD]; + [self showSuccessToast:YMLocalizedString(@"XPMonentsMineViewController2")]; + __block MonentsInfoModel * deleteInfo; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == monentsInfo.integerValue) { + deleteInfo = obj; + } + }]; + + if (deleteInfo) { + [self.datasource removeObject:deleteInfo]; + [self.tableView reloadData]; + } } - - (void)deleteMonentsSuccess:(NSString *)monentsInfo { - [self showSuccessToast:YMLocalizedString(@"XPMonentsLatestViewController2")]; - __block MonentsInfoModel * deleteInfo; - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.dynamicId.integerValue == monentsInfo.integerValue) { - deleteInfo = obj; - } - }]; - - if (deleteInfo) { - [self.datasource removeObject:deleteInfo]; - [self.tableView reloadData]; - } + [self showSuccessToast:YMLocalizedString(@"XPMonentsLatestViewController2")]; + __block MonentsInfoModel * deleteInfo; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == monentsInfo.integerValue) { + deleteInfo = obj; + } + }]; + + if (deleteInfo) { + [self.datasource removeObject:deleteInfo]; + [self.tableView reloadData]; + } } #pragma mark - Getters And Setters - (UITableView *)tableView { - if (!_tableView) { - _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; - _tableView.delegate = self; - _tableView.dataSource = self; - _tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0); - _tableView.tableFooterView = [UIView new]; - _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; - _tableView.backgroundColor = [UIColor clearColor]; - if (@available(iOS 11.0, *)) { - _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; - } - [_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; - [_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; - } - return _tableView; + if (!_tableView) { + _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; + _tableView.delegate = self; + _tableView.dataSource = self; + _tableView.tableFooterView = [UIView new]; + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; + _tableView.backgroundColor = [UIColor clearColor]; + if (@available(iOS 11.0, *)) { + _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } + [_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; + [_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; + } + return _tableView; } - (NSMutableArray *)datasource { - if (!_datasource) { - _datasource = [NSMutableArray array]; - } - return _datasource; + if (!_datasource) { + _datasource = [NSMutableArray array]; + } + return _datasource; } @end diff --git a/YuMi/Modules/YMMonents/View/XPMonentsRecommendViewController.m b/YuMi/Modules/YMMonents/View/XPMonentsRecommendViewController.m index 93afcbce..959e6662 100644 --- a/YuMi/Modules/YMMonents/View/XPMonentsRecommendViewController.m +++ b/YuMi/Modules/YMMonents/View/XPMonentsRecommendViewController.m @@ -1,8 +1,8 @@ // -// YMMonentsRecommendViewController.m -// YUMI +// XPMonentsRecommendViewController.m +// xplan-ios // -// Created by YUMI on 2022/5/11. +// Created by 冯硕 on 2022/5/11. // #import "XPMonentsRecommendViewController.h" @@ -10,12 +10,10 @@ #import #import ///Tool -#import "DJDKMIMOMColor.h" -#import "YUMIMacroUitls.h" + + #import "XPMonentsLayoutConfig.h" #import "TTPopup.h" -#import "NSArray+Safe.h" -#import "ClientConfig.h" ///Model #import "MonentsInfoModel.h" #import "MonentsTopicModel.h" @@ -27,11 +25,11 @@ #import "XPMonentsEmptyTableViewCell.h" #import "XPMonentsRecommendHeaderView.h" #import "XPMonentsDetailViewController.h" -#import "XPMomentsSimpleDetailViewController.h" #import "XPMonentTopicContainerViewController.h" #import "XPMoentsTopicListViewController.h" -@interface XPMonentsRecommendViewController () +UIKIT_EXTERN NSString *kRequestRicket; +@interface XPMonentsRecommendViewController () ///列表 @property (nonatomic,strong) UITableView *tableView; ///数据源 @@ -45,268 +43,303 @@ @end @implementation XPMonentsRecommendViewController - +-(void)dealloc{ + [[NSNotificationCenter defaultCenter]removeObserver:self]; +} - (BOOL)isHiddenNavBar { - return YES; + return YES; } - (__kindof id)createPresenter { - return [[XPMonentsRecommendPresenter alloc] init]; + return [[XPMonentsRecommendPresenter alloc] init]; } - (void)viewDidLoad { [super viewDidLoad]; - [self initHeaderAndFooterRrfresh]; - [self initSubViews]; - [self initSubViewConstraints]; + [self initHeaderAndFooterRrfresh]; + [self initSubViews]; + [self initSubViewConstraints]; } #pragma mark - Private Method - (void)initSubViews { - [self.view addSubview:self.tableView]; - self.tableView.tableHeaderView = self.headerView; + [self.view addSubview:self.tableView]; + self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0); + self.tableView.tableHeaderView = self.headerView; } - (void)initSubViewConstraints { - [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self.view); - }]; + [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.view); + }]; + [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(requestRicketSuccess:) name:kRequestRicket object:nil]; + +} +-(void)requestRicketSuccess:(NSNotification *)not{ + if([not.object isKindOfClass:[NSDictionary class]])return; + BOOL is = [not.object boolValue]; + if(is == YES){ + [self headerRefresh]; + }else{ + [XNDJTDDLoadingTool hideOnlyView:self.tabBarController.view]; + } } #pragma mark - 下拉刷新 - (void)initHeaderAndFooterRrfresh { - MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)]; - header.stateLabel.font = [UIFont systemFontOfSize:10.0]; - header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0]; - header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; - header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor]; - self.tableView.mj_header = header; - - MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)]; - footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; - footer.stateLabel.font = [UIFont systemFontOfSize:10.0]; - self.tableView.mj_footer = footer; - - [self headerRefresh]; + MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)]; + header.stateLabel.font = [UIFont systemFontOfSize:10.0]; + header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0]; + header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; + header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor]; + self.tableView.mj_header = header; + + MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)]; + footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; + footer.stateLabel.font = [UIFont systemFontOfSize:10.0]; + self.tableView.mj_footer = footer; + + [self headerRefresh]; } #pragma mark - 刷新的fangfa - (void)headerRefresh { - self.page = 1; - [self.presenter getMonentsRecommendList:self.page pageSize:20 state:0]; - [self.presenter getMonentsTopicList:self.page pageSize:20]; + [XNDJTDDLoadingTool showOnlyView:self.tabBarController.view]; + if([AccountInfoStorage instance].isRequestRicket == YES){ + return; + } + self.page = 1; + [self.presenter getMonentsRecommendList:self.page pageSize:20 state:0]; + [self.presenter getMonentsTopicList:self.page pageSize:20]; } - (void)footerRefresh { - if (self.hasNoMoreData) { - [self showErrorToast:YMLocalizedString(@"XPMonentsRecommendViewController0")]; - [self.tableView.mj_footer endRefreshing]; - return; - } - self.page++; - [self.presenter getMonentsRecommendList:self.page pageSize:20 state:1]; + if([AccountInfoStorage instance].isRequestRicket == YES)return; + if (self.hasNoMoreData) { + [self showErrorToast:YMLocalizedString(@"XPMonentsRecommendViewController0")]; + [self.tableView.mj_footer endRefreshing]; + return; + } + self.page++; + [self.presenter getMonentsRecommendList:self.page pageSize:20 state:1]; } #pragma mark - UITableViewDelegate And UITableViewDataSource - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return self.datasource.count > 0 ? self.datasource.count : 1; + return self.datasource.count > 0 ? self.datasource.count : 1; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - if (self.datasource.count > 0) { - MonentsInfoModel * monentInfo= [self.datasource safeObjectAtIndex1:indexPath.row]; - [XPMonentsLayoutConfig layoutMonentsModel:monentInfo]; - return monentInfo.rowHeight; - } - return KScreenHeight - kNavigationHeight - 49 - kSafeAreaBottomHeight; + if (self.datasource.count > 0) { + MonentsInfoModel * monentInfo= [self.datasource safeObjectAtIndex1:indexPath.row]; + [XPMonentsLayoutConfig layoutMonentsModel:monentInfo]; + + if(monentInfo.squareTop && monentInfo.content.length == 0){ + return monentInfo.rowHeight + 20 ; + }else{ + return monentInfo.rowHeight; + } + + } + return KScreenHeight - kNavigationHeight - 49 - kSafeAreaBottomHeight; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - if (self.datasource.count > 0) { - XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; - MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; - cell.monentsInfo = monentsInfo; - cell.delegate = self; - return cell; - } - XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; - return cell; + if (self.datasource.count > 0) { + XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; + MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; + cell.monentsInfo = monentsInfo; + cell.delegate = self; + return cell; + } + XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; + return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - [tableView deselectRowAtIndexPath:indexPath animated:YES]; - if (self.datasource.count > 0) { - - MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; - - if ([ClientConfig shareConfig].canOpen) { - XPMonentsDetailViewController * detailVC = [[XPMonentsDetailViewController alloc] init]; - detailVC.monentsInfo = monentsInfo; - detailVC.delegate = self; - [self.navigationController pushViewController:detailVC animated:YES]; - }else{ - XPMomentsSimpleDetailViewController * detailVC = [[XPMomentsSimpleDetailViewController alloc] init]; - detailVC.monentsInfo = monentsInfo; - detailVC.delegate = self; - [self.navigationController pushViewController:detailVC animated:YES]; - } - } + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + if (self.datasource.count > 0) { + XPMonentsDetailViewController * detailVC = [[XPMonentsDetailViewController alloc] init]; + MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; + detailVC.monentsInfo = monentsInfo; + detailVC.delegate = self; + [self.navigationController pushViewController:detailVC animated:YES]; + } } #pragma mark - XPMonentsDetailViewControllerDelegate - (void)xPMonentsDetailViewController:(XPMonentsDetailViewController *)view deleteMonents:(NSString *)dynamicId { - __block MonentsInfoModel * deleteInfo; - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.dynamicId.integerValue == dynamicId.integerValue) { - deleteInfo = obj; - } - }]; - - if (deleteInfo) { - [self.datasource removeObject:deleteInfo]; - [self.tableView reloadData]; - } + __block MonentsInfoModel * deleteInfo; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == dynamicId.integerValue) { + deleteInfo = obj; + } + }]; + + if (deleteInfo) { + [self.datasource removeObject:deleteInfo]; + [self.tableView reloadData]; + } } #pragma mark - XPMonentsTableViewCellDelegate + +- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicShielding:(MonentsInfoModel *)monentsInfo{ + [self showLoading]; + [self.presenter requesstShieldingWtihType:@"0" objId:monentsInfo.dynamicId]; +} - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo { - [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; + [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; } - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicDelete:(MonentsInfoModel *)monentsInfo { - [TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsTopicLatestViewController1") confirmHandler:^{ - [self.presenter deleteMonents:monentsInfo.dynamicId worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; - } cancelHandler:^{ - - }]; + [TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsRecommendViewController1") confirmHandler:^{ + [self.presenter deleteMonents:monentsInfo.dynamicId worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; + } cancelHandler:^{ + + }]; } - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicFold:(MonentsInfoModel *)monentsInfo { - __block MonentsInfoModel * monentsInfos; - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.dynamicId.integerValue == monentsInfo.dynamicId.integerValue) { - monentsInfos = obj; - *stop = YES; - } - }]; - if (monentsInfos) { - NSInteger row = [self.datasource indexOfObject:monentsInfo]; - [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:row inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; - } + __block MonentsInfoModel * monentsInfos; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == monentsInfo.dynamicId.integerValue) { + monentsInfos = obj; + *stop = YES; + } + }]; + if (monentsInfos) { + NSInteger row = [self.datasource indexOfObject:monentsInfo]; + [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:row inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; + } } #pragma mark - XPMonentsRecommendHeaderViewDelegate - (void)xPMonentsRecommendHeaderView:(XPMonentsRecommendHeaderView *)view didSelectItem:(MonentsTopicModel *)info { - XPMonentTopicContainerViewController * topicVC = [[XPMonentTopicContainerViewController alloc] init]; - topicVC.worldId = info.tId; - [self.navigationController pushViewController:topicVC animated:YES]; + XPMonentTopicContainerViewController * topicVC = [[XPMonentTopicContainerViewController alloc] init]; + topicVC.worldId = info.tId; + [self.navigationController pushViewController:topicVC animated:YES]; } - (void)xPMonentsRecommendHeaderView:(XPMonentsRecommendHeaderView *)view didClickMoreTopic:(UIButton *)sender { - XPMoentsTopicListViewController * topicListVC = [[XPMoentsTopicListViewController alloc] init]; - [self.navigationController pushViewController:topicListVC animated:YES]; + XPMoentsTopicListViewController * topicListVC = [[XPMoentsTopicListViewController alloc] init]; + [self.navigationController pushViewController:topicListVC animated:YES]; } #pragma mark -JXCategoryListContainerViewDelegate - (UIView *)listView { - return self.view; + return self.view; } #pragma mark - XPMonentsRecommendProtocol - (void)getMonentsRecommendListSuccess:(NSArray *)array state:(int)state { - if (state == 0) { - [self.datasource removeAllObjects]; - } - if (array.count > 0) { - [self.datasource addObjectsFromArray:array]; - } - - if (state == 0) { - self.hasNoMoreData = NO; - [self.tableView.mj_header endRefreshing]; - } else { - if (array.count > 0) { - self.hasNoMoreData = NO; - } else { - self.hasNoMoreData = YES; - } - [self.tableView.mj_footer endRefreshing]; - } - [self.tableView reloadData]; + if (state == 0) { + [self.datasource removeAllObjects]; + } + if (array.count > 0) { + [self.datasource addObjectsFromArray:array]; + } + + if (state == 0) { + self.hasNoMoreData = NO; + [self.tableView.mj_header endRefreshing]; + } else { + if (array.count > 0) { + self.hasNoMoreData = NO; + } else { + self.hasNoMoreData = YES; + } + [self.tableView.mj_footer endRefreshing]; + } + [XNDJTDDLoadingTool hideOnlyView:self.tabBarController.view]; + [self.tableView reloadData]; } - (void)getMonentsRecommendListFail:(NSString *)msg state:(int)state { - if (state == 0) { - [self.tableView.mj_header endRefreshing]; - } else { - [self.tableView.mj_footer endRefreshing]; - } + [XNDJTDDLoadingTool hideOnlyView:self.tabBarController.view]; + if (state == 0) { + [self.tableView.mj_header endRefreshing]; + } else { + [self.tableView.mj_footer endRefreshing]; + } } - (void)monentsTopicListSuccess:(NSArray *)array { - self.headerView.topicList = array; + self.headerView.topicList = array; } - (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status { - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if ([obj.dynamicId isEqualToString:dynamicId]) { - if (status) { - obj.isLike += 1; - } else { - obj.isLike -= 1; - } - *stop = YES; - } - }]; - [self.tableView reloadData]; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj.dynamicId isEqualToString:dynamicId]) { + if (status) { + obj.isLike += 1; + } else { + obj.isLike -= 1; + } + *stop = YES; + } + }]; + [self.tableView reloadData]; +} +-(void)requesstShieldingSuccess:(NSString *)monentsInfo{ + [self hideHUD]; + [self showSuccessToast:YMLocalizedString(@"XPMonentsMineViewController2")]; + __block MonentsInfoModel * deleteInfo; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == monentsInfo.integerValue) { + deleteInfo = obj; + } + }]; + if (deleteInfo) { + [self.datasource removeObject:deleteInfo]; + [self.tableView reloadData]; + } } - - (void)deleteMonentsSuccess:(NSString *)monentsInfo { - [self showSuccessToast:YMLocalizedString(@"XPMonentsRecommendViewController2")]; - __block MonentsInfoModel * deleteInfo; - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.dynamicId.integerValue == monentsInfo.integerValue) { - deleteInfo = obj; - } - }]; - if (deleteInfo) { - [self.datasource removeObject:deleteInfo]; - [self.tableView reloadData]; - } + [self showSuccessToast:YMLocalizedString(@"XPMonentsRecommendViewController2")]; + __block MonentsInfoModel * deleteInfo; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == monentsInfo.integerValue) { + deleteInfo = obj; + } + }]; + if (deleteInfo) { + [self.datasource removeObject:deleteInfo]; + [self.tableView reloadData]; + } } #pragma mark - Getters And Setters - (UITableView *)tableView { - if (!_tableView) { - _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; - _tableView.delegate = self; - _tableView.dataSource = self; - _tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0); - _tableView.tableFooterView = [UIView new]; - _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; - _tableView.backgroundColor = [UIColor clearColor]; - if (@available(iOS 11.0, *)) { - _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; - } - [_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; - [_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; - } - return _tableView; + if (!_tableView) { + _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; + _tableView.delegate = self; + _tableView.dataSource = self; + _tableView.tableFooterView = [UIView new]; + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; + _tableView.backgroundColor = [UIColor clearColor]; + if (@available(iOS 11.0, *)) { + _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } + [_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; + [_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; + } + return _tableView; } - (NSMutableArray *)datasource { - if (!_datasource) { - _datasource = [NSMutableArray array]; - } - return _datasource; + if (!_datasource) { + _datasource = [NSMutableArray array]; + } + return _datasource; } - (XPMonentsRecommendHeaderView *)headerView { - if (!_headerView) { - _headerView = [[XPMonentsRecommendHeaderView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 110)]; - _headerView.delegate = self; - } - return _headerView; + if (!_headerView) { + _headerView = [[XPMonentsRecommendHeaderView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 145)]; + _headerView.delegate = self; + } + return _headerView; } @end diff --git a/YuMi/Modules/YMMonents/View/XPMonentsTopicLatestViewController.m b/YuMi/Modules/YMMonents/View/XPMonentsTopicLatestViewController.m index 1c51421f..af87c4f1 100644 --- a/YuMi/Modules/YMMonents/View/XPMonentsTopicLatestViewController.m +++ b/YuMi/Modules/YMMonents/View/XPMonentsTopicLatestViewController.m @@ -1,8 +1,8 @@ // -// YMMonentsTopicLatestViewController.m -// YUMI +// XPMonentsTopicLatestViewController.m +// xplan-ios // -// Created by YUMI on 2022/8/18. +// Created by 冯硕 on 2022/8/18. // #import "XPMonentsTopicLatestViewController.h" @@ -10,12 +10,9 @@ #import #import ///Tool -#import "DJDKMIMOMColor.h" -#import "YUMIMacroUitls.h" + #import "XPMonentsLayoutConfig.h" #import "TTPopup.h" -#import "NSArray+Safe.h" -#import "ClientConfig.h" ///Model #import "MonentsListInfoModel.h" ///P @@ -25,9 +22,8 @@ #import "XPMonentsTableViewCell.h" #import "XPMonentsEmptyTableViewCell.h" #import "XPMonentsDetailViewController.h" -#import "XPMomentsSimpleDetailViewController.h" -@interface XPMonentsTopicLatestViewController () +@interface XPMonentsTopicLatestViewController () ///列表 @property (nonatomic,strong) UITableView *tableView; ///数据源 @@ -39,253 +35,308 @@ @end @implementation XPMonentsTopicLatestViewController - +-(void)dealloc{ + [[NSNotificationCenter defaultCenter]removeObserver:self]; +} - (BOOL)isHiddenNavBar { - return YES; + return YES; } - (__kindof id)createPresenter { - return [[XPMonentsTopicLatestPresenter alloc] init]; + return [[XPMonentsTopicLatestPresenter alloc] init]; } - (void)viewDidLoad { - [super viewDidLoad]; - [self initHeaderAndFooterRrfresh]; - [self initSubViews]; - [self initSubViewConstraints]; -} + [super viewDidLoad]; + [self initHeaderAndFooterRrfresh]; + [self initSubViews]; + [self initSubViewConstraints]; + [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(refreshDynamicData:) name:@"kRefreshDynamicData" object:nil]; +} +-(void)refreshDynamicData:(NSNotification *)not{ + NSDictionary *refreshData = not.object; + int type = [refreshData[@"type"] intValue]; + ///type,0=点赞,1=删除,2=屏蔽,3=评论 + switch (type) { + case 0: + { + + NSString *dynamicId = refreshData[@"dynamicId"]; + BOOL status = [refreshData[@"status"] boolValue]; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj.dynamicId isEqualToString:dynamicId]) { + if (status) { + obj.isLike = YES; + obj.likeCount = [NSString stringWithFormat:@"%ld",obj.likeCount.integerValue + 1]; + } else { + obj.likeCount = [NSString stringWithFormat:@"%ld",(obj.likeCount.integerValue - 1 >= 0) ? (obj.likeCount.integerValue - 1) : 0]; + obj.isLike = NO; + } + *stop = YES; + } + }]; + + [self.tableView reloadData]; + break; + } + case 1: + { + + NSString *dynamicId = refreshData[@"dynamicId"]; + __block MonentsInfoModel * deleteInfo; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == dynamicId.integerValue) { + deleteInfo = obj; + + *stop = YES; + } + }]; + + if (deleteInfo) { + [self.datasource removeObject:deleteInfo]; + [self.tableView reloadData]; + } + break; + } + case 2: + { + NSString *dynamicId = refreshData[@"dynamicId"]; + __block MonentsInfoModel * deleteInfo; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == dynamicId.integerValue) { + deleteInfo = obj; + *stop = YES; + + } + }]; + + if (deleteInfo) { + [self.datasource removeObject:deleteInfo]; + [self.tableView reloadData]; + } + break; + } + default: + { + NSString *dynamicId = refreshData[@"dynamicId"]; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj.dynamicId isEqualToString:dynamicId]) { + obj.commentCount = [NSString stringWithFormat:@"%ld",obj.commentCount.integerValue + 1]; + *stop = YES; + } + }]; + + [self.tableView reloadData]; + break; + } + } +} #pragma mark - Private Method - (void)initSubViews { - [self.view addSubview:self.tableView]; + [self.view addSubview:self.tableView]; } - (void)initSubViewConstraints { - [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self.view); - }]; + [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.view); + }]; } #pragma mark - 下拉刷新 - (void)initHeaderAndFooterRrfresh { - MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)]; - header.stateLabel.font = [UIFont systemFontOfSize:10.0]; - header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0]; - header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; - header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor]; - self.tableView.mj_header = header; + MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)]; + header.stateLabel.font = [UIFont systemFontOfSize:10.0]; + header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0]; + header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; + header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor]; + self.tableView.mj_header = header; - MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)]; - footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; - footer.stateLabel.font = [UIFont systemFontOfSize:10.0]; - self.tableView.mj_footer = footer; + MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)]; + footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; + footer.stateLabel.font = [UIFont systemFontOfSize:10.0]; + self.tableView.mj_footer = footer; - [self headerRefresh]; + [self headerRefresh]; } #pragma mark - 刷新的fangfa - (void)headerRefresh { - [self.presenter getMonentsTopicLatestList:@"" worldId:self.worldId state:0]; + [self.presenter getMonentsTopicLatestList:@"" worldId:self.worldId state:0]; } - (void)footerRefresh { - if (self.hasNoMoreData) { - [self showErrorToast:YMLocalizedString(@"XPMonentsTopicLatestViewController0")]; - [self.tableView.mj_footer endRefreshing]; - return; - } - [self.presenter getMonentsTopicLatestList:self.listInfo.nextDynamicId worldId:self.worldId state:1]; + if (self.hasNoMoreData) { + [self showErrorToast:YMLocalizedString(@"XPMonentsTopicLatestViewController0")]; + [self.tableView.mj_footer endRefreshing]; + return; + } + [self.presenter getMonentsTopicLatestList:self.listInfo.nextDynamicId worldId:self.worldId state:1]; } #pragma mark - UITableViewDelegate And UITableViewDataSource - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return self.datasource.count > 0 ? self.datasource.count : 1; + return self.datasource.count > 0 ? self.datasource.count : 1; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - if (self.datasource.count > 0) { - MonentsInfoModel * monentInfo= [self.datasource safeObjectAtIndex1:indexPath.row]; - [XPMonentsLayoutConfig layoutMonentsModel:monentInfo]; - return monentInfo.rowHeight; - } - return KScreenHeight - kNavigationHeight - 49 - kSafeAreaBottomHeight; + if (self.datasource.count > 0) { + MonentsInfoModel * monentInfo= [self.datasource safeObjectAtIndex1:indexPath.row]; + [XPMonentsLayoutConfig layoutMonentsModel:monentInfo]; + if(monentInfo.squareTop && monentInfo.content.length == 0){ + return monentInfo.rowHeight + 20 ; + }else{ + return monentInfo.rowHeight; + } + } + return KScreenHeight - kNavigationHeight - 49 - kSafeAreaBottomHeight; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - if (self.datasource.count > 0) { - XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; - MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; - cell.delegate = self; - cell.monentsInfo = monentsInfo; - return cell; - } - XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; - return cell; + if (self.datasource.count > 0) { + XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; + MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; + cell.delegate = self; + cell.monentsInfo = monentsInfo; + return cell; + } + XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; + return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - [tableView deselectRowAtIndexPath:indexPath animated:YES]; - if (self.datasource.count > 0) { - - if ([ClientConfig shareConfig].canOpen) { - XPMonentsDetailViewController * detailVC = [[XPMonentsDetailViewController alloc] init]; - MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; - detailVC.monentsInfo = monentsInfo; - detailVC.delegate = self; - [self.navigationController pushViewController:detailVC animated:YES]; - }else{ - XPMomentsSimpleDetailViewController * detailVC = [[XPMomentsSimpleDetailViewController alloc] init]; - MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; - detailVC.monentsInfo = monentsInfo; - detailVC.delegate = self; - [self.navigationController pushViewController:detailVC animated:YES]; - } - } + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + if (self.datasource.count > 0) { + XPMonentsDetailViewController * detailVC = [[XPMonentsDetailViewController alloc] init]; + MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; + detailVC.monentsInfo = monentsInfo; + [self.navigationController pushViewController:detailVC animated:YES]; + } } #pragma mark - XPMonentsTableViewCellDelegate +- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicShielding:(MonentsInfoModel *)monentsInfo{ + [self showLoading]; + [self.presenter requesstShieldingWtihType:@"0" objId:monentsInfo.dynamicId]; +} - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo { - [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; + [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; } - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicDelete:(MonentsInfoModel *)monentsInfo { - [TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsTopicLatestViewController1") confirmHandler:^{ - [self.presenter deleteMonents:monentsInfo.dynamicId worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; - } cancelHandler:^{ + [TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsTopicLatestViewController1") confirmHandler:^{ + [self.presenter deleteMonents:monentsInfo.dynamicId worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; + } cancelHandler:^{ - }]; + }]; } - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicFold:(MonentsInfoModel *)monentsInfo { - __block MonentsInfoModel * monentsInfos; - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.dynamicId.integerValue == monentsInfo.dynamicId.integerValue) { - monentsInfos = obj; - *stop = YES; - } - }]; - if (monentsInfos) { - NSInteger row = [self.datasource indexOfObject:monentsInfo]; - [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:row inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; - } + __block MonentsInfoModel * monentsInfos; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == monentsInfo.dynamicId.integerValue) { + monentsInfos = obj; + *stop = YES; + } + }]; + if (monentsInfos) { + NSInteger row = [self.datasource indexOfObject:monentsInfo]; + [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:row inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; + } } #pragma mark - JXPagingViewListViewDelegate - (UIScrollView *)listScrollView { - return self.tableView; + return self.tableView; } - (void)listViewDidScrollCallback:(void (^)(UIScrollView *))callback { - self.scrollCallback = callback; + self.scrollCallback = callback; } - (UIView *)listView { - return self.view; + return self.view; } - (void)scrollViewDidScroll:(UIScrollView *)scrollView { - self.scrollCallback(scrollView); + self.scrollCallback(scrollView); } -#pragma mark - XPMonentsDetailViewControllerDelegate -- (void)xPMonentsDetailViewController:(XPMonentsDetailViewController *)view deleteMonents:(NSString *)dynamicId { - __block MonentsInfoModel * deleteInfo; - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.dynamicId.integerValue == dynamicId.integerValue) { - deleteInfo = obj; - } - }]; - if (deleteInfo) { - [self.datasource removeObject:deleteInfo]; - [self.tableView reloadData]; - } -} #pragma mark - XPMonentsTopicLatestProtocol - (void)getMonentsTopicLatestListSuccess:(MonentsListInfoModel *)listInfo state:(int)state{ - self.listInfo = listInfo; - if (state == 0) { - [self.datasource removeAllObjects]; - } - if (listInfo.dynamicList.count > 0) { - [self.datasource addObjectsFromArray:listInfo.dynamicList]; - } + self.listInfo = listInfo; + if (state == 0) { + [self.datasource removeAllObjects]; + } + if (listInfo.dynamicList.count > 0) { + [self.datasource addObjectsFromArray:listInfo.dynamicList]; + } - if (state == 0) { - self.hasNoMoreData = NO; - [self.tableView.mj_header endRefreshing]; - } else { - if (listInfo.dynamicList.count > 0) { - self.hasNoMoreData = NO; - } else { - self.hasNoMoreData = YES; - } - [self.tableView.mj_footer endRefreshing]; - } - [self.tableView reloadData]; + if (state == 0) { + self.hasNoMoreData = NO; + [self.tableView.mj_header endRefreshing]; + } else { + if (listInfo.dynamicList.count > 0) { + self.hasNoMoreData = NO; + } else { + self.hasNoMoreData = YES; + } + [self.tableView.mj_footer endRefreshing]; + } + [self.tableView reloadData]; } - (void)getMonentsTopicLatestListFail:(NSString *)msg state:(int)state { - if (state == 0) { - [self.tableView.mj_header endRefreshing]; - } else { - [self.tableView.mj_footer endRefreshing]; - } + if (state == 0) { + [self.tableView.mj_header endRefreshing]; + } else { + [self.tableView.mj_footer endRefreshing]; + } } - (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status { - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if ([obj.dynamicId isEqualToString:dynamicId]) { - if (status) { - obj.isLike += 1; - } else { - obj.isLike -= 1; - } - *stop = YES; - } - }]; - [self.tableView reloadData]; + + ///type,0=点赞,1=删除,2=屏蔽,3=评论 + [[NSNotificationCenter defaultCenter]postNotificationName:@"kRefreshDynamicData" object:@{@"dynamicId":dynamicId,@"type":@"0",@"status":@(status)}]; +} +- (void)requesstShieldingSuccess:(NSString *)monentsInfo{ + [self hideHUD]; + [self showSuccessToast:YMLocalizedString(@"XPMonentsMineViewController2")]; + ///type,0=点赞,1=删除,2=屏蔽,3=评论 + [[NSNotificationCenter defaultCenter]postNotificationName:@"kRefreshDynamicData" object:@{@"dynamicId":monentsInfo,@"type":@"2"}]; } - - (void)deleteMonentsSuccess:(NSString *)monentsInfo { - [self showSuccessToast:YMLocalizedString(@"XPMonentsTopicLatestViewController2")]; - __block MonentsInfoModel * deleteInfo; - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.dynamicId.integerValue == monentsInfo.integerValue) { - deleteInfo = obj; - } - }]; - - if (deleteInfo) { - [self.datasource removeObject:deleteInfo]; - [self.tableView reloadData]; - } + [self showSuccessToast:YMLocalizedString(@"XPMonentsTopicLatestViewController2")]; + ///type,0=点赞,1=删除,2=屏蔽,3=评论 + [[NSNotificationCenter defaultCenter]postNotificationName:@"kRefreshDynamicData" object:@{@"dynamicId":monentsInfo,@"type":@"1"}]; + } #pragma mark - Getters And Setters - (UITableView *)tableView { - if (!_tableView) { - _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; - _tableView.delegate = self; - _tableView.dataSource = self; - _tableView.tableFooterView = [UIView new]; - _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; - _tableView.backgroundColor = [UIColor clearColor]; - if (@available(iOS 11.0, *)) { - _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; - } - [_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; - [_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; - } - return _tableView; + if (!_tableView) { + _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; + _tableView.delegate = self; + _tableView.dataSource = self; + _tableView.tableFooterView = [UIView new]; + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; + _tableView.backgroundColor = [UIColor clearColor]; + if (@available(iOS 11.0, *)) { + _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } + [_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; + [_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; + } + return _tableView; } - (NSMutableArray *)datasource { - if (!_datasource) { - _datasource = [NSMutableArray array]; - } - return _datasource; + if (!_datasource) { + _datasource = [NSMutableArray array]; + } + return _datasource; } @end diff --git a/YuMi/Modules/YMMonents/View/XPMonentsTopicRecommondViewController.m b/YuMi/Modules/YMMonents/View/XPMonentsTopicRecommondViewController.m index da4f79d4..e7188b5b 100644 --- a/YuMi/Modules/YMMonents/View/XPMonentsTopicRecommondViewController.m +++ b/YuMi/Modules/YMMonents/View/XPMonentsTopicRecommondViewController.m @@ -1,8 +1,8 @@ // -// YMMonentsTopicRecommondViewController.m -// YUMI +// XPMonentsTopicRecommondViewController.m +// xplan-ios // -// Created by YUMI on 2022/8/18. +// Created by 冯硕 on 2022/8/18. // #import "XPMonentsTopicRecommondViewController.h" @@ -10,12 +10,9 @@ #import #import ///Tool -#import "DJDKMIMOMColor.h" -#import "YUMIMacroUitls.h" + #import "XPMonentsLayoutConfig.h" #import "TTPopup.h" -#import "NSArray+Safe.h" -#import "ClientConfig.h" ///Model #import "MonentsListInfoModel.h" ///P @@ -25,7 +22,6 @@ #import "XPMonentsTableViewCell.h" #import "XPMonentsEmptyTableViewCell.h" #import "XPMonentsDetailViewController.h" -#import "XPMomentsSimpleDetailViewController.h" @interface XPMonentsTopicRecommondViewController () ///列表 @@ -41,251 +37,266 @@ @implementation XPMonentsTopicRecommondViewController - (BOOL)isHiddenNavBar { - return YES; + return YES; } - (__kindof id)createPresenter { - return [[XPMonentsTopicRecommendPresenter alloc] init]; + return [[XPMonentsTopicRecommendPresenter alloc] init]; } - (void)viewDidLoad { - [super viewDidLoad]; - [self initHeaderAndFooterRrfresh]; - [self initSubViews]; - [self initSubViewConstraints]; + [super viewDidLoad]; + [self initHeaderAndFooterRrfresh]; + [self initSubViews]; + [self initSubViewConstraints]; } #pragma mark - Private Method - (void)initSubViews { - [self.view addSubview:self.tableView]; + [self.view addSubview:self.tableView]; } - (void)initSubViewConstraints { - [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self.view); - }]; + [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.view); + }]; } #pragma mark - 下拉刷新 - (void)initHeaderAndFooterRrfresh { - MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)]; - header.stateLabel.font = [UIFont systemFontOfSize:10.0]; - header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0]; - header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; - header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor]; - self.tableView.mj_header = header; + MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)]; + header.stateLabel.font = [UIFont systemFontOfSize:10.0]; + header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0]; + header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; + header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor]; + self.tableView.mj_header = header; - MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)]; - footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; - footer.stateLabel.font = [UIFont systemFontOfSize:10.0]; - self.tableView.mj_footer = footer; + MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)]; + footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; + footer.stateLabel.font = [UIFont systemFontOfSize:10.0]; + self.tableView.mj_footer = footer; - [self headerRefresh]; + [self headerRefresh]; } #pragma mark - 刷新的fangfa - (void)headerRefresh { - [self.presenter getMonentsTopicRecommendList:@"" worldId:self.worldId state:0]; + [self.presenter getMonentsTopicRecommendList:@"" worldId:self.worldId state:0]; } - (void)footerRefresh { - if (self.hasNoMoreData) { - [self showErrorToast:YMLocalizedString(@"XPMonentsTopicRecommondViewController0")]; - [self.tableView.mj_footer endRefreshing]; - return; - } - [self.presenter getMonentsTopicRecommendList:self.listInfo.nextDynamicId worldId:self.worldId state:1]; + if (self.hasNoMoreData) { + [self showErrorToast:YMLocalizedString(@"XPMonentsTopicRecommondViewController0")]; + [self.tableView.mj_footer endRefreshing]; + return; + } + [self.presenter getMonentsTopicRecommendList:self.listInfo.nextDynamicId worldId:self.worldId state:1]; } #pragma mark - UITableViewDelegate And UITableViewDataSource - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return self.datasource.count > 0 ? self.datasource.count : 1; + return self.datasource.count > 0 ? self.datasource.count : 1; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - if (self.datasource.count > 0) { - MonentsInfoModel * monentInfo= [self.datasource safeObjectAtIndex1:indexPath.row]; - [XPMonentsLayoutConfig layoutMonentsModel:monentInfo]; - return monentInfo.rowHeight; - } - return KScreenHeight - kNavigationHeight - 49 - kSafeAreaBottomHeight; + if (self.datasource.count > 0) { + MonentsInfoModel * monentInfo= [self.datasource safeObjectAtIndex1:indexPath.row]; + [XPMonentsLayoutConfig layoutMonentsModel:monentInfo]; + if(monentInfo.squareTop && monentInfo.content.length == 0){ + return monentInfo.rowHeight + 20 ; + }else{ + return monentInfo.rowHeight; + } + } + return KScreenHeight - kNavigationHeight - 49 - kSafeAreaBottomHeight; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - if (self.datasource.count > 0) { - XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; - MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; - cell.delegate = self; - cell.monentsInfo = monentsInfo; - return cell; - } - XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; - return cell; + if (self.datasource.count > 0) { + XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; + MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; + cell.delegate = self; + cell.isTopic = YES; + cell.monentsInfo = monentsInfo; + return cell; + } + XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; + return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - [tableView deselectRowAtIndexPath:indexPath animated:YES]; - if (self.datasource.count > 0) { - - if ([ClientConfig shareConfig].canOpen) { - XPMonentsDetailViewController * detailVC = [[XPMonentsDetailViewController alloc] init]; - MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; - detailVC.monentsInfo = monentsInfo; - detailVC.delegate = self; - [self.navigationController pushViewController:detailVC animated:YES]; - }else{ - XPMomentsSimpleDetailViewController * detailVC = [[XPMomentsSimpleDetailViewController alloc] init]; - MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; - detailVC.monentsInfo = monentsInfo; - detailVC.delegate = self; - [self.navigationController pushViewController:detailVC animated:YES]; - } - } + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + if (self.datasource.count > 0) { + XPMonentsDetailViewController * detailVC = [[XPMonentsDetailViewController alloc] init]; + MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; + detailVC.monentsInfo = monentsInfo; + detailVC.delegate = self; + [self.navigationController pushViewController:detailVC animated:YES]; + } } #pragma mark - XPMonentsDetailViewControllerDelegate -- (void)xPMonentsDetailViewController:(XPMonentsDetailViewController *)view deleteMonents:(NSString *)dynamicId { - __block MonentsInfoModel * deleteInfo; - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.dynamicId.integerValue == dynamicId.integerValue) { - deleteInfo = obj; - } - }]; - if (deleteInfo) { - [self.datasource removeObject:deleteInfo]; - [self.tableView reloadData]; - } +- (void)xPMonentsDetailViewController:(XPMonentsDetailViewController *)view deleteMonents:(NSString *)dynamicId { + __block MonentsInfoModel * deleteInfo; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == dynamicId.integerValue) { + deleteInfo = obj; + } + }]; + + if (deleteInfo) { + [self.datasource removeObject:deleteInfo]; + [self.tableView reloadData]; + } } #pragma mark - XPMonentsTableViewCellDelegate +- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicShielding:(MonentsInfoModel *)monentsInfo{ + [self showLoading]; + [self.presenter requesstShieldingWtihType:@"0" objId:monentsInfo.dynamicId]; +} - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo { - [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; + [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; } - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicDelete:(MonentsInfoModel *)monentsInfo { - [TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsTopicLatestViewController1") confirmHandler:^{ - [self.presenter deleteMonents:monentsInfo.dynamicId worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; - } cancelHandler:^{ + [TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsTopicRecommondViewController1") confirmHandler:^{ + [self.presenter deleteMonents:monentsInfo.dynamicId worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; + } cancelHandler:^{ - }]; + }]; } - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicFold:(MonentsInfoModel *)monentsInfo { - __block MonentsInfoModel * monentsInfos; - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.dynamicId.integerValue == monentsInfo.dynamicId.integerValue) { - monentsInfos = obj; - *stop = YES; - } - }]; - if (monentsInfos) { - NSInteger row = [self.datasource indexOfObject:monentsInfo]; - [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:row inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; - } + __block MonentsInfoModel * monentsInfos; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == monentsInfo.dynamicId.integerValue) { + monentsInfos = obj; + *stop = YES; + } + }]; + if (monentsInfos) { + NSInteger row = [self.datasource indexOfObject:monentsInfo]; + [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:row inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; + } } #pragma mark - JXPagingViewListViewDelegate - (UIScrollView *)listScrollView { - return self.tableView; + return self.tableView; } - (void)listViewDidScrollCallback:(void (^)(UIScrollView *))callback { - self.scrollCallback = callback; + self.scrollCallback = callback; } - (UIView *)listView { - return self.view; + return self.view; } - (void)scrollViewDidScroll:(UIScrollView *)scrollView { - self.scrollCallback(scrollView); + self.scrollCallback(scrollView); } #pragma mark - XPMonentsRecommendProtocol - (void)getMonentsTopicRecommendListSuccess:(MonentsListInfoModel *)listInfo state:(int)state { - self.listInfo = listInfo; - if (state == 0) { - [self.datasource removeAllObjects]; - } - if (listInfo.dynamicList.count > 0) { - [self.datasource addObjectsFromArray:listInfo.dynamicList]; - } + self.listInfo = listInfo; + if (state == 0) { + [self.datasource removeAllObjects]; + } + if (listInfo.dynamicList.count > 0) { + [self.datasource addObjectsFromArray:listInfo.dynamicList]; + } - if (state == 0) { - self.hasNoMoreData = NO; - [self.tableView.mj_header endRefreshing]; - } else { - if (listInfo.dynamicList.count > 0) { - self.hasNoMoreData = NO; - } else { - self.hasNoMoreData = YES; - } - [self.tableView.mj_footer endRefreshing]; - } - [self.tableView reloadData]; + if (state == 0) { + self.hasNoMoreData = NO; + [self.tableView.mj_header endRefreshing]; + } else { + if (listInfo.dynamicList.count > 0) { + self.hasNoMoreData = NO; + } else { + self.hasNoMoreData = YES; + } + [self.tableView.mj_footer endRefreshing]; + } + [self.tableView reloadData]; } - (void)getMonentsTopicRecommendListFail:(NSString *)msg state:(int)state { - if (state == 0) { - [self.tableView.mj_header endRefreshing]; - } else { - [self.tableView.mj_footer endRefreshing]; - } + if (state == 0) { + [self.tableView.mj_header endRefreshing]; + } else { + [self.tableView.mj_footer endRefreshing]; + } } - (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status { - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if ([obj.dynamicId isEqualToString:dynamicId]) { - if (status) { - obj.isLike += 1; - } else { - obj.isLike -= 1; - } - *stop = YES; - } - }]; - [self.tableView reloadData]; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj.dynamicId isEqualToString:dynamicId]) { + if (status) { + obj.isLike += 1; + } else { + obj.isLike -= 1; + } + *stop = YES; + } + }]; + [self.tableView reloadData]; } +-(void)requesstShieldingSuccess:(NSString *)monentsInfo{ + [self hideHUD]; + [self showSuccessToast:YMLocalizedString(@"XPMonentsMineViewController2")]; + __block MonentsInfoModel * deleteInfo; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == monentsInfo.integerValue) { + deleteInfo = obj; + } + }]; + if (deleteInfo) { + [self.datasource removeObject:deleteInfo]; + [self.tableView reloadData]; + } +} - (void)deleteMonentsSuccess:(NSString *)monentsInfo { - [self showSuccessToast:YMLocalizedString(@"XPMonentsTopicRecommondViewController2")]; - __block MonentsInfoModel * deleteInfo; - [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.dynamicId.integerValue == monentsInfo.integerValue) { - deleteInfo = obj; - } - }]; + [self showSuccessToast:YMLocalizedString(@"XPMonentsTopicRecommondViewController2")]; + __block MonentsInfoModel * deleteInfo; + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.dynamicId.integerValue == monentsInfo.integerValue) { + deleteInfo = obj; + } + }]; - if (deleteInfo) { - [self.datasource removeObject:deleteInfo]; - [self.tableView reloadData]; - } + if (deleteInfo) { + [self.datasource removeObject:deleteInfo]; + [self.tableView reloadData]; + } } #pragma mark - Getters And Setters - (UITableView *)tableView { - if (!_tableView) { - _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; - _tableView.delegate = self; - _tableView.dataSource = self; - _tableView.tableFooterView = [UIView new]; - _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; - _tableView.backgroundColor = [UIColor clearColor]; - if (@available(iOS 11.0, *)) { - _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; - } - [_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; - [_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; - } - return _tableView; + if (!_tableView) { + _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; + _tableView.delegate = self; + _tableView.dataSource = self; + _tableView.tableFooterView = [UIView new]; + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; + _tableView.backgroundColor = [UIColor clearColor]; + if (@available(iOS 11.0, *)) { + _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } + [_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; + [_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; + } + return _tableView; } - (NSMutableArray *)datasource { - if (!_datasource) { - _datasource = [NSMutableArray array]; - } - return _datasource; + if (!_datasource) { + _datasource = [NSMutableArray array]; + } + return _datasource; } @end diff --git a/YuMi/Modules/YMMonents/View/XPMonentsViewController.m b/YuMi/Modules/YMMonents/View/XPMonentsViewController.m index effe49c3..d02ed070 100644 --- a/YuMi/Modules/YMMonents/View/XPMonentsViewController.m +++ b/YuMi/Modules/YMMonents/View/XPMonentsViewController.m @@ -1,8 +1,8 @@ // -// YMMonentsViewController.m -// YUMI +// XPMonentsViewController.m +// xplan-ios // -// Created by YUMI on 2022/5/11. +// Created by 冯硕 on 2022/5/11. // #import "XPMonentsViewController.h" @@ -11,9 +11,7 @@ #import #import #import -///Tool -#import "DJDKMIMOMColor.h" -#import "YUMIMacroUitls.h" + ///Tool #import "AttachMentModel.h" #import "MonentsUnReadModel.h" @@ -24,7 +22,8 @@ #import "XPMonentsInteractiveViewController.h" #import "XPMonentsPublishViewController.h" -@interface XPMonentsViewController () + +@interface XPMonentsViewController () ///标题 @property (nonatomic,strong) NSArray *titles; ///导航栏 @@ -36,6 +35,7 @@ ///滑块 @property (nonatomic,strong) JXCategoryTitleView *titleView; @property (nonatomic, strong) JXCategoryListContainerView *listContainerView; + ///发布的按钮 @property (nonatomic,strong) UIButton *publishButton; ///关注 @@ -47,233 +47,240 @@ @end @implementation XPMonentsViewController -@synthesize parentMode = _parentMode; - (void)dealloc { - [[NIMSDK sharedSDK].systemNotificationManager removeDelegate:self]; + [[NIMSDK sharedSDK].systemNotificationManager removeDelegate:self]; } - (BOOL)isHiddenNavBar { - return YES; + return YES; } - (void)viewDidLoad { - [super viewDidLoad]; - [[NIMSDK sharedSDK].systemNotificationManager addDelegate:self]; - [self initSubViews]; - [self initSubViewConstraints]; + [super viewDidLoad]; + [[NIMSDK sharedSDK].systemNotificationManager addDelegate:self]; + [self initSubViews]; + [self initSubViewConstraints]; } #pragma mark - Private Method - (void)initSubViews { - [self.view addSubview:self.navView]; - [self.view addSubview:self.listContainerView]; - [self.view addSubview:self.publishButton]; - - [self.navView addSubview:self.titleView]; - [self.navView addSubview:self.messageButton]; - [self.navView addSubview:self.dotView]; + [self.view addSubview:self.navView]; + [self.view addSubview:self.listContainerView]; + [self.view addSubview:self.publishButton]; + + [self.navView addSubview:self.titleView]; + [self.navView addSubview:self.messageButton]; + [self.navView addSubview:self.dotView]; + self.dotView.hidden = self.tabBarItem.badgeValue == 0; } - (void)initSubViewConstraints { - [self.navView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.top.mas_equalTo(self.view); - make.height.mas_equalTo(kNavigationHeight); - }]; - - [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self.navView); - make.height.mas_equalTo(20); - make.top.mas_equalTo(self.navView).offset(kSafeAreaTopHeight + 40); - }]; - - [self.messageButton mas_makeConstraints:^(MASConstraintMaker *make) { - make.centerY.mas_equalTo(self.titleView); - make.right.mas_equalTo(self.navView).offset(-15); - make.size.mas_equalTo(CGSizeMake(22, 22)); - }]; - - [self.dotView mas_makeConstraints:^(MASConstraintMaker *make) { - make.size.mas_equalTo(CGSizeMake(10, 10)); - make.centerY.mas_equalTo(self.messageButton.mas_top); - make.centerX.mas_equalTo(self.messageButton.mas_right); - }]; - - [self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.bottom.mas_equalTo(self.view); - make.top.mas_equalTo(self.navView.mas_bottom); - }]; - - [self.publishButton mas_makeConstraints:^(MASConstraintMaker *make) { - make.size.mas_equalTo(CGSizeMake(45, 45)); - make.bottom.mas_equalTo(self.view).offset(-kSafeAreaBottomHeight - 60); - make.right.mas_equalTo(self.view).offset(-25); - }]; + [self.navView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.top.mas_equalTo(self.view); + make.height.mas_equalTo(kNavigationHeight); + }]; + + [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.navView); + make.height.mas_equalTo(45); + make.top.mas_equalTo(self.navView).offset(kSafeAreaTopHeight + 20); + }]; + + [self.messageButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerY.mas_equalTo(self.titleView); + make.right.mas_equalTo(self.navView).offset(-15); + make.size.mas_equalTo(CGSizeMake(22, 22)); + }]; + + [self.dotView mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(10, 10)); + make.centerY.mas_equalTo(self.messageButton.mas_top); + make.centerX.mas_equalTo(self.messageButton.mas_right); + }]; + + [self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.bottom.mas_equalTo(self.view); + make.top.mas_equalTo(self.navView.mas_bottom); + }]; + + [self.publishButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(45, 45)); + make.bottom.mas_equalTo(self.view).offset(-kSafeAreaBottomHeight - 30); + make.right.mas_equalTo(self.view).offset(-15); + }]; } #pragma mark - JXCategoryListContainerViewDelegate - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView { - return self.titles.count; + return self.titles.count; } + // 根据下标 index 返回对应遵守并实现 `JXCategoryListContentViewDelegate` 协议的列表实例 - (id)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index { - UIViewController * list = (UIViewController *)[self.listContainerView.validListDict objectForKey:[NSNumber numberWithInteger:index]]; - if (list) { - return list; - } else { - if (index == 0) { - return self.attentionVC; - }else if (index == 1) { - return self.recommendVC; - } else if(index == 2) { - return self.latestVC; - } - return nil; - } + UIViewController * list = (UIViewController *)[self.listContainerView.validListDict objectForKey:[NSNumber numberWithInteger:index]]; + if (list) { + return list; + } else { + if (index == 0) { + return self.attentionVC; + }else if (index == 1) { + return self.recommendVC; + } else if(index == 2) { + return self.latestVC; + } + return nil; + } } #pragma mark -NIMSystemNotificationManagerDelegate - (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification { - if (notification.receiverType == NIMSessionTypeP2P) { - if (notification.content != nil) { - AttachmentModel *attachment = [AttachmentModel modelWithJSON:notification.content]; - if (attachment.first == CustomMessageType_Monents && attachment.second == Custom_Message_Sub_Monents_Unread_Update) { - MonentsUnReadModel * unreadModel = [MonentsUnReadModel modelWithDictionary:attachment.data]; - if (unreadModel.total > 0) { - self.dotView.hidden = NO; - } else { - self.dotView.hidden = YES; - } - [self setTabBarItemBadge:unreadModel.total]; - } - } - } + if (notification.receiverType == NIMSessionTypeP2P) { + if (notification.content != nil) { + AttachmentModel *attachment = [AttachmentModel modelWithJSON:notification.content]; + if (attachment.first == CustomMessageType_Monents && attachment.second == Custom_Message_Sub_Monents_Unread_Update) { + MonentsUnReadModel * unreadModel = [MonentsUnReadModel modelWithDictionary:attachment.data]; + if (unreadModel.total > 0) { + self.dotView.hidden = NO; + } else { + self.dotView.hidden = YES; + } + [self setTabBarItemBadge:unreadModel.total]; + } + } + } } - (void)setTabBarItemBadge:(NSInteger)value { - if (value > 0) { - if (value > 99) { - [self.tabBarItem setBadgeValue:@"99+"]; - } else { - [self.tabBarItem setBadgeValue:[NSString stringWithFormat:@"%ld", value]]; - } - } else { - [self.tabBarItem setBadgeValue:nil]; - } + if (value > 0) { + if (value > 99) { + [self.tabBarItem setBadgeValue:@"99+"]; + } else { + [self.tabBarItem setBadgeValue:[NSString stringWithFormat:@"%ld", value]]; + } + } else { + [self.tabBarItem setBadgeValue:nil]; + } } #pragma mark - Event Response - (void)messageButtonAction:(UIButton *)sender { - XPMonentsInteractiveViewController * messageVC = [[XPMonentsInteractiveViewController alloc] init]; - [self.navigationController pushViewController:messageVC animated:YES]; + XPMonentsInteractiveViewController * messageVC = [[XPMonentsInteractiveViewController alloc] init]; + [self.navigationController pushViewController:messageVC animated:YES]; } - (void)publishButtonAction:(UIButton *)sender { - XPMonentsPublishViewController * publishVC = [[XPMonentsPublishViewController alloc] init]; - [self.navigationController pushViewController:publishVC animated:YES]; + XPMonentsPublishViewController * publishVC = [[XPMonentsPublishViewController alloc] init]; + [self.navigationController pushViewController:publishVC animated:YES]; } #pragma mark - Getters And Setters - (JXCategoryListContainerView *)listContainerView { - if (!_listContainerView) { - _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self]; - _listContainerView.listCellBackgroundColor = [UIColor clearColor]; - } - return _listContainerView; + if (!_listContainerView) { + _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self]; + _listContainerView.listCellBackgroundColor = [UIColor clearColor]; + } + return _listContainerView; } - (JXCategoryTitleView *)titleView { - if (!_titleView) { - _titleView = [[JXCategoryTitleView alloc] initWithFrame:CGRectZero]; - _titleView.backgroundColor =[UIColor clearColor]; - _titleView.delegate = self; - _titleView.titleColor = [DJDKMIMOMColor secondTextColor]; - _titleView.titleSelectedColor = [DJDKMIMOMColor mainTextColor]; - _titleView.titleFont = [UIFont systemFontOfSize:15 weight:UIFontWeightSemibold]; - _titleView.titleSelectedFont = [UIFont systemFontOfSize:20 weight:UIFontWeightHeavy]; - _titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter; - _titleView.contentScrollViewClickTransitionAnimationEnabled = NO; - _titleView.averageCellSpacingEnabled = NO; - _titleView.defaultSelectedIndex = 0; - _titleView.cellSpacing = 20; - _titleView.titles = self.titles; - _titleView.listContainer = self.listContainerView; - _titleView.defaultSelectedIndex = 1; - CGFloat itemWidth = [YMLocalizedString(@"XPMonentsViewController0") boundingRectWithSize:CGSizeMake(100, CGFLOAT_MAX) options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20 weight:UIFontWeightHeavy]} context:nil].size.width; - _titleView.cellWidth = itemWidth; - _titleView.contentEdgeInsetLeft = (KScreenWidth - itemWidth * self.titles.count - 20 * (self.titles.count - 1))/ 2; - } - return _titleView; + if (!_titleView) { + _titleView = [[JXCategoryTitleView alloc] initWithFrame:CGRectZero]; + _titleView.backgroundColor =[UIColor clearColor]; + _titleView.delegate = self; + _titleView.titleColor = [DJDKMIMOMColor secondTextColor]; + _titleView.titleSelectedColor = [DJDKMIMOMColor mainTextColor]; + _titleView.titleFont = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold]; + _titleView.titleSelectedFont = [UIFont systemFontOfSize:22 weight:UIFontWeightHeavy]; + _titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter; + _titleView.contentScrollViewClickTransitionAnimationEnabled = NO; + _titleView.averageCellSpacingEnabled = NO; + _titleView.defaultSelectedIndex = 0; + _titleView.cellSpacing = 26; + _titleView.titles = self.titles; + _titleView.listContainer = self.listContainerView; + _titleView.defaultSelectedIndex = 1; + _titleView.contentEdgeInsetLeft = 15; + + JXCategoryIndicatorImageView *lineView = [[JXCategoryIndicatorImageView alloc] init]; + lineView.indicatorImageViewSize = CGSizeMake(45, 10); + lineView.verticalMargin = 7; + lineView.indicatorImageView.image = [UIImage imageNamed:@"mine_dynamic"]; + _titleView.indicators = @[lineView]; + + } + return _titleView; } - (UIView *)navView { - if (!_navView) { - _navView = [[UIView alloc] init]; - _navView.backgroundColor = [DJDKMIMOMColor appCellBackgroundColor]; - } - return _navView; + if (!_navView) { + _navView = [[UIView alloc] init]; + _navView.backgroundColor = [DJDKMIMOMColor appCellBackgroundColor]; + } + return _navView; } - (NSArray *)titles { - if (!_titles) { - _titles = @[YMLocalizedString(@"XPMonentsViewController1"),YMLocalizedString(@"XPMonentsViewController2"), YMLocalizedString(@"XPMonentsViewController3")]; - } - return _titles; + if (!_titles) { + _titles = @[YMLocalizedString(@"XPMonentsViewController1"),YMLocalizedString(@"XPMonentsViewController2"), YMLocalizedString(@"XPMonentsViewController3")]; + } + return _titles; } - (UIButton *)messageButton { - if (!_messageButton) { - _messageButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_messageButton setImage:[UIImage imageNamed:@"monents_nav_interavtive_message"] forState:UIControlStateNormal]; - [_messageButton setImage:[UIImage imageNamed:@"monents_nav_interavtive_message"] forState:UIControlStateSelected]; - [_messageButton addTarget:self action:@selector(messageButtonAction:) forControlEvents:UIControlEventTouchUpInside]; - } - return _messageButton; + if (!_messageButton) { + _messageButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_messageButton setImage:[UIImage imageNamed:@"monents_nav_interavtive_message"] forState:UIControlStateNormal]; + [_messageButton setImage:[UIImage imageNamed:@"monents_nav_interavtive_message"] forState:UIControlStateSelected]; + [_messageButton addTarget:self action:@selector(messageButtonAction:) forControlEvents:UIControlEventTouchUpInside]; + } + return _messageButton; } - (UIView *)dotView { - if (!_dotView) { - _dotView = [[UIView alloc] init]; - _dotView.backgroundColor = UIColorFromRGB(0xFF2D55); - _dotView.layer.masksToBounds = YES; - _dotView.layer.cornerRadius = 5; - _dotView.hidden = YES; - } - return _dotView; + if (!_dotView) { + _dotView = [[UIView alloc] init]; + _dotView.backgroundColor = UIColorFromRGB(0xFF2D55); + _dotView.layer.masksToBounds = YES; + _dotView.layer.cornerRadius = 5; + _dotView.hidden = YES; + } + return _dotView; } - (UIButton *)publishButton { - if (!_publishButton) { - _publishButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_publishButton setImage:[UIImage imageNamed:@"monents_publish"] forState:UIControlStateNormal]; - [_publishButton setImage:[UIImage imageNamed:@"monents_publish"] forState:UIControlStateSelected]; - [_publishButton addTarget:self action:@selector(publishButtonAction:) forControlEvents:UIControlEventTouchUpInside]; - } - return _publishButton; + if (!_publishButton) { + _publishButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_publishButton setImage:[UIImage imageNamed:@"monents_publish"] forState:UIControlStateNormal]; + [_publishButton setImage:[UIImage imageNamed:@"monents_publish"] forState:UIControlStateSelected]; + [_publishButton addTarget:self action:@selector(publishButtonAction:) forControlEvents:UIControlEventTouchUpInside]; + } + return _publishButton; } - (XPMonentsAttentionViewController *)attentionVC { - if (!_attentionVC) { - XPMonentsAttentionViewController * attentionVC = [[XPMonentsAttentionViewController alloc] init]; - _attentionVC = attentionVC; - } - return _attentionVC; + if (!_attentionVC) { + XPMonentsAttentionViewController * attentionVC = [[XPMonentsAttentionViewController alloc] init]; + _attentionVC = attentionVC; + } + return _attentionVC; } - (XPMonentsLatestViewController *)latestVC { - if (!_latestVC) { - _latestVC = [[XPMonentsLatestViewController alloc] init]; - } - return _latestVC; + if (!_latestVC) { + _latestVC = [[XPMonentsLatestViewController alloc] init]; + } + return _latestVC; } - (XPMonentsRecommendViewController *)recommendVC { - if (!_recommendVC) { - _recommendVC = [[XPMonentsRecommendViewController alloc] init]; - } - return _recommendVC; + if (!_recommendVC) { + _recommendVC = [[XPMonentsRecommendViewController alloc] init]; + } + return _recommendVC; } + @end diff --git a/YuMi/Structure/PrefixHeader.pch b/YuMi/Structure/PrefixHeader.pch index b92d0d08..79413a1d 100644 --- a/YuMi/Structure/PrefixHeader.pch +++ b/YuMi/Structure/PrefixHeader.pch @@ -40,4 +40,5 @@ #import #import "StatisticsServiceHelper.h" #import "YUMIConstant.h" +#import "YUMINNNN.h" #endif /* PrefixHeader_pch */ diff --git a/YuMi/zh-Hans.lproj/Localizable.strings b/YuMi/zh-Hans.lproj/Localizable.strings index 0d8ed0bf..4f244da0 100644 --- a/YuMi/zh-Hans.lproj/Localizable.strings +++ b/YuMi/zh-Hans.lproj/Localizable.strings @@ -89,11 +89,12 @@ "PLTimeUtil3" = "yyyy年MM月"; "PLTimeUtil4" = "MM月dd日"; -"NSString_Utils0" = "%@万"; -"NSString_Utils1" = "MM月dd日"; -"NSString_Utils2" = "YYYY年MM月dd日"; -"NSString_Utils3" = "刚刚"; -"NSString_Utils4" = "%ld分钟前"; +///NSString+Utils.m +"NSString_Utils0" = "MM月dd日"; +"NSString_Utils1" = "YYYY年MM月dd日"; +"NSString_Utils2" = "刚刚"; +"NSString_Utils3" = "%ld分钟前"; +"NSString_Utils4" = "%@万"; "QEmotionBoardView0" = "发送"; @@ -2007,8 +2008,10 @@ "XPMonentsAttentionViewController1" = "删除后不可恢复\n确定删除该动态吗"; "XPMonentsAttentionViewController2" = "删除成功"; -"XPMonentsMineViewController0" = "删除后不可恢复\n确定删除该动态吗"; +///XPMonentsMineViewController.m +"XPMonentsMineViewController0" = "删除后不可恢复\n确定删除该动态吗?"; "XPMonentsMineViewController1" = "删除成功"; +"XPMonentsMineViewController2" = "屏蔽成功"; "XPMonentsViewController0" = "推荐"; "XPMonentsViewController1" = "关注"; @@ -2017,25 +2020,31 @@ "XPMonentsRecommendHeaderView0" = "推荐话题"; -"XPMonentsContentView0" = "展开"; -"XPMonentsContentView1" = "收起"; +///XPMonentsContentView.m +"XPMonentsContentView0" = "置顶 "; +"XPMonentsContentView1" = "展开"; +"XPMonentsContentView2" = "收起"; "XPMoentsTopicListView0" = "没有更多数据了"; "XPMonentsPublishTopicView0" = "添加话题"; "XPMonentsPublishTopicView1" = "重新选择"; -"XPMonentsUserInfoView0" = "直播中"; +///XPMonentsUserInfoView.m +"XPMonentsUserInfoView0" = "删除"; +"XPMonentsUserInfoView1" = "举报"; +"XPMonentsUserInfoView2" = "直播中"; +///XPMonentsTooBarView.m "XPMonentsTooBarView0" = "删除"; -"XPMonentsTooBarView1" = "举报"; -"XPMonentsTooBarView2" = "您的请求我们已经收到,我们将儘快处理"; -"XPMonentsTooBarView3" = "好友"; -"XPMonentsTooBarView4" = "朋友圈"; -"XPMonentsTooBarView5" = "微信好友"; -"XPMonentsTooBarView6" = "QQ好友"; -"XPMonentsTooBarView7" = "QQ空间"; -"XPMonentsTooBarView8" = "%@发佈了一条动态"; +"XPMonentsTooBarView1" = "举报动态或用户"; +"XPMonentsTooBarView2" = "好友"; +"XPMonentsTooBarView3" = "朋友圈"; +"XPMonentsTooBarView4" = "微信好友"; +"XPMonentsTooBarView5" = "QQ好友"; +"XPMonentsTooBarView6" = "QQ空间"; +"XPMonentsTooBarView7" = "%@发布了一条动态"; +"XPMonentsTooBarView8" = "屏蔽动态"; "XPMonentPublishSuccessView0" = "审核中"; "XPMonentPublishSuccessView1" = "咻,收到小可爱的动态了呢~\n审核通过后小秘书会帮你发送并通知你哦"; @@ -2212,7 +2221,7 @@ "LoginVerifCodeViewController4" = "重新获取"; "XPLoginViewController11" = "同意隐私政策和用户协议后,才可以注册登录哦~"; -"XPMonentsMineViewController2" = "删除后不可恢複\n确定删除该动态吗?"; + "PKLoginViewController1" = "同意隐私政策和用户协议后,才可以注册登录哦~"; diff --git a/YuMi/zh-Hant.lproj/Localizable.strings b/YuMi/zh-Hant.lproj/Localizable.strings index adf8de0d..38341f0e 100644 --- a/YuMi/zh-Hant.lproj/Localizable.strings +++ b/YuMi/zh-Hant.lproj/Localizable.strings @@ -89,11 +89,12 @@ "PLTimeUtil3" = "yyyy年MM月"; "PLTimeUtil4" = "MM月dd日"; -"NSString_Utils0" = "%@萬"; -"NSString_Utils1" = "MM月dd日"; -"NSString_Utils2" = "YYYY年MM月dd日"; -"NSString_Utils3" = "剛剛"; -"NSString_Utils4" = "%ld分鐘前"; +///NSString+Utils.m +"NSString_Utils0" = "MM月dd日"; +"NSString_Utils1" = "YYYY年MM月dd日"; +"NSString_Utils2" = "剛剛"; +"NSString_Utils3" = "%ld分鐘前"; +"NSString_Utils4" = "%@萬"; "QEmotionBoardView0" = "發送"; @@ -2014,8 +2015,10 @@ "XPMonentsAttentionViewController1" = "刪除後不可恢復\n確定刪除該動態嗎"; "XPMonentsAttentionViewController2" = "刪除成功"; -"XPMonentsMineViewController0" = "刪除後不可恢復\n確定刪除該動態嗎"; +///XPMonentsMineViewController.m +"XPMonentsMineViewController0" = "刪除後不可恢復\n確定刪除該動態嗎?"; "XPMonentsMineViewController1" = "刪除成功"; +"XPMonentsMineViewController2" = "屏蔽成功"; "XPMonentsViewController0" = "推薦"; "XPMonentsViewController1" = "關註"; @@ -2024,25 +2027,31 @@ "XPMonentsRecommendHeaderView0" = "推薦話題"; -"XPMonentsContentView0" = "展開"; -"XPMonentsContentView1" = "收起"; +///XPMonentsContentView.m +"XPMonentsContentView0" = "置頂 "; +"XPMonentsContentView1" = "展開"; +"XPMonentsContentView2" = "收起"; "XPMoentsTopicListView0" = "沒有更多數據了"; "XPMonentsPublishTopicView0" = "添加話題"; "XPMonentsPublishTopicView1" = "重新選擇"; -"XPMonentsUserInfoView0" = "直播中"; +///XPMonentsUserInfoView.m +"XPMonentsUserInfoView0" = "刪除"; +"XPMonentsUserInfoView1" = "舉報"; +"XPMonentsUserInfoView2" = "直播中"; +///XPMonentsTooBarView.m "XPMonentsTooBarView0" = "刪除"; -"XPMonentsTooBarView1" = "舉報"; -"XPMonentsTooBarView2" = "您的請求我們已經收到,我們將儘快處理"; -"XPMonentsTooBarView3" = "好友"; -"XPMonentsTooBarView4" = "朋友圈"; -"XPMonentsTooBarView5" = "微信好友"; -"XPMonentsTooBarView6" = "QQ好友"; -"XPMonentsTooBarView7" = "QQ空間"; -"XPMonentsTooBarView8" = "%@發佈了一條動態"; +"XPMonentsTooBarView1" = "舉報動態或用戶"; +"XPMonentsTooBarView2" = "好友"; +"XPMonentsTooBarView3" = "朋友圈"; +"XPMonentsTooBarView4" = "微信好友"; +"XPMonentsTooBarView5" = "QQ好友"; +"XPMonentsTooBarView6" = "QQ空間"; +"XPMonentsTooBarView7" = "%@發佈了一條動態"; +"XPMonentsTooBarView8" = "屏蔽動態"; "XPMonentPublishSuccessView0" = "審核中"; "XPMonentPublishSuccessView1" = "咻,收到小可愛的動態了呢~\n審核通過後小秘書會幫你發送並通知你哦"; @@ -2218,7 +2227,7 @@ "LoginVerifCodeViewController4" = "重新獲取"; "XPLoginViewController11" = "同意隱私政策和用戶協議後,才可以註冊登錄哦~"; -"XPMonentsMineViewController2" = "刪除後不可恢複\n確定刪除該動態嗎?"; + "PKLoginViewController1" = "同意隱私政策和用戶協議後,才可以註冊登錄哦~";