diff --git a/YuMi.xcodeproj/project.pbxproj b/YuMi.xcodeproj/project.pbxproj index 76cc456e..4ca02260 100644 --- a/YuMi.xcodeproj/project.pbxproj +++ b/YuMi.xcodeproj/project.pbxproj @@ -527,6 +527,9 @@ 545831A62C2C085C00364026 /* ArabMicroView.m in Sources */ = {isa = PBXBuildFile; fileRef = 545831A52C2C085C00364026 /* ArabMicroView.m */; }; 545888332C1AFFB500897585 /* XPRoomPKPanelView.m in Sources */ = {isa = PBXBuildFile; fileRef = 545888322C1AFFB500897585 /* XPRoomPKPanelView.m */; }; 545888362C1C306B00897585 /* XPRoomPKPaneAvatarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 545888352C1C306B00897585 /* XPRoomPKPaneAvatarView.m */; }; + 5458EC1F2C341C3F009D9757 /* FeedBackViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5458EC1D2C341C3F009D9757 /* FeedBackViewController.m */; }; + 5458EC202C341C3F009D9757 /* FeedBackViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5458EC1E2C341C3F009D9757 /* FeedBackViewController.xib */; }; + 5458EC232C352D9C009D9757 /* FeedBackConfigModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 5458EC222C352D9C009D9757 /* FeedBackConfigModel.m */; }; 547853A12C258F2A00F45E60 /* XPMineUserViewHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = 547853A02C258F2A00F45E60 /* XPMineUserViewHeader.m */; }; 54C3895C2C215F5100FD47B1 /* XPHomeMineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 54C3895B2C215F5100FD47B1 /* XPHomeMineViewController.m */; }; 54C3895F2C2189DD00FD47B1 /* XPHomeMinePresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 54C3895E2C2189DD00FD47B1 /* XPHomeMinePresenter.m */; }; @@ -2588,6 +2591,11 @@ 545888322C1AFFB500897585 /* XPRoomPKPanelView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomPKPanelView.m; sourceTree = ""; }; 545888342C1C306B00897585 /* XPRoomPKPaneAvatarView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomPKPaneAvatarView.h; sourceTree = ""; }; 545888352C1C306B00897585 /* XPRoomPKPaneAvatarView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomPKPaneAvatarView.m; sourceTree = ""; }; + 5458EC1C2C341C3F009D9757 /* FeedBackViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FeedBackViewController.h; sourceTree = ""; }; + 5458EC1D2C341C3F009D9757 /* FeedBackViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FeedBackViewController.m; sourceTree = ""; }; + 5458EC1E2C341C3F009D9757 /* FeedBackViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FeedBackViewController.xib; sourceTree = ""; }; + 5458EC212C352D9C009D9757 /* FeedBackConfigModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FeedBackConfigModel.h; sourceTree = ""; }; + 5458EC222C352D9C009D9757 /* FeedBackConfigModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FeedBackConfigModel.m; sourceTree = ""; }; 5478539F2C258F2A00F45E60 /* XPMineUserViewHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineUserViewHeader.h; sourceTree = ""; }; 547853A02C258F2A00F45E60 /* XPMineUserViewHeader.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineUserViewHeader.m; sourceTree = ""; }; 54C3895A2C215F5100FD47B1 /* XPHomeMineViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPHomeMineViewController.h; sourceTree = ""; }; @@ -5061,6 +5069,9 @@ E824543426F57D6E00BE8163 /* XPLoginVerifBindPhoneViewController.m */, 23B2AEC32A6516C200543D17 /* LoginForgetPasswordViewController.h */, 23B2AEC22A6516C200543D17 /* LoginForgetPasswordViewController.m */, + 5458EC1C2C341C3F009D9757 /* FeedBackViewController.h */, + 5458EC1D2C341C3F009D9757 /* FeedBackViewController.m */, + 5458EC1E2C341C3F009D9757 /* FeedBackViewController.xib */, ); path = View; sourceTree = ""; @@ -10401,6 +10412,8 @@ E81C27AA26EF2D920031E639 /* ThirdUserInfo.m */, E818DD1D2A48974300F163F7 /* LoginAreaModel.h */, E818DD1E2A48974300F163F7 /* LoginAreaModel.m */, + 5458EC212C352D9C009D9757 /* FeedBackConfigModel.h */, + 5458EC222C352D9C009D9757 /* FeedBackConfigModel.m */, ); path = Model; sourceTree = ""; @@ -11148,6 +11161,7 @@ E80EC83228ACD84000D133C5 /* emoji_00@2x.png in Resources */, E80EC89C28ACD84000D133C5 /* emoji_50@2x.png in Resources */, E80EC87A28ACD84000D133C5 /* emoji_113@2x.png in Resources */, + 5458EC202C341C3F009D9757 /* FeedBackViewController.xib in Resources */, 23FF25622ABAE6310064E904 /* pi_room_game_fine_love.svga in Resources */, 23FF42672AA5CFBB0055733C /* home_sound_wave.gif in Resources */, E80EC88A28ACD84000D133C5 /* emoji_25@2x.png in Resources */, @@ -12444,6 +12458,7 @@ E852D74428633A08001465ED /* MonentsCommentModel.m in Sources */, 238B37C42AC55A2C00BFC9D5 /* XPTreasureFairyBallContentView.m in Sources */, E8C1CD6D27D8938C00376F83 /* XPRoomFaceTitleCollectionViewCell.m in Sources */, + 5458EC1F2C341C3F009D9757 /* FeedBackViewController.m in Sources */, E8C1CD7627D8AE3D00376F83 /* XPRoomFacePresenter.m in Sources */, E85E7B362A4EB0D300B6D00A /* XPClanRoomCollectionViewCell.m in Sources */, 18F4043A275E20D900A6C548 /* TRTCRtcImpl.m in Sources */, @@ -12573,6 +12588,7 @@ 23E9EB152A84D02400B792F2 /* XPMineUserInfoEditPickView.m in Sources */, 9BA812D628BF52E100783EA7 /* XPRoomSendRedPacketViewController.m in Sources */, E86E79D328A4E94E006DAF48 /* SessionRiskView.m in Sources */, + 5458EC232C352D9C009D9757 /* FeedBackConfigModel.m in Sources */, E85E7B1F2A4EB0D300B6D00A /* XPMineGuildIncomeStatisViewController.m in Sources */, E85E7B412A4EB0D300B6D00A /* XPMineGuildEmptyTableViewCell.m in Sources */, E8133916273E532D00708B66 /* XPGiftItemCollectionViewCell.m in Sources */, diff --git a/YuMi/Assets.xcassets/Login/login_custom_servise.imageset/Contents.json b/YuMi/Assets.xcassets/Login/login_custom_servise.imageset/Contents.json new file mode 100644 index 00000000..aaa6b80d --- /dev/null +++ b/YuMi/Assets.xcassets/Login/login_custom_servise.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "login_custom_servise@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/YuMi/Assets.xcassets/Login/login_custom_servise.imageset/login_custom_servise@3x.png b/YuMi/Assets.xcassets/Login/login_custom_servise.imageset/login_custom_servise@3x.png new file mode 100644 index 00000000..b3d33d14 Binary files /dev/null and b/YuMi/Assets.xcassets/Login/login_custom_servise.imageset/login_custom_servise@3x.png differ diff --git a/YuMi/Assets.xcassets/Login/login_feedback_add_photo.imageset/Contents.json b/YuMi/Assets.xcassets/Login/login_feedback_add_photo.imageset/Contents.json new file mode 100644 index 00000000..384e247b --- /dev/null +++ b/YuMi/Assets.xcassets/Login/login_feedback_add_photo.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "login_feedback_add_photo@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/YuMi/Assets.xcassets/Login/login_feedback_add_photo.imageset/login_feedback_add_photo@3x.png b/YuMi/Assets.xcassets/Login/login_feedback_add_photo.imageset/login_feedback_add_photo@3x.png new file mode 100644 index 00000000..2f63421e Binary files /dev/null and b/YuMi/Assets.xcassets/Login/login_feedback_add_photo.imageset/login_feedback_add_photo@3x.png differ diff --git a/YuMi/Modules/YMLogin/Api/Api+Login.h b/YuMi/Modules/YMLogin/Api/Api+Login.h index 1c62f7ff..ac46e3df 100644 --- a/YuMi/Modules/YMLogin/Api/Api+Login.h +++ b/YuMi/Modules/YMLogin/Api/Api+Login.h @@ -79,6 +79,16 @@ NS_ASSUME_NONNULL_BEGIN /// @param complection 完成 +(void)bindAuthorizationCode:(HttpRequestHelperCompletion)complection authCode:(NSString *)authCode; + + +///反馈 ++ (void)loadFeedbackConfig:(HttpRequestHelperCompletion)completion; ++ (void)commitFeedback:(HttpRequestHelperCompletion)completion + type:(NSString *)type + desc:(NSString *)desc + screenUrl:(NSString *)screenUrl + contact:(NSString *)contact; + @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMLogin/Api/Api+Login.m b/YuMi/Modules/YMLogin/Api/Api+Login.m index 230e3b89..66bed317 100644 --- a/YuMi/Modules/YMLogin/Api/Api+Login.m +++ b/YuMi/Modules/YMLogin/Api/Api+Login.m @@ -84,4 +84,20 @@ +(void)bindAuthorizationCode:(HttpRequestHelperCompletion)complection authCode:(NSString *)authCode{ [self makeRequest:@"phone/auth/bound" method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__,authCode, nil]; } + +///反馈 ++ (void)loadFeedbackConfig:(HttpRequestHelperCompletion)completion { + [self makeRequest:@"feedback/getConfig" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, nil]; +} + ++ (void)commitFeedback:(HttpRequestHelperCompletion)completion + type:(NSString *)type + desc:(NSString *)desc + screenUrl:(NSString *)screenUrl + contact:(NSString *)contact { + [self makeRequest:@"feedback/commit" + method:HttpRequestHelperMethodPOST + completion:completion, __FUNCTION__, type, desc, screenUrl, contact, nil]; + +} @end diff --git a/YuMi/Modules/YMLogin/Model/FeedBackConfigModel.h b/YuMi/Modules/YMLogin/Model/FeedBackConfigModel.h new file mode 100644 index 00000000..26abe2c4 --- /dev/null +++ b/YuMi/Modules/YMLogin/Model/FeedBackConfigModel.h @@ -0,0 +1,23 @@ +// +// FeedBackConfigModel.h +// YuMi +// +// Created by P on 2024/7/3. +// + +#import "PIBaseModel.h" + +NS_ASSUME_NONNULL_BEGIN + + +@interface FeedBackTypeModel : PIBaseModel +@property (nonatomic, copy) NSString *desc; +@property (nonatomic, copy) NSString *type; +@end + +@interface FeedBackConfigModel : PIBaseModel +@property (nonatomic, copy) NSDictionary *customContactMap; +@property (nonatomic, copy) NSArray *typeEnumList; +@end + +NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMLogin/Model/FeedBackConfigModel.m b/YuMi/Modules/YMLogin/Model/FeedBackConfigModel.m new file mode 100644 index 00000000..0a8c8f9a --- /dev/null +++ b/YuMi/Modules/YMLogin/Model/FeedBackConfigModel.m @@ -0,0 +1,20 @@ +// +// FeedBackConfigModel.m +// YuMi +// +// Created by P on 2024/7/3. +// + +#import "FeedBackConfigModel.h" + +@implementation FeedBackTypeModel + +@end + +@implementation FeedBackConfigModel ++ (NSDictionary *)objectClassInArray{ + return @{ + @"typeEnumList":FeedBackTypeModel.class + }; +} +@end diff --git a/YuMi/Modules/YMLogin/Presenter/LoginPresenter.h b/YuMi/Modules/YMLogin/Presenter/LoginPresenter.h index 5543f08f..04657412 100644 --- a/YuMi/Modules/YMLogin/Presenter/LoginPresenter.h +++ b/YuMi/Modules/YMLogin/Presenter/LoginPresenter.h @@ -10,6 +10,9 @@ #import #import #import + +@class FeedBackConfigModel; + NS_ASSUME_NONNULL_BEGIN @interface LoginPresenter : BaseMvpPresenter @@ -42,6 +45,16 @@ NS_ASSUME_NONNULL_BEGIN /// @param password 验证码 - (void)loginWithPhone:(NSString *)phone password:(NSString *)password; +///反馈 +- (void)loadFeedbackConfig:(void(^)(FeedBackConfigModel *model))success + failure:(void(^)(NSString *errorMessage))failure; +- (void)submitFeedback:(void(^)(void))success + failure:(void(^)(NSString *errorMessage))failure + type:(NSString *)type + desc:(NSString *)desc + photoURLString:(nullable NSString *)photoURLString + contact:(nullable NSString *)contact; + @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMLogin/Presenter/LoginPresenter.m b/YuMi/Modules/YMLogin/Presenter/LoginPresenter.m index edcb977f..1aa0f88f 100644 --- a/YuMi/Modules/YMLogin/Presenter/LoginPresenter.m +++ b/YuMi/Modules/YMLogin/Presenter/LoginPresenter.m @@ -24,6 +24,7 @@ #import #import #import "YuMi-swift.h" +#import "FeedBackConfigModel.h" @implementation LoginPresenter - (void)dealloc{ @@ -33,13 +34,12 @@ self = [super init]; if(self){ - @weakify(self); +// @weakify(self); [[NSNotificationCenter defaultCenter] addObserverForName:FBSDKProfileDidChangeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock: ^(NSNotification *notification) { - if ([FBSDKProfile currentProfile]) { //获取当前用户名 [FBSDKProfile loadCurrentProfileWithCompletion: @@ -47,7 +47,6 @@ if (profile) { [AccountInfoStorage instance].thirdUserInfo.userName = profile.name; [AccountInfoStorage instance].thirdUserInfo.avatarUrl = profile.imageURL.absoluteString; - } }]; } @@ -302,4 +301,44 @@ } errorToast:YES] phone:desPhone password:desPassword client_secret:@"uyzjdhds" version:@"1" client_id:@"erban-client" grant_type:@"password"]; } +///反馈 +- (void)loadFeedbackConfig:(void(^)(FeedBackConfigModel *model))success + failure:(void(^)(NSString *errorMessage))failure { + [Api loadFeedbackConfig:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if (code == 200) { + FeedBackConfigModel *model =[FeedBackConfigModel modelWithDictionary:data.data]; + if (success) { + success(model); + } + } else { + if (failure) { + failure(msg); + } + } + }]; +} +- (void)submitFeedback:(void(^)(void))success + failure:(void(^)(NSString *errorMessage))failure + type:(NSString *)type + desc:(NSString *)desc + photoURLString:(nullable NSString *)photoURLString + contact:(nullable NSString *)contact { + [Api commitFeedback:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if (code == 200) { + if (success) { + success(); + } + } else { + if (failure) { + failure(msg); + } + } + } + type:type + desc:desc + screenUrl:photoURLString ? photoURLString : @"" + contact:contact ? contact : @""]; + +} + @end diff --git a/YuMi/Modules/YMLogin/View/FeedBackViewController.h b/YuMi/Modules/YMLogin/View/FeedBackViewController.h new file mode 100644 index 00000000..4aead217 --- /dev/null +++ b/YuMi/Modules/YMLogin/View/FeedBackViewController.h @@ -0,0 +1,40 @@ +// +// FeedBackViewController.h +// YuMi +// +// Created by P on 2024/7/2. +// + +#import "MvpViewController.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface FeedBackViewController : MvpViewController + +@property (nonatomic, strong) IBOutlet UIScrollView *scrollView; +@property (nonatomic, strong) IBOutlet UIView *scrollContentView; + +@property (nonatomic, weak) IBOutlet UIButton *closeKeyboardButton; + +@property (nonatomic, weak) IBOutlet UILabel *title_1; +@property (nonatomic, weak) IBOutlet UILabel *title_2; +@property (nonatomic, weak) IBOutlet UILabel *title_3; +@property (nonatomic, weak) IBOutlet UILabel *title_4; + +@property (nonatomic, weak) IBOutlet UICollectionView *typeCollectionView; + +@property (nonatomic, weak) IBOutlet UITextView *feedbackTextView; +@property (nonatomic, weak) IBOutlet UILabel *feedbackPlaceholderLabel; +@property (nonatomic, weak) IBOutlet UILabel *feedbackCharCountLabel; +@property (nonatomic, weak) IBOutlet UILabel *feedbackCharLimitLabel; + +@property (nonatomic, weak) IBOutlet UIButton *uploadImageButton; +@property (weak, nonatomic) IBOutlet UIImageView *uploadImageView; + +@property (nonatomic, weak) IBOutlet UITextField *contactTextField; + +@property (nonatomic, weak) IBOutlet UIButton *submitButton; + +@end + +NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMLogin/View/FeedBackViewController.m b/YuMi/Modules/YMLogin/View/FeedBackViewController.m new file mode 100644 index 00000000..bbd2829c --- /dev/null +++ b/YuMi/Modules/YMLogin/View/FeedBackViewController.m @@ -0,0 +1,776 @@ +// +// FeedBackViewController.m +// YuMi +// +// Created by P on 2024/7/2. +// + +#import "FeedBackViewController.h" +#import "LoginPresenter.h" +#import "UploadFile.h" + +#import "FeedBackConfigModel.h" + +@interface FeedBackContactPopUpCell : UICollectionViewCell +@property (nonatomic, strong) UILabel *content; +@property (nonatomic, strong) UIImageView *icon; +//@ +@end + +@implementation FeedBackContactPopUpCell + +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + _content = [UILabel labelInitWithText:@"" + font:[UIFont systemFontOfSize:16 weight:UIFontWeightBold] + textColor:UIColorFromRGB(0x333333)]; + _icon = [[UIImageView alloc] initWithImage:kImage(@"user_card_copy_id1")]; + [self.contentView addSubview:_content]; + [self.contentView addSubview:_icon]; + [_content mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.left.mas_equalTo(0); + }]; + [_icon mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.height.mas_equalTo(12); + make.centerY.mas_equalTo(self.content); + make.left.mas_equalTo(self.content.mas_right).offset(2); + }]; + } + return self; +} + +@end + +@interface FeedBackContactPopUp : UIView + +@property (nonatomic, copy) NSArray *contactArray; + +@property (nonatomic, strong) UICollectionView *collectionView; + +@end + +@implementation FeedBackContactPopUp + ++ (CGFloat)popUpHeight:(NSDictionary *)dataSource { + return 32 + 75 + 14 * dataSource.count + 18 * dataSource.count; +} + +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + [self setup]; + } + return self; +} + +- (void)setup { + self.backgroundColor = [UIColor whiteColor]; + self.layer.cornerRadius = 15.5; + self.clipsToBounds = YES; + self.layer.masksToBounds = YES; + + UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom]; + b.layer.cornerRadius = 19; + b.layer.masksToBounds = YES; + [b setTitle:YMLocalizedString(@"XPRoomViewController16") forState:UIControlStateNormal]; + [b setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x57e193),UIColorFromRGB(0x14d2a6)] + gradientType:GradientTypeLeftToRight + imgSize:CGSizeMake(120, 38)] + forState:UIControlStateNormal]; + [b addTarget:self action:@selector(didTapButton) forControlEvents:UIControlEventTouchUpInside]; + [self addSubview:b]; + [b mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerX.mas_equalTo(self); + make.bottom.mas_equalTo(self).offset(-16); + make.height.mas_equalTo(38); + }]; + + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; + layout.scrollDirection = UICollectionViewScrollDirectionVertical; + _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; + _collectionView.backgroundColor = [UIColor clearColor]; + _collectionView.scrollEnabled = NO; + _collectionView.delegate = self; + _collectionView.dataSource = self; + [_collectionView registerClass:[FeedBackContactPopUpCell class] forCellWithReuseIdentifier:@"cell"]; + [self addSubview:_collectionView]; + [_collectionView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self).insets(UIEdgeInsetsMake(32, 0, 75, 0)); + }]; +} + +- (void)setContactDic:(NSDictionary *)contactDic { + NSMutableArray *tempArr = @[].mutableCopy; + [contactDic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { + [tempArr addObject:@[key, obj]]; + }]; + _contactArray = tempArr; + + [self.collectionView reloadData]; +} + +- (void)didTapButton { + [TTPopup dismiss]; +} + +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { + return self.contactArray.count; +} + +- (CGSize)collectionView:(UICollectionView *)collectionView + layout:(UICollectionViewLayout *)collectionViewLayout + sizeForItemAtIndexPath:(NSIndexPath *)indexPath { + CGFloat padding = 24.0; + CGFloat totalPadding = padding * 2; // 左右两边的间距 + 中间两个间距 + CGFloat availableWidth = collectionView.frame.size.width - totalPadding; + NSArray *subArray = [self.contactArray xpSafeObjectAtIndex:indexPath.row]; + return CGSizeMake(availableWidth, subArray.count > 1 ? 14 : 0); +} + +- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section { + return 18.0; +} + +- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section { + return 18.0; +} + +// 返回 cell +- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { + FeedBackContactPopUpCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath]; + + NSArray *subArray = [self.contactArray xpSafeObjectAtIndex:indexPath.row]; + if (subArray.count > 1) { + cell.content.text = [NSString stringWithFormat:@"%@: %@", [subArray firstObject], [subArray lastObject]]; + } + + return cell; +} + +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { + NSArray *subArray = [self.contactArray xpSafeObjectAtIndex:indexPath.row]; + if (subArray.count > 1) { + UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; + [pasteboard setString:[subArray lastObject]]; + [XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"XPShareView0")]; + } +} + +@end + +@interface TypeCollectionCell : UICollectionViewCell + +@property (nonatomic, strong) UILabel *titleLabel; + +@end + +@implementation TypeCollectionCell + +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + self.contentView.userInteractionEnabled = YES; + _titleLabel = [UILabel labelInitWithText:@"" + font:[UIFont systemFontOfSize:14 weight:UIFontWeightMedium] textColor:UIColorFromRGB(0x22252c)]; + _titleLabel.layer.cornerRadius = 15.5; + _titleLabel.layer.masksToBounds = YES; + _titleLabel.textAlignment = NSTextAlignmentCenter; + _titleLabel.backgroundColor = UIColorFromRGB(0xf3f5fa); + _titleLabel.userInteractionEnabled = NO; + _titleLabel.minimumScaleFactor = 0.7; + _titleLabel.numberOfLines = 2; + [self.contentView addSubview:_titleLabel]; + [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.contentView); + }]; + } + return self; +} + +- (void)setSelected:(BOOL)selected { + if (selected) { + self.titleLabel.backgroundColor = UIColorFromRGB(0x85f6d3); + } else { + self.titleLabel.backgroundColor = UIColorFromRGB(0xf3f5fa); + } +} + +@end + +@interface FeedBackViewController () + +@property (nonatomic, strong) UIView *fakeTopBar; +@property (nonatomic, copy) NSString *uploadPhotoURLString; +@property (nonatomic, strong) UIImage *selectedImage; +@property (nonatomic, strong) FeedBackConfigModel *configModel; +@property (nonatomic, strong) FeedBackTypeModel *selectTypeModel; + +@end + +@implementation FeedBackViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + [self setup]; + [self customLayout]; + [self loadFeedbackConfig]; +} + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + + [self addNavigationItemWithImageNames:@[@"login_custom_servise"] + isLeft:NO + target:self + action:@selector(rightButtonTapped) tags:nil]; +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; +} + +- (LoginPresenter *)createPresenter { + return [[LoginPresenter alloc] init]; +} + +- (BOOL)isHiddenNavBar { + return YES; +} + +- (void)setup { + self.title = YMLocalizedString(@"XPMineFeedbackViewController0"); + self.view.backgroundColor = [UIColor whiteColor]; + + [self setupFakeTopBar]; + + [self.closeKeyboardButton setTitle:@"" forState:UIControlStateNormal]; + + self.typeCollectionView.delegate = self; + self.typeCollectionView.dataSource = self; + self.typeCollectionView.allowsSelection = YES; + [self.typeCollectionView registerClass:[TypeCollectionCell class] forCellWithReuseIdentifier:@"cell"]; + + self.feedbackTextView.delegate = self; + self.feedbackTextView.textContainerInset = UIEdgeInsetsMake(8, 8, 20, 8); + + self.title_1.textColor = [UIColor blackColor]; + self.title_2.textColor = [UIColor blackColor]; + self.title_3.textColor = [UIColor blackColor]; + self.title_4.textColor = [UIColor blackColor]; + + self.title_2.text = YMLocalizedString(@"FeedBackViewController2"); + + NSAttributedString *redMark = [[NSAttributedString alloc] initWithString:@"* " + attributes:@{NSForegroundColorAttributeName: UIColorFromRGB(0xeb5c2c), + NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightBold]}]; + NSDictionary *defaultAttributes = @{NSForegroundColorAttributeName: UIColorFromRGB(0x000000), + NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightBold]}; + NSMutableAttributedString *attributedTitle_1 = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"FeedBackViewController0") attributes:defaultAttributes]; + [attributedTitle_1 insertAttributedString:redMark atIndex:0]; + NSMutableAttributedString *attributedTitle_2 = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"FeedBackViewController1") attributes:defaultAttributes]; + [attributedTitle_2 insertAttributedString:redMark atIndex:0]; + NSMutableAttributedString *attributedTitle_4 = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"FeedBackViewController3") attributes:defaultAttributes]; + [attributedTitle_4 insertAttributedString:redMark atIndex:0]; + + self.title_1.attributedText = attributedTitle_1; + self.title_2.attributedText = attributedTitle_2; + self.title_4.attributedText = attributedTitle_4; + + self.feedbackPlaceholderLabel.text = YMLocalizedString(@"FeedBackViewController4"); + self.feedbackCharCountLabel.text = @"0"; + if (isMSRTL()) { + self.feedbackCharCountLabel.textAlignment = NSTextAlignmentRight; + self.feedbackCharLimitLabel.textAlignment = NSTextAlignmentRight; + self.feedbackCharLimitLabel.text = @"300/"; + } else { + self.feedbackCharCountLabel.textAlignment = NSTextAlignmentLeft; + self.feedbackCharLimitLabel.textAlignment = NSTextAlignmentLeft ; + self.feedbackCharLimitLabel.text = @"/300"; + } + + [self.uploadImageButton setTitle:@"" forState:UIControlStateNormal]; + + UIColor *placeholderColor = UIColorFromRGB(0xacb0b7); + self.contactTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:YMLocalizedString(@"FeedBackViewController5") + attributes:@{NSForegroundColorAttributeName: placeholderColor}]; + + [self.submitButton setTitle:YMLocalizedString(@"LoginForgetPasswordViewController6") forState:UIControlStateNormal]; + [self.submitButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xa5eec8),UIColorFromRGB(0xabf5e3)] + gradientType:GradientTypeTopToBottom + imgSize:CGSizeMake(300, 50)] + forState:UIControlStateNormal]; + [self.submitButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorRGBAlpha(0x57e193, 0.5),UIColorRGBAlpha(0x1402a6, 0.5)] + gradientType:GradientTypeTopToBottom + imgSize:CGSizeMake(300, 50)] + forState:UIControlStateSelected]; +} + +- (void)setupFakeTopBar { + UIView *fakeTopBar = [[UIView alloc] init]; + fakeTopBar.backgroundColor = UIColorFromRGB(0xebecf3); + [self.view addSubview:fakeTopBar]; + _fakeTopBar = fakeTopBar; + CGFloat navigationBarHeight = self.navigationController.navigationBar.frame.size.height + [UIApplication sharedApplication].keyWindow.safeAreaInsets.top; + [fakeTopBar mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(self.view.mas_top); + make.left.equalTo(self.view.mas_left); + make.right.equalTo(self.view.mas_right); + make.height.mas_equalTo(navigationBarHeight); + }]; + + UILabel *title = [UILabel labelInitWithText:YMLocalizedString(@"XPMineFeedbackViewController0") + font:[UIFont systemFontOfSize:17 weight:UIFontWeightMedium] + textColor:UIColorFromRGB(0x010101)]; + [fakeTopBar addSubview:title]; + [title mas_makeConstraints:^(MASConstraintMaker *make) { + make.bottom.mas_equalTo(-16); + make.centerX.mas_equalTo(0); + }]; + + UIButton *back = [UIButton buttonWithType:UIButtonTypeCustom]; + [back enlargeTouchArea:UIEdgeInsetsMake(10, 10, 10, 10)]; + [back.imageView setContentMode:UIViewContentModeScaleAspectFill]; + [back setImage:kImage(@"room_info_back") forState:UIControlStateNormal]; + [back addTarget:self + action:@selector(didTapBackButton) + forControlEvents:UIControlEventTouchUpInside]; + if (isMSRTL()) { + back.imageView.transform = CGAffineTransformMakeScale(-1.0, 1.0); + } + [fakeTopBar addSubview:back]; + [back mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerY.mas_equalTo(title); + make.width.height.mas_equalTo(15); + if (isMSRTL()) { + make.right.mas_equalTo(-16); + } else { + make.left.mas_equalTo(16); + } + }]; + + UIButton *cs = [UIButton buttonWithType:UIButtonTypeCustom]; + [cs enlargeTouchArea:UIEdgeInsetsMake(10, 10, 10, 10)]; + [cs setImage:kImage(@"login_custom_servise") forState:UIControlStateNormal]; + [cs addTarget:self + action:@selector(rightButtonTapped) + forControlEvents:UIControlEventTouchUpInside]; + + [fakeTopBar addSubview:cs]; + [cs mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerY.mas_equalTo(title); + make.width.height.mas_equalTo(18); + if (isMSRTL()) { + make.left.mas_equalTo(fakeTopBar).offset(16); + } else { + make.right.mas_equalTo(fakeTopBar).offset(-16); + } + }]; +} + +- (void)customLayout { + [self.submitButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerX.mas_equalTo(self.view); + make.bottom.mas_equalTo(self.view).offset(-40); + make.left.mas_equalTo(36); + make.right.mas_equalTo(-36); + make.height.mas_equalTo(49); + }]; + + [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.fakeTopBar.mas_bottom).offset(0); + make.left.right.mas_equalTo(self.view); + make.bottom.mas_equalTo(self.submitButton.mas_top).offset(-8); + }]; + + [self.scrollContentView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.scrollView); + }]; + + [self.title_1 mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.scrollContentView).offset(30); + if (isMSRTL()) { + make.right.mas_equalTo(self.scrollContentView).offset(-16); + } else { + make.left.mas_equalTo(self.scrollContentView).offset(16); + } + }]; + + [self.typeCollectionView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.title_1.mas_bottom).offset(18); + make.left.mas_equalTo(self.scrollContentView).offset(16); + make.right.mas_equalTo(self.scrollContentView).offset(-16); + make.height.mas_equalTo(31); + make.width.mas_equalTo(KScreenWidth - 32); + }]; + + [self.closeKeyboardButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.typeCollectionView.mas_bottom); + make.bottom.left.right.mas_equalTo(self.scrollContentView); + }]; + + [self.title_2 mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.typeCollectionView.mas_bottom).offset(31); + if (isMSRTL()) { + make.right.mas_equalTo(self.scrollContentView).offset(-16); + } else { + make.left.mas_equalTo(self.scrollContentView).offset(16); + } + }]; + + [self.feedbackTextView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.title_2.mas_bottom).offset(18); + make.left.mas_equalTo(self.scrollContentView).offset(16); + make.right.mas_equalTo(self.scrollContentView).offset(-16); + make.height.mas_equalTo(150); + }]; + + [self.feedbackPlaceholderLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.feedbackTextView).offset(8); + if (isMSRTL()) { + make.right.mas_equalTo(self.feedbackTextView).offset(-8); + } else { + make.left.mas_equalTo(self.feedbackTextView).offset(8); + } + }]; + + [self.feedbackCharLimitLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.bottom.mas_equalTo(self.feedbackTextView).offset(-8); + make.width.mas_equalTo(40); + if (isMSRTL()) { + make.left.mas_equalTo(self.feedbackTextView).offset(8); + } else { + make.right.mas_equalTo(self.feedbackTextView).offset(-8); + } + }]; + + [self.feedbackCharCountLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.bottom.mas_equalTo(self.feedbackTextView).offset(-8); + if (isMSRTL()) { + make.left.mas_equalTo(self.feedbackCharLimitLabel.mas_right).offset(0); + } else { + make.right.mas_equalTo(self.feedbackCharLimitLabel.mas_left).offset(0); + } + }]; + + [self.title_3 mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.feedbackTextView.mas_bottom).offset(31); + if (isMSRTL()) { + make.right.mas_equalTo(self.scrollContentView).offset(-16); + } else { + make.left.mas_equalTo(self.scrollContentView).offset(16); + } + }]; + + [self.uploadImageButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.title_3.mas_bottom).offset(18); + make.width.height.mas_equalTo(76); + if (isMSRTL()) { + make.right.mas_equalTo(self.scrollContentView).offset(-16); + } else { + make.left.mas_equalTo(self.scrollContentView).offset(16); + } + }]; + + [self.uploadImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.uploadImageButton); + }]; + + [self.title_4 mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.uploadImageButton.mas_bottom).offset(31); + if (isMSRTL()) { + make.right.mas_equalTo(self.scrollContentView).offset(-16); + } else { + make.left.mas_equalTo(self.scrollContentView).offset(16); + } + }]; + + [self.contactTextField mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.scrollContentView).offset(16); + make.right.mas_equalTo(self.scrollContentView).offset(-16); + make.top.mas_equalTo(self.title_4.mas_bottom).offset(17.5); + make.bottom.mas_equalTo(self.scrollContentView).offset (-30); + make.height.mas_equalTo(43.5); + }]; +} + +- (void)updateSubmitButtonStatus { + if (self.selectTypeModel == nil) { + [self.submitButton setSelected:NO]; + } else if(self.feedbackTextView.text.length == 0) { + [self.submitButton setSelected:NO]; + } else if(self.contactTextField.text.length == 0) { + [self.submitButton setSelected:NO]; + } else { + [self.submitButton setSelected:YES]; + } +} + +- (void)showPhotoSelectionSheet { + @kWeakify(self); + TTActionSheetConfig *cameraConfig = [TTActionSheetConfig normalTitle:YMLocalizedString(@"XPMineUserInfoEditViewController1") clickAction:^{ + [YYUtility checkCameraAvailable:^{ + @kStrongify(self); + UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; + imagePicker.delegate = self; + imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; + imagePicker.allowsEditing = NO; + [self presentViewController:imagePicker animated:YES completion:NULL]; + } denied:^{ + @kStrongify(self); + [self showNotPhoto:YMLocalizedString(@"XPMineUserInfoEditViewController2") content:YMLocalizedString(@"XPMineUserInfoEditViewController3")]; + } restriction:^{ + @kStrongify(self); + [self showNotPhoto:YMLocalizedString(@"XPMineUserInfoEditViewController4") content:YMLocalizedString(@"XPMineUserInfoEditViewController5")]; + }]; + }]; + + TTActionSheetConfig *photoLibrayConfig = [TTActionSheetConfig normalTitle:YMLocalizedString(@"XPMineUserInfoEditViewController6") clickAction:^{ + [YYUtility checkAssetsLibrayAvailable:^{ + @kStrongify(self); + UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; + imagePicker.modalPresentationCapturesStatusBarAppearance = YES; + imagePicker.delegate = self; + imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; + imagePicker.allowsEditing = NO; + [self presentViewController:imagePicker animated:YES completion:NULL]; + } denied:^{ + @kStrongify(self); + [self showNotPhoto:YMLocalizedString(@"XPMineUserInfoEditViewController7") content:YMLocalizedString(@"XPMineUserInfoEditViewController8")]; + } restriction:^{ + @kStrongify(self); + [self showNotPhoto:YMLocalizedString(@"XPMineUserInfoEditViewController9") content:YMLocalizedString(@"XPMineUserInfoEditViewController10")]; + }]; + }]; + + [TTPopup actionSheetWithItems:@[cameraConfig, photoLibrayConfig]]; +} + +- (void)showNotPhoto:(NSString *)title content:(NSString *)content { + TTAlertConfig *config = [[TTAlertConfig alloc] init]; + config.title = title; + config.message = content; + + [TTPopup alertWithConfig:config confirmHandler:^{ + NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; + if ([[UIApplication sharedApplication] canOpenURL:url]) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { + + }]; + } + } cancelHandler:^{ + }]; +} + +#pragma mark - UX Actions +- (void)didTapBackButton { + [self.navigationController popViewControllerAnimated:YES]; +} + +- (IBAction)didTapUploadImageButton:(id)sender { + [self showPhotoSelectionSheet]; +} + +- (IBAction)didTapSubmitButton:(id)sender { + if (self.submitButton.isSelected) { + [self uploadAvatar]; + } +} +- (IBAction)didTapCloseKeyboardButton:(id)sender { + [self.view endEditing:YES]; +} + +- (void)rightButtonTapped { + FeedBackContactPopUp *popUp = [[FeedBackContactPopUp alloc] initWithFrame:CGRectMake(0, + 0, + 290, + [FeedBackContactPopUp popUpHeight:self.configModel.customContactMap])]; + [popUp setContactDic:self.configModel.customContactMap]; + [TTPopup popupView:popUp style:TTPopupStyleAlert]; +} + +#pragma mark - API +- (void)loadFeedbackConfig { + [self showLoading]; + @kWeakify(self); + [self.presenter loadFeedbackConfig:^(FeedBackConfigModel * _Nonnull model) { + @kStrongify(self); + [self hideHUD]; + self.configModel = model; + [self.typeCollectionView reloadData]; + [self updateCollectionViewHeight]; + } failure:^(NSString * _Nonnull errorMessage) { + @kStrongify(self); + [self hideHUD]; + [TTPopup alertWithMessage:errorMessage confirmHandler:^{ + + } cancelHandler:^{ + + }]; + }]; +} + +- (void)uploadAvatar { + [self showLoading]; + if (self.selectedImage) { + @kWeakify(self); + NSData *data = UIImageJPEGRepresentation(self.selectedImage, 0.5); + NSString *format = [UIImage getImageTypeWithImageData:data]; + NSString *name = [NSString stringWithFormat:@"image/%@.%@",[NSString createUUID],format]; + [[UploadFile share]QCloudUploadImage:data named:name success:^(NSString * _Nonnull key, NSDictionary * _Nonnull resp) { + @kStrongify(self); + self.uploadPhotoURLString = key; + [self submitFeedBack]; + } failure:^(NSNumber * _Nonnull resCode, NSString * _Nonnull message) { + @kStrongify(self); + [self showErrorToast:message]; + }]; + } else { + [self submitFeedBack]; + } +} + +- (void)submitFeedBack { + @kWeakify(self); + dispatch_async(dispatch_get_main_queue(), ^{ + @kStrongify(self); + @kWeakify(self); + [self.presenter submitFeedback:^{ + @kStrongify(self); + [self showSuccessToast:YMLocalizedString(@"XPMineFeedbackViewController1")]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self.navigationController popViewControllerAnimated:YES]; + }); + } failure:^(NSString * _Nonnull errorMessage) { + @kStrongify(self); + [self showErrorToast:errorMessage]; + } + type:self.selectTypeModel.type + desc:self.feedbackTextView.text + photoURLString:self.uploadPhotoURLString + contact:self.contactTextField.text]; + }); + +} + +#pragma mark - UICollectionView Delegate & DataSource +- (void)updateCollectionViewHeight { + [self.typeCollectionView layoutIfNeeded]; + CGSize contentSize = self.typeCollectionView.collectionViewLayout.collectionViewContentSize; + [self.typeCollectionView mas_updateConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(contentSize.height); + }]; +} + +// 返回 section 中的 item 数量 +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { + return self.configModel.typeEnumList.count; // 根据你的需求返回实际数量 +} + +- (CGSize)collectionView:(UICollectionView *)collectionView + layout:(UICollectionViewLayout*)collectionViewLayout + sizeForItemAtIndexPath:(NSIndexPath *)indexPath { + CGFloat padding = 24.0; + CGFloat totalPadding = padding * 2 + padding * 2; // 左右两边的间距 + 中间两个间距 + CGFloat availableWidth = collectionView.frame.size.width - totalPadding; + CGFloat itemWidth = availableWidth / 3; + return CGSizeMake(itemWidth, 31); +} + +- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section { + return 14.0; +} + +- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section { + return 24.0; +} + +// 返回 cell +- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { + TypeCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath]; + cell.contentView.layer.cornerRadius = 15.5; + cell.contentView.layer.masksToBounds = YES; + + FeedBackTypeModel *model = [self.configModel.typeEnumList xpSafeObjectAtIndex:indexPath.row]; + if (model) { + cell.titleLabel.text = model.desc; + } + return cell; +} + +// 处理 cell 的选中状态 +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { + TypeCollectionCell *cell = (TypeCollectionCell *)[collectionView cellForItemAtIndexPath:indexPath]; + [cell setSelected:YES]; + + // 取消其他 cell 的选中状态 + for (NSIndexPath *visibleIndexPath in [collectionView indexPathsForVisibleItems]) { + if (![visibleIndexPath isEqual:indexPath]) { + [collectionView deselectItemAtIndexPath:visibleIndexPath animated:NO]; + TypeCollectionCell *otherCell = (TypeCollectionCell *)[collectionView cellForItemAtIndexPath:visibleIndexPath]; + [otherCell setSelected:NO]; + } + } + + FeedBackTypeModel *model = [self.configModel.typeEnumList xpSafeObjectAtIndex:indexPath.row]; + if (model) { + self.selectTypeModel = model; + [self updateSubmitButtonStatus]; + } +} + +// 处理 cell 的取消选中状态 +- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath { + TypeCollectionCell *cell = (TypeCollectionCell *)[collectionView cellForItemAtIndexPath:indexPath]; + [cell setSelected:NO]; +} + +#pragma mark - UIImagePickerControllerDelegate +- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info +{ + UIImage *selectedPhoto = [info objectForKey:UIImagePickerControllerOriginalImage]; + if (selectedPhoto) { + if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) { + UIImageWriteToSavedPhotosAlbum(selectedPhoto, nil, nil, nil); + } + self.selectedImage = selectedPhoto; + self.uploadImageView.hidden = NO; + self.uploadImageView.image = selectedPhoto; +// [self.uploadImageButton setBackgroundImage:selectedPhoto forState:UIControlStateNormal]; +// [self.uploadImageButton setImage:selectedPhoto forState:UIControlStateNormal]; + } + [picker dismissViewControllerAnimated:YES + completion:^{}]; +} + +- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{ + [picker dismissViewControllerAnimated:YES + completion:^{}]; +} + +#pragma mark - UITextViewDelegate +- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { + + NSString *newText = [textView.text stringByReplacingCharactersInRange:range withString:text]; + + self.feedbackCharCountLabel.text = [NSString stringWithFormat:@"%ld", (unsigned long)newText.length]; + + self.feedbackPlaceholderLabel.hidden = newText.length > 0; + self.feedbackCharCountLabel.textColor = newText.length > 0 ? + UIColorFromRGB(0x3fddac) : UIColorFromRGB(0xa7acb3); + + [self updateSubmitButtonStatus]; + + if (newText.length > 300) { + return NO; + } + + return YES; +} + + + +@end diff --git a/YuMi/Modules/YMLogin/View/FeedBackViewController.xib b/YuMi/Modules/YMLogin/View/FeedBackViewController.xib new file mode 100644 index 00000000..69bdeb11 --- /dev/null +++ b/YuMi/Modules/YMLogin/View/FeedBackViewController.xib @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/YuMi/Modules/YMLogin/View/NewLogin/XPLoginViewController.m b/YuMi/Modules/YMLogin/View/NewLogin/XPLoginViewController.m index 842e575a..1f686157 100644 --- a/YuMi/Modules/YMLogin/View/NewLogin/XPLoginViewController.m +++ b/YuMi/Modules/YMLogin/View/NewLogin/XPLoginViewController.m @@ -31,6 +31,7 @@ #import "XPLoginAraeViewController.h" #import "XPForgetPwdViewController.h" #import "PISwitchingEnvironmentVC.h" +#import "FeedBackViewController.h" UIKIT_EXTERN NSString * const kYouMiNumberCountKey; NSString * const HadAgreePrivacy = @"HadAgreePrivacy"; @@ -491,7 +492,8 @@ NSString * const HadAgreePrivacy = @"HadAgreePrivacy"; } - (void)didTapFeedback { - + FeedBackViewController *vc = [[FeedBackViewController alloc] init]; + [self.navigationController pushViewController:vc animated:YES]; } #pragma mark - LoginProtocol @@ -905,12 +907,14 @@ NSString * const HadAgreePrivacy = @"HadAgreePrivacy"; - (UIButton *)feedBackButton { if (!_feedBackButton) { _feedBackButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_feedBackButton setTitle:@"反馈" forState:UIControlStateNormal]; +// [_feedBackButton setBackgroundImage:kImage(@"login_custom_servise") forState:UIControlStateNormal]; + [_feedBackButton setTitle:YMLocalizedString(@"XPMineFeedbackViewController0") forState:UIControlStateNormal]; [_feedBackButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; _feedBackButton.titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightBold]; [_feedBackButton addTarget:self action:@selector(didTapFeedback) forControlEvents:UIControlEventTouchUpInside]; + [_feedBackButton enlargeTouchArea:UIEdgeInsetsMake(10, 10, 10, 10)]; } return _feedBackButton; } diff --git a/YuMi/ar.lproj/Localizable.strings b/YuMi/ar.lproj/Localizable.strings index 7f67a5f1..451cbad2 100644 --- a/YuMi/ar.lproj/Localizable.strings +++ b/YuMi/ar.lproj/Localizable.strings @@ -3852,3 +3852,12 @@ ineHeadView12" = "الحمل"; "XPRoomTypeSelectionViewController3" = "بعد الإعداد، ستتم إزالة الأعضاء الذين يتجاوزون خارج الترتيب علي المايك ؛ هل تريد تأكيد الإعداد ؟"; "XPRoomTypeSelectionViewController4" = "نوع الغرفة"; "XPRoomTypeSelectionViewController5" = "قيد الاستخدام"; + + +"FeedBackViewController0" = "اختر نوع المشكلة"; +"FeedBackViewController1" = "صف المشكلة"; +"FeedBackViewController2" = "تحميل لقطة شاشة"; +"FeedBackViewController3" = "وسيلة تواصل"; +"FeedBackViewController4" = "من فضلك ادخل"; +"FeedBackViewController5" = " رقم الهاتف او البريد الالكتروني"; + diff --git a/YuMi/en.lproj/Localizable.strings b/YuMi/en.lproj/Localizable.strings index bfd64d90..5796c528 100644 --- a/YuMi/en.lproj/Localizable.strings +++ b/YuMi/en.lproj/Localizable.strings @@ -3652,3 +3652,10 @@ "XPRoomTypeSelectionViewController3" = "After the setting is completed, members who are out of the microphone order will be removed. Do you confirm the setting?"; "XPRoomTypeSelectionViewController4" = "Room type"; "XPRoomTypeSelectionViewController5" = "Using"; + +"FeedBackViewController0" = "choose the problem type"; +"FeedBackViewController1" = "describe the problem"; +"FeedBackViewController2" = "upload screenshot"; +"FeedBackViewController3" = "contact information"; +"FeedBackViewController4" = "Please enter..."; +"FeedBackViewController5" = "Mobile phone number or email"; diff --git a/YuMi/zh-Hans.lproj/Localizable.strings b/YuMi/zh-Hans.lproj/Localizable.strings index 44222941..4b820545 100644 --- a/YuMi/zh-Hans.lproj/Localizable.strings +++ b/YuMi/zh-Hans.lproj/Localizable.strings @@ -3315,3 +3315,11 @@ "XPRoomTypeSelectionViewController3" = "设置后将移除超出麦序的成员,确认设置?"; "XPRoomTypeSelectionViewController4" = "房間類型"; "XPRoomTypeSelectionViewController5" = "使用中"; + +"FeedBackViewController0" = "選擇問題類型"; +"FeedBackViewController1" = "問題描述"; +"FeedBackViewController2" = "上傳截圖"; +"FeedBackViewController3" = "聯係方式"; +"FeedBackViewController4" = "請輸入…"; +"FeedBackViewController5" = "手機號或郵箱"; + diff --git a/YuMi/zh-Hant.lproj/Localizable.strings b/YuMi/zh-Hant.lproj/Localizable.strings index 8f75cb30..0b4f4283 100644 --- a/YuMi/zh-Hant.lproj/Localizable.strings +++ b/YuMi/zh-Hant.lproj/Localizable.strings @@ -3305,3 +3305,10 @@ "XPRoomTypeSelectionViewController3" = "设置后将移除超出麦序的成员,确认设置?"; "XPRoomTypeSelectionViewController4" = "房間類型"; "XPRoomTypeSelectionViewController5" = "使用中"; + +"FeedBackViewController0" = "選擇問題類型"; +"FeedBackViewController1" = "問題描述"; +"FeedBackViewController2" = "上傳截圖"; +"FeedBackViewController3" = "聯係方式"; +"FeedBackViewController4" = "請輸入…"; +"FeedBackViewController5" = "手機號或郵箱";