mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Add sign up announcement setting
This commit is contained in:
parent
b5ebd034c4
commit
3b538509e8
@ -10981,3 +10981,7 @@ Sorry for the inconvenience.";
|
||||
"ChatList.DeleteSavedPeerMyNotesConfirmationTitle" = "My Notes";
|
||||
|
||||
"Conversation.ForwardOptions.SenderNamesRemoved" = "Sender names removed";
|
||||
|
||||
"Login.Announce.Info" = "Notify people on Telegram who know my phone number that I signed up.";
|
||||
"Login.Announce.Notify" = "Notify";
|
||||
"Login.Announce.DontNotify" = "Do Not Notify";
|
||||
|
@ -40,6 +40,8 @@ swift_library(
|
||||
"//submodules/ManagedAnimationNode:ManagedAnimationNode",
|
||||
"//submodules/AlertUI:AlertUI",
|
||||
"//submodules/TelegramUI/Components/TextNodeWithEntities:TextNodeWithEntities",
|
||||
"//submodules/MoreButtonNode:MoreButtonNode",
|
||||
"//submodules/ContextUI:ContextUI",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -1037,7 +1037,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
|
||||
}
|
||||
self.openUrl(url)
|
||||
}
|
||||
controller.signUpWithName = { [weak self, weak controller] firstName, lastName, avatarData, avatarAsset, avatarAdjustments in
|
||||
controller.signUpWithName = { [weak self, weak controller] firstName, lastName, avatarData, avatarAsset, avatarAdjustments, announceSignUp in
|
||||
if let strongSelf = self {
|
||||
controller?.inProgress = true
|
||||
|
||||
@ -1097,6 +1097,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
|
||||
avatarVideo = nil
|
||||
}
|
||||
|
||||
//TODO: pass signup announcement
|
||||
strongSelf.actionDisposable.set((signUpWithName(accountManager: strongSelf.sharedContext.accountManager, account: strongSelf.account, firstName: firstName, lastName: lastName, avatarData: avatarData, avatarVideo: avatarVideo, videoStartTimestamp: videoStartTimestamp, forcedPasswordSetupNotice: { value in
|
||||
guard let entry = CodableEntry(ApplicationSpecificCounterNotice(value: value)) else {
|
||||
return nil
|
||||
|
@ -11,6 +11,8 @@ import ImageCompression
|
||||
import LegacyMediaPickerUI
|
||||
import Postbox
|
||||
import TextFormat
|
||||
import MoreButtonNode
|
||||
import ContextUI
|
||||
|
||||
final class AuthorizationSequenceSignUpController: ViewController {
|
||||
private var controllerNode: AuthorizationSequenceSignUpControllerNode {
|
||||
@ -19,18 +21,22 @@ final class AuthorizationSequenceSignUpController: ViewController {
|
||||
|
||||
private var validLayout: ContainerViewLayout?
|
||||
|
||||
private let moreButtonNode: MoreButtonNode
|
||||
|
||||
private let presentationData: PresentationData
|
||||
private let back: () -> Void
|
||||
|
||||
var initialName: (String, String) = ("", "")
|
||||
private var termsOfService: UnauthorizedAccountTermsOfService?
|
||||
|
||||
var signUpWithName: ((String, String, Data?, Any?, TGVideoEditAdjustments?) -> Void)?
|
||||
var signUpWithName: ((String, String, Data?, Any?, TGVideoEditAdjustments?, Bool) -> Void)?
|
||||
var openUrl: ((String) -> Void)?
|
||||
|
||||
var avatarAsset: Any?
|
||||
var avatarAdjustments: TGVideoEditAdjustments?
|
||||
|
||||
var announceSignUp = true
|
||||
|
||||
private let hapticFeedback = HapticFeedback()
|
||||
|
||||
var inProgress: Bool = false {
|
||||
@ -44,6 +50,9 @@ final class AuthorizationSequenceSignUpController: ViewController {
|
||||
self.presentationData = presentationData
|
||||
self.back = back
|
||||
|
||||
self.moreButtonNode = MoreButtonNode(theme: self.presentationData.theme)
|
||||
self.moreButtonNode.iconNode.enqueueState(.more, animated: false)
|
||||
|
||||
super.init(navigationBarPresentationData: NavigationBarPresentationData(theme: AuthorizationSequenceController.navigationBarTheme(presentationData.theme), strings: NavigationBarStrings(presentationStrings: presentationData.strings)))
|
||||
|
||||
self.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait)
|
||||
@ -68,6 +77,14 @@ final class AuthorizationSequenceSignUpController: ViewController {
|
||||
if displayCancel {
|
||||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: presentationData.strings.Common_Cancel, style: .plain, target: self, action: #selector(self.cancelPressed))
|
||||
}
|
||||
|
||||
self.navigationItem.rightBarButtonItem = UIBarButtonItem(customDisplayNode: self.moreButtonNode)
|
||||
|
||||
self.moreButtonNode.action = { [weak self] _, gesture in
|
||||
if let strongSelf = self {
|
||||
strongSelf.morePressed(node: strongSelf.moreButtonNode.contextSourceNode, gesture: gesture)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
required init(coder aDecoder: NSCoder) {
|
||||
@ -81,6 +98,46 @@ final class AuthorizationSequenceSignUpController: ViewController {
|
||||
})]), in: .window(.root))
|
||||
}
|
||||
|
||||
@objc private func moreButtonPressed() {
|
||||
self.moreButtonNode.buttonPressed()
|
||||
}
|
||||
|
||||
@objc private func morePressed(node: ContextReferenceContentNode, gesture: ContextGesture?) {
|
||||
let presentationData = self.presentationData
|
||||
|
||||
let announceSignUp = self.announceSignUp
|
||||
var items: [ContextMenuItem] = []
|
||||
|
||||
let nop: ((ContextMenuActionItem.Action) -> Void)? = nil
|
||||
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Login_Announce_Info, textLayout: .multiline, textFont: .small, icon: { _ in return nil }, action: nop)))
|
||||
items.append(.separator)
|
||||
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Login_Announce_Notify, icon: { theme in
|
||||
if !announceSignUp {
|
||||
return nil
|
||||
}
|
||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.contextMenu.primaryColor)
|
||||
}, iconPosition: .left, action: { [weak self] _, a in
|
||||
a(.default)
|
||||
|
||||
self?.announceSignUp = true
|
||||
})))
|
||||
|
||||
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Login_Announce_DontNotify, icon: { theme in
|
||||
if announceSignUp {
|
||||
return nil
|
||||
}
|
||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.contextMenu.primaryColor)
|
||||
}, iconPosition: .left, action: { [weak self] _, a in
|
||||
a(.default)
|
||||
|
||||
self?.announceSignUp = false
|
||||
})))
|
||||
|
||||
|
||||
let contextController = ContextController(presentationData: self.presentationData, source: .reference(AuthorizationContextReferenceContentSource(controller: self, sourceNode: node)), items: .single(ContextController.Items(content: .list(items))), gesture: gesture)
|
||||
self.present(contextController, in: .window(.root))
|
||||
}
|
||||
|
||||
func updateNavigationItems() {
|
||||
guard let layout = self.validLayout, layout.size.width < 360.0 else {
|
||||
return
|
||||
@ -211,7 +268,21 @@ final class AuthorizationSequenceSignUpController: ViewController {
|
||||
let result = compressImageToJPEG(image, quality: 0.7, tempFilePath: tempFile.path)
|
||||
TempBox.shared.dispose(tempFile)
|
||||
return result
|
||||
}), self.avatarAsset, self.avatarAdjustments)
|
||||
}), self.avatarAsset, self.avatarAdjustments, self.announceSignUp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final class AuthorizationContextReferenceContentSource: ContextReferenceContentSource {
|
||||
private let controller: ViewController
|
||||
private let sourceNode: ContextReferenceContentNode
|
||||
|
||||
init(controller: ViewController, sourceNode: ContextReferenceContentNode) {
|
||||
self.controller = controller
|
||||
self.sourceNode = sourceNode
|
||||
}
|
||||
|
||||
func transitionInfo() -> ContextControllerReferenceViewInfo? {
|
||||
return ContextControllerReferenceViewInfo(referenceView: self.sourceNode.view, contentAreaInScreenSpace: UIScreen.main.bounds)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user