@ -225,6 +225,125 @@ private class IntroductingReadReceiptsExperienceUpgradeViewController: Experienc
}
}
}
}
private class IntroductingTypingIndicatorsExperienceUpgradeViewController : ExperienceUpgradeViewController {
var buttonAction : ( ( UIButton ) -> Void ) ?
override func loadView ( ) {
self . view = UIView . container ( )
// / 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 = Theme . primaryColor
bodyLabel . numberOfLines = 0
bodyLabel . lineBreakMode = . byWordWrapping
bodyLabel . textAlignment = . center
// I m a g e
let imageView : UIView
if let gifPath = Bundle . main . path ( forResource : " typing-animation " , ofType : " gif " ) {
let animatedImage = YYImage ( contentsOfFile : gifPath )
imageView = YYAnimatedImageView ( image : animatedImage )
} else {
owsFailDebug ( " gifPath was unexpectedly nil " )
imageView = UIImageView ( image : image )
}
view . addSubview ( imageView )
imageView . contentMode = . scaleAspectFit
let buttonTitle = NSLocalizedString ( " UPGRADE_EXPERIENCE_INTRODUCING_TYPING_INDICATOR_PRIVACY_SETTINGS " , comment : " button label shown one time, after upgrade " )
let button = addButton ( title : buttonTitle ) { _ in
// 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 .
self . experienceUpgradesPageViewController . dismiss ( animated : true ) {
guard let fromViewController = UIApplication . shared . frontmostViewController as ? HomeViewController else {
owsFailDebug ( " unexpected frontmostViewController: \( String ( describing : UIApplication . shared . frontmostViewController ) ) " )
return
}
// C o n s t r u c t t h e " s e t t i n g s " v i e w & p u s h t h e " p r i v a c y s e t t i n g s " v i e w .
let navigationController = AppSettingsViewController . inModalNavigationController ( )
navigationController . pushViewController ( PrivacySettingsTableViewController ( ) , animated : false )
fromViewController . present ( navigationController , animated : true )
}
}
let bottomSpacer = UIView ( )
view . addSubview ( bottomSpacer )
// / 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 ( . width , toSize : ScaleFromIPhone5 ( 180 ) )
// 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 . autoPinTopToSuperviewMargin ( )
// 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 . setContentHuggingVerticalHigh ( )
// B u t t o n l a y o u t
button . autoPinEdge ( . top , to : . bottom , of : bodyLabel , withOffset : ScaleFromIPhone5 ( 16 ) )
button . autoPinWidthToSuperview ( withMargin : ScaleFromIPhone5 ( 32 ) )
bottomSpacer . autoPinEdge ( . top , to : . bottom , of : button , withOffset : ScaleFromIPhone5 ( 16 ) )
bottomSpacer . autoPinEdge ( toSuperviewEdge : . bottom )
bottomSpacer . autoPinWidthToSuperview ( )
}
// MARK: - A c t i o n s
func addButton ( title : String , action : @ escaping ( UIButton ) -> Void ) -> UIButton {
self . buttonAction = action
let button = MultiLineButton ( )
view . addSubview ( button )
button . setTitle ( title , for : . normal )
button . setTitleColor ( UIColor . ows_signalBrandBlue , for : . normal )
button . isUserInteractionEnabled = true
button . addTarget ( self , action : #selector ( didTapButton ) , for : . touchUpInside )
button . contentEdgeInsets = UIEdgeInsets ( top : 10 , left : 10 , bottom : 10 , right : 10 )
button . titleLabel ? . textAlignment = . center
button . titleLabel ? . font = UIFont . ows_mediumFont ( withSize : ScaleFromIPhone5 ( 18 ) )
return button
}
@objc func didTapButton ( sender : UIButton ) {
Logger . debug ( " " )
guard let buttonAction = self . buttonAction else {
owsFailDebug ( " button action was nil " )
return
}
buttonAction ( sender )
}
}
/* *
/* *
* Allows multiple lines of button text , and ensures the buttons intrinsic content size reflects that of it ' s label .
* Allows multiple lines of button text , and ensures the buttons intrinsic content size reflects that of it ' s label .
*/
*/
@ -667,6 +786,8 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView
return IntroductingReadReceiptsExperienceUpgradeViewController ( experienceUpgrade : experienceUpgrade , experienceUpgradesPageViewController : self )
return IntroductingReadReceiptsExperienceUpgradeViewController ( experienceUpgrade : experienceUpgrade , experienceUpgradesPageViewController : self )
case . introducingCustomNotificationAudio :
case . introducingCustomNotificationAudio :
return IntroducingCustomNotificationAudioExperienceUpgradeViewController ( experienceUpgrade : experienceUpgrade , experienceUpgradesPageViewController : self )
return IntroducingCustomNotificationAudioExperienceUpgradeViewController ( experienceUpgrade : experienceUpgrade , experienceUpgradesPageViewController : self )
case . introducingTypingIndicators :
return IntroductingTypingIndicatorsExperienceUpgradeViewController ( experienceUpgrade : experienceUpgrade , experienceUpgradesPageViewController : self )
default :
default :
return ExperienceUpgradeViewController ( experienceUpgrade : experienceUpgrade , experienceUpgradesPageViewController : self )
return ExperienceUpgradeViewController ( experienceUpgrade : experienceUpgrade , experienceUpgradesPageViewController : self )
}
}