react-native-gizwits-scroll-ruler 1.0.12 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -55,6 +55,7 @@ public class RNScrollRuler extends View {
|
|
|
55
55
|
* 刻度最小值
|
|
56
56
|
*/
|
|
57
57
|
private int minScale = 0;
|
|
58
|
+
private int rawMinScale = 0;
|
|
58
59
|
/**
|
|
59
60
|
* 第一次显示的刻度
|
|
60
61
|
*/
|
|
@@ -63,8 +64,9 @@ public class RNScrollRuler extends View {
|
|
|
63
64
|
* 刻度最大值
|
|
64
65
|
*/
|
|
65
66
|
private int maxScale = 100;
|
|
67
|
+
private int rawMaxScale = 100;
|
|
66
68
|
|
|
67
|
-
private float step = (float) 1
|
|
69
|
+
private float step = (float) 0.1;
|
|
68
70
|
/**
|
|
69
71
|
* kg颜色
|
|
70
72
|
*/
|
|
@@ -658,6 +660,7 @@ public class RNScrollRuler extends View {
|
|
|
658
660
|
|
|
659
661
|
public void setMinScale(int minScale) {
|
|
660
662
|
this.minScale = (int)(minScale / step);
|
|
663
|
+
this.rawMinScale = minScale;
|
|
661
664
|
invalidate();
|
|
662
665
|
}
|
|
663
666
|
|
|
@@ -667,6 +670,7 @@ public class RNScrollRuler extends View {
|
|
|
667
670
|
}
|
|
668
671
|
public void setMaxScale(int maxScale) {
|
|
669
672
|
this.maxScale = (int)(maxScale / step);
|
|
673
|
+
this.rawMaxScale = maxScale;
|
|
670
674
|
invalidate();
|
|
671
675
|
}
|
|
672
676
|
|
|
@@ -737,6 +741,9 @@ public class RNScrollRuler extends View {
|
|
|
737
741
|
public void setScaleLimit(float step) {
|
|
738
742
|
this.scaleLimit = (int)(step * 10);
|
|
739
743
|
this.step = step;
|
|
744
|
+
|
|
745
|
+
this.setMinScale(this.rawMinScale);
|
|
746
|
+
this.setMaxScale(this.rawMaxScale);
|
|
740
747
|
invalidate();
|
|
741
748
|
}
|
|
742
749
|
|
|
@@ -82,7 +82,29 @@
|
|
|
82
82
|
@end
|
|
83
83
|
@implementation DYRulerView
|
|
84
84
|
|
|
85
|
+
-(void)setMaxValue:(int)maxValue{
|
|
86
|
+
if(_maxValue != maxValue){
|
|
87
|
+
_maxValue = maxValue;
|
|
88
|
+
[self setNeedsDisplay];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
-(void)setMinValue:(int)minValue{
|
|
93
|
+
if(_minValue != minValue){
|
|
94
|
+
_minValue = minValue;
|
|
95
|
+
[self setNeedsDisplay];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
-(void)setStep:(float)step{
|
|
100
|
+
if(_step != step){
|
|
101
|
+
_step = step;
|
|
102
|
+
[self setNeedsDisplay];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
85
106
|
-(void)drawRect:(CGRect)rect{
|
|
107
|
+
[super drawRect:rect];
|
|
86
108
|
CGFloat startX = 0;
|
|
87
109
|
CGFloat lineCenterX = RulerGap;
|
|
88
110
|
CGFloat shortLineY = rect.size.height - RulerLong;
|
|
@@ -210,6 +232,7 @@
|
|
|
210
232
|
- (void)setMinValue:(int)minValue {
|
|
211
233
|
NSLog(@"设置最小值");
|
|
212
234
|
[[self subviews]makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
|
235
|
+
BOOL diff = _minValue != minValue;
|
|
213
236
|
_minValue = minValue;
|
|
214
237
|
_stepNum = (_maxValue-_minValue)/_step/_betweenNum;
|
|
215
238
|
// _bgColor = [UIColor clearColor];
|
|
@@ -223,11 +246,15 @@
|
|
|
223
246
|
// [self addSubview:self.grayLine];
|
|
224
247
|
[self setDefaultValue:_defaultValue];
|
|
225
248
|
self.unitLab.text = _unit;
|
|
249
|
+
if(diff){
|
|
250
|
+
[self.collectionView reloadData];
|
|
251
|
+
}
|
|
226
252
|
}
|
|
227
253
|
|
|
228
254
|
- (void)setMaxValue:(int)maxValue {
|
|
229
255
|
NSLog(@"设置最大值");
|
|
230
256
|
[[self subviews]makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
|
257
|
+
BOOL diff = _maxValue != maxValue;
|
|
231
258
|
_maxValue = maxValue;
|
|
232
259
|
_stepNum = (_maxValue-_minValue)/_step/_betweenNum;
|
|
233
260
|
// _bgColor = [UIColor clearColor];
|
|
@@ -241,11 +268,15 @@
|
|
|
241
268
|
// [self addSubview:self.grayLine];
|
|
242
269
|
[self setDefaultValue:_defaultValue];
|
|
243
270
|
self.unitLab.text = _unit;
|
|
271
|
+
if(diff){
|
|
272
|
+
[self.collectionView reloadData];
|
|
273
|
+
}
|
|
244
274
|
}
|
|
245
275
|
|
|
246
276
|
- (void)setStep:(float)step {
|
|
247
277
|
NSLog(@"设置步长");
|
|
248
278
|
[[self subviews]makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
|
279
|
+
BOOL diff = _step != step;
|
|
249
280
|
_step = step;
|
|
250
281
|
_stepNum = (_maxValue-_minValue)/_step/_betweenNum;
|
|
251
282
|
// _bgColor = [UIColor clearColor];
|
|
@@ -259,6 +290,9 @@
|
|
|
259
290
|
// [self addSubview:self.grayLine];
|
|
260
291
|
[self setDefaultValue:_defaultValue];
|
|
261
292
|
self.unitLab.text = _unit;
|
|
293
|
+
if(diff){
|
|
294
|
+
[self.collectionView reloadData];
|
|
295
|
+
}
|
|
262
296
|
}
|
|
263
297
|
|
|
264
298
|
- (void)setDefaultValue:(double)defaultValue {
|
|
@@ -276,8 +310,10 @@
|
|
|
276
310
|
- (void)setNum:(int)num {
|
|
277
311
|
NSLog(@"设置间隔");
|
|
278
312
|
[[self subviews]makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
|
313
|
+
BOOL diff = _num != num;
|
|
279
314
|
_num = num;
|
|
280
|
-
|
|
315
|
+
_betweenNum = _num;
|
|
316
|
+
_stepNum = (_maxValue-_minValue)/_step/_betweenNum;
|
|
281
317
|
|
|
282
318
|
[self addSubview:self.valueLab];
|
|
283
319
|
[self addSubview:self.unitLab];
|
|
@@ -286,6 +322,9 @@
|
|
|
286
322
|
// [self addSubview:self.grayLine];
|
|
287
323
|
[self setDefaultValue:_defaultValue];
|
|
288
324
|
self.unitLab.text = _unit;
|
|
325
|
+
if(diff){
|
|
326
|
+
[self.collectionView reloadData];
|
|
327
|
+
}
|
|
289
328
|
}
|
|
290
329
|
|
|
291
330
|
- (void)setUnit:(NSString *)unit {
|
|
@@ -460,21 +499,14 @@
|
|
|
460
499
|
if (!rulerView){
|
|
461
500
|
rulerView = [[DYRulerView alloc]initWithFrame:CGRectMake(0, 0, RulerGap*_betweenNum, CollectionHeight)];
|
|
462
501
|
rulerView.tag = 1002;
|
|
463
|
-
rulerView.step = _step;
|
|
464
502
|
rulerView.betweenNumber = _betweenNum;
|
|
465
503
|
[cell.contentView addSubview:rulerView];
|
|
466
504
|
}
|
|
467
|
-
// if(indexPath.item>=8 && indexPath.item<=12){
|
|
468
|
-
// rulerView.backgroundColor = [UIColor greenColor];
|
|
469
|
-
// }else if(indexPath.item>=13 && indexPath.item<=18){
|
|
470
|
-
// rulerView.backgroundColor = [UIColor redColor];
|
|
471
|
-
// }else{
|
|
472
|
-
// rulerView.backgroundColor = [UIColor grayColor];
|
|
473
|
-
// }
|
|
474
505
|
rulerView.backgroundColor = _bgColor;
|
|
506
|
+
rulerView.step = _step;
|
|
475
507
|
rulerView.minValue = (int)(_step*(indexPath.item-1)*_betweenNum+_minValue);
|
|
476
508
|
rulerView.maxValue = (int)(_step*indexPath.item*_betweenNum);
|
|
477
|
-
[rulerView setNeedsDisplay];
|
|
509
|
+
// [rulerView setNeedsDisplay];
|
|
478
510
|
|
|
479
511
|
return cell;
|
|
480
512
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gizwits-scroll-ruler",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.15",
|
|
4
|
+
"description": "iOS更新bug修复",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|