session-ios/Session/Shared/OWSBezierPathView.m
Morgan Pretty 1345e89809 Further config util logic
Removed the usage of the OWSAES256Key (using CryptoKit and raw data instead)
Removed the pre-compiled headers to speed up builds with minor changes (explicit imports instead)

# Conflicts:
#	Session.xcodeproj/project.pbxproj
#	SessionMessagingKit/Database/Models/ClosedGroup.swift
#	SessionMessagingKit/Protos/Generated/SNProto.swift
#	SessionMessagingKit/Protos/Generated/SessionProtos.pb.swift
#	SessionMessagingKit/Protos/SessionProtos.proto
#	SessionMessagingKit/Sending & Receiving/MessageSender.swift
#	SessionMessagingKit/Sending & Receiving/Pollers/CurrentUserPoller.swift
#	SessionMessagingKit/Utilities/ProfileManager.swift
#	SessionSnodeKit/Models/DeleteAllMessagesRequest.swift
#	SessionSnodeKit/Models/GetMessagesRequest.swift
#	SessionSnodeKit/Models/SendMessageRequest.swift
#	SessionSnodeKit/Types/SnodeAPINamespace.swift
2022-12-07 15:06:15 +11:00

106 lines
2.1 KiB
Objective-C

//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "OWSBezierPathView.h"
#import <SignalCoreKit/OWSAsserts.h>
NS_ASSUME_NONNULL_BEGIN
#pragma mark -
@implementation OWSBezierPathView
- (id)init
{
self = [super init];
if (self) {
[self initCommon];
}
return self;
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initCommon];
}
return self;
}
- (void)initCommon
{
self.opaque = NO;
self.userInteractionEnabled = NO;
}
- (void)setFrame:(CGRect)frame
{
BOOL didChangeSize = !CGSizeEqualToSize(frame.size, self.frame.size);
[super setFrame:frame];
if (didChangeSize) {
[self updateLayers];
}
}
- (void)setBounds:(CGRect)bounds
{
BOOL didChangeSize = !CGSizeEqualToSize(bounds.size, self.bounds.size);
[super setBounds:bounds];
if (didChangeSize) {
[self updateLayers];
}
}
- (void)setConfigureShapeLayerBlock:(ConfigureShapeLayerBlock)configureShapeLayerBlock
{
OWSAssertDebug(configureShapeLayerBlock);
[self setConfigureShapeLayerBlocks:@[ configureShapeLayerBlock ]];
}
- (void)setConfigureShapeLayerBlocks:(NSArray<ConfigureShapeLayerBlock> *)configureShapeLayerBlocks
{
OWSAssertDebug(configureShapeLayerBlocks.count > 0);
_configureShapeLayerBlocks = configureShapeLayerBlocks;
[self updateLayers];
}
- (void)updateLayers
{
if (self.bounds.size.width <= 0.f || self.bounds.size.height <= 0.f) {
return;
}
for (CALayer *layer in self.layer.sublayers) {
[layer removeFromSuperlayer];
}
// Prevent the shape layer from animating changes.
[CATransaction begin];
[CATransaction setDisableActions:YES];
for (ConfigureShapeLayerBlock configureShapeLayerBlock in self.configureShapeLayerBlocks) {
CAShapeLayer *shapeLayer = [CAShapeLayer new];
configureShapeLayerBlock(shapeLayer, self.bounds);
[self.layer addSublayer:shapeLayer];
}
[CATransaction commit];
[self setNeedsDisplay];
}
@end
NS_ASSUME_NONNULL_END