@ -61,19 +61,19 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate {
setUpGradientBackground ( )
setUpNavBarStyle ( )
setNavBarTitle ( NSLocalizedString ( " vc_settings_title " , comment : " " ) )
// Se t u p n a v i g a t i o n b a r b u t t o n s
// N a v i g a t i o n b a r b u t t o n s
let backButton = UIBarButtonItem ( title : " Back " , style : . plain , target : nil , action : nil )
backButton . tintColor = Colors . text
navigationItem . backBarButtonItem = backButton
updateNavigationBarButtons ( )
// Se t u p p r o f i l e p i c t u r e v i e w
// P r o f i l e p i c t u r e v i e w
let profilePictureTapGestureRecognizer = UITapGestureRecognizer ( target : self , action : #selector ( showEditProfilePictureUI ) )
profilePictureView . addGestureRecognizer ( profilePictureTapGestureRecognizer )
profilePictureView . publicKey = getUserHexEncodedPublicKey ( )
profilePictureView . update ( )
// Se t u p d i s p l a y n a m e l a b e l
// D i s p l a y n a m e l a b e l
displayNameLabel . text = Storage . shared . getUser ( ) ? . name
// Se t u p d i s p l a y n a m e c o n t a i n e r
// D i s p l a y n a m e c o n t a i n e r
let displayNameContainer = UIView ( )
displayNameContainer . accessibilityLabel = " Edit display name text field "
displayNameContainer . isAccessibilityElement = true
@ -85,14 +85,14 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate {
displayNameTextField . alpha = 0
let displayNameContainerTapGestureRecognizer = UITapGestureRecognizer ( target : self , action : #selector ( showEditDisplayNameUI ) )
displayNameContainer . addGestureRecognizer ( displayNameContainerTapGestureRecognizer )
// Se t u p h e a d e r v i e w
// H e a d e r v i e w
let headerStackView = UIStackView ( arrangedSubviews : [ profilePictureView , displayNameContainer ] )
headerStackView . axis = . vertical
headerStackView . spacing = Values . smallSpacing
headerStackView . alignment = . center
// S e t u p s e pa r a t o r
// S e pa r a t o r
let separator = Separator ( title : NSLocalizedString ( " your_session_id " , comment : " " ) )
// Se t u p p u b l i c k e y l a b e l
// P u b l i c k e y l a b e l
let publicKeyLabel = UILabel ( )
publicKeyLabel . textColor = Colors . text
publicKeyLabel . font = Fonts . spaceMono ( ofSize : isIPhone5OrSmaller ? Values . mediumFontSize : Values . largeFontSize )
@ -100,27 +100,27 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate {
publicKeyLabel . textAlignment = . center
publicKeyLabel . lineBreakMode = . byCharWrapping
publicKeyLabel . text = getUserHexEncodedPublicKey ( )
// S et u p s ha r e b u t t o n
// S ha r e b u t t o n
let shareButton = Button ( style : . regular , size : . medium )
shareButton . setTitle ( NSLocalizedString ( " share " , comment : " " ) , for : UIControl . State . normal )
shareButton . addTarget ( self , action : #selector ( sharePublicKey ) , for : UIControl . Event . touchUpInside )
// Se t u p b u t t o n c o n t a i n e r
// B u t t o n c o n t a i n e r
let buttonContainer = UIStackView ( arrangedSubviews : [ copyButton , shareButton ] )
buttonContainer . axis = . horizontal
buttonContainer . spacing = Values . mediumSpacing
buttonContainer . distribution = . fillEqually
// Se t u p t o p s t a c k v i e w
// T o p s t a c k v i e w
let topStackView = UIStackView ( arrangedSubviews : [ headerStackView , separator , publicKeyLabel , buttonContainer ] )
topStackView . axis = . vertical
topStackView . spacing = Values . largeSpacing
topStackView . alignment = . fill
topStackView . layoutMargins = UIEdgeInsets ( top : 0 , left : Values . largeSpacing , bottom : 0 , right : Values . largeSpacing )
topStackView . isLayoutMarginsRelativeArrangement = true
// S e t u p s e t ti n g b u t t o n s s t a c k v i e w
// S e t ti n g b u t t o n s s t a c k v i e w
getSettingButtons ( ) . forEach { settingButtonOrSeparator in
settingButtonsStackView . addArrangedSubview ( settingButtonOrSeparator )
}
// Se t u p v e r s i o n l a b e l
// V e r s i o n l a b e l
let versionLabel = UILabel ( )
versionLabel . textColor = Colors . text . withAlphaComponent ( Values . mediumOpacity )
versionLabel . font = . systemFont ( ofSize : Values . verySmallFontSize )
@ -130,15 +130,25 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate {
let version = Bundle . main . infoDictionary ! [ " CFBundleShortVersionString " ] !
let buildNumber = Bundle . main . infoDictionary ! [ " CFBundleVersion " ] !
versionLabel . text = " Version \( version ) ( \( buildNumber ) ) "
// S e t u p s t a c k v i e w
let stackView = UIStackView ( arrangedSubviews : [ topStackView , settingButtonsStackView , versionLabel ] )
let inviteButton = UIButton ( )
inviteButton . setTitle ( " Invite a Friend " , for : UIControl . State . normal )
inviteButton . setTitleColor ( Colors . text , for : UIControl . State . normal )
inviteButton . titleLabel ! . font = . boldSystemFont ( ofSize : Values . smallFontSize )
inviteButton . addTarget ( self , action : #selector ( sendInvitation ) , for : UIControl . Event . touchUpInside )
let helpTranslateButton = UIButton ( )
helpTranslateButton . setTitle ( " Help us Translate Session " , for : UIControl . State . normal )
helpTranslateButton . setTitleColor ( Colors . text , for : UIControl . State . normal )
helpTranslateButton . titleLabel ! . font = . boldSystemFont ( ofSize : Values . smallFontSize )
helpTranslateButton . addTarget ( self , action : #selector ( helpTranslate ) , for : UIControl . Event . touchUpInside )
// M a i n s t a c k v i e w
let stackView = UIStackView ( arrangedSubviews : [ topStackView , settingButtonsStackView , inviteButton , helpTranslateButton , versionLabel ] )
stackView . axis = . vertical
stackView . spacing = Values . largeSpacing
stackView . alignment = . fill
stackView . layoutMargins = UIEdgeInsets ( top : Values . mediumSpacing , left : 0 , bottom : Values . mediumSpacing , right : 0 )
stackView . isLayoutMarginsRelativeArrangement = true
stackView . set ( . width , to : UIScreen . main . bounds . width )
// S e t u p s c r o l l v i e w
// S cr o l l v i e w
let scrollView = UIScrollView ( )
scrollView . showsVerticalScrollIndicator = false
scrollView . addSubview ( stackView )
@ -183,8 +193,6 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate {
getSettingButton ( withTitle : NSLocalizedString ( " vc_settings_privacy_button_title " , comment : " " ) , color : Colors . text , action : #selector ( showPrivacySettings ) ) ,
getSeparator ( ) ,
getSettingButton ( withTitle : NSLocalizedString ( " vc_settings_notifications_button_title " , comment : " " ) , color : Colors . text , action : #selector ( showNotificationSettings ) ) ,
getSeparator ( ) ,
getSettingButton ( withTitle : " Invite " , color : Colors . text , action : #selector ( sendInvitation ) ) ,
getSeparator ( )
]
if ! KeyPairUtilities . hasV2KeyPair ( ) {
@ -423,6 +431,11 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate {
navigationController ! . present ( shareVC , animated : true , completion : nil )
}
@objc private func helpTranslate ( ) {
let url = URL ( string : " https://crowdin.com/project/session-ios " ) !
UIApplication . shared . open ( url )
}
@objc private func upgradeSessionID ( ) {
let message = " You’ re upgrading to a new Session ID. This will give you improved privacy and security, but it will clear ALL app data. Contacts and conversations will be lost. Proceed? "
let alert = UIAlertController ( title : " Upgrade Session ID? " , message : message , preferredStyle : . alert )