Skip to content

Commit e9b0e4b

Browse files
committed
分享面板 - 改成 定高&滑动 的
1 parent abe655b commit e9b0e4b

4 files changed

Lines changed: 77 additions & 13 deletions

File tree

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211
4E5D13151C0EDFE700985AEB /* SendRewardManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E5D13141C0EDFE700985AEB /* SendRewardManager.m */; };
212212
4E5D13181C0EF48200985AEB /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4E5D13161C0EF48200985AEB /* [email protected] */; };
213213
4E5D13191C0EF48200985AEB /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4E5D13171C0EF48200985AEB /* [email protected] */; };
214+
4E5D131B1C11865D00985AEB /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4E5D131A1C11865D00985AEB /* [email protected] */; };
214215
4E5F39021AC951060010515D /* TaskCommentCCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E5F39011AC951060010515D /* TaskCommentCCell.m */; };
215216
4E5F39051ACA958C0010515D /* TopicCommentCCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E5F39041ACA958C0010515D /* TopicCommentCCell.m */; };
216217
4E5F39071ACBFDCD0010515D /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4E5F39061ACBFDCD0010515D /* [email protected] */; };
@@ -1307,6 +1308,7 @@
13071308
4E5D13141C0EDFE700985AEB /* SendRewardManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SendRewardManager.m; sourceTree = "<group>"; };
13081309
4E5D13161C0EF48200985AEB /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
13091310
4E5D13171C0EF48200985AEB /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
1311+
4E5D131A1C11865D00985AEB /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
13101312
4E5F39001AC951060010515D /* TaskCommentCCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TaskCommentCCell.h; sourceTree = "<group>"; };
13111313
4E5F39011AC951060010515D /* TaskCommentCCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TaskCommentCCell.m; sourceTree = "<group>"; };
13121314
4E5F39031ACA958C0010515D /* TopicCommentCCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopicCommentCCell.h; sourceTree = "<group>"; };
@@ -2747,6 +2749,7 @@
27472749
4E2BF3CC1B96CDF800A5A0A8 /* [email protected] */,
27482750
4E2BF3CD1B96CDF800A5A0A8 /* [email protected] */,
27492751
4E2BF3CE1B96CDF800A5A0A8 /* [email protected] */,
2752+
4E5D131A1C11865D00985AEB /* [email protected] */,
27502753
);
27512754
path = share_btn;
27522755
sourceTree = "<group>";
@@ -5429,6 +5432,7 @@
54295432
4E2719C71AB07ED6006AE214 /* [email protected] in Resources */,
54305433
4E2DB34D1BA6AEB4002F27C4 /* [email protected] in Resources */,
54315434
4E8F92DF1B67BE3C00033D8F /* [email protected] in Resources */,
5435+
4E5D131B1C11865D00985AEB /* [email protected] in Resources */,
54325436
8E64ED8B19EE484A006E99DA /* README.textile in Resources */,
54335437
8E97CE9D1A0C7E26006F9AD7 /* [email protected] in Resources */,
54345438
4E0849821A918A7F00BD27F6 /* [email protected] in Resources */,
-3.3 KB
Loading
11.4 KB
Loading

Coding_iOS/Views/CodingShareView.m

Lines changed: 73 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,28 @@
77
//
88

99
#define kCodingShareView_NumPerLine 4
10+
#define kCodingShareView_NumPerScroll (2 * kCodingShareView_NumPerLine)
1011
#define kCodingShareView_TopHeight 60.0
11-
#define kCodingShareView_BottomHeight 60.0
12+
#define kCodingShareView_BottomHeight 65.0
1213

1314
#import "CodingShareView.h"
15+
#import "SMPageControl.h"
1416
#import <UMengSocial/UMSocial.h>
1517
#import <evernote-cloud-sdk-ios/ENSDK/ENSDK.h>
1618

1719
#import "PrivateMessage.h"
1820
#import "UsersViewController.h"
1921
#import "Coding_NetAPIManager.h"
22+
#import "ReportIllegalViewController.h"
23+
2024

2125
@interface CodingShareView ()<UMSocialUIDelegate>
2226
@property (strong, nonatomic) UIView *bgView;
2327
@property (strong, nonatomic) UIView *contentView;
2428
@property (strong, nonatomic) UILabel *titleL;
2529
@property (strong, nonatomic) UIButton *dismissBtn;
2630
@property (strong, nonatomic) UIScrollView *itemsScrollView;
31+
@property (strong, nonatomic) SMPageControl *myPageControl;
2732

2833
@property (strong, nonatomic) NSArray *shareSnsValues;
2934
@property (weak, nonatomic) NSObject *objToShare;
@@ -92,6 +97,9 @@ - (instancetype)init
9297
if (!_itemsScrollView) {
9398
_itemsScrollView = ({
9499
UIScrollView *scrollView = [UIScrollView new];
100+
scrollView.pagingEnabled = YES;
101+
scrollView.showsHorizontalScrollIndicator = NO;
102+
scrollView.showsVerticalScrollIndicator = NO;
95103
scrollView;
96104
});
97105
[_contentView addSubview:_itemsScrollView];
@@ -108,25 +116,69 @@ - (instancetype)init
108116
return self;
109117
}
110118

119+
- (SMPageControl *)myPageControl{
120+
if (!_myPageControl) {
121+
_myPageControl = ({
122+
SMPageControl *pageControl = [[SMPageControl alloc] init];
123+
pageControl.userInteractionEnabled = NO;
124+
pageControl.backgroundColor = [UIColor clearColor];
125+
pageControl.pageIndicatorImage = [UIImage imageNamed:@"banner__page_unselected"];
126+
pageControl.currentPageIndicatorImage = [UIImage imageNamed:@"banner__page_selected"];
127+
pageControl;
128+
});
129+
[self addSubview:_myPageControl];
130+
[_myPageControl mas_makeConstraints:^(MASConstraintMaker *make) {
131+
make.left.right.equalTo(_contentView);
132+
make.height.mas_equalTo(10);
133+
make.bottom.equalTo(_dismissBtn.mas_top).offset(-10);
134+
}];
135+
136+
[RACObserve(self, itemsScrollView.contentOffset) subscribeNext:^(NSValue *point) {
137+
CGPoint contentOffset;
138+
[point getValue:&contentOffset];
139+
CGFloat pageWidth = kScreen_Width;
140+
NSUInteger page = MAX(0, floor((contentOffset.x + (pageWidth / 2)) / pageWidth));
141+
if (page != self.myPageControl.currentPage) {
142+
self.myPageControl.currentPage = page;
143+
}
144+
}];
145+
}
146+
return _myPageControl;
147+
}
148+
111149
- (void)setShareSnsValues:(NSArray *)shareSnsValues{
112150
if (![_shareSnsValues isEqualToArray:shareSnsValues]) {
113151
_shareSnsValues = shareSnsValues;
114152
[[_itemsScrollView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
115153
for (int index = 0; index < _shareSnsValues.count; index++) {
154+
NSInteger scrollIndex = index/kCodingShareView_NumPerScroll;
155+
NSInteger itemIndex = index % kCodingShareView_NumPerScroll;
156+
CGPoint pointO = CGPointZero;
157+
pointO.x = [CodingShareView_Item itemWidth] * (itemIndex % kCodingShareView_NumPerLine) + kScreen_Width * scrollIndex;
158+
pointO.y = [CodingShareView_Item itemHeight] * (itemIndex / kCodingShareView_NumPerLine);
159+
116160
NSString *snsName = _shareSnsValues[index];
117161
CodingShareView_Item *item = [CodingShareView_Item itemWithSnsName:snsName];
118-
CGPoint pointO = CGPointZero;
119-
pointO.x = [CodingShareView_Item itemWidth] * (index%kCodingShareView_NumPerLine);
120-
pointO.y = [CodingShareView_Item itemHeight] * (index/kCodingShareView_NumPerLine);
121162
[item setOrigin:pointO];
122163
item.clickedBlock = ^(NSString *snsName){
123164
[self p_shareItemClickedWithSnsName:snsName];
124165
};
125166
[_itemsScrollView addSubview:item];
126167
}
127-
CGFloat contentHeight = kCodingShareView_TopHeight + kCodingShareView_BottomHeight + ((_shareSnsValues.count - 1)/kCodingShareView_NumPerLine + 1)* [CodingShareView_Item itemHeight];
168+
CGFloat scrollPageNum = 1 + (_shareSnsValues.count/kCodingShareView_NumPerScroll);
169+
[_itemsScrollView setContentSize:CGSizeMake(scrollPageNum * kScreen_Width, 2* [CodingShareView_Item itemHeight])];
170+
_itemsScrollView.scrollEnabled = scrollPageNum > 1;
171+
172+
if (scrollPageNum > 1) {
173+
self.myPageControl.numberOfPages = scrollPageNum;
174+
self.myPageControl.hidden = NO;
175+
}else{
176+
_myPageControl.hidden = YES;
177+
}
178+
CGFloat contentHeight = kCodingShareView_TopHeight + kCodingShareView_BottomHeight + 2* [CodingShareView_Item itemHeight];
128179
[self.contentView setSize:CGSizeMake(kScreen_Width, contentHeight)];
129180
}
181+
[_itemsScrollView setContentOffset:CGPointZero];
130182
}
131183

132184
#pragma mark common M
@@ -152,6 +204,7 @@ + (NSDictionary *)snsNameDict{
152204
@"qq": @"QQ好友",
153205
@"wxtimeline": @"朋友圈",
154206
@"wxsession": @"微信好友",
207+
@"inform": @"举报",
155208
};
156209
});
157210
return snsNameDict;
@@ -172,25 +225,26 @@ +(NSArray *)supportSnsValues{
172225
@"evernote",
173226
@"coding",
174227
@"copylink",
228+
@"inform",
175229
] mutableCopy];
176-
if (![self p_canOpen:@"weixin://"]) {
230+
if (![self p_canOpen:@"weixin://"] && rand()%2) {
177231
[resultSnsValues removeObjectsInArray:@[
178232
@"wxsession",
179233
@"wxtimeline",
180234
]];
181235
}
182-
if (![self p_canOpen:@"mqqapi://"]) {
236+
if (![self p_canOpen:@"mqqapi://"] && rand()%2) {
183237
[resultSnsValues removeObjectsInArray:@[
184238
@"qq",
185239
@"qzone",
186240
]];
187241
}
188-
if (![self p_canOpen:@"weibosdk://request"]) {
189-
[resultSnsValues removeObjectsInArray:@[@"sina"]];
190-
}
191-
if (![self p_canOpen:@"evernote://"]) {
192-
[resultSnsValues removeObjectsInArray:@[@"evernote"]];
193-
}
242+
// if (![self p_canOpen:@"weibosdk://request"]) {
243+
// [resultSnsValues removeObjectsInArray:@[@"sina"]];
244+
// }
245+
// if (![self p_canOpen:@"evernote://"]) {
246+
// [resultSnsValues removeObjectsInArray:@[@"evernote"]];
247+
// }
194248
return resultSnsValues;
195249
}
196250

@@ -265,6 +319,8 @@ - (void)p_doShareToSnsName:(NSString *)snsName{
265319
}else if ([snsName isEqualToString:@"coding"]){
266320
PrivateMessage *curMsg = [PrivateMessage privateMessageWithObj:[self p_shareLinkStr] andFriend:nil];
267321
[self willTranspondMessage:curMsg];
322+
}else if ([snsName isEqualToString:@"inform"]){
323+
[self goToInform];
268324
}else if ([snsName isEqualToString:@"evernote"]){
269325
__weak typeof(self) weakSelf = self;
270326
[self p_shareENNoteWithompletion:^(ENNote *note) {
@@ -404,6 +460,10 @@ - (void)doTranspondMessage:(PrivateMessage *)curMessage{
404460
}];
405461
}
406462

463+
- (void)goToInform{
464+
[ReportIllegalViewController showReportWithIllegalContent:[self p_shareLinkStr] andType:IllegalContentTypeWebsite];
465+
}
466+
407467
#pragma mark UMSocialUIDelegate
408468
-(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response{
409469
NSLog(@"didFinishGetUMSocialDataInViewController : %@",response);

0 commit comments

Comments
 (0)