This commit is contained in:
Yao
2025-01-11 15:54:19 +08:00
parent 1095c32599
commit 36ca0e65b5
8 changed files with 63 additions and 28 deletions

View File

@@ -30,7 +30,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "20B61C7729DC008500CE7946"
BuildableName = "Tinju55.app"
BuildableName = "TESTAPP.app"
BlueprintName = "ShenQi"
ReferencedContainer = "container:ShenQi.xcodeproj">
</BuildableReference>
@@ -61,7 +61,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "20B61C7729DC008500CE7946"
BuildableName = "Tinju55.app"
BuildableName = "TESTAPP.app"
BlueprintName = "ShenQi"
ReferencedContainer = "container:ShenQi.xcodeproj">
</BuildableReference>
@@ -80,7 +80,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "20B61C7729DC008500CE7946"
BuildableName = "Tinju55.app"
BuildableName = "TESTAPP.app"
BlueprintName = "ShenQi"
ReferencedContainer = "container:ShenQi.xcodeproj">
</BuildableReference>

View File

@@ -15,7 +15,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "20B61C7729DC008500CE7946"
BuildableName = "Tinju55.app"
BuildableName = "TESTAPP.app"
BlueprintName = "ShenQi"
ReferencedContainer = "container:ShenQi.xcodeproj">
</BuildableReference>
@@ -31,7 +31,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
@@ -45,7 +45,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "20B61C7729DC008500CE7946"
BuildableName = "Tinju55.app"
BuildableName = "TESTAPP.app"
BlueprintName = "ShenQi"
ReferencedContainer = "container:ShenQi.xcodeproj">
</BuildableReference>
@@ -62,7 +62,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "20B61C7729DC008500CE7946"
BuildableName = "Tinju55.app"
BuildableName = "TESTAPP.app"
BlueprintName = "ShenQi"
ReferencedContainer = "container:ShenQi.xcodeproj">
</BuildableReference>

View File

@@ -21,6 +21,7 @@
#import "MainOldViewController.h"
#import "LaunchViewController.h"
#import "NotiCenterViewController.h"
@interface AppDelegate () <FIRMessagingDelegate,UNUserNotificationCenterDelegate>
@@ -223,6 +224,11 @@
NSString *jumpUrl = [messageNotiDic objectForKey:@"jumpUrl"];
NSInteger pushId = [[messageNotiDic objectForKey:@"pushId"] longValue];
NotiCenterViewController *notiCenterViewController = [[NotiCenterViewController alloc] initWithNibName:@"NotiCenterViewController" bundle:nil];
notiCenterViewController.modalPresentationStyle = UIModalPresentationFullScreen;
notiCenterViewController.pushId = pushId;
[self.window.rootViewController presentViewController:notiCenterViewController animated:NO completion:nil];
// pushId
if (pushId > 0) {
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:PushStatisticsURL]];
@@ -238,6 +244,7 @@
}];
[dataTask resume];
}
/*
if (type == 2 && !ISNULLSTR(image)) {
dispatch_async(dispatch_get_main_queue(), ^{
NSURL *url = [NSURL URLWithString:image];
@@ -266,6 +273,7 @@
[self.window.rootViewController presentViewController:view animated:YES completion:^{}];
});
}
*/
}
}
}

View File

@@ -26,7 +26,7 @@
NSURL *url = [NSURL URLWithString:self.list.image];
self.contentLabel.text = self.list.content;
self.imageHeightConstraint.constant = self.list.imageHeight;
[self.contentImageView sd_setImageWithURL:url];
[self.contentImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"zhanwei"]];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {

View File

@@ -36,7 +36,7 @@
}
UIFont *textFont = [UIFont boldSystemFontOfSize:15];
CGFloat width = [self.typeLabel.text boundingRectWithSize:CGSizeMake(MAXFLOAT, 30) options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName: textFont} context:nil].size.width;
self.widthConstraint.constant = width+20;
self.widthConstraint.constant = width+10;
self.dateLabel.text = self.list.createTime;
self.titleLabel.text = self.list.title;
}

View File

@@ -11,6 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface NotiCenterViewController : UIViewController
@property (nonatomic, assign) NSInteger pushId;
@end
NS_ASSUME_NONNULL_END

View File

@@ -17,6 +17,7 @@
#import <SDWebImage.h>
#import "DataModels.h"
#import "UIButton+DSButtonBlock.h"
#import <MJRefresh.h>
#import "MainOldViewController.h"
@@ -32,6 +33,8 @@ static NSString *linkidentifier = @"NotiCenterJumpLinkTableViewCell";
@property (nonatomic, strong) NSString *mainUserId;
@property (nonatomic, strong) NSMutableArray *notiArray;
@property (nonatomic, assign) NSInteger page;
@end
@implementation NotiCenterViewController
@@ -56,16 +59,22 @@ static NSString *linkidentifier = @"NotiCenterJumpLinkTableViewCell";
[self.tableView registerNib:[UINib nibWithNibName:@"NotiCenterContentTableViewCell" bundle:nil] forCellReuseIdentifier:contentidentifier];
[self.tableView registerNib:[UINib nibWithNibName:@"NotiCenterImageTableViewCell" bundle:nil] forCellReuseIdentifier:imageidentifier];
[self.tableView registerNib:[UINib nibWithNibName:@"NotiCenterJumpLinkTableViewCell" bundle:nil] forCellReuseIdentifier:linkidentifier];
self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
self.notiArray = @[].mutableCopy;
self.page = 1;
[self refreshDatasource];
}];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.tableFooterView = [UIView new];
self.notiArray = @[].mutableCopy;
[self setupDatasource];
self.page = 1;
[self refreshDatasource];
}
-(void)setupDatasource
-(void)refreshDatasource
{
NSString *urlstring = [NSString stringWithFormat:@"%@?userId=%@&page=1&size=100",PushRecordsURL,self.mainUserId];
NSString *urlstring = [NSString stringWithFormat:@"%@?userId=%@&page=%ld&size=20",PushRecordsURL,self.mainUserId,(long)self.page];
NSURL *url = [NSURL URLWithString:urlstring];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
@@ -85,17 +94,28 @@ static NSString *linkidentifier = @"NotiCenterJumpLinkTableViewCell";
}else{
if (ISNULL(error) && !ISNULL(responseObject) && [[responseObject objectForKey:@"code"] integerValue] == 1) {
PushRecordDataModel *model = [[PushRecordDataModel alloc] initWithDictionary:responseObject];
for (PushRecordList *list in self.notiArray) {
for (PushRecordList *list in model.data.list) {
if (list.type == 2) {
list.imageHeight = SCREEN_WIDTH-30;
}
}
[self.notiArray addObjectsFromArray:model.data.list];
if (model.data.list.count == 20) {
self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
self.page++;
[self refreshDatasource];
}];
}else{
self.tableView.mj_footer = nil;
}
[self.tableView reloadData];
[self refreshImageDatasource];
[self scrollViewToRecordIDSection];
}
}
}
[self.tableView.mj_header endRefreshing];
[self.tableView.mj_footer endRefreshing];
});
}];
[dataTask resume];
@@ -103,16 +123,35 @@ static NSString *linkidentifier = @"NotiCenterJumpLinkTableViewCell";
-(void)refreshImageDatasource
{
for (PushRecordList *list in self.notiArray) {
for (NSInteger i=0; i<self.notiArray.count; i++) {
PushRecordList *list = self.notiArray[i];
NSURL *url = [NSURL URLWithString:list.image];
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:url completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
if (image && error == nil) {
list.imageHeight = (SCREEN_WIDTH-30)*image.size.height/image.size.width;
if (list.isOpen == YES) {
[self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:1 inSection:i]] withRowAnimation:(UITableViewRowAnimationNone)];
}
}
}];
}
}
-(void)scrollViewToRecordIDSection
{
if (self.pushId > 0) {
for (NSInteger i=0; i<self.notiArray.count; i++) {
PushRecordList *list = self.notiArray[i];
if (list.recordId == self.pushId) {
list.isOpen = YES;
[self.tableView reloadData];
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:i] atScrollPosition:(UITableViewScrollPositionNone) animated:YES];
break;
}
}
}
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.notiArray.count;
@@ -130,20 +169,6 @@ static NSString *linkidentifier = @"NotiCenterJumpLinkTableViewCell";
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
// PushRecordList *list = self.notiArray[indexPath.section];
// if (list.isOpen == YES) {
// if (indexPath.row == 0) {
// return UITableViewAutomaticDimension;
// }else{
// if (list.type == 2) {
// return list.imageHeight;
// }else{
// return UITableViewAutomaticDimension;
// }
// }
// }else{
// return UITableViewAutomaticDimension;
// }
return UITableViewAutomaticDimension;
}