@ -4,6 +4,94 @@
import Foundation
private class IntroductingProfilesExperienceUpgradeViewController : ExperienceUpgradeViewController {
override func loadView ( ) {
self . view = UIView ( )
// / C r e a t e V i e w s
// T i t l e l a b e l
let titleLabel = UILabel ( )
view . addSubview ( titleLabel )
titleLabel . text = header
titleLabel . textAlignment = . center
titleLabel . font = UIFont . ows_regularFont ( withSize : ScaleFromIPhone5 ( 24 ) )
titleLabel . textColor = UIColor . white
titleLabel . minimumScaleFactor = 0.5
titleLabel . adjustsFontSizeToFitWidth = true
// B o d y l a b e l
let bodyLabel = UILabel ( )
self . bodyLabel = bodyLabel
view . addSubview ( bodyLabel )
bodyLabel . text = body
bodyLabel . font = UIFont . ows_lightFont ( withSize : ScaleFromIPhone5To7Plus ( 17 , 22 ) )
bodyLabel . textColor = UIColor . black
bodyLabel . numberOfLines = 0
bodyLabel . lineBreakMode = . byWordWrapping
bodyLabel . textAlignment = . center
// I m a g e
let imageView = UIImageView ( image : image )
view . addSubview ( imageView )
imageView . contentMode = . scaleAspectFit
// B u t t o n
let button = UIButton ( )
view . addSubview ( button )
let buttonTitle = NSLocalizedString ( " UPGRADE_EXPERIENCE_INTRODUCING_PROFILES_BUTTON " , comment : " button label shown one time, after user upgrades app " )
button . setTitle ( buttonTitle , for : . normal )
button . setTitleColor ( UIColor . white , for : . normal )
button . backgroundColor = UIColor . ows_materialBlue ( )
button . isUserInteractionEnabled = true
button . addTarget ( self , action : #selector ( didTapButton ) , for : . touchUpInside )
button . contentEdgeInsets = UIEdgeInsets ( top : 10 , left : 20 , bottom : 10 , right : 20 )
button . titleLabel ? . font = UIFont . ows_mediumFont ( withSize : ScaleFromIPhone5 ( 18 ) )
// / L a y o u t V i e w s
// I m a g e l a y o u t
imageView . autoAlignAxis ( toSuperviewAxis : . vertical )
imageView . autoPinToSquareAspectRatio ( )
imageView . autoPinEdge ( . top , to : . bottom , of : titleLabel , withOffset : ScaleFromIPhone5To7Plus ( 36 , 40 ) )
imageView . autoSetDimension ( . height , toSize : ScaleFromIPhone5 ( 225 ) )
// T i t l e l a b e l l a y o u t
titleLabel . autoSetDimension ( . height , toSize : ScaleFromIPhone5 ( 40 ) )
titleLabel . autoPinWidthToSuperview ( withMargin : ScaleFromIPhone5To7Plus ( 16 , 24 ) )
titleLabel . autoPinEdge ( toSuperviewEdge : . top )
// B o d y l a b e l l a y o u t
bodyLabel . autoPinEdge ( . top , to : . bottom , of : imageView , withOffset : ScaleFromIPhone5To7Plus ( 18 , 28 ) )
bodyLabel . autoPinWidthToSuperview ( withMargin : bodyMargin )
bodyLabel . sizeToFit ( )
// B u t t o n l a y o u t
button . autoPinEdge ( . top , to : . bottom , of : bodyLabel , withOffset : ScaleFromIPhone5 ( 18 ) )
button . autoPinWidthToSuperview ( withMargin : ScaleFromIPhone5 ( 32 ) )
button . autoPinEdge ( toSuperviewEdge : . bottom , withInset : ScaleFromIPhone5 ( 16 ) )
button . autoSetDimension ( . height , toSize : ScaleFromIPhone5 ( 36 ) )
}
// MARK: - A c t i o n s
func didTapButton ( sender : UIButton ) {
Logger . debug ( " \( TAG ) in \( #function ) " )
// d i s m i s s t h e m o d a l l y p r e s e n t e d v i e w c o n t r o l l e r , t h e n p r o c e e d .
experienceUpgradesPageViewController . dismiss ( animated : true ) {
guard let fromViewController = UIApplication . shared . frontmostViewController as ? SignalsViewController else {
owsFail ( " unexpected frontmostViewController: \( String ( describing : UIApplication . shared . frontmostViewController ) ) " )
return
}
ProfileViewController . presentForUpgradeOrNag ( from : fromViewController )
}
}
}
private class CallKitExperienceUpgradeViewController : ExperienceUpgradeViewController {
override func loadView ( ) {
@ -79,7 +167,7 @@ private class ExperienceUpgradeViewController: OWSViewController {
view . addSubview ( titleLabel )
titleLabel . text = header
titleLabel . textAlignment = . center
titleLabel . font = UIFont . ows_regularFont ( withSize : ScaleFromIPhone5 To7Plus( 26 , 32 ) )
titleLabel . font = UIFont . ows_regularFont ( withSize : ScaleFromIPhone5 ( 24 ) )
titleLabel . textColor = UIColor . white
titleLabel . minimumScaleFactor = 0.5
titleLabel . adjustsFontSizeToFitWidth = true
@ -102,19 +190,22 @@ private class ExperienceUpgradeViewController: OWSViewController {
// / L a y o u t V i e w s
// I m a g e l a y o u t
imageView . autoAlignAxis ( toSuperviewAxis : . vertical )
imageView . autoPinToSquareAspectRatio ( )
imageView . autoPinEdge ( . top , to : . bottom , of : titleLabel , withOffset : ScaleFromIPhone5To7Plus ( 36 , 60 ) )
imageView . autoSetDimension ( . height , toSize : ScaleFromIPhone5 ( 225 ) )
// T i t l e l a b e l l a y o u t
titleLabel . autoSetDimension ( . height , toSize : ScaleFromIPhone5 ( 40 ) )
titleLabel . autoPinWidthToSuperview ( withMargin : ScaleFromIPhone5To7Plus ( 16 , 24 ) )
titleLabel . autoPinEdge ( toSuperviewEdge : . top )
// B o d y l a b e l l a y o u t
bodyLabel . autoPinEdge ( . top , to : . bottom , of : imageView , withOffset : ScaleFromIPhone5To7Plus ( 18 , 28 ) )
bodyLabel . autoPinWidthToSuperview ( withMargin : bodyMargin )
bodyLabel . sizeToFit ( )
// I m a g e l a y o u t
imageView . autoPinWidthToSuperview ( )
imageView . autoSetDimension ( . height , toSize : ScaleFromIPhone5To7Plus ( 200 , 280 ) )
imageView . autoPinEdge ( . top , to : . bottom , of : titleLabel , withOffset : ScaleFromIPhone5To7Plus ( 24 , 32 ) )
imageView . autoPinEdge ( . bottom , to : . top , of : bodyLabel , withOffset : - ScaleFromIPhone5To7Plus ( 18 , 28 ) )
bodyLabel . autoPinEdge ( toSuperviewEdge : . bottom , withInset : ScaleFromIPhone5 ( 16 ) )
}
}
@ -122,7 +213,7 @@ func setPageControlAppearance() {
if #available ( iOS 9.0 , * ) {
let pageControl = UIPageControl . appearance ( whenContainedInInstancesOf : [ UIPageViewController . self ] )
pageControl . pageIndicatorTintColor = UIColor . lightGray
pageControl . currentPageIndicatorTintColor = UIColor . white
pageControl . currentPageIndicatorTintColor = UIColor . ows_materialBlue( )
} else {
// i O S 8 w o n ' t s e e t h e p a g e c o n t r o l s = (
}
@ -185,20 +276,14 @@ class ExperienceUpgradesPageViewController: OWSViewController, UIPageViewControl
view . addSubview ( headerBackgroundView )
headerBackgroundView . backgroundColor = UIColor . ows_materialBlue ( )
// F o o t e r B a c k g r o u n d
let footerBackgroundView = UIView ( )
view . addSubview ( footerBackgroundView )
footerBackgroundView . backgroundColor = UIColor . ows_materialBlue ( )
// D i s m i s s b u t t o n
let dismissButton = UIButton ( )
view . addSubview ( dismissButton )
dismissButton . setTitle ( CommonStrings . dismissButton , for : . normal )
dismissButton . setTitleColor ( UIColor . white , for : . normal )
dismissButton . setTitleColor ( UIColor . ows_signalBrandBlue ( ) , for : . normal )
dismissButton . isUserInteractionEnabled = true
dismissButton . addTarget ( self , action : #selector ( didTapDismissButton ) , for : . touchUpInside )
dismissButton . titleLabel ? . font = UIFont . ows_mediumFont ( withSize : ScaleFromIPhone5 ( 20 ) )
dismissButton . titleLabel ? . font = UIFont . ows_mediumFont ( withSize : ScaleFromIPhone5 ( 16 ) )
let dismissInsetValue : CGFloat = ScaleFromIPhone5 ( 10 )
dismissButton . contentEdgeInsets = UIEdgeInsets ( top : dismissInsetValue , left : dismissInsetValue , bottom : dismissInsetValue , right : dismissInsetValue )
@ -216,11 +301,6 @@ class ExperienceUpgradesPageViewController: OWSViewController, UIPageViewControl
headerBackgroundView . autoPinEdge ( toSuperviewEdge : . top )
headerBackgroundView . autoSetDimension ( . height , toSize : ScaleFromIPhone5 ( 80 ) )
// F o o t e r B a c k g r o u n d l a y o u t
footerBackgroundView . autoPinWidthToSuperview ( )
footerBackgroundView . autoPinEdge ( toSuperviewEdge : . bottom )
footerBackgroundView . autoSetDimension ( . height , toSize : ScaleFromIPhone5 ( 95 ) )
// D i s m i s s b u t t o n l a y o u t
dismissButton . autoHCenterInSuperview ( )
dismissButton . autoPinEdge ( toSuperviewEdge : . bottom , withInset : ScaleFromIPhone5 ( 10 ) )
@ -230,7 +310,7 @@ class ExperienceUpgradesPageViewController: OWSViewController, UIPageViewControl
// n e g a t i v e i n s e t s o a s t o o v e r l a y t h e h e a d e r t e x t i n t h e c a r o u s e l v i e w w i t h t h e h e a d e r b a c k g r o u n d w h i c h
// l i v e s o u t s i d e o f t h e c a r o u s e l . W e d o t h i s s o t h a t t h e u s e r c a n ' t b o u n c e p a s t t h e p a g e v i e w c o n t r o l l e r s
// w i d t h l i m i t s , e x p o s i n g t h e e d g e o f t h e h e a d e r .
carouselView . autoPin Edge( . top , to : . bottom , of : headerBackgroundView , withOffset : ScaleFromIPhone5 ( - 35 ) )
carouselView . autoPin ( toTopLayoutGuideOf : self , withInset : ScaleFromIPhone5To7Plus ( 14 , 24 ) )
carouselView . autoPinEdge ( . bottom , to : . top , of : dismissButton , withOffset : ScaleFromIPhone5 ( - 10 ) )
}
@ -301,6 +381,8 @@ class ExperienceUpgradesPageViewController: OWSViewController, UIPageViewControl
switch identifier {
case . callKit :
return CallKitExperienceUpgradeViewController ( experienceUpgrade : experienceUpgrade , experienceUpgradesPageViewController : self )
case . introducingProfiles :
return IntroductingProfilesExperienceUpgradeViewController ( experienceUpgrade : experienceUpgrade , experienceUpgradesPageViewController : self )
default :
return ExperienceUpgradeViewController ( experienceUpgrade : experienceUpgrade , experienceUpgradesPageViewController : self )
}