mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various Fixes
This commit is contained in:
parent
e0d4cb86fe
commit
e4f09f39fd
12
submodules/LegacyComponents/LegacyImages.xcassets/Camera/Flash.imageset/Contents.json
vendored
Normal file
12
submodules/LegacyComponents/LegacyImages.xcassets/Camera/Flash.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "ic_cam_flashon (1).pdf",
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
BIN
submodules/LegacyComponents/LegacyImages.xcassets/Camera/Flash.imageset/ic_cam_flashon (1).pdf
vendored
Normal file
BIN
submodules/LegacyComponents/LegacyImages.xcassets/Camera/Flash.imageset/ic_cam_flashon (1).pdf
vendored
Normal file
Binary file not shown.
@ -6,15 +6,13 @@
|
|||||||
@property (nonatomic, assign) PGCameraFlashMode mode;
|
@property (nonatomic, assign) PGCameraFlashMode mode;
|
||||||
@property (nonatomic, assign) UIInterfaceOrientation interfaceOrientation;
|
@property (nonatomic, assign) UIInterfaceOrientation interfaceOrientation;
|
||||||
|
|
||||||
@property (nonatomic, copy) void(^becameActive)(void);
|
|
||||||
@property (nonatomic, copy) void(^modeChanged)(PGCameraFlashMode mode);
|
@property (nonatomic, copy) void(^modeChanged)(PGCameraFlashMode mode);
|
||||||
|
|
||||||
- (void)setFlashUnavailable:(bool)unavailable;
|
- (void)setFlashUnavailable:(bool)unavailable;
|
||||||
|
- (void)setFlashActive:(bool)active;
|
||||||
|
|
||||||
- (void)setHidden:(bool)hidden animated:(bool)animated;
|
- (void)setHidden:(bool)hidden animated:(bool)animated;
|
||||||
|
|
||||||
- (void)dismissAnimated:(bool)animated;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
extern const CGFloat TGCameraFlashControlHeight;
|
extern const CGFloat TGCameraFlashControlHeight;
|
||||||
|
@ -712,8 +712,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
|||||||
|
|
||||||
TGDispatchOnMainThread(^
|
TGDispatchOnMainThread(^
|
||||||
{
|
{
|
||||||
if (!strongSelf->_camera.isRecordingVideo)
|
[strongSelf->_interfaceView setFlashActive:active];
|
||||||
[strongSelf->_interfaceView setFlashActive:active];
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,21 +2,118 @@
|
|||||||
|
|
||||||
#import "LegacyComponentsInternal.h"
|
#import "LegacyComponentsInternal.h"
|
||||||
|
|
||||||
|
#import "TGImageUtils.h"
|
||||||
|
|
||||||
#import "UIControl+HitTestEdgeInsets.h"
|
#import "UIControl+HitTestEdgeInsets.h"
|
||||||
|
|
||||||
#import "TGCameraInterfaceAssets.h"
|
#import "TGCameraInterfaceAssets.h"
|
||||||
#import <LegacyComponents/TGModernButton.h>
|
#import <LegacyComponents/TGModernButton.h>
|
||||||
|
|
||||||
|
#import "POPBasicAnimation.h"
|
||||||
|
|
||||||
const CGFloat TGCameraFlashControlHeight = 44.0f;
|
const CGFloat TGCameraFlashControlHeight = 44.0f;
|
||||||
|
|
||||||
|
@interface TGCameraFlashIcon: UIView
|
||||||
|
{
|
||||||
|
bool _active;
|
||||||
|
CGFloat _progress;
|
||||||
|
bool _on;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation TGCameraFlashIcon
|
||||||
|
|
||||||
|
- (instancetype)initWithFrame:(CGRect)frame {
|
||||||
|
self = [super initWithFrame:frame];
|
||||||
|
if (self != nil) {
|
||||||
|
self.contentMode = UIViewContentModeRedraw;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setOn:(bool)on animated:(bool)animated {
|
||||||
|
_on = on;
|
||||||
|
if (animated) {
|
||||||
|
POPBasicAnimation *animation = [POPBasicAnimation animation];
|
||||||
|
animation.property = [POPAnimatableProperty propertyWithName:@"progress" initializer:^(POPMutableAnimatableProperty *prop)
|
||||||
|
{
|
||||||
|
prop.readBlock = ^(TGCameraFlashIcon *view, CGFloat values[])
|
||||||
|
{
|
||||||
|
if (view != nil) {
|
||||||
|
values[0] = view->_progress;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
prop.writeBlock = ^(TGCameraFlashIcon *view, const CGFloat values[])
|
||||||
|
{
|
||||||
|
view->_progress = values[0];
|
||||||
|
[view setNeedsDisplay];
|
||||||
|
};
|
||||||
|
|
||||||
|
prop.threshold = 0.03f;
|
||||||
|
}];
|
||||||
|
animation.fromValue = @(_progress);
|
||||||
|
animation.toValue = @(on ? 1.0 : 0.0);
|
||||||
|
animation.duration = 0.2;
|
||||||
|
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
|
||||||
|
[self pop_addAnimation:animation forKey:@"progress"];
|
||||||
|
} else {
|
||||||
|
_progress = on ? 1.0 : 0.0;
|
||||||
|
[self setNeedsDisplay];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setActive:(bool)active {
|
||||||
|
_active = active;
|
||||||
|
[self setNeedsDisplay];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)drawRect:(CGRect)__unused rect
|
||||||
|
{
|
||||||
|
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||||
|
CGRect bounds = CGRectMake(0, 0, rect.size.width, rect.size.height);
|
||||||
|
|
||||||
|
CGContextClearRect(context, bounds);
|
||||||
|
|
||||||
|
UIImage *iconImage = [UIImage imageNamed:@"Camera/Flash"];
|
||||||
|
|
||||||
|
if (_active && _on) {
|
||||||
|
CGContextSetFillColorWithColor(context, [TGCameraInterfaceAssets accentColor].CGColor);
|
||||||
|
CGContextFillEllipseInRect(context, CGRectInset(bounds, 2.5, 2.5));
|
||||||
|
|
||||||
|
[TGTintedImage(iconImage, [UIColor blackColor]) drawInRect:CGRectMake(0, 0, 30, 30)];
|
||||||
|
} else {
|
||||||
|
CGContextSetLineWidth(context, 1.0);
|
||||||
|
CGContextSetStrokeColorWithColor(context, [UIColor colorWithWhite:1.0 alpha:0.5].CGColor);
|
||||||
|
CGContextStrokeEllipseInRect(context, CGRectInset(bounds, 3.0, 3.0));
|
||||||
|
|
||||||
|
[TGTintedImage(iconImage, [UIColor whiteColor]) drawInRect:CGRectMake(0, 0, 30, 30)];
|
||||||
|
}
|
||||||
|
|
||||||
|
CGFloat lineProgress = 1.0 - _progress;
|
||||||
|
|
||||||
|
if (lineProgress > 0.0) {
|
||||||
|
CGMutablePathRef path = CGPathCreateMutable();
|
||||||
|
CGPathMoveToPoint(path, NULL, 5, 5);
|
||||||
|
CGPathAddLineToPoint(path, NULL, 5 + (bounds.size.width - 10.0) * lineProgress, 5 + (bounds.size.height - 10.0) * lineProgress);
|
||||||
|
|
||||||
|
CGPathRef strokedPath = CGPathCreateCopyByStrokingPath(path, NULL, 2.0f, kCGLineCapRound, kCGLineJoinMiter, 10);
|
||||||
|
CGContextAddPath(context, strokedPath);
|
||||||
|
CGPathRelease(strokedPath);
|
||||||
|
CGPathRelease(path);
|
||||||
|
|
||||||
|
CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
|
||||||
|
CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
|
||||||
|
CGContextDrawPath(context, kCGPathFillStroke);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@interface TGCameraFlashControl ()
|
@interface TGCameraFlashControl ()
|
||||||
{
|
{
|
||||||
UIButton *_flashIconView;
|
TGCameraFlashIcon *_icon;
|
||||||
UIButton *_autoButton;
|
UIButton *_button;
|
||||||
UIButton *_onButton;
|
|
||||||
UIButton *_offButton;
|
|
||||||
|
|
||||||
bool _active;
|
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -27,23 +124,22 @@ const CGFloat TGCameraFlashControlHeight = 44.0f;
|
|||||||
self = [super initWithFrame:frame];
|
self = [super initWithFrame:frame];
|
||||||
if (self != nil)
|
if (self != nil)
|
||||||
{
|
{
|
||||||
|
self.mode = PGCameraFlashModeOff;
|
||||||
|
|
||||||
self.hitTestEdgeInsets = UIEdgeInsetsMake(-10, -10, -10, -10);
|
self.hitTestEdgeInsets = UIEdgeInsetsMake(-10, -10, -10, -10);
|
||||||
|
|
||||||
_flashIconView = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
|
_icon = [[TGCameraFlashIcon alloc] initWithFrame:CGRectMake(7, 7, 30, 30)];
|
||||||
_flashIconView.adjustsImageWhenHighlighted = false;
|
_icon.userInteractionEnabled = false;
|
||||||
_flashIconView.contentMode = UIViewContentModeCenter;
|
[self addSubview:_icon];
|
||||||
_flashIconView.exclusiveTouch = true;
|
|
||||||
_flashIconView.hitTestEdgeInsets = UIEdgeInsetsMake(0, -10, 0, -10);
|
_button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
|
||||||
_flashIconView.tag = -1;
|
_button.adjustsImageWhenHighlighted = false;
|
||||||
[_flashIconView setImage:[UIImage imageNamed:@"Camera/FlashOff"] forState:UIControlStateNormal];
|
_button.contentMode = UIViewContentModeCenter;
|
||||||
[_flashIconView addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
_button.exclusiveTouch = true;
|
||||||
[self addSubview:_flashIconView];
|
_button.hitTestEdgeInsets = UIEdgeInsetsMake(0, -10, 0, -10);
|
||||||
|
_button.tag = -1;
|
||||||
[UIView performWithoutAnimation:^
|
[_button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
||||||
{
|
[self addSubview:_button];
|
||||||
self.mode = PGCameraFlashModeOff;
|
|
||||||
[self setActive:false animated:false];
|
|
||||||
}];
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -61,11 +157,11 @@ const CGFloat TGCameraFlashControlHeight = 44.0f;
|
|||||||
- (void)buttonPressed:(UIButton *)sender
|
- (void)buttonPressed:(UIButton *)sender
|
||||||
{
|
{
|
||||||
if (_mode == PGCameraFlashModeOff) {
|
if (_mode == PGCameraFlashModeOff) {
|
||||||
self.mode = PGCameraFlashModeOn;
|
self.mode = PGCameraFlashModeAuto;
|
||||||
[_flashIconView setImage:[UIImage imageNamed:@"Camera/FlashOn"] forState:UIControlStateNormal];
|
[_icon setOn:true animated:true];
|
||||||
} else {
|
} else {
|
||||||
self.mode = PGCameraFlashModeOff;
|
self.mode = PGCameraFlashModeOff;
|
||||||
[_flashIconView setImage:[UIImage imageNamed:@"Camera/FlashOff"] forState:UIControlStateNormal];
|
[_icon setOn:false animated:true];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.modeChanged != nil)
|
if (self.modeChanged != nil)
|
||||||
@ -75,35 +171,24 @@ const CGFloat TGCameraFlashControlHeight = 44.0f;
|
|||||||
- (void)setFlashUnavailable:(bool)unavailable
|
- (void)setFlashUnavailable:(bool)unavailable
|
||||||
{
|
{
|
||||||
self.userInteractionEnabled = !unavailable;
|
self.userInteractionEnabled = !unavailable;
|
||||||
[self setActive:false animated:false];
|
self.alpha = unavailable ? 0.4 : 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setActive:(bool)active animated:(bool)animated
|
- (void)setFlashActive:(bool)active
|
||||||
{
|
{
|
||||||
return;
|
[_icon setActive:active];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setMode:(PGCameraFlashMode)mode
|
- (void)setMode:(PGCameraFlashMode)mode
|
||||||
{
|
{
|
||||||
_mode = mode;
|
_mode = mode;
|
||||||
|
[_icon setOn:mode == PGCameraFlashModeAuto animated:true];
|
||||||
[self setActive:false animated:_active];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)dismissAnimated:(bool)animated
|
|
||||||
{
|
|
||||||
if (animated && _active)
|
|
||||||
[self setActive:false animated:animated];
|
|
||||||
else
|
|
||||||
[self setActive:false animated:false];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setHidden:(BOOL)hidden
|
- (void)setHidden:(BOOL)hidden
|
||||||
{
|
{
|
||||||
self.alpha = hidden ? 0.0f : 1.0f;
|
self.alpha = hidden ? 0.0f : 1.0f;
|
||||||
super.hidden = hidden;
|
super.hidden = hidden;
|
||||||
|
|
||||||
[self setActive:false animated:false];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setHidden:(bool)hidden animated:(bool)animated
|
- (void)setHidden:(bool)hidden animated:(bool)animated
|
||||||
@ -123,16 +208,12 @@ const CGFloat TGCameraFlashControlHeight = 44.0f;
|
|||||||
|
|
||||||
if (finished)
|
if (finished)
|
||||||
self.hidden = hidden;
|
self.hidden = hidden;
|
||||||
|
|
||||||
[self setActive:false animated:false];
|
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
self.alpha = hidden ? 0.0f : 1.0f;
|
self.alpha = hidden ? 0.0f : 1.0f;
|
||||||
super.hidden = hidden;
|
super.hidden = hidden;
|
||||||
|
|
||||||
[self setActive:false animated:false];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,13 +440,6 @@
|
|||||||
|
|
||||||
#pragma mark - Actions
|
#pragma mark - Actions
|
||||||
|
|
||||||
- (void)shutterButtonReleased
|
|
||||||
{
|
|
||||||
[super shutterButtonReleased];
|
|
||||||
|
|
||||||
[_flashControl dismissAnimated:true];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)updateForCameraModeChangeWithPreviousMode:(PGCameraMode)previousMode
|
- (void)updateForCameraModeChangeWithPreviousMode:(PGCameraMode)previousMode
|
||||||
{
|
{
|
||||||
[super updateForCameraModeChangeWithPreviousMode:previousMode];
|
[super updateForCameraModeChangeWithPreviousMode:previousMode];
|
||||||
@ -490,7 +483,6 @@
|
|||||||
[self _attachControlsToTopPanel];
|
[self _attachControlsToTopPanel];
|
||||||
|
|
||||||
[self _layoutTopPanelSubviewsForInterfaceOrientation:orientation];
|
[self _layoutTopPanelSubviewsForInterfaceOrientation:orientation];
|
||||||
[_flashControl dismissAnimated:false];
|
|
||||||
|
|
||||||
[UIView animateWithDuration:0.2f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^
|
[UIView animateWithDuration:0.2f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^
|
||||||
{
|
{
|
||||||
@ -512,7 +504,7 @@
|
|||||||
|
|
||||||
- (void)setFlashActive:(bool)active
|
- (void)setFlashActive:(bool)active
|
||||||
{
|
{
|
||||||
[_flashActiveView setActive:active animated:true];
|
[_flashControl setFlashActive:active];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFlashUnavailable:(bool)unavailable
|
- (void)setFlashUnavailable:(bool)unavailable
|
||||||
@ -522,9 +514,6 @@
|
|||||||
|
|
||||||
- (void)setHasFlash:(bool)hasFlash
|
- (void)setHasFlash:(bool)hasFlash
|
||||||
{
|
{
|
||||||
if (!hasFlash)
|
|
||||||
[_flashActiveView setActive:false animated:true];
|
|
||||||
|
|
||||||
[_flashControl setHidden:!hasFlash animated:true];
|
[_flashControl setHidden:!hasFlash animated:true];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -676,8 +665,6 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[_flashControl dismissAnimated:false];
|
|
||||||
|
|
||||||
_flipButton.transform = CGAffineTransformMakeRotation(TGRotationForInterfaceOrientation(orientation));
|
_flipButton.transform = CGAffineTransformMakeRotation(TGRotationForInterfaceOrientation(orientation));
|
||||||
_flashControl.transform = CGAffineTransformMakeRotation(TGRotationForInterfaceOrientation(orientation));
|
_flashControl.transform = CGAffineTransformMakeRotation(TGRotationForInterfaceOrientation(orientation));
|
||||||
_zoomModeView.interfaceOrientation = orientation;
|
_zoomModeView.interfaceOrientation = orientation;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user