diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 88129f50..2ba82266 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -573,6 +573,9 @@ E8788948273A55D000BF1D57 /* XPGiftBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8788947273A55D000BF1D57 /* XPGiftBarView.m */; }; E878894C273A607C00BF1D57 /* XPGiftUserCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E878894B273A607C00BF1D57 /* XPGiftUserCollectionViewCell.m */; }; E8788950273A699900BF1D57 /* ThemeColor+SendGift.m in Sources */ = {isa = PBXBuildFile; fileRef = E878894F273A699900BF1D57 /* ThemeColor+SendGift.m */; }; + E878B8582835F0D300E22DCF /* MonentsInteractiveModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E878B8572835F0D300E22DCF /* MonentsInteractiveModel.m */; }; + E878B85B2835F3BF00E22DCF /* XPMonentsInteractiveTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E878B85A2835F3BF00E22DCF /* XPMonentsInteractiveTableViewCell.m */; }; + E878B85E283640A500E22DCF /* MonentsUnReadModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E878B85D283640A500E22DCF /* MonentsUnReadModel.m */; }; E87A24F1272935920086A794 /* XPMessageRemoteExtModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E87A24F0272935920086A794 /* XPMessageRemoteExtModel.m */; }; E87A26F627587C48002DDC7A /* XPHomePartyContainerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E87A26F527587C48002DDC7A /* XPHomePartyContainerViewController.m */; }; E87A26F927587C62002DDC7A /* XPHomeContainerPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = E87A26F827587C62002DDC7A /* XPHomeContainerPresenter.m */; }; @@ -2107,6 +2110,12 @@ E878894D273A672200BF1D57 /* XPGiftProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPGiftProtocol.h; sourceTree = ""; }; E878894E273A699900BF1D57 /* ThemeColor+SendGift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ThemeColor+SendGift.h"; sourceTree = ""; }; E878894F273A699900BF1D57 /* ThemeColor+SendGift.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "ThemeColor+SendGift.m"; sourceTree = ""; }; + E878B8562835F0D300E22DCF /* MonentsInteractiveModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MonentsInteractiveModel.h; sourceTree = ""; }; + E878B8572835F0D300E22DCF /* MonentsInteractiveModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MonentsInteractiveModel.m; sourceTree = ""; }; + E878B8592835F3BF00E22DCF /* XPMonentsInteractiveTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMonentsInteractiveTableViewCell.h; sourceTree = ""; }; + E878B85A2835F3BF00E22DCF /* XPMonentsInteractiveTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMonentsInteractiveTableViewCell.m; sourceTree = ""; }; + E878B85C283640A500E22DCF /* MonentsUnReadModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MonentsUnReadModel.h; sourceTree = ""; }; + E878B85D283640A500E22DCF /* MonentsUnReadModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MonentsUnReadModel.m; sourceTree = ""; }; E87A24EF272935920086A794 /* XPMessageRemoteExtModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMessageRemoteExtModel.h; sourceTree = ""; }; E87A24F0272935920086A794 /* XPMessageRemoteExtModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMessageRemoteExtModel.m; sourceTree = ""; }; E87A26F427587C48002DDC7A /* XPHomePartyContainerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPHomePartyContainerViewController.h; sourceTree = ""; }; @@ -4934,6 +4943,10 @@ E81A653B2834E9AE00F55894 /* MonentsListInfoModel.m */, E81A6544283519CA00F55894 /* MonentsTopicModel.h */, E81A6545283519CA00F55894 /* MonentsTopicModel.m */, + E878B8562835F0D300E22DCF /* MonentsInteractiveModel.h */, + E878B8572835F0D300E22DCF /* MonentsInteractiveModel.m */, + E878B85C283640A500E22DCF /* MonentsUnReadModel.h */, + E878B85D283640A500E22DCF /* MonentsUnReadModel.m */, ); path = Model; sourceTree = ""; @@ -7048,6 +7061,8 @@ E8098CAD282E07C00090B9F0 /* XPMonentsEmptyTableViewCell.m */, E81A654A28351D9900F55894 /* XPMonentsTopicCollectionViewCell.h */, E81A654B28351D9900F55894 /* XPMonentsTopicCollectionViewCell.m */, + E878B8592835F3BF00E22DCF /* XPMonentsInteractiveTableViewCell.h */, + E878B85A2835F3BF00E22DCF /* XPMonentsInteractiveTableViewCell.m */, ); path = Cell; sourceTree = ""; @@ -8204,6 +8219,7 @@ E81D58822720082A003063FE /* MicroWaveView.m in Sources */, E8A73F8728586A6F00FD9CBC /* XPGiftWeekStarCollectionViewCell.m in Sources */, E8B825C226EA00DF009E8E9F /* LoginVerifCodePresent.m in Sources */, + E878B85B2835F3BF00E22DCF /* XPMonentsInteractiveTableViewCell.m in Sources */, 9B9EEF4E27C8755C006B0EB3 /* XPSkillCardResourcePropModel.m in Sources */, E88B5CB026FB1C6500DA9178 /* XPMineTeenagerPresenter.m in Sources */, E800163B28041F7B00D6D17A /* XPGuildSingleRoomIncomeTableViewCell.m in Sources */, @@ -8480,6 +8496,7 @@ E8C1CD7027D894B800376F83 /* RoomFaceTitleItemModel.m in Sources */, 189DD73D26E21C3F00AB55B1 /* YYUtility+Device.m in Sources */, 187EEEDC26E89B32002833B2 /* BaseModel.m in Sources */, + E878B85E283640A500E22DCF /* MonentsUnReadModel.m in Sources */, E81366FC26F0D2980076364C /* UIButton+EnlargeTouchArea.m in Sources */, E824546426F5FF1C00BE8163 /* XPMineResetPayPasswordPresenter.m in Sources */, E877A7EE278428FB00EFACED /* MicroDatingProgressView.m in Sources */, @@ -8527,6 +8544,7 @@ 189DD74526E21CCC00AB55B1 /* YYReachability.m in Sources */, E82109AD26F1C8A000FC3319 /* CountDownHelper.m in Sources */, E8A6C28C27CF436300AC7442 /* XPHomeLikeViewController.m in Sources */, + E878B8582835F0D300E22DCF /* MonentsInteractiveModel.m in Sources */, 9BCF586227995426008401A4 /* XPSkillCardSelectPropCell.m in Sources */, 9BD2ECCE288F829600F5CD9A /* XPMineFootPrintViewController.m in Sources */, E86A16BF2856D4D5004228B8 /* XPSessionFindNewGreetListView.m in Sources */, diff --git a/xplan-ios/Assets.xcassets/Monents/monents_interactive_delete_message.imageset/Contents.json b/xplan-ios/Assets.xcassets/Monents/monents_interactive_delete_message.imageset/Contents.json new file mode 100644 index 00000000..d2bfc256 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Monents/monents_interactive_delete_message.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "monents_interactive_delete_message@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "monents_interactive_delete_message@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Monents/monents_interactive_delete_message.imageset/monents_interactive_delete_message@2x.png b/xplan-ios/Assets.xcassets/Monents/monents_interactive_delete_message.imageset/monents_interactive_delete_message@2x.png new file mode 100644 index 00000000..6dbc4069 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Monents/monents_interactive_delete_message.imageset/monents_interactive_delete_message@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Monents/monents_interactive_delete_message.imageset/monents_interactive_delete_message@3x.png b/xplan-ios/Assets.xcassets/Monents/monents_interactive_delete_message.imageset/monents_interactive_delete_message@3x.png new file mode 100644 index 00000000..22d046bf Binary files /dev/null and b/xplan-ios/Assets.xcassets/Monents/monents_interactive_delete_message.imageset/monents_interactive_delete_message@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/Contents.json b/xplan-ios/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/Contents.json new file mode 100644 index 00000000..51def40b --- /dev/null +++ b/xplan-ios/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "monents_nav_interavtive_message@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "monents_nav_interavtive_message@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/monents_nav_interavtive_message@2x.png b/xplan-ios/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/monents_nav_interavtive_message@2x.png new file mode 100644 index 00000000..c35b7521 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/monents_nav_interavtive_message@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/monents_nav_interavtive_message@3x.png b/xplan-ios/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/monents_nav_interavtive_message@3x.png new file mode 100644 index 00000000..61dfc062 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Monents/monents_nav_interavtive_message.imageset/monents_nav_interavtive_message@3x.png differ diff --git a/xplan-ios/Main/IM/Model/AttachmentModel.h b/xplan-ios/Main/IM/Model/AttachmentModel.h index 41535e87..73fd8d05 100644 --- a/xplan-ios/Main/IM/Model/AttachmentModel.h +++ b/xplan-ios/Main/IM/Model/AttachmentModel.h @@ -50,6 +50,8 @@ typedef NS_ENUM(NSUInteger, CustomMessageType) { CustomMessageType_Room_GiftValue = 42, ///公会超管 CustomMessageType_Hall_Super_Admin = 50, + ///动态 + CustomMessageType_Monents = 52, ///收藏房间 CustomMessageType_Collection_Room = 59, ///福袋消息 @@ -292,6 +294,18 @@ typedef NS_ENUM(NSInteger, CustomMessageSubHallSuperAdmin) { Custom_Message_Sub_Hall_Super_Admin_Kick_Manager_Out_Room = 508, }; +/// first == CustomMessageType_Monents +typedef NS_ENUM(NSUInteger, Custom_Noti_Sub_Dynamic) { + ///未读更新 + Custom_Message_Sub_Monents_Unread_Update = 521, + /// 违禁删除 + Custom_Message_Sub_Monents_Ban_Delete = 522, + /// 动态审核通过 + Custom_Message_Sub_Monents_Approved = 523, + /// app内分享动态 + Custom_Message_Sub_Monents_Share = 524, +}; + ///first = CustomMessageType_Collection_Room typedef NS_ENUM(NSUInteger, CustomMessageSubCollectRoom) { /// 福袋礼物房间飘屏通知 diff --git a/xplan-ios/Main/Monents/Api/Api+Monents.h b/xplan-ios/Main/Monents/Api/Api+Monents.h index 290822b1..d9eee6d0 100644 --- a/xplan-ios/Main/Monents/Api/Api+Monents.h +++ b/xplan-ios/Main/Monents/Api/Api+Monents.h @@ -38,6 +38,11 @@ NS_ASSUME_NONNULL_BEGIN /// @param uid 类型 uid + (void)monentsInteractiveList:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId pageSize:(NSString *)pageSize uid:(NSString *)uid; +/// 清空互动消息 +/// @param complection 完成 +/// @param uid 用户的uid ++ (void)monentsInteractiveClear:(HttpRequestHelperCompletion)complection uid:(NSString *)uid; + /// 获取话题列表 /// @param completion 完成 /// @param uid uid diff --git a/xplan-ios/Main/Monents/Api/Api+Monents.m b/xplan-ios/Main/Monents/Api/Api+Monents.m index aafb0102..d0e06d86 100644 --- a/xplan-ios/Main/Monents/Api/Api+Monents.m +++ b/xplan-ios/Main/Monents/Api/Api+Monents.m @@ -49,6 +49,13 @@ [HttpRequestHelper request:@"interactive/list" method:HttpRequestHelperMethodPOST params:dic completion:completion]; } +/// 清空互动消息 +/// @param complection 完成 +/// @param uid 用户的uid ++ (void)monentsInteractiveClear:(HttpRequestHelperCompletion)complection uid:(NSString *)uid { + [self makeRequest:@"interactive/clear" method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__, uid, nil]; +} + /// 获取话题列表 /// @param completion 完成 /// @param uid uid diff --git a/xplan-ios/Main/Monents/Model/MonentsInteractiveModel.h b/xplan-ios/Main/Monents/Model/MonentsInteractiveModel.h new file mode 100644 index 00000000..7edd38b3 --- /dev/null +++ b/xplan-ios/Main/Monents/Model/MonentsInteractiveModel.h @@ -0,0 +1,65 @@ +// +// MonentsInteractiveModel.h +// xplan-ios +// +// Created by 冯硕 on 2022/5/19. +// + +#import +#import "MonentsInfoModel.h" +#import "XPEnum.h" +NS_ASSUME_NONNULL_BEGIN + +typedef NS_ENUM(NSInteger, MonentsInteractiveActionType) { + ///评论 + MonentsInteractiveActionType_Comment = 1, + ///回复 + MonentsInteractiveActionType_Reply, + ///点赞 + MonentsInteractiveActionType_Like, + ///分享 + MonentsInteractiveActionType_Share +}; + +@interface MonentsInteractiveModel : NSObject +///msgType为2时为评论id +@property (nonatomic,assign) NSInteger targetId; +///类型 0:纯文本,2图片, +@property (nonatomic,assign) MonentsContentType type; +///动态内容 +@property (nonatomic,copy) NSString *content; +///性别 +@property (nonatomic,assign) GenderType gender; +///年龄 +@property (nonatomic,assign) NSInteger age; +///动态id +@property (nonatomic,copy) NSString *dynamicId; +///消息id +@property (nonatomic,copy) NSString *msgId; +///用户的uid +@property (nonatomic,assign) NSInteger uid; +///动作类型,1-评论,2-回复,3-点赞,4-分享 +@property (nonatomic,assign) MonentsInteractiveActionType actionType; +///消息,如"赞了你的动态" +@property (nonatomic,copy) NSString *message; +///类型,1-动态,2-评论(回复也算评论) +@property (nonatomic,assign) NSInteger msgType; +///昵称 +@property (nonatomic,copy) NSString *nick; +///头像 +@property (nonatomic,copy) NSString *avatar; +///目标对象uid +@property (nonatomic,copy) NSString *targetUid; +///发布时间 +@property (nonatomic,copy) NSString *publishTime; +///动态发布者uid +@property (nonatomic,copy) NSString *dynamicUid; +///话题id +@property (nonatomic,copy) NSString *worldId; +///话题的名称 +@property (nonatomic,copy) NSString *worldName; +///动态的图片 +@property (nonatomic,strong) MonentsPicInfoModel *dynamicRes; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Monents/Model/MonentsInteractiveModel.m b/xplan-ios/Main/Monents/Model/MonentsInteractiveModel.m new file mode 100644 index 00000000..286b3759 --- /dev/null +++ b/xplan-ios/Main/Monents/Model/MonentsInteractiveModel.m @@ -0,0 +1,12 @@ +// +// MonentsInteractiveModel.m +// xplan-ios +// +// Created by 冯硕 on 2022/5/19. +// + +#import "MonentsInteractiveModel.h" + +@implementation MonentsInteractiveModel + +@end diff --git a/xplan-ios/Main/Monents/Model/MonentsUnReadModel.h b/xplan-ios/Main/Monents/Model/MonentsUnReadModel.h new file mode 100644 index 00000000..c7a04412 --- /dev/null +++ b/xplan-ios/Main/Monents/Model/MonentsUnReadModel.h @@ -0,0 +1,25 @@ +// +// MonentsUnReadModel.h +// xplan-ios +// +// Created by 冯硕 on 2022/5/19. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface MonentsUnReadModel : NSObject +/// 总计未读消息数 +@property (nonatomic, assign) NSInteger total; +/// 评论未读消息数 +@property (nonatomic, assign) NSInteger comment; +/// 分享未读消息数 +@property (nonatomic, assign) NSInteger share; +/// 回复未读消息数 +@property (nonatomic, assign) NSInteger reply; +/// 点赞未读消息数 +@property (nonatomic, assign) NSInteger like; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Monents/Model/MonentsUnReadModel.m b/xplan-ios/Main/Monents/Model/MonentsUnReadModel.m new file mode 100644 index 00000000..666c2f73 --- /dev/null +++ b/xplan-ios/Main/Monents/Model/MonentsUnReadModel.m @@ -0,0 +1,12 @@ +// +// MonentsUnReadModel.m +// xplan-ios +// +// Created by 冯硕 on 2022/5/19. +// + +#import "MonentsUnReadModel.h" + +@implementation MonentsUnReadModel + +@end diff --git a/xplan-ios/Main/Monents/Presenter/XPMonentsInteractivePresenter.h b/xplan-ios/Main/Monents/Presenter/XPMonentsInteractivePresenter.h index 7401e76a..328b942b 100644 --- a/xplan-ios/Main/Monents/Presenter/XPMonentsInteractivePresenter.h +++ b/xplan-ios/Main/Monents/Presenter/XPMonentsInteractivePresenter.h @@ -16,6 +16,9 @@ NS_ASSUME_NONNULL_BEGIN /// @param pageSize 一页的个数 /// @param state 状态 - (void)getMonentsInteractiveList:(NSString *)dynamicId pageSize:(int)pageSize state:(int)state; + +///清空互动消息 +- (void)clearInteractiveMessage; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Monents/Presenter/XPMonentsInteractivePresenter.m b/xplan-ios/Main/Monents/Presenter/XPMonentsInteractivePresenter.m index b1a0d45b..13e71d6d 100644 --- a/xplan-ios/Main/Monents/Presenter/XPMonentsInteractivePresenter.m +++ b/xplan-ios/Main/Monents/Presenter/XPMonentsInteractivePresenter.m @@ -9,6 +9,7 @@ #import "Api+Monents.h" #import "XPMonentsInteractiveProtocol.h" #import "AccountInfoStorage.h" +#import "MonentsInteractiveModel.h" @implementation XPMonentsInteractivePresenter @@ -21,11 +22,19 @@ NSString * pageSizeStr = [NSString stringWithFormat:@"%d", pageSize]; NSString * uid = [AccountInfoStorage instance].getUid; [Api monentsInteractiveList:[self createHttpCompletion:^(BaseModel * _Nonnull data) { - NSArray * array; + NSArray * array = [MonentsInteractiveModel modelsWithArray:data.data]; [[self getView] getMonentsInteractiveListSueccess:array state:state]; } fail:^(NSInteger code, NSString * _Nullable msg) { [[self getView] getMonentsInteractiveListFail:msg state:state]; }] dynamicId:dynamicId pageSize:pageSizeStr uid:uid]; } +///清空互动消息 +- (void)clearInteractiveMessage { + NSString * uid = [AccountInfoStorage instance].getUid; + [Api monentsInteractiveClear:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] clearInteractiveMessageSuccess]; + } showLoading:YES] uid:uid]; +} + @end diff --git a/xplan-ios/Main/Monents/Protocol/XPMonentsInteractiveProtocol.h b/xplan-ios/Main/Monents/Protocol/XPMonentsInteractiveProtocol.h index 93c43614..030a008a 100644 --- a/xplan-ios/Main/Monents/Protocol/XPMonentsInteractiveProtocol.h +++ b/xplan-ios/Main/Monents/Protocol/XPMonentsInteractiveProtocol.h @@ -13,6 +13,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)getMonentsInteractiveListSueccess:(NSArray *)array state:(int)state; - (void)getMonentsInteractiveListFail:(NSString *)msg state:(int)state; +///清空互动消息 +- (void)clearInteractiveMessageSuccess; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Monents/View/Cell/XPMonentsInteractiveTableViewCell.h b/xplan-ios/Main/Monents/View/Cell/XPMonentsInteractiveTableViewCell.h new file mode 100644 index 00000000..6f7651ed --- /dev/null +++ b/xplan-ios/Main/Monents/View/Cell/XPMonentsInteractiveTableViewCell.h @@ -0,0 +1,16 @@ +// +// XPMonentsInteractiveTableViewCell.h +// xplan-ios +// +// Created by 冯硕 on 2022/5/19. +// + +#import + +NS_ASSUME_NONNULL_BEGIN +@class MonentsInteractiveModel; +@interface XPMonentsInteractiveTableViewCell : UITableViewCell +@property (nonatomic,strong) MonentsInteractiveModel *interactiveInfo; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Monents/View/Cell/XPMonentsInteractiveTableViewCell.m b/xplan-ios/Main/Monents/View/Cell/XPMonentsInteractiveTableViewCell.m new file mode 100644 index 00000000..eb955637 --- /dev/null +++ b/xplan-ios/Main/Monents/View/Cell/XPMonentsInteractiveTableViewCell.m @@ -0,0 +1,308 @@ +// +// XPMonentsInteractiveTableViewCell.m +// xplan-ios +// +// Created by 冯硕 on 2022/5/19. +// + +#import "XPMonentsInteractiveTableViewCell.h" +///Third +#import +///Tool +#import "ThemeColor.h" +#import "NetImageView.h" +#import "XPMacro.h" +#import "UIImage+Utils.h" +///Model +#import "MonentsInteractiveModel.h" + +@interface XPMonentsInteractiveTableViewCell () +///容器 +@property (nonatomic,strong) UIStackView *stackView; +///显示话题 +@property (nonatomic,strong) UIButton *topicButton; +///显示内容 +@property (nonatomic,strong) UIView * infoView; +///显示头像 +@property (nonatomic,strong) NetImageView *avatarImageView; +///昵称 +@property (nonatomic,strong) UILabel *nickLabel; +///性别 +@property (nonatomic,strong) UIImageView *sexImageView; +///评论了你 +@property (nonatomic,strong) UILabel *commentLabel; +///赞了动态或者显示评论的内容 +@property (nonatomic,strong) UILabel *contentLabel; +///时间 +@property (nonatomic,strong) UILabel *timeLabel; +///动态的图片 +@property (nonatomic,strong) NetImageView *dynamicImageView; +///动态的内容 +@property (nonatomic,strong) UILabel *dynamicLabel; +///显示分割线 +@property (nonatomic,strong) UIView * lineView; +///时间格式 +@property (nonatomic,strong) NSDateFormatter *dataFormatter; +@end +@implementation XPMonentsInteractiveTableViewCell + +- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { + if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; +} + +#pragma mark - Private Method +- (void)initSubViews { + self.backgroundColor = [ThemeColor appCellBackgroundColor]; + self.selectionStyle = UITableViewCellSelectionStyleNone; + [self.contentView addSubview:self.stackView]; + + [self.stackView addArrangedSubview:self.topicButton]; + [self.stackView addArrangedSubview:self.infoView]; + + + [self.infoView addSubview:self.avatarImageView]; + [self.infoView addSubview:self.nickLabel]; + [self.infoView addSubview:self.sexImageView]; + [self.infoView addSubview:self.commentLabel]; + [self.infoView addSubview:self.contentLabel]; + [self.infoView addSubview:self.timeLabel]; + [self.infoView addSubview:self.dynamicImageView]; + [self.infoView addSubview:self.dynamicLabel]; + [self.infoView addSubview:self.lineView]; +} + +- (void)initSubViewConstraints { + [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.contentView).inset(15); + make.top.mas_equalTo(self.contentView).offset(10); + make.bottom.mas_equalTo(self.contentView); + }]; + + [self.topicButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(30); + make.width.mas_equalTo(50); + }]; + + [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(KScreenWidth- 15 * 2); + }]; + + [self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(44, 44)); + make.left.top.mas_equalTo(self.infoView); + }]; + + [self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.avatarImageView.mas_right).offset(10); + make.top.mas_equalTo(self.avatarImageView); + }]; + + [self.sexImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(15, 15)); + make.centerY.mas_equalTo(self.nickLabel); + make.left.mas_equalTo(self.nickLabel.mas_right).offset(2); + }]; + + [self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerY.mas_equalTo(self.nickLabel); + make.left.mas_equalTo(self.sexImageView.mas_right).offset(2); + }]; + + [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.nickLabel.mas_bottom).offset(10); + make.left.mas_equalTo(self.nickLabel); + make.right.mas_lessThanOrEqualTo(self.dynamicImageView.mas_left).offset(-5); + }]; + + [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.nickLabel); + make.top.mas_equalTo(self.contentLabel.mas_bottom).offset(10); + }]; + + + [self.dynamicImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(60, 60)); + make.right.mas_equalTo(self.infoView); + make.centerY.mas_equalTo(self.infoView); + }]; + + [self.dynamicLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerY.right.mas_equalTo(self.dynamicImageView); + }]; + + [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.nickLabel); + make.right.mas_equalTo(self.infoView); + make.height.mas_equalTo(1); + make.bottom.mas_equalTo(self.infoView); + }]; +} +#pragma mark - Getters And Setters +- (void)setInteractiveInfo:(MonentsInteractiveModel *)interactiveInfo { + _interactiveInfo = interactiveInfo; + if (_interactiveInfo) { + self.topicButton.hidden = _interactiveInfo.worldName.length <=0; + [self.topicButton setTitle:_interactiveInfo.worldName forState:UIControlStateNormal]; + self.avatarImageView.imageUrl = _interactiveInfo.avatar; + NSString * nick = interactiveInfo.nick; + if (nick.length > 6) { + nick = [NSString stringWithFormat:@"%@…", [nick substringToIndex:6]]; + } + self.nickLabel.text = nick.length > 0 ? nick : @""; + self.sexImageView.image = _interactiveInfo.gender == GenderType_Female ? [UIImage imageNamed:@"common_female"] : [UIImage imageNamed:@"common_male"]; + BOOL isComment = _interactiveInfo.actionType == MonentsInteractiveActionType_Comment; + self.commentLabel.text = isComment ? @"评论了你" : @""; + BOOL isText = _interactiveInfo.type == MonentsContentType_Text; + self.dynamicImageView.hidden = isText; + self.dynamicLabel.hidden = !isText; + if (isText) { + self.dynamicLabel.text = _interactiveInfo.content; + } else { + self.dynamicImageView.imageUrl = _interactiveInfo.dynamicRes.resUrl; + } + self.contentLabel.text = _interactiveInfo.message; + + NSDate *date = [NSDate dateWithTimeIntervalSince1970:_interactiveInfo.publishTime.floatValue/1000]; + NSString *dateString = [self.dataFormatter stringFromDate:date]; + self.timeLabel.text = dateString; + + CGFloat width = [_interactiveInfo.worldName boundingRectWithSize:CGSizeMake(150,CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]} context:nil].size.width + 10; + [self.topicButton mas_updateConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(width); + }]; + } +} + +- (UIStackView *)stackView { + if (!_stackView) { + _stackView = [[UIStackView alloc] init]; + _stackView.axis = UILayoutConstraintAxisVertical; + _stackView.distribution = UIStackViewDistributionFill; + _stackView.alignment = UIStackViewAlignmentLeading; + _stackView.spacing = 10; + } + return _stackView; +} + +- (UIButton *)topicButton { + if (!_topicButton) { + _topicButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_topicButton setTitle:@"邀请" forState:UIControlStateNormal]; + [_topicButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + _topicButton.titleLabel.font = [UIFont systemFontOfSize:12]; + [_topicButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal]; + _topicButton.layer.masksToBounds = YES; + _topicButton.layer.cornerRadius = 15; + } + return _topicButton; +} + +- (UIView *)infoView { + if (!_infoView) { + _infoView = [[UIView alloc] init]; + _infoView.backgroundColor = [UIColor clearColor]; + } + return _infoView; +} + +- (NetImageView *)avatarImageView { + if (!_avatarImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.imageType = ImageTypeUserIcon; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _avatarImageView = [[NetImageView alloc] initWithConfig:config]; + _avatarImageView.layer.masksToBounds = YES; + _avatarImageView.layer.cornerRadius = 22; + } + return _avatarImageView; +} + +- (UILabel *)nickLabel { + if (!_nickLabel) { + _nickLabel = [[UILabel alloc] init]; + _nickLabel.font = [UIFont systemFontOfSize:15]; + _nickLabel.textColor = [ThemeColor textThirdColor]; + } + return _nickLabel; +} + +- (UIImageView *)sexImageView { + if (!_sexImageView) { + _sexImageView = [[UIImageView alloc] init]; + _sexImageView.userInteractionEnabled = YES; + } + return _sexImageView; +} + +- (UILabel *)commentLabel { + if (!_commentLabel) { + _commentLabel = [[UILabel alloc] init]; + _commentLabel.font = [UIFont systemFontOfSize:15]; + _commentLabel.textColor = [ThemeColor textThirdColor]; + } + return _commentLabel; +} + +- (UILabel *)contentLabel { + if (!_contentLabel) { + _contentLabel = [[UILabel alloc] init]; + _contentLabel.font = [UIFont systemFontOfSize:15]; + _contentLabel.textColor = [ThemeColor mainTextColor]; + } + return _contentLabel; +} + +- (UILabel *)timeLabel { + if (!_timeLabel) { + _timeLabel = [[UILabel alloc] init]; + _timeLabel.font = [UIFont systemFontOfSize:12]; + _timeLabel.textColor = [ThemeColor textThirdColor]; + } + return _timeLabel; +} + +- (NetImageView *)dynamicImageView { + if (!_dynamicImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.imageType = ImageTypeUserIcon; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _dynamicImageView = [[NetImageView alloc] initWithConfig:config]; + _dynamicImageView.layer.masksToBounds = YES; + _dynamicImageView.layer.cornerRadius = 8; + _dynamicImageView.contentMode = UIViewContentModeScaleAspectFill; + } + return _dynamicImageView; +} + +- (UILabel *)dynamicLabel { + if (!_dynamicLabel) { + _dynamicLabel = [[UILabel alloc] init]; + _dynamicLabel.font = [UIFont systemFontOfSize:12]; + _dynamicLabel.textColor = [ThemeColor textThirdColor]; + } + return _dynamicLabel; +} + +- (UIView *)lineView { + if (!_lineView) { + _lineView = [[UIView alloc] init]; + _lineView.backgroundColor = [ThemeColor dividerColor]; + } + return _lineView; +} + +- (NSDateFormatter *)dataFormatter { + if (!_dataFormatter) { + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"]; + _dataFormatter = dateFormatter; + } + return _dataFormatter; +} + + +@end diff --git a/xplan-ios/Main/Monents/View/XPMonentsInteractiveViewController.m b/xplan-ios/Main/Monents/View/XPMonentsInteractiveViewController.m index 02854144..a501d90c 100644 --- a/xplan-ios/Main/Monents/View/XPMonentsInteractiveViewController.m +++ b/xplan-ios/Main/Monents/View/XPMonentsInteractiveViewController.m @@ -11,28 +11,26 @@ #import ///Tool #import "ThemeColor.h" +#import "TTPopup.h" #import "XPMacro.h" -#import "XPMonentsLayoutConfig.h" ///Model -#import "MonentsListInfoModel.h" +#import "MonentsInteractiveModel.h" ///P #import "XPMonentsInteractivePresenter.h" #import "XPMonentsInteractiveProtocol.h" ///View -#import "XPMonentsTableViewCell.h" +#import "XPMonentsInteractiveTableViewCell.h" #import "XPMonentsEmptyTableViewCell.h" @interface XPMonentsInteractiveViewController () ///列表 @property (nonatomic,strong) UITableView *tableView; ///数据源 -@property (nonatomic,strong) NSMutableArray *datasource; +@property (nonatomic,strong) NSMutableArray *datasource; ///当前的页数 @property (nonatomic,assign) NSInteger page; ///是否有更多的数据 @property (nonatomic,assign) BOOL hasNoMoreData; -///数据信息 -@property (nonatomic,strong) MonentsListInfoModel *listInfo; @end @implementation XPMonentsInteractiveViewController @@ -50,7 +48,9 @@ #pragma mark - Private Method - (void)initSubViews { + self.title = @"全部消息"; [self.view addSubview:self.tableView]; + [self addNavigationItemWithImageNames:@[@"monents_interactive_delete_message"] isLeft:NO target:self action:@selector(rightButtonAction:) tags:nil]; } - (void)initSubViewConstraints { @@ -79,7 +79,7 @@ #pragma mark - 刷新的fangfa - (void)headerRefresh { self.page = 1; - [self.presenter getMonentsInteractiveList:@"0" pageSize:20 state:0]; + [self.presenter getMonentsInteractiveList:@"" pageSize:20 state:0]; } - (void)footerRefresh { @@ -89,7 +89,12 @@ return; } self.page++; - [self.presenter getMonentsInteractiveList:@"0" pageSize:20 state:1]; + NSString * dynamicId = @""; + if (self.datasource.count > 0) { + MonentsInteractiveModel * model = [self.datasource lastObject]; + dynamicId = model.dynamicId; + } + [self.presenter getMonentsInteractiveList:dynamicId pageSize:20 state:1]; } #pragma mark - UITableViewDelegate And UITableViewDataSource @@ -99,18 +104,17 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (self.datasource.count > 0) { - MonentsInfoModel * monentInfo= [self.datasource objectAtIndex:indexPath.row]; - [XPMonentsLayoutConfig layoutMonentsModel:monentInfo]; - return monentInfo.rowHeight; + MonentsInteractiveModel * model = [self.datasource objectAtIndex:indexPath.row]; + return model.worldName.length > 0? 130 : 90; } - return KScreenHeight - kNavigationHeight - 49 - kSafeAreaBottomHeight; + return KScreenHeight - kNavigationHeight; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (self.datasource.count > 0) { - XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; - MonentsInfoModel * monentsInfo = [self.datasource objectAtIndex:indexPath.row]; - cell.monentsInfo = monentsInfo; + XPMonentsInteractiveTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsInteractiveTableViewCell class])]; + MonentsInteractiveModel * model = [self.datasource objectAtIndex:indexPath.row]; + cell.interactiveInfo = model; return cell; } XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; @@ -152,6 +156,19 @@ } } +- (void)clearInteractiveMessageSuccess { + [self.datasource removeAllObjects]; + [self.tableView reloadData]; +} + +#pragma mark - Event Response +- (void)rightButtonAction:(UIButton *)sender { + [TTPopup alertWithMessage:@"清空后所有互动通知将被删除,确定清空吗?" confirmHandler:^{ + [[self presenter] clearInteractiveMessage]; + } cancelHandler:^{ + }]; +} + #pragma mark - Getters And Setters - (UITableView *)tableView { if (!_tableView) { @@ -164,14 +181,14 @@ if (@available(iOS 11.0, *)) { _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; } - [_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; + [_tableView registerClass:[XPMonentsInteractiveTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsInteractiveTableViewCell class])]; [_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; } return _tableView; } -- (NSMutableArray *)datasource { +- (NSMutableArray *)datasource { if (!_datasource) { _datasource = [NSMutableArray array]; } diff --git a/xplan-ios/Main/Monents/View/XPMonentsViewController.m b/xplan-ios/Main/Monents/View/XPMonentsViewController.m index 32068225..da37bf12 100644 --- a/xplan-ios/Main/Monents/View/XPMonentsViewController.m +++ b/xplan-ios/Main/Monents/View/XPMonentsViewController.m @@ -8,21 +8,28 @@ #import "XPMonentsViewController.h" ///Third #import +#import #import #import ///Tool #import "ThemeColor.h" #import "XPMacro.h" +///Tool +#import "AttachMentModel.h" +#import "MonentsUnReadModel.h" ///View #import "XPMonentsRecommendViewController.h" #import "XPMonentsAttentionViewController.h" #import "XPMonentsLatestViewController.h" +#import "XPMonentsInteractiveViewController.h" @interface XPMonentsViewController () ///标题 @property (nonatomic,strong) NSArray *titles; ///导航栏 @property (nonatomic,strong) UIView * navView; +///显示小红点 +@property (nonatomic,strong) UIView * dotView; ///消息的 @property (nonatomic,strong) UIButton *messageButton; ///滑块 @@ -32,12 +39,17 @@ @implementation XPMonentsViewController +- (void)dealloc { + [[NIMSDK sharedSDK].systemNotificationManager removeDelegate:self]; +} + - (BOOL)isHiddenNavBar { return YES; } - (void)viewDidLoad { [super viewDidLoad]; + [[NIMSDK sharedSDK].systemNotificationManager addDelegate:self]; [self initSubViews]; [self initSubViewConstraints]; } @@ -49,6 +61,7 @@ [self.navView addSubview:self.titleView]; [self.navView addSubview:self.messageButton]; + [self.navView addSubview:self.dotView]; } - (void)initSubViewConstraints { @@ -69,6 +82,12 @@ 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); @@ -99,6 +118,29 @@ } +#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; + } + } + } + } +} + +#pragma mark - Event Response +- (void)messageButtonAction:(UIButton *)sender { + XPMonentsInteractiveViewController * messageVC = [[XPMonentsInteractiveViewController alloc] init]; + [self.navigationController pushViewController:messageVC animated:YES]; +} + #pragma mark - Getters And Setters - (JXCategoryListContainerView *)listContainerView { if (!_listContainerView) { @@ -147,4 +189,25 @@ 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; +} + +- (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; +} + @end