update color picker cell per design

pull/1/head
Michael Kirk 7 years ago
parent 8faf8668bd
commit 5127352f7a

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "color-palette-24@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "color-palette-24@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "color-palette-24@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 716 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -4,6 +4,15 @@
import Foundation
@objc (OWSCircleView)
class CircleView: UIView {
override var bounds: CGRect {
didSet {
self.layer.cornerRadius = self.bounds.size.height / 2
}
}
}
protocol ColorViewDelegate: class {
func colorViewWasTapped(_ colorView: ColorView)
}
@ -12,8 +21,8 @@ class ColorView: UIView {
public weak var delegate: ColorViewDelegate?
public let conversationColor: OWSConversationColor
private let swatchView: UIView
private let selectedRing: UIView
private let swatchView: CircleView
private let selectedRing: CircleView
public var isSelected: Bool = false {
didSet {
self.selectedRing.isHidden = !isSelected
@ -22,8 +31,8 @@ class ColorView: UIView {
required init(conversationColor: OWSConversationColor) {
self.conversationColor = conversationColor
self.swatchView = UIView()
self.selectedRing = UIView()
self.swatchView = CircleView()
self.selectedRing = CircleView()
super.init(frame: .zero)
self.addSubview(selectedRing)
@ -32,7 +41,6 @@ class ColorView: UIView {
let cellHeight: CGFloat = 64
selectedRing.autoSetDimensions(to: CGSize(width: cellHeight, height: cellHeight))
selectedRing.layer.cornerRadius = cellHeight / 2
selectedRing.layer.borderColor = Theme.secondaryColor.cgColor
selectedRing.layer.borderWidth = 2
selectedRing.autoPinEdgesToSuperviewEdges()
@ -40,7 +48,6 @@ class ColorView: UIView {
swatchView.backgroundColor = conversationColor.primaryColor
let swatchSize: CGFloat = 48
self.swatchView.layer.cornerRadius = swatchSize / 2
swatchView.autoSetDimensions(to: CGSize(width: swatchSize, height: swatchSize))
swatchView.autoCenterInSuperview()

@ -298,7 +298,9 @@ const CGFloat kIconViewLength = 24;
[OWSConversationColor conversationColorOrDefaultForColorName:colorName].themeColor;
NSString *title = NSLocalizedString(@"CONVERSATION_SETTINGS_CONVERSATION_COLOR",
@"Label for table cell which leads to picking a new conversation color");
return [weakSelf disclosureCellWithName:title iconColor:currentColor];
return [weakSelf cellWithName:title
iconName:@"ic_color_palette"
disclosureIconColor:currentColor];
}
actionBlock:^{
[weakSelf showColorPicker];
@ -693,32 +695,37 @@ const CGFloat kIconViewLength = 24;
return 12.f;
}
- (UITableViewCell *)disclosureCellWithName:(NSString *)name iconColor:(UIColor *)iconColor
- (UITableViewCell *)cellWithName:(NSString *)name
iconName:(NSString *)iconName
disclosureIconColor:(UIColor *)disclosureIconColor
{
OWSAssertDebug(name.length > 0);
UIView *iconView = [UIView containerView];
[iconView autoSetDimensionsToSize:CGSizeMake(kIconViewLength, kIconViewLength)];
UIView *accessoryView = [NeverClearView new];
OWSCircleView *swatchView = [OWSCircleView new];
[accessoryView addSubview:swatchView];
[swatchView autoPinEdgesToSuperviewEdges];
UIView *swatchView = [NeverClearView new];
const CGFloat kSwatchWidth = 20;
[swatchView autoSetDimensionsToSize:CGSizeMake(kSwatchWidth, kSwatchWidth)];
swatchView.layer.cornerRadius = kSwatchWidth / 2;
swatchView.backgroundColor = iconColor;
[iconView addSubview:swatchView];
[swatchView autoCenterInSuperview];
swatchView.backgroundColor = disclosureIconColor;
[swatchView setCompressionResistanceHigh];
return [self cellWithName:name iconView:iconView];
UITableViewCell *cell = [self cellWithName:name iconName:iconName customAccessoryView:accessoryView];
// cell.accessoryView = accessoryView;
return cell;
}
- (UITableViewCell *)cellWithName:(NSString *)name iconName:(NSString *)iconName
- (UITableViewCell *)cellWithName:(NSString *)name
iconName:(NSString *)iconName
customAccessoryView:(nullable UIView *)customAccessoryView
{
OWSAssertDebug(iconName.length > 0);
UIImageView *iconView = [self viewForIconWithName:iconName];
return [self cellWithName:name iconView:iconView];
return [self cellWithName:name iconView:iconView customAccessoryView:customAccessoryView];
}
- (UITableViewCell *)cellWithName:(NSString *)name iconView:(UIView *)iconView
- (UITableViewCell *)cellWithName:(NSString *)name
iconView:(UIView *)iconView
customAccessoryView:(nullable UIView *)customAccessoryView
{
OWSAssertDebug(name.length > 0);
@ -733,6 +740,17 @@ const CGFloat kIconViewLength = 24;
rowLabel.lineBreakMode = NSLineBreakByTruncatingTail;
UIStackView *contentRow = [[UIStackView alloc] initWithArrangedSubviews:@[ iconView, rowLabel ]];
if (customAccessoryView) {
OWSAssertDebug(cell.accessoryView == nil);
UIView *accessoryView = [UIView containerView];
[accessoryView autoSetDimensionsToSize:CGSizeMake(kIconViewLength, kIconViewLength)];
[accessoryView addSubview:customAccessoryView];
[customAccessoryView autoAlignAxis:ALAxisHorizontal toSameAxisOfView:accessoryView withOffset:0];
[customAccessoryView autoAlignAxis:ALAxisVertical toSameAxisOfView:accessoryView withOffset:6];
[contentRow addArrangedSubview:accessoryView];
}
contentRow.spacing = self.iconSpacing;
[cell.contentView addSubview:contentRow];
@ -743,14 +761,14 @@ const CGFloat kIconViewLength = 24;
- (UITableViewCell *)disclosureCellWithName:(NSString *)name iconName:(NSString *)iconName
{
UITableViewCell *cell = [self cellWithName:name iconName:iconName];
UITableViewCell *cell = [self cellWithName:name iconName:iconName customAccessoryView:nil];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (UITableViewCell *)labelCellWithName:(NSString *)name iconName:(NSString *)iconName
{
UITableViewCell *cell = [self cellWithName:name iconName:iconName];
UITableViewCell *cell = [self cellWithName:name iconName:iconName customAccessoryView:nil];
cell.accessoryType = UITableViewCellAccessoryNone;
return cell;
}

Loading…
Cancel
Save