Skip to content

Commit 5e9747f

Browse files
committed
Merge branch 'master' of github.com:reactnativecomponent/react-native-imui
2 parents f30f402 + 2425041 commit 5e9747f

22 files changed

+576
-25
lines changed

ios/RCTAuroraIMUI.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
4E77A3C81F30840000098CAF /* IMUITextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E77A3941F30840000098CAF /* IMUITextView.swift */; };
9898
4E77A3C91F30840000098CAF /* IMUIVideoMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E77A3951F30840000098CAF /* IMUIVideoMessageCell.swift */; };
9999
4E77A3CA1F30840000098CAF /* IMUIVoiceMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E77A3961F30840000098CAF /* IMUIVoiceMessageCell.swift */; };
100+
4E7F98881F56ABB500C9075D /* DWOrigImgView.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E7F98861F56ABB500C9075D /* DWOrigImgView.h */; };
101+
4E7F98891F56ABB500C9075D /* DWOrigImgView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E7F98871F56ABB500C9075D /* DWOrigImgView.m */; };
100102
4EC4F96D1F46F0B1000C5CA6 /* MenuPopOverView.h in Headers */ = {isa = PBXBuildFile; fileRef = 4EC4F96B1F46F0B1000C5CA6 /* MenuPopOverView.h */; settings = {ATTRIBUTES = (Public, ); }; };
101103
4EC4F96E1F46F0B1000C5CA6 /* MenuPopOverView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EC4F96C1F46F0B1000C5CA6 /* MenuPopOverView.m */; };
102104
623EA9A21EE55D0800EC43AE /* RCTAuroraIMUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 623EA9991EE55D0800EC43AE /* RCTAuroraIMUI.framework */; };
@@ -230,6 +232,8 @@
230232
4E77A3941F30840000098CAF /* IMUITextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IMUITextView.swift; sourceTree = "<group>"; };
231233
4E77A3951F30840000098CAF /* IMUIVideoMessageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IMUIVideoMessageCell.swift; sourceTree = "<group>"; };
232234
4E77A3961F30840000098CAF /* IMUIVoiceMessageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IMUIVoiceMessageCell.swift; sourceTree = "<group>"; };
235+
4E7F98861F56ABB500C9075D /* DWOrigImgView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWOrigImgView.h; sourceTree = "<group>"; };
236+
4E7F98871F56ABB500C9075D /* DWOrigImgView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DWOrigImgView.m; sourceTree = "<group>"; };
233237
4EC4F96B1F46F0B1000C5CA6 /* MenuPopOverView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuPopOverView.h; sourceTree = "<group>"; };
234238
4EC4F96C1F46F0B1000C5CA6 /* MenuPopOverView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MenuPopOverView.m; sourceTree = "<group>"; };
235239
6239E6641EDDB1F700B9AC9C /* libAuroraIMUI.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAuroraIMUI.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -351,6 +355,8 @@
351355
4E49ADE71F346B7500B50439 /* DWEmoticonView */ = {
352356
isa = PBXGroup;
353357
children = (
358+
4E7F98861F56ABB500C9075D /* DWOrigImgView.h */,
359+
4E7F98871F56ABB500C9075D /* DWOrigImgView.m */,
354360
4EC4F96A1F46F0B1000C5CA6 /* MenuPopOverView */,
355361
4E49AE2E1F3476F800B50439 /* NSString+NIMKit.h */,
356362
4E49AE2F1F3476F800B50439 /* NSString+NIMKit.m */,
@@ -593,6 +599,7 @@
593599
4E466FA21F3AE5480014451B /* NIMInputEmoticonParser.h in Headers */,
594600
4E49AD851F34176100B50439 /* RNCustomInputView.h in Headers */,
595601
4E49AE1A1F34760500B50439 /* NIMPageView.h in Headers */,
602+
4E7F98881F56ABB500C9075D /* DWOrigImgView.h in Headers */,
596603
4E49AD951F34178000B50439 /* DWInputBarControl.h in Headers */,
597604
4E49AD9B1F34178000B50439 /* HPTextViewInternal.h in Headers */,
598605
);
@@ -762,6 +769,7 @@
762769
4E34C33B1F3D8AB600AF4B73 /* IMUINotificationMessageCell.swift in Sources */,
763770
4E77A3A71F30840000098CAF /* CIImageExtension.swift in Sources */,
764771
4E77A3B31F30840000098CAF /* UIImageMessageListExtension.swift in Sources */,
772+
4E7F98891F56ABB500C9075D /* DWOrigImgView.m in Sources */,
765773
4E77A3C01F30840000098CAF /* IMUIBaseMessageCell.swift in Sources */,
766774
4E77A3AA1F30840000098CAF /* StringExtension.swift in Sources */,
767775
4E77A3A61F30840000098CAF /* CGRectExtension.swift in Sources */,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// DWOrigImgView.h
3+
// RCTAuroraIMUI
4+
//
5+
// Created by Dowin on 2017/8/29.
6+
// Copyright © 2017年 HXHG. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
#define screenW [UIScreen mainScreen].bounds.size.width
11+
#define screenH [UIScreen mainScreen].bounds.size.height
12+
@interface DWOrigImgView : UIView
13+
+ (instancetype)origImgViewWithDict:(NSDictionary *)dict;
14+
@end
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
//
2+
// DWOrigImgView.m
3+
// RCTAuroraIMUI
4+
//
5+
// Created by Dowin on 2017/8/29.
6+
// Copyright © 2017年 HXHG. All rights reserved.
7+
//
8+
9+
#import "DWOrigImgView.h"
10+
#import "UIView+Extend.h"
11+
#import "MyCacheImageView.h"
12+
13+
14+
@interface DWOrigImgView (){
15+
MyCacheImageView *imgView;
16+
UIPinchGestureRecognizer *pinchGest;
17+
UIPanGestureRecognizer *panGest;
18+
UITapGestureRecognizer *tapGest;
19+
CGRect orginFrame;
20+
UIButton *downBtn;
21+
22+
}
23+
24+
@end
25+
26+
@implementation DWOrigImgView
27+
28+
- (void)dealloc{
29+
[imgView removeGestureRecognizer:pinchGest];
30+
[imgView removeGestureRecognizer:panGest];
31+
[self removeGestureRecognizer:tapGest];
32+
}
33+
34+
+ (instancetype)origImgViewWithDict:(NSDictionary *)dict{
35+
DWOrigImgView *orgView = [[DWOrigImgView alloc]init];
36+
[orgView setupImgViewWithDict:dict];
37+
return orgView;
38+
}
39+
40+
- (void)setupImgViewWithDict:(NSDictionary *)dict{
41+
NSString *thumbPath = [dict objectForKey:@"thumbPath"];
42+
NSString *strUrl = [dict objectForKey:@"url"];
43+
UIImage *placeImg = [UIImage imageWithData:[NSData dataWithContentsOfFile:thumbPath]];
44+
[imgView setImageURL:strUrl placeImage:placeImg];
45+
NSNumber *numW = [dict objectForKey:@"imageWidth"];
46+
NSNumber *numH = [dict objectForKey:@"imageHeight"];
47+
CGFloat multiple = numW.floatValue / numH.floatValue;
48+
CGFloat imgW = screenW;
49+
CGFloat imgH = imgW / multiple;
50+
CGFloat imgY = 0;
51+
if (imgH < screenH) {
52+
imgY = (screenH-imgH)*0.5;
53+
}
54+
imgView.frame = CGRectMake(0, imgY, imgW, imgH);
55+
orginFrame = imgView.frame;
56+
}
57+
58+
59+
- (instancetype)initWithFrame:(CGRect)frame{
60+
if (self = [super initWithFrame:frame]) {
61+
self.backgroundColor = [UIColor blackColor];
62+
self.userInteractionEnabled = YES;
63+
[self addContentView];
64+
}
65+
return self;
66+
}
67+
68+
- (void)addContentView{
69+
imgView = [[MyCacheImageView alloc]init];
70+
imgView.contentMode = UIViewContentModeScaleAspectFit;
71+
imgView.userInteractionEnabled = YES;
72+
imgView.multipleTouchEnabled = YES;
73+
[self addSubview:imgView];
74+
pinchGest = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(clickPinchView:)];
75+
[imgView addGestureRecognizer:pinchGest];
76+
panGest = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(clickPanView:)];
77+
[imgView addGestureRecognizer:panGest];
78+
79+
tapGest = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickTapGest)];
80+
[self addGestureRecognizer:tapGest];
81+
82+
CGFloat btnWH = 35;
83+
CGFloat btnX = screenW - btnWH - 20;
84+
CGFloat btnY = screenH - btnWH - 20;
85+
downBtn = [[UIButton alloc]initWithFrame:CGRectMake(btnX, btnY, btnWH, btnWH)];
86+
[downBtn setBackgroundImage:[UIImage imageNamed:@"download"] forState:UIControlStateNormal];
87+
[downBtn addTarget:self action:@selector(clickDownLoadBtn) forControlEvents:UIControlEventTouchUpInside];
88+
[self addSubview:downBtn];
89+
[self performSelector:@selector(delayMethod) withObject:nil afterDelay:3.0];
90+
91+
}
92+
93+
- (void)delayMethod{
94+
[UIView animateWithDuration:0.5 animations:^{
95+
downBtn.alpha -= 1;
96+
} completion:^(BOOL finished) {
97+
downBtn.hidden = YES;
98+
downBtn.alpha = 1;
99+
}];
100+
101+
}
102+
103+
- (void)clickDownLoadBtn{
104+
UIImageWriteToSavedPhotosAlbum(imgView.image, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
105+
}
106+
107+
- (void)image: (UIImage *) image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo{
108+
NSString *msg = nil ;
109+
if(error != NULL){
110+
msg = @"保存图片失败" ;
111+
}else{
112+
msg = @"保存图片成功" ;
113+
}
114+
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:msg message:@"" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
115+
[alert show];
116+
}
117+
118+
119+
- (void)clickPinchView:(UIPinchGestureRecognizer *)gest{
120+
UIView *view = gest.view;
121+
if (gest.state == UIGestureRecognizerStateBegan || gest.state == UIGestureRecognizerStateChanged) {
122+
view.transform = CGAffineTransformScale(view.transform, gest.scale, gest.scale);
123+
gest.scale = 1;
124+
}
125+
if (gest.state == UIGestureRecognizerStateEnded) {
126+
if (view.frame.size.width < screenW) {
127+
CGFloat tmpW = screenW - view.width;
128+
CGFloat tmpH = orginFrame.size.height - view.height;
129+
[UIView animateWithDuration:0.3 animations:^{
130+
view.width += tmpW;
131+
view.height += tmpH;
132+
view.x -= tmpW*0.5;
133+
view.y -= tmpH*0.5;
134+
135+
} completion:^(BOOL finished) {
136+
view.frame = orginFrame;
137+
}];
138+
}
139+
if (view.width > 1.5 * screenW) {
140+
CGFloat maxH = view.height - orginFrame.size.height*1.5;
141+
CGFloat maxW = view.width - screenW*1.5;
142+
[UIView animateWithDuration:0.3 animations:^{
143+
view.width -= maxW;
144+
view.height -= maxH;
145+
view.x += maxW*0.5;
146+
view.y += maxH*0.5;
147+
}];
148+
}
149+
}
150+
}
151+
152+
- (void)clickPanView:(UIPanGestureRecognizer *)gest{
153+
UIView *view = gest.view;
154+
if (gest.state == UIGestureRecognizerStateBegan || gest.state == UIGestureRecognizerStateChanged) {
155+
CGPoint translation = [gest translationInView:view.superview];
156+
[view setCenter:(CGPoint){view.center.x + translation.x, view.center.y + translation.y}];
157+
[gest setTranslation:CGPointZero inView:view.superview];
158+
}
159+
if (gest.state == UIGestureRecognizerStateEnded) {
160+
if (view.x>0) {
161+
CGFloat tmpX = view.x;
162+
[UIView animateWithDuration:0.3 animations:^{
163+
view.x -= tmpX;
164+
} completion:^(BOOL finished) {
165+
view.x = 0;
166+
}];
167+
}else if((screenW-view.x)>view.width){
168+
CGFloat tmpx = screenW - view.x - view.width;
169+
[UIView animateWithDuration:0.3 animations:^{
170+
view.x += tmpx;
171+
} completion:^(BOOL finished) {
172+
view.x = screenW - view.width;
173+
}];
174+
}
175+
if (view.height > screenH) {
176+
if ((view.height - screenH + view.y)<0) {
177+
CGFloat tmpH = screenH - view.height - view.y;
178+
[UIView animateWithDuration:0.3 animations:^{
179+
view.y += tmpH;
180+
}];
181+
}else if (view.y > 0){
182+
CGFloat tmpH = view.y ;
183+
[UIView animateWithDuration:0.3 animations:^{
184+
view.y -= tmpH;
185+
}];
186+
}
187+
}else{
188+
CGFloat tmpH = view.y - (screenH - view.height)*0.5;;
189+
[UIView animateWithDuration:0.3 animations:^{
190+
view.y -= tmpH;
191+
}];
192+
}
193+
}
194+
}
195+
196+
- (void)clickTapGest{
197+
[self removeFromSuperview];
198+
}
199+
200+
@end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// DWOrigImgView.h
3+
// RCTAuroraIMUI
4+
//
5+
// Created by Dowin on 2017/8/29.
6+
// Copyright © 2017年 HXHG. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
#define screenW [UIScreen mainScreen].bounds.size.width
11+
#define screenH [UIScreen mainScreen].bounds.size.height
12+
@interface DWOrigImgView : UIView
13+
+ (instancetype)origImgViewWithDict:(NSDictionary *)dict;
14+
@end

0 commit comments

Comments
 (0)