forked from organicmaps/organicmaps
[ios] Update Facebook button disabled state, refactoring
This commit is contained in:
parent
edf48ab1af
commit
e512195cc6
4 changed files with 31 additions and 21 deletions
|
@ -55,6 +55,8 @@
|
|||
+ (BOOL)isNightMode;
|
||||
|
||||
- (UIColor *)opposite;
|
||||
- (UIColor *)colorByBlendingWithColor:(UIColor * _Nonnull)color;
|
||||
|
||||
+ (UIColor *)facebookButtonBackground;
|
||||
+ (UIColor *)facebookButtonBackgroundDisabled;
|
||||
|
||||
@end
|
||||
|
|
|
@ -378,26 +378,11 @@ UIColor * color(SEL cmd)
|
|||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
- (UIColor *)colorByBlendingWithColor:(UIColor *)color {
|
||||
CGFloat bgR;
|
||||
CGFloat bgG;
|
||||
CGFloat bgB;
|
||||
CGFloat bgA;
|
||||
|
||||
CGFloat fgR;
|
||||
CGFloat fgG;
|
||||
CGFloat fgB;
|
||||
CGFloat fgA;
|
||||
|
||||
[self getRed:&bgR green:&bgG blue:&bgB alpha:&bgA];
|
||||
[color getRed:&fgR green:&fgG blue:&fgB alpha:&fgA];
|
||||
|
||||
CGFloat r = fgA * fgR + (1 - fgA) * bgR;
|
||||
CGFloat g = fgA * fgG + (1 - fgA) * bgG;
|
||||
CGFloat b = fgA * fgB + (1 - fgA) * bgB;
|
||||
|
||||
return [UIColor colorWithRed:r green:g blue:b alpha:bgA];
|
||||
+ (UIColor *)facebookButtonBackground {
|
||||
return [UIColor colorWithRed:scaled(59) green:scaled(89) blue:scaled(152) alpha:alpha100];
|
||||
}
|
||||
|
||||
|
||||
+ (UIColor *)facebookButtonBackgroundDisabled {
|
||||
return [self.facebookButtonBackground colorWithAlphaComponent:.7];
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -1,4 +1,25 @@
|
|||
extension UIColor {
|
||||
func blending(with color: UIColor) -> UIColor {
|
||||
var bgR: CGFloat = 0
|
||||
var bgG: CGFloat = 0
|
||||
var bgB: CGFloat = 0
|
||||
var bgA: CGFloat = 0
|
||||
|
||||
var fgR: CGFloat = 0
|
||||
var fgG: CGFloat = 0
|
||||
var fgB: CGFloat = 0
|
||||
var fgA: CGFloat = 0
|
||||
|
||||
self.getRed(&bgR, green: &bgG, blue: &bgB, alpha: &bgA)
|
||||
color.getRed(&fgR, green: &fgG, blue: &fgB, alpha: &fgA)
|
||||
|
||||
let r = fgA * fgR + (1 - fgA) * bgR
|
||||
let g = fgA * fgG + (1 - fgA) * bgG
|
||||
let b = fgA * fgB + (1 - fgA) * bgB
|
||||
|
||||
return UIColor(red: r, green: g, blue: b, alpha: bgA)
|
||||
}
|
||||
|
||||
func lighter(percent: CGFloat) -> UIColor {
|
||||
return colorWithBrightnessFactor(factor: 1 + percent)
|
||||
}
|
||||
|
|
|
@ -88,6 +88,8 @@ final class AuthorizationViewController: MWMViewController {
|
|||
facebookButton.layer.cornerRadius = 8
|
||||
facebookButton.clipsToBounds = true
|
||||
facebookButton.titleLabel?.font = UIFont.bold14()
|
||||
facebookButton.setBackgroundColor(UIColor.facebookButtonBackground(), for: .normal)
|
||||
facebookButton.setBackgroundColor(UIColor.facebookButtonBackgroundDisabled(), for: .disabled)
|
||||
facebookButton.isEnabled = false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue