mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
0a9f514e03
commit
40080bbe1f
@ -809,7 +809,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
|
||||
if navigationResponse.canShowMIMEType {
|
||||
if navigationResponse.canShowMIMEType || navigationResponse.response.url?.scheme == "tonsite" {
|
||||
decisionHandler(.allow)
|
||||
} else if #available(iOS 14.5, *) {
|
||||
if navigationResponse.response.suggestedFilename?.lowercased().hasSuffix(".pkpass") == true {
|
||||
|
@ -169,9 +169,9 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
return 12
|
||||
case .bioPrivacy:
|
||||
return 13
|
||||
case .birthdayPrivacy:
|
||||
return 14
|
||||
case .giftsAutoSavePrivacy:
|
||||
return 14
|
||||
case .birthdayPrivacy:
|
||||
return 15
|
||||
case .forwardPrivacy:
|
||||
return 16
|
||||
@ -655,8 +655,8 @@ private func privacyAndSecurityControllerEntries(
|
||||
entries.append(.lastSeenPrivacy(presentationData.theme, presentationData.strings.PrivacySettings_LastSeen, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.presence)))
|
||||
entries.append(.profilePhotoPrivacy(presentationData.theme, presentationData.strings.Privacy_ProfilePhoto, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.profilePhoto)))
|
||||
entries.append(.bioPrivacy(presentationData.theme, presentationData.strings.Privacy_Bio, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.bio)))
|
||||
entries.append(.birthdayPrivacy(presentationData.theme, presentationData.strings.Privacy_Birthday, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.birthday)))
|
||||
entries.append(.giftsAutoSavePrivacy(presentationData.theme, presentationData.strings.Privacy_Gifts, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.giftsAutoSave)))
|
||||
entries.append(.birthdayPrivacy(presentationData.theme, presentationData.strings.Privacy_Birthday, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.birthday)))
|
||||
entries.append(.forwardPrivacy(presentationData.theme, presentationData.strings.Privacy_Forwards, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.forwards)))
|
||||
entries.append(.voiceCallPrivacy(presentationData.theme, presentationData.strings.Privacy_Calls, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.voiceCalls)))
|
||||
if !isPremiumDisabled {
|
||||
@ -670,8 +670,8 @@ private func privacyAndSecurityControllerEntries(
|
||||
entries.append(.lastSeenPrivacy(presentationData.theme, presentationData.strings.PrivacySettings_LastSeen, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.profilePhotoPrivacy(presentationData.theme, presentationData.strings.Privacy_ProfilePhoto, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.bioPrivacy(presentationData.theme, presentationData.strings.Privacy_GroupsAndChannels, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.birthdayPrivacy(presentationData.theme, presentationData.strings.Privacy_Birthday, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.giftsAutoSavePrivacy(presentationData.theme, presentationData.strings.Privacy_Gifts, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.birthdayPrivacy(presentationData.theme, presentationData.strings.Privacy_Birthday, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.forwardPrivacy(presentationData.theme, presentationData.strings.Privacy_Forwards, presentationData.strings.Channel_NotificationLoading))
|
||||
entries.append(.voiceCallPrivacy(presentationData.theme, presentationData.strings.Privacy_Calls, presentationData.strings.Channel_NotificationLoading))
|
||||
if !isPremiumDisabled {
|
||||
|
@ -12,9 +12,11 @@ import LottieAnimationComponent
|
||||
|
||||
final class FullscreenControlsComponent: Component {
|
||||
let context: AccountContext
|
||||
let strings: PresentationStrings
|
||||
let title: String
|
||||
let isVerified: Bool
|
||||
let insets: UIEdgeInsets
|
||||
let statusBarStyle: StatusBarStyle
|
||||
var hasBack: Bool
|
||||
let backPressed: () -> Void
|
||||
let minimizePressed: () -> Void
|
||||
@ -22,18 +24,22 @@ final class FullscreenControlsComponent: Component {
|
||||
|
||||
init(
|
||||
context: AccountContext,
|
||||
strings: PresentationStrings,
|
||||
title: String,
|
||||
isVerified: Bool,
|
||||
insets: UIEdgeInsets,
|
||||
statusBarStyle: StatusBarStyle,
|
||||
hasBack: Bool,
|
||||
backPressed: @escaping () -> Void,
|
||||
minimizePressed: @escaping () -> Void,
|
||||
morePressed: @escaping (ASDisplayNode, ContextGesture?) -> Void
|
||||
) {
|
||||
self.context = context
|
||||
self.strings = strings
|
||||
self.title = title
|
||||
self.isVerified = isVerified
|
||||
self.insets = insets
|
||||
self.statusBarStyle = statusBarStyle
|
||||
self.hasBack = hasBack
|
||||
self.backPressed = backPressed
|
||||
self.minimizePressed = minimizePressed
|
||||
@ -53,6 +59,9 @@ final class FullscreenControlsComponent: Component {
|
||||
if lhs.insets != rhs.insets {
|
||||
return false
|
||||
}
|
||||
if lhs.statusBarStyle != rhs.statusBarStyle {
|
||||
return false
|
||||
}
|
||||
if lhs.hasBack != rhs.hasBack {
|
||||
return false
|
||||
}
|
||||
@ -161,8 +170,8 @@ final class FullscreenControlsComponent: Component {
|
||||
let leftBackgroundSize = CGSize(width: 30.0, height: 30.0)
|
||||
let rightBackgroundSize = CGSize(width: 72.0, height: 30.0)
|
||||
|
||||
self.leftBackgroundView.updateColor(color: UIColor(white: 0.67, alpha: 0.35), transition: transition.containedViewLayoutTransition)
|
||||
self.rightBackgroundView.updateColor(color: UIColor(white: 0.67, alpha: 0.35), transition: transition.containedViewLayoutTransition)
|
||||
self.leftBackgroundView.updateColor(color: UIColor(white: 0.7, alpha: 0.35), transition: transition.containedViewLayoutTransition)
|
||||
self.rightBackgroundView.updateColor(color: UIColor(white: 0.7, alpha: 0.35), transition: transition.containedViewLayoutTransition)
|
||||
|
||||
let rightBackgroundFrame = CGRect(origin: CGPoint(x: availableSize.width - component.insets.right - sideInset - rightBackgroundSize.width, y: 0.0), size: rightBackgroundSize)
|
||||
self.rightBackgroundView.update(size: rightBackgroundSize, cornerRadius: rightBackgroundFrame.height / 2.0, transition: transition.containedViewLayoutTransition)
|
||||
@ -170,10 +179,13 @@ final class FullscreenControlsComponent: Component {
|
||||
|
||||
var isAnimatingTextTransition = false
|
||||
|
||||
let textColor: UIColor = component.statusBarStyle == .Black ? UIColor(rgb: 0x808080) : .white
|
||||
self.moreNode.updateColor(textColor, transition: .immediate)
|
||||
|
||||
var additionalLeftWidth: CGFloat = 0.0
|
||||
let titleSize = self.title.update(
|
||||
transition: .immediate,
|
||||
component: AnyComponent(MultilineTextComponent(text: .plain(NSAttributedString(string: component.title, font: Font.with(size: 13.0, design: .round, weight: .semibold), textColor: .white)))),
|
||||
component: AnyComponent(MultilineTextComponent(text: .plain(NSAttributedString(string: component.title, font: Font.with(size: 13.0, design: .round, weight: .semibold), textColor: textColor)))),
|
||||
environment: {},
|
||||
containerSize: availableSize
|
||||
)
|
||||
@ -207,7 +219,7 @@ final class FullscreenControlsComponent: Component {
|
||||
|
||||
let buttonTitleSize = self.buttonTitle.update(
|
||||
transition: .immediate,
|
||||
component: AnyComponent(MultilineTextComponent(text: .plain(NSAttributedString(string: component.hasBack ? "Back" : "Close", font: Font.with(size: 13.0, design: .round, weight: .semibold), textColor: .white)))),
|
||||
component: AnyComponent(MultilineTextComponent(text: .plain(NSAttributedString(string: component.hasBack ? component.strings.Common_Back : component.strings.Common_Close, font: Font.with(size: 13.0, design: .round, weight: .semibold), textColor: textColor)))),
|
||||
environment: {},
|
||||
containerSize: availableSize
|
||||
)
|
||||
@ -233,7 +245,7 @@ final class FullscreenControlsComponent: Component {
|
||||
if component.isVerified {
|
||||
let credibilitySize = self.credibility.update(
|
||||
transition: .immediate,
|
||||
component: AnyComponent(BundleIconComponent(name: "Instant View/Verified", tintColor: .white)),
|
||||
component: AnyComponent(BundleIconComponent(name: "Instant View/Verified", tintColor: textColor)),
|
||||
environment: {},
|
||||
containerSize: availableSize
|
||||
)
|
||||
@ -284,7 +296,7 @@ final class FullscreenControlsComponent: Component {
|
||||
mode: .animating(loop: false),
|
||||
range: component.hasBack ? (0.5, 1.0) : (0.0, 0.5)
|
||||
),
|
||||
colors: ["__allcolors__": .white],
|
||||
colors: ["__allcolors__": textColor],
|
||||
size: CGSize(width: 30.0, height: 30.0)
|
||||
)
|
||||
),
|
||||
@ -304,7 +316,7 @@ final class FullscreenControlsComponent: Component {
|
||||
transition: .immediate,
|
||||
component: AnyComponent(Button(
|
||||
content: AnyComponent(
|
||||
BundleIconComponent(name: "Instant View/MinimizeArrow", tintColor: .white)
|
||||
BundleIconComponent(name: "Instant View/MinimizeArrow", tintColor: textColor)
|
||||
),
|
||||
action: { [weak self] in
|
||||
guard let self, let component = self.component else {
|
||||
|
@ -281,7 +281,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
placeholder = self.context.engine.messages.getAttachMenuBot(botId: controller.botId, cached: true)
|
||||
|> map(Optional.init)
|
||||
|> `catch` { error -> Signal<AttachMenuBot?, NoError> in
|
||||
return .complete()
|
||||
return .single(nil)
|
||||
}
|
||||
|> mapToSignal { bot -> Signal<(FileMediaReference, Bool)?, NoError> in
|
||||
if let bot = bot, let peerReference = PeerReference(bot.peer._asPeer()) {
|
||||
@ -301,14 +301,14 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
return .complete()
|
||||
}
|
||||
} else {
|
||||
return .complete()
|
||||
return .single(nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let placeholderData = controller.botAppSettings?.placeholderData {
|
||||
Queue.mainQueue().justDispatch {
|
||||
let size = CGSize(width: 75.0, height: 75.0)
|
||||
let size = CGSize(width: 78.0, height: 78.0)
|
||||
if let image = generateStickerPlaceholderImage(data: placeholderData, size: size, scale: min(2.0, UIScreenScale), imageSize: CGSize(width: 512.0, height: 512.0), backgroundColor: nil, foregroundColor: .white) {
|
||||
self.placeholderIcon = (image.withRenderingMode(.alwaysTemplate), false)
|
||||
if let (layout, navigationBarHeight) = self.validLayout {
|
||||
@ -334,28 +334,41 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
|
||||
if let fileReference = fileReference {
|
||||
let _ = freeMediaFileInteractiveFetched(account: strongSelf.context.account, userLocation: .other, fileReference: fileReference).start()
|
||||
}
|
||||
let _ = (svgIconImageFile(account: strongSelf.context.account, fileReference: fileReference, stickToTop: isPlaceholder)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] transform in
|
||||
if let strongSelf = self {
|
||||
let imageSize: CGSize
|
||||
if isPlaceholder, let (layout, _) = strongSelf.validLayout {
|
||||
let minSize = min(layout.size.width, layout.size.height)
|
||||
imageSize = CGSize(width: minSize, height: minSize * 2.0)
|
||||
} else {
|
||||
imageSize = CGSize(width: 75.0, height: 75.0)
|
||||
}
|
||||
let arguments = TransformImageArguments(corners: ImageCorners(), imageSize: imageSize, boundingSize: imageSize, intrinsicInsets: UIEdgeInsets())
|
||||
let drawingContext = transform(arguments)
|
||||
if let image = drawingContext?.generateImage()?.withRenderingMode(.alwaysTemplate) {
|
||||
strongSelf.placeholderIcon = (image, isPlaceholder)
|
||||
if let (layout, navigationBarHeight) = strongSelf.validLayout {
|
||||
strongSelf.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: .immediate)
|
||||
let _ = (svgIconImageFile(account: strongSelf.context.account, fileReference: fileReference, stickToTop: isPlaceholder)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] transform in
|
||||
if let strongSelf = self {
|
||||
let imageSize: CGSize
|
||||
if isPlaceholder, let (layout, _) = strongSelf.validLayout {
|
||||
let minSize = min(layout.size.width, layout.size.height)
|
||||
imageSize = CGSize(width: minSize, height: minSize * 2.0)
|
||||
} else {
|
||||
imageSize = CGSize(width: 78.0, height: 78.0)
|
||||
}
|
||||
let arguments = TransformImageArguments(corners: ImageCorners(), imageSize: imageSize, boundingSize: imageSize, intrinsicInsets: UIEdgeInsets())
|
||||
let drawingContext = transform(arguments)
|
||||
if let image = drawingContext?.generateImage()?.withRenderingMode(.alwaysTemplate) {
|
||||
strongSelf.placeholderIcon = (image, isPlaceholder)
|
||||
if let (layout, navigationBarHeight) = strongSelf.validLayout {
|
||||
strongSelf.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: .immediate)
|
||||
}
|
||||
}
|
||||
strongSelf.placeholderNode?.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
}
|
||||
strongSelf.placeholderNode?.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
}
|
||||
})
|
||||
})
|
||||
} else {
|
||||
let image = generateImage(CGSize(width: 78.0, height: 78.0), rotatedContext: { size, context in
|
||||
context.clear(CGRect(origin: .zero, size: size))
|
||||
context.setFillColor(UIColor.white.cgColor)
|
||||
|
||||
let squareSize = CGSize(width: 36.0, height: 36.0)
|
||||
context.addPath(UIBezierPath(roundedRect: CGRect(origin: .zero, size: squareSize), cornerRadius: 5.0).cgPath)
|
||||
context.addPath(UIBezierPath(roundedRect: CGRect(origin: CGPoint(x: size.width - squareSize.width, y: 0.0), size: squareSize), cornerRadius: 5.0).cgPath)
|
||||
context.addPath(UIBezierPath(roundedRect: CGRect(origin: CGPoint(x: 0.0, y: size.height - squareSize.height), size: squareSize), cornerRadius: 5.0).cgPath)
|
||||
context.addPath(UIBezierPath(roundedRect: CGRect(origin: CGPoint(x: size.width - squareSize.width, y: size.height - squareSize.height), size: squareSize), cornerRadius: 5.0).cgPath)
|
||||
context.fillPath()
|
||||
})!
|
||||
strongSelf.placeholderIcon = (image.withRenderingMode(.alwaysTemplate), false)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
@ -680,14 +693,15 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
return
|
||||
}
|
||||
|
||||
self.controller?.navigationBar?.alpha = controller.isFullscreen ? 0.0 : 1.0
|
||||
self.updateStatusBarStyle()
|
||||
|
||||
controller.navigationBar?.alpha = controller.isFullscreen ? 0.0 : 1.0
|
||||
transition.updateAlpha(node: self.headerBackgroundNode, alpha: controller.isFullscreen ? 0.0 : 1.0)
|
||||
|
||||
transition.updateFrame(node: self.backgroundNode, frame: CGRect(origin: .zero, size: layout.size))
|
||||
transition.updateFrame(node: self.headerBackgroundNode, frame: CGRect(origin: .zero, size: CGSize(width: layout.size.width, height: navigationBarHeight)))
|
||||
transition.updateFrame(node: self.topOverscrollNode, frame: CGRect(origin: CGPoint(x: 0.0, y: -1000.0), size: CGSize(width: layout.size.width, height: 1000.0)))
|
||||
|
||||
|
||||
var contentTopInset: CGFloat = 0.0
|
||||
if controller.isFullscreen {
|
||||
var added = false
|
||||
@ -706,9 +720,11 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
component: AnyComponent(
|
||||
FullscreenControlsComponent(
|
||||
context: self.context,
|
||||
strings: self.presentationData.strings,
|
||||
title: controller.botName,
|
||||
isVerified: controller.botVerified,
|
||||
insets: UIEdgeInsets(top: 0.0, left: layout.safeInsets.left, bottom: 0.0, right: layout.safeInsets.right),
|
||||
statusBarStyle: self.fullScreenStatusBarStyle,
|
||||
hasBack: self.hasBackButton,
|
||||
backPressed: { [weak self] in
|
||||
guard let self else {
|
||||
@ -1472,6 +1488,10 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
if let json = json, let url = json["url"] as? String, let fileName = json["file_name"] as? String {
|
||||
self.downloadFile(url: url, fileName: fileName)
|
||||
}
|
||||
case "web_app_toggle_orientation_lock":
|
||||
if let json = json, let lock = json["locked"] as? Bool {
|
||||
controller.parentController()?.lockOrientation = lock
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -1479,6 +1499,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
|
||||
fileprivate var needDismissConfirmation = false
|
||||
|
||||
fileprivate var fullScreenStatusBarStyle: StatusBarStyle = .White
|
||||
fileprivate var appBackgroundColor: UIColor?
|
||||
fileprivate var placeholderBackgroundColor: UIColor?
|
||||
fileprivate var headerColor: UIColor?
|
||||
@ -1534,6 +1555,23 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
self.updateNavigationBarAlpha(transition: transition)
|
||||
controller.updateNavigationBarTheme(transition: transition)
|
||||
|
||||
let statusBarStyle: StatusBarStyle
|
||||
if let primaryTextColor {
|
||||
if primaryTextColor.lightness < 0.5 {
|
||||
statusBarStyle = .Black
|
||||
} else {
|
||||
statusBarStyle = .White
|
||||
}
|
||||
} else {
|
||||
statusBarStyle = .White
|
||||
}
|
||||
|
||||
if statusBarStyle != self.fullScreenStatusBarStyle {
|
||||
self.fullScreenStatusBarStyle = statusBarStyle
|
||||
self.updateStatusBarStyle()
|
||||
self.requestLayout(transition: .immediate)
|
||||
}
|
||||
|
||||
controller.titleView?.updateTextColors(primary: primaryTextColor, secondary: secondaryTextColor, transition: transition)
|
||||
controller.cancelButtonNode.updateColor(primaryTextColor, transition: transition)
|
||||
controller.moreButtonNode.updateColor(primaryTextColor, transition: transition)
|
||||
@ -1541,6 +1579,21 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
transition.updateBackgroundColor(node: self.topOverscrollNode, color: color ?? .clear)
|
||||
}
|
||||
|
||||
private func updateStatusBarStyle() {
|
||||
guard let controller = self.controller, let parentController = controller.parentController() else {
|
||||
return
|
||||
}
|
||||
if controller.isFullscreen {
|
||||
if parentController.statusBar.statusBarStyle != self.fullScreenStatusBarStyle {
|
||||
parentController.setStatusBarStyle(self.fullScreenStatusBarStyle, animated: true)
|
||||
}
|
||||
} else {
|
||||
if parentController.statusBar.statusBarStyle != .Ignore {
|
||||
parentController.setStatusBarStyle(.Ignore, animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func handleSendData(data string: String) {
|
||||
guard let controller = self.controller, let buttonText = controller.buttonText, !self.dismissed else {
|
||||
return
|
||||
@ -2176,14 +2229,15 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
if let refreshRate {
|
||||
self.motionManager.deviceMotionUpdateInterval = refreshRate * 0.001
|
||||
}
|
||||
self.motionManager.startDeviceMotionUpdates(to: OperationQueue.main) { [weak self] data, error in
|
||||
self.motionManager.startDeviceMotionUpdates(using: .xTrueNorthZVertical, to: OperationQueue.main) { [weak self] data, error in
|
||||
guard let self, let data else {
|
||||
return
|
||||
}
|
||||
self.webView?.sendEvent(
|
||||
name: "device_orientation_changed",
|
||||
data: "{alpha: \(data.attitude.roll), beta: \(data.attitude.pitch), gamma: \(data.attitude.yaw)}"
|
||||
data: "{alpha: \(data.attitude.yaw), beta: \(data.attitude.pitch), gamma: \(data.attitude.roll)}"
|
||||
)
|
||||
print("{alpha: \(data.attitude.yaw), beta: \(data.attitude.pitch), gamma: \(data.attitude.roll)}")
|
||||
}
|
||||
} else {
|
||||
if self.motionManager.isDeviceMotionActive {
|
||||
|
Loading…
x
Reference in New Issue
Block a user