Various fixes

This commit is contained in:
Ilya Laktyushin
2022-07-24 22:57:22 +03:00
parent ccb0b57d5c
commit b96430093c
13 changed files with 245 additions and 85 deletions

View File

@@ -800,39 +800,40 @@ public final class WebAppController: ViewController, AttachmentContainable {
self.needDismissConfirmation = needConfirmation
}
case "web_app_request_phone":
let _ = (self.context.account.postbox.loadedPeerWithId(self.context.account.peerId)
|> deliverOnMainQueue).start(next: { [weak self] accountPeer in
guard let strongSelf = self else {
return
}
guard let user = accountPeer as? TelegramUser, let phoneNumber = user.phone else {
return
}
let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData)
var items: [ActionSheetItem] = []
items.append(ActionSheetTextItem(title: strongSelf.presentationData.strings.WebApp_ShareMyPhoneNumberConfirmation(formatPhoneNumber(phoneNumber), strongSelf.controller?.botName ?? "").string, parseMarkdown: true))
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.WebApp_ShareMyPhoneNumber, action: { [weak actionSheet] in
actionSheet?.dismissAnimated()
guard let strongSelf = self else {
return
}
strongSelf.sendPhoneRequestedEvent(phone: phoneNumber)
}))
actionSheet.setItemGroups([ActionSheetItemGroup(items: items), ActionSheetItemGroup(items: [
ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
actionSheet?.dismissAnimated()
guard let strongSelf = self else {
return
}
strongSelf.sendPhoneRequestedEvent(phone: nil)
})
])])
strongSelf.controller?.present(actionSheet, in: .window(.root))
})
break
// let _ = (self.context.account.postbox.loadedPeerWithId(self.context.account.peerId)
// |> deliverOnMainQueue).start(next: { [weak self] accountPeer in
// guard let strongSelf = self else {
// return
// }
// guard let user = accountPeer as? TelegramUser, let phoneNumber = user.phone else {
// return
// }
//
// let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData)
// var items: [ActionSheetItem] = []
// items.append(ActionSheetTextItem(title: strongSelf.presentationData.strings.WebApp_ShareMyPhoneNumberConfirmation(formatPhoneNumber(phoneNumber), strongSelf.controller?.botName ?? "").string, parseMarkdown: true))
// items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.WebApp_ShareMyPhoneNumber, action: { [weak actionSheet] in
// actionSheet?.dismissAnimated()
// guard let strongSelf = self else {
// return
// }
//
// strongSelf.sendPhoneRequestedEvent(phone: phoneNumber)
// }))
//
// actionSheet.setItemGroups([ActionSheetItemGroup(items: items), ActionSheetItemGroup(items: [
// ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
// actionSheet?.dismissAnimated()
// guard let strongSelf = self else {
// return
// }
//
// strongSelf.sendPhoneRequestedEvent(phone: nil)
// })
// ])])
// strongSelf.controller?.present(actionSheet, in: .window(.root))
// })
default:
break
}