Files
GLEGram-iOS/submodules/LegacyComponents/Sources/TGCameraFlipButton.m
T
Leeksov 4647310322 GLEGram 12.5 — Initial public release
Based on Swiftgram 12.5 (Telegram iOS 12.5).
All GLEGram features ported and organized in GLEGram/ folder.

Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass,
Font Replacement, Fake Profile, Chat Export, Plugin System, and more.

See CHANGELOG_12.5.md for full details.
2026-04-06 09:48:12 +03:00

174 lines
4.3 KiB
Objective-C

#import <LegacyComponents/TGCameraFlipButton.h>
#import <LegacyComponents/TGCameraInterfaceAssets.h>
#import "LegacyComponentsInternal.h"
#import <LegacyComponents/TGImageUtils.h>
@implementation TGCameraFlipButton
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self != nil)
{
self.adjustsImageWhenHighlighted = false;
self.modernHighlight = false;
self.exclusiveTouch = true;
self.backgroundColor = [TGCameraInterfaceAssets buttonColor];
self.layer.cornerRadius = 24.0;
[self setImage:[UIImage imageNamed:@"Camera/Flip"] forState:UIControlStateNormal];
}
return self;
}
- (void)_setHighligtedAnimated:(bool)highlighted animated:(bool)animated {
if (animated) {
[UIView animateWithDuration:0.3 animations:^{
self.layer.sublayerTransform = highlighted ? CATransform3DMakeScale(0.9, 0.9, 1.0) : CATransform3DIdentity;
}];
} else {
self.layer.sublayerTransform = highlighted ? CATransform3DMakeScale(0.9, 0.9, 1.0) : CATransform3DIdentity;
}
}
- (void)setHidden:(BOOL)hidden
{
self.alpha = hidden ? 0.0f : 1.0f;
super.hidden = hidden;
}
- (void)setHidden:(bool)hidden animated:(bool)animated
{
if (animated)
{
super.hidden = false;
self.userInteractionEnabled = false;
[UIView animateWithDuration:0.25f animations:^
{
self.alpha = hidden ? 0.0f : 1.0f;
} completion:^(BOOL finished)
{
self.userInteractionEnabled = true;
if (finished)
self.hidden = hidden;
}];
}
else
{
self.alpha = hidden ? 0.0f : 1.0f;
super.hidden = hidden;
}
}
@end
@implementation TGCameraSmallFlipButton
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self != nil)
{
self.exclusiveTouch = true;
UIImage *image = TGTintedImage(TGComponentsImageNamed(@"CameraFlipButton"), [UIColor whiteColor]);
[self setImage:image forState:UIControlStateNormal];
}
return self;
}
- (void)setHidden:(BOOL)hidden
{
self.alpha = hidden ? 0.0f : 1.0f;
super.hidden = hidden;
}
- (void)setHidden:(bool)hidden animated:(bool)animated
{
if (animated)
{
super.hidden = false;
self.userInteractionEnabled = false;
[UIView animateWithDuration:0.25f animations:^
{
self.alpha = hidden ? 0.0f : 1.0f;
} completion:^(BOOL finished)
{
self.userInteractionEnabled = true;
if (finished)
self.hidden = hidden;
}];
}
else
{
self.alpha = hidden ? 0.0f : 1.0f;
super.hidden = hidden;
}
}
@end
@implementation TGCameraCancelButton
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self != nil)
{
self.adjustsImageWhenHighlighted = false;
self.modernHighlight = false;
self.exclusiveTouch = true;
self.backgroundColor = [TGCameraInterfaceAssets buttonColor];
self.layer.cornerRadius = 24.0;
[self setImage:[UIImage imageNamed:@"Camera/Cancel"] forState:UIControlStateNormal];
}
return self;
}
- (void)_setHighligtedAnimated:(bool)highlighted animated:(bool)animated {
if (animated) {
[UIView animateWithDuration:0.3 animations:^{
self.layer.sublayerTransform = highlighted ? CATransform3DMakeScale(0.9, 0.9, 1.0) : CATransform3DIdentity;
}];
} else {
self.layer.sublayerTransform = highlighted ? CATransform3DMakeScale(0.9, 0.9, 1.0) : CATransform3DIdentity;
}
}
- (void)setHidden:(BOOL)hidden
{
self.alpha = hidden ? 0.0f : 1.0f;
super.hidden = hidden;
}
- (void)setHidden:(bool)hidden animated:(bool)animated
{
if (animated)
{
super.hidden = false;
self.userInteractionEnabled = false;
[UIView animateWithDuration:0.25f animations:^
{
self.alpha = hidden ? 0.0f : 1.0f;
} completion:^(BOOL finished)
{
self.userInteractionEnabled = true;
if (finished)
self.hidden = hidden;
}];
}
else
{
self.alpha = hidden ? 0.0f : 1.0f;
super.hidden = hidden;
}
}
@end