@ -20,6 +20,14 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S
Logger . debug ( " \( self . logTag ) \( #function ) " )
// W e c a n ' t s h o w t h e c o n v e r s a t i o n p i c k e r u n t i l t h e D B i s s e t u p .
// N o r m a l l y t h i s w i l l o n l y t a k e a m o m e n t , s o r a t h e r t h a n f l i c k e r i n g a n d t h e n h i d i n g t h e l o a d i n g s c r e e n
// W e s t a r t a s i n v i s i b l e , a n d o n l y f a d e i t i n i f i t ' s g o i n g t o t a k e a w h i l e
self . view . alpha = 0
UIView . animate ( withDuration : 0.1 , delay : 0.5 , options : [ . curveEaseInOut ] , animations : {
self . view . alpha = 1
} , completion : nil )
// T h i s s h o u l d b e t h e f i r s t t h i n g w e d o .
let appContext = ShareAppExtensionContext ( rootViewController : self )
SetCurrentAppContext ( appContext )
@ -78,7 +86,7 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S
let loadViewController = SAELoadViewController ( delegate : self )
self . pushViewController ( loadViewController , animated : false )
self . isNavigationBarHidden = fals e
self . isNavigationBarHidden = tru e
// W e d o n ' t n e e d t o u s e " s c r e e n p r o t e c t i o n " i n t h e S A E .
@ -225,7 +233,7 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S
Logger . info ( " Presenting initial root view controller " )
if TSAccountManager . isRegistered ( ) {
show ConversationPicker( )
present ConversationPicker( )
} else {
showNotRegisteredView ( )
}
@ -276,9 +284,15 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S
}
private func showErrorView ( title : String , message : String ) {
// e n s u r e v i e w i s v i s i b l e .
self . view . layer . removeAllAnimations ( )
UIView . animate ( withDuration : 0.1 , delay : 0 , options : [ . curveEaseInOut ] , animations : {
self . view . alpha = 1
} , completion : nil )
let viewController = SAEFailedViewController ( delegate : self , title : title , message : message )
self . setViewControllers ( [ viewController ] , animated : false )
self . isNavigationBarHidden = false
}
// MARK: V i e w L i f e c y c l e
@ -329,11 +343,15 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S
// MARK: H e l p e r s
private func showConversationPicker ( ) {
let conversationPicker = SendExternalFileViewController ( )
buildAttachment ( ) . then { attachment -> Void in
private func presentConversationPicker ( ) {
// p a u s e a n y a n i m a t i o n r e v e a l i n g t h e " l o a d i n g " s c r e e n
self . view . layer . removeAllAnimations ( )
self . buildAttachment ( ) . then { attachment -> Void in
let conversationPicker = SendExternalFileViewController ( )
let navigationController = UINavigationController ( rootViewController : conversationPicker )
navigationController . isNavigationBarHidden = true
conversationPicker . attachment = attachment
self . setViewControllers ( [ conversationPicker ] , animated : true )
self . present( navigationController , animated : true , completion : nil )
Logger . info ( " showing picker with attachment: \( attachment ) " )
} . catch { error in
let alertTitle = NSLocalizedString ( " SHARE_EXTENSION_UNABLE_TO_BUILD_ATTACHMENT_ALERT_TITLE " , comment : " Shown when trying to share content to a Signal user for the share extension. Followed by failure details. " )