Files
real-e-party-iOS/YuMi/Modules/YMMine/View/Friend/XPMineShareViewController.m
edwinQQQ a35a711be6 chore: Initial clean commit
- Removed YuMi/Library/ (138 MB, not tracked)
- Removed YuMi/Resources/ (23 MB, not tracked)
- Removed old version assets (566 files, not tracked)
- Excluded Pods/, xcuserdata/ and other build artifacts
- Clean repository optimized for company server deployment
2025-10-09 16:19:14 +08:00

233 lines
7.5 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// YMMineShareViewController.m
// YUMI
//
// Created by YUMI on 2022/6/27.
//
#import "XPMineShareViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <NIMSDK/NIMSDK.h>
#import <JXCategoryView/JXCategoryView.h>
#import <JXCategoryView/JXCategoryListContainerView.h>
///Tool
#import "DJDKMIMOMColor.h"
#import "YUMIMacroUitls.h"
#import "TTPopup.h"
///Model
#import "XPShareInfoModel.h"
#import "FansInfoModel.h"
#import "UserInfoModel.h"
#import "AttachMentModel.h"
#import "ContentShareMonentsModel.h"
///View
#import "SessionViewController.h"
#import "SessionListViewController.h"
#import "XPMineFriendViewController.h"
#import "XPMineAttentionViewController.h"
#import "XPMineFansViewController.h"
@interface XPMineShareViewController ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate, XPMineAttentionViewControllerDelegate, XPMineFansViewControllerDelegate, XPMineFriendViewControllerDelegate>
///标题
@property (nonatomic,strong) NSArray<NSString *> *titles;
///滑块
@property (nonatomic,strong) JXCategoryTitleView *titleView;
@property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
///好友
@property (nonatomic,strong) XPMineFriendViewController *friendVC;
///关注
@property (nonatomic,strong) XPMineAttentionViewController *attentionVC;
///粉丝
@property (nonatomic,strong) XPMineFansViewController *fansVC;
///回话的id
@property (nonatomic,copy) NSString *sessionId;
@end
@implementation XPMineShareViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self initSubViews];
[self initSubViewConstraints];
}
#pragma mark - Private Method
- (void)initSubViews {
self.title = YMLocalizedString(@"XPMineShareViewController0");
[self.view addSubview:self.titleView];
[self.view addSubview:self.listContainerView];
}
- (void)initSubViewConstraints {
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.top.mas_equalTo(self.view);
make.height.mas_equalTo(50);
}];
[self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.bottom.mas_equalTo(self.view);
make.top.mas_equalTo(self.titleView.mas_bottom);
}];
}
- (void)sendCustomMessage:(AttachmentModel *)attachment {
NIMMessage *message = [[NIMMessage alloc]init];
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachment;
message.messageObject = object;
NIMSessionType sessionType = NIMSessionTypeP2P;
//构造会话
NIMSession *session = [NIMSession session:self.sessionId type:sessionType];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
}
- (void)shareToUser:(NSString *)nick {
NSString * title;
AttachmentModel * attachment = [[AttachmentModel alloc] init];
// 添加类型安全检查
if (![self.shareInfo isKindOfClass:[XPShareInfoModel class]]) {
NSLog(@"警告self.shareInfo不是XPShareInfoModel类型而是%@类型", NSStringFromClass([self.shareInfo class]));
return;
}
switch (self.shareType) {
case MineShareType_Monents:
{
title = [NSString stringWithFormat:YMLocalizedString(@"XPMineShareViewController1"), nick];
attachment.first = CustomMessageType_Monents;
attachment.second = Custom_Message_Sub_Monents_Share;
ContentShareMonentsModel * shareInfo = [[ContentShareMonentsModel alloc] init];
shareInfo.imageUrl = self.shareInfo.imageUrl;
shareInfo.nick = self.shareInfo.nick;
shareInfo.content = self.shareInfo.content;
shareInfo.dynamicId= self.shareInfo.dynamicId;
shareInfo.routerValue = self.shareInfo.dynamicId;
shareInfo.routerType = 50;
attachment.data = shareInfo.model2dictionary;
}
break;
default:
break;
}
if (title.length > 0) {
[TTPopup alertWithMessage:title confirmHandler:^{
[self sendCustomMessage:attachment];
} cancelHandler:^{
}];
}
}
#pragma mark - JXCategoryListContainerViewDelegate
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
return self.titles.count;
}
// 根据下标 index 返回对应遵守并实现 `JXCategoryListContentViewDelegate` 协议的列表实例
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
if (index == 0) {
return self.friendVC;
} else if(index == 1) {
return self.fansVC;
} else {
return self.attentionVC;
}
}
#pragma mark - XPMineAttentionViewControllerDelegate
///点击了关注的某个人
- (void)xPMineAttentionViewController:(XPMineAttentionViewController *)viewController didSelectItem:(FansInfoModel *)userInfo {
self.sessionId = userInfo.uid;
[self shareToUser:userInfo.nick];
}
#pragma mark - XPMineFansViewControllerDelegate
///点击了粉丝
- (void)xPMineFansViewController:(XPMineFansViewController *)view didSelectItem:(FansInfoModel *)userInfo {
self.sessionId = userInfo.uid;
[self shareToUser:userInfo.nick];
}
#pragma mark - XPMineFriendViewControllerDelegate
///点击了好友
- (void)xPMineFriendViewController:(XPMineFriendViewController *)viewController didSelectItem:(UserInfoModel *)userInfo {
self.sessionId = [NSString stringWithFormat:@"%ld", userInfo.uid];
[self shareToUser:userInfo.nick];
}
#pragma mark - Getters And Setters
- (JXCategoryListContainerView *)listContainerView {
if (!_listContainerView) {
_listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
_listContainerView.listCellBackgroundColor = [UIColor clearColor];
}
return _listContainerView;
}
- (NSArray<NSString *> *)titles {
if (!_titles) {
_titles = @[YMLocalizedString(@"XPMonentsTooBarView3"),YMLocalizedString(@"XPMineContactViewController3"), YMLocalizedString(@"XPMineShareViewController4")];
}
return _titles;
}
- (JXCategoryTitleView *)titleView {
if (!_titleView) {
_titleView = [[JXCategoryTitleView alloc] initWithFrame:CGRectZero];
_titleView.backgroundColor =[UIColor clearColor];
_titleView.titleColor = UIColorFromRGB(0x444444);
_titleView.titleSelectedColor = [DJDKMIMOMColor mainTextColor];
_titleView.titleFont = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
_titleView.titleSelectedFont = [UIFont systemFontOfSize:18 weight:UIFontWeightHeavy];
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
_titleView.averageCellSpacingEnabled = NO;
_titleView.defaultSelectedIndex = 0;
_titleView.titles = self.titles;
_titleView.delegate = self;
_titleView.cellSpacing = 0;
_titleView.cellWidth = (CGFloat)KScreenWidth/ 3.0;
_titleView.listContainer = self.listContainerView;
JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
lineView.indicatorColor = [DJDKMIMOMColor appMainColor];
lineView.indicatorWidth = 8.f;
lineView.indicatorHeight = 4.f;
lineView.indicatorCornerRadius = 2.f;
_titleView.indicators = @[lineView];
}
return _titleView;
}
- (XPMineAttentionViewController *)attentionVC {
if (!_attentionVC) {
_attentionVC = [[XPMineAttentionViewController alloc] init];
_attentionVC.type = ContactUseingType_Share;
_attentionVC.delegate = self;
}
return _attentionVC;
}
- (XPMineFriendViewController *)friendVC {
if (!_friendVC) {
_friendVC = [[XPMineFriendViewController alloc] init];
_friendVC.type = ContactUseingType_Share;
_friendVC.delegate = self;
}
return _friendVC;
}
- (XPMineFansViewController *)fansVC {
if (!_fansVC) {
_fansVC = [[XPMineFansViewController alloc] init];
_fansVC.type = ContactUseingType_Share;
_fansVC.delegate = self;
}
return _fansVC;
}
@end