mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
2.6 KiB
Matlab
100 lines
2.6 KiB
Matlab
8 years ago
|
//
|
||
6 years ago
|
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||
8 years ago
|
//
|
||
|
|
||
|
#import "ConversationScrollButton.h"
|
||
|
#import "UIColor+OWS.h"
|
||
|
#import "UIFont+OWS.h"
|
||
|
#import "UIView+OWS.h"
|
||
5 years ago
|
#import <SignalUtilitiesKit/Theme.h>
|
||
5 years ago
|
#import "Session-Swift.h"
|
||
8 years ago
|
|
||
|
NS_ASSUME_NONNULL_BEGIN
|
||
|
|
||
|
@interface ConversationScrollButton ()
|
||
|
|
||
|
@property (nonatomic) NSString *iconText;
|
||
|
@property (nonatomic) UILabel *iconLabel;
|
||
|
@property (nonatomic) UIView *circleView;
|
||
|
|
||
|
@end
|
||
|
|
||
|
#pragma mark -
|
||
|
|
||
|
@implementation ConversationScrollButton
|
||
|
|
||
|
- (nullable instancetype)initWithIconText:(NSString *)iconText
|
||
|
{
|
||
8 years ago
|
self = [super initWithFrame:CGRectZero];
|
||
8 years ago
|
if (!self) {
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
self.iconText = iconText;
|
||
|
|
||
|
[self createContents];
|
||
|
|
||
|
return self;
|
||
|
}
|
||
|
|
||
8 years ago
|
+ (CGFloat)circleSize
|
||
8 years ago
|
{
|
||
|
return ScaleFromIPhone5To7Plus(35.f, 40.f);
|
||
|
}
|
||
|
|
||
8 years ago
|
+ (CGFloat)buttonSize
|
||
8 years ago
|
{
|
||
|
return self.circleSize + 2 * 15.f;
|
||
|
}
|
||
|
|
||
|
- (void)createContents
|
||
|
{
|
||
|
UILabel *iconLabel = [UILabel new];
|
||
|
self.iconLabel = iconLabel;
|
||
|
iconLabel.userInteractionEnabled = NO;
|
||
|
|
||
8 years ago
|
const CGFloat circleSize = self.class.circleSize;
|
||
8 years ago
|
UIView *circleView = [UIView new];
|
||
|
self.circleView = circleView;
|
||
|
circleView.userInteractionEnabled = NO;
|
||
8 years ago
|
circleView.layer.cornerRadius = circleSize * 0.5f;
|
||
5 years ago
|
circleView.layer.borderColor = [LKColors.text colorWithAlphaComponent:LKValues.composeViewTextFieldBorderOpacity].CGColor;
|
||
|
circleView.layer.borderWidth = LKValues.composeViewTextFieldBorderThickness;
|
||
8 years ago
|
[circleView autoSetDimension:ALDimensionWidth toSize:circleSize];
|
||
|
[circleView autoSetDimension:ALDimensionHeight toSize:circleSize];
|
||
8 years ago
|
|
||
|
[self addSubview:circleView];
|
||
|
[self addSubview:iconLabel];
|
||
|
[circleView autoCenterInSuperview];
|
||
|
[iconLabel autoCenterInSuperview];
|
||
|
|
||
|
[self updateColors];
|
||
|
}
|
||
|
|
||
|
- (void)setHasUnreadMessages:(BOOL)hasUnreadMessages
|
||
|
{
|
||
|
_hasUnreadMessages = hasUnreadMessages;
|
||
|
|
||
|
[self updateColors];
|
||
|
}
|
||
|
|
||
|
- (void)updateColors
|
||
|
{
|
||
5 years ago
|
UIColor *foregroundColor = LKColors.text;
|
||
|
UIColor *backgroundColor = LKColors.composeViewBackground;
|
||
7 years ago
|
|
||
8 years ago
|
const CGFloat circleSize = self.class.circleSize;
|
||
7 years ago
|
self.circleView.backgroundColor = backgroundColor;
|
||
|
self.iconLabel.attributedText =
|
||
|
[[NSAttributedString alloc] initWithString:self.iconText
|
||
|
attributes:@{
|
||
5 years ago
|
NSFontAttributeName : [UIFont ows_fontAwesomeFont:circleSize * 0.75f],
|
||
7 years ago
|
NSForegroundColorAttributeName : foregroundColor,
|
||
|
NSBaselineOffsetAttributeName : @(-0.5f),
|
||
|
}];
|
||
8 years ago
|
}
|
||
|
|
||
|
@end
|
||
|
|
||
|
NS_ASSUME_NONNULL_END
|