Skip to content

Commit

Permalink
Merge pull request #120 from SUPLA/develop
Browse files Browse the repository at this point in the history
v2.3.18
  • Loading branch information
przemyslawzygmunt authored Aug 24, 2020
2 parents 4cd99ee + 1de7760 commit 730c7fa
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 8 deletions.
8 changes: 4 additions & 4 deletions SUPLA.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2752,7 +2752,7 @@
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 56;
CURRENT_PROJECT_VERSION = 58;
DEFINES_MODULE = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherited)",
Expand All @@ -2767,7 +2767,7 @@
"$(inherited)",
"$(PROJECT_DIR)/SUPLA/lib",
);
MARKETING_VERSION = 2.3.17;
MARKETING_VERSION = 2.3.18;
PRODUCT_BUNDLE_IDENTIFIER = com.acsoftware.ios.supla;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "SUPLA/SUPLA-Bridging-Header.h";
Expand All @@ -2784,7 +2784,7 @@
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 56;
CURRENT_PROJECT_VERSION = 58;
DEFINES_MODULE = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherited)",
Expand All @@ -2799,7 +2799,7 @@
"$(inherited)",
"$(PROJECT_DIR)/SUPLA/lib",
);
MARKETING_VERSION = 2.3.17;
MARKETING_VERSION = 2.3.18;
PRODUCT_BUNDLE_IDENTIFIER = com.acsoftware.ios.supla;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "SUPLA/SUPLA-Bridging-Header.h";
Expand Down
2 changes: 2 additions & 0 deletions SUPLA/RGBWDetailView.m
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ -(void)showDimmer {
[self onPickerTypeTabTouch:_varilight ? self.tabSlider : self.tabWheel];
}

self.cbPicker.minBrightness = _varilight ? 1.0 : 0.0;

[self setExtraButtonsHidden:!_varilight];
[self setWheelSliderTabsHidden:NO];
self.tabRGB.selected = NO;
Expand Down
1 change: 1 addition & 0 deletions SUPLA/SAColorBrightnessPicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
@property(nonatomic, copy) UIColor *powerButtonColorOff;
@property(nonatomic, copy) UIColor *color;
@property(nonatomic, assign) float brightness;
@property(nonatomic, assign) float minBrightness;
@property(nonatomic, readonly) BOOL moving;
@property(nonatomic, copy) NSArray *brightnessMarkers;
@property(nonatomic, copy) NSArray *colorMarkers;
Expand Down
39 changes: 35 additions & 4 deletions SUPLA/SAColorBrightnessPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ @implementation SAColorBrightnessPicker {

UIColor *_color;
float _brightness;
float _minBrightness;
float _colorAngle;

float lastPanPosition;
Expand Down Expand Up @@ -817,15 +818,26 @@ -(UIView *) hitTest:(CGPoint)point withEvent:(UIEvent *)event
} else if ([self touchOverBrightnessWheel:transPoint]) {
activeTouchPoint = ACTIVE_TOUCHPOINT_BRIGHTNESS_POINTER;
angle = [self addAngle:-90 toAngle:angle];
[self setBrightness:angle * 100 / 360 raiseEvent:YES];

float brightness = angle * 100 / 360;
if (brightness < _minBrightness) {
brightness = _minBrightness;
}

[self setBrightness:brightness raiseEvent:YES];
}
} else if ([self touchOverSlider: transPoint]) {
activeTouchPoint = ACTIVE_TOUCHPOINT_BRIGHTNESS_POINTER;
float percent = (transPoint.y - _sliderRect.origin.y
- (_sliderRect.size.height-_sliderPointerRange)/2)
* 100 / _sliderPointerRange;

[self setBrightness:100-percent raiseEvent:YES];
float brightness = 100-percent;
if (brightness < _minBrightness) {
brightness = _minBrightness;
}

[self setBrightness:brightness raiseEvent:YES];
}
} else {
if ( !_colorWheelHidden
Expand Down Expand Up @@ -872,7 +884,8 @@ -(void)setBrightness:(float)brightness raiseEvent:(BOOL)raiseEvent {
_brightness = brightness;
[self setNeedsDisplay];

if ( delegate != nil
if ( raiseEvent
&& delegate != nil
&& [delegate respondsToSelector:@selector(cbPickerDataChanged:)] )
[delegate cbPickerDataChanged: self];
}
Expand All @@ -883,8 +896,26 @@ -(void)setBrightness:(float)brightness {
[self setBrightness:brightness raiseEvent:NO];
}

-(void)setMinBrightness:(float)minBrightness {
if (minBrightness > 100) {
minBrightness = 100;
} else if (minBrightness < 0) {
minBrightness = 0;
}

_minBrightness = minBrightness;
}

-(float)minBrightness {
return _minBrightness;
}

- (void)addBrightnessOffset:(float)offset {
[self setBrightness:_brightness+offset raiseEvent:YES];
float brightness = _brightness+offset;
if (brightness < _minBrightness) {
brightness = _minBrightness;
}
[self setBrightness:brightness raiseEvent:YES];
}

- (void)handleTap:(UITapGestureRecognizer *)gr {
Expand Down
12 changes: 12 additions & 0 deletions SUPLATests/SAColorBrightnessPickerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ - (void)testBrightnessProperty {
XCTAssertEqual(picker.brightness, 100);
}

- (void)testMinBrightnessProperty {
XCTAssertEqual(picker.minBrightness, 0.0);
picker.minBrightness = 55.54;
XCTAssertEqualWithAccuracy(picker.minBrightness, 55.54, 0.001);
picker.minBrightness = -1;
XCTAssertEqual(picker.minBrightness, 0.0);
picker.minBrightness = 80.88;
XCTAssertEqualWithAccuracy(picker.minBrightness, 80.88, 0.001);
picker.minBrightness = 110;
XCTAssertEqual(picker.minBrightness, 100);
}

- (void)testMovingProperty {
XCTAssertFalse(picker.moving);
}
Expand Down

0 comments on commit 730c7fa

Please sign in to comment.