mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 01:10:09 +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) {
|
func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
|
||||||
if navigationResponse.canShowMIMEType {
|
if navigationResponse.canShowMIMEType || navigationResponse.response.url?.scheme == "tonsite" {
|
||||||
decisionHandler(.allow)
|
decisionHandler(.allow)
|
||||||
} else if #available(iOS 14.5, *) {
|
} else if #available(iOS 14.5, *) {
|
||||||
if navigationResponse.response.suggestedFilename?.lowercased().hasSuffix(".pkpass") == true {
|
if navigationResponse.response.suggestedFilename?.lowercased().hasSuffix(".pkpass") == true {
|
||||||
|
|||||||
@ -169,9 +169,9 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
|||||||
return 12
|
return 12
|
||||||
case .bioPrivacy:
|
case .bioPrivacy:
|
||||||
return 13
|
return 13
|
||||||
case .birthdayPrivacy:
|
|
||||||
return 14
|
|
||||||
case .giftsAutoSavePrivacy:
|
case .giftsAutoSavePrivacy:
|
||||||
|
return 14
|
||||||
|
case .birthdayPrivacy:
|
||||||
return 15
|
return 15
|
||||||
case .forwardPrivacy:
|
case .forwardPrivacy:
|
||||||
return 16
|
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(.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(.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(.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(.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(.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)))
|
entries.append(.voiceCallPrivacy(presentationData.theme, presentationData.strings.Privacy_Calls, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.voiceCalls)))
|
||||||
if !isPremiumDisabled {
|
if !isPremiumDisabled {
|
||||||
@ -670,8 +670,8 @@ private func privacyAndSecurityControllerEntries(
|
|||||||
entries.append(.lastSeenPrivacy(presentationData.theme, presentationData.strings.PrivacySettings_LastSeen, presentationData.strings.Channel_NotificationLoading))
|
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(.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(.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(.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(.forwardPrivacy(presentationData.theme, presentationData.strings.Privacy_Forwards, presentationData.strings.Channel_NotificationLoading))
|
||||||
entries.append(.voiceCallPrivacy(presentationData.theme, presentationData.strings.Privacy_Calls, presentationData.strings.Channel_NotificationLoading))
|
entries.append(.voiceCallPrivacy(presentationData.theme, presentationData.strings.Privacy_Calls, presentationData.strings.Channel_NotificationLoading))
|
||||||
if !isPremiumDisabled {
|
if !isPremiumDisabled {
|
||||||
|
|||||||
@ -12,9 +12,11 @@ import LottieAnimationComponent
|
|||||||
|
|
||||||
final class FullscreenControlsComponent: Component {
|
final class FullscreenControlsComponent: Component {
|
||||||
let context: AccountContext
|
let context: AccountContext
|
||||||
|
let strings: PresentationStrings
|
||||||
let title: String
|
let title: String
|
||||||
let isVerified: Bool
|
let isVerified: Bool
|
||||||
let insets: UIEdgeInsets
|
let insets: UIEdgeInsets
|
||||||
|
let statusBarStyle: StatusBarStyle
|
||||||
var hasBack: Bool
|
var hasBack: Bool
|
||||||
let backPressed: () -> Void
|
let backPressed: () -> Void
|
||||||
let minimizePressed: () -> Void
|
let minimizePressed: () -> Void
|
||||||
@ -22,18 +24,22 @@ final class FullscreenControlsComponent: Component {
|
|||||||
|
|
||||||
init(
|
init(
|
||||||
context: AccountContext,
|
context: AccountContext,
|
||||||
|
strings: PresentationStrings,
|
||||||
title: String,
|
title: String,
|
||||||
isVerified: Bool,
|
isVerified: Bool,
|
||||||
insets: UIEdgeInsets,
|
insets: UIEdgeInsets,
|
||||||
|
statusBarStyle: StatusBarStyle,
|
||||||
hasBack: Bool,
|
hasBack: Bool,
|
||||||
backPressed: @escaping () -> Void,
|
backPressed: @escaping () -> Void,
|
||||||
minimizePressed: @escaping () -> Void,
|
minimizePressed: @escaping () -> Void,
|
||||||
morePressed: @escaping (ASDisplayNode, ContextGesture?) -> Void
|
morePressed: @escaping (ASDisplayNode, ContextGesture?) -> Void
|
||||||
) {
|
) {
|
||||||
self.context = context
|
self.context = context
|
||||||
|
self.strings = strings
|
||||||
self.title = title
|
self.title = title
|
||||||
self.isVerified = isVerified
|
self.isVerified = isVerified
|
||||||
self.insets = insets
|
self.insets = insets
|
||||||
|
self.statusBarStyle = statusBarStyle
|
||||||
self.hasBack = hasBack
|
self.hasBack = hasBack
|
||||||
self.backPressed = backPressed
|
self.backPressed = backPressed
|
||||||
self.minimizePressed = minimizePressed
|
self.minimizePressed = minimizePressed
|
||||||
@ -53,6 +59,9 @@ final class FullscreenControlsComponent: Component {
|
|||||||
if lhs.insets != rhs.insets {
|
if lhs.insets != rhs.insets {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if lhs.statusBarStyle != rhs.statusBarStyle {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if lhs.hasBack != rhs.hasBack {
|
if lhs.hasBack != rhs.hasBack {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -161,8 +170,8 @@ final class FullscreenControlsComponent: Component {
|
|||||||
let leftBackgroundSize = CGSize(width: 30.0, height: 30.0)
|
let leftBackgroundSize = CGSize(width: 30.0, height: 30.0)
|
||||||
let rightBackgroundSize = CGSize(width: 72.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.leftBackgroundView.updateColor(color: UIColor(white: 0.7, alpha: 0.35), transition: transition.containedViewLayoutTransition)
|
||||||
self.rightBackgroundView.updateColor(color: UIColor(white: 0.67, 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)
|
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)
|
self.rightBackgroundView.update(size: rightBackgroundSize, cornerRadius: rightBackgroundFrame.height / 2.0, transition: transition.containedViewLayoutTransition)
|
||||||
@ -170,10 +179,13 @@ final class FullscreenControlsComponent: Component {
|
|||||||
|
|
||||||
var isAnimatingTextTransition = false
|
var isAnimatingTextTransition = false
|
||||||
|
|
||||||
|
let textColor: UIColor = component.statusBarStyle == .Black ? UIColor(rgb: 0x808080) : .white
|
||||||
|
self.moreNode.updateColor(textColor, transition: .immediate)
|
||||||
|
|
||||||
var additionalLeftWidth: CGFloat = 0.0
|
var additionalLeftWidth: CGFloat = 0.0
|
||||||
let titleSize = self.title.update(
|
let titleSize = self.title.update(
|
||||||
transition: .immediate,
|
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: {},
|
environment: {},
|
||||||
containerSize: availableSize
|
containerSize: availableSize
|
||||||
)
|
)
|
||||||
@ -207,7 +219,7 @@ final class FullscreenControlsComponent: Component {
|
|||||||
|
|
||||||
let buttonTitleSize = self.buttonTitle.update(
|
let buttonTitleSize = self.buttonTitle.update(
|
||||||
transition: .immediate,
|
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: {},
|
environment: {},
|
||||||
containerSize: availableSize
|
containerSize: availableSize
|
||||||
)
|
)
|
||||||
@ -233,7 +245,7 @@ final class FullscreenControlsComponent: Component {
|
|||||||
if component.isVerified {
|
if component.isVerified {
|
||||||
let credibilitySize = self.credibility.update(
|
let credibilitySize = self.credibility.update(
|
||||||
transition: .immediate,
|
transition: .immediate,
|
||||||
component: AnyComponent(BundleIconComponent(name: "Instant View/Verified", tintColor: .white)),
|
component: AnyComponent(BundleIconComponent(name: "Instant View/Verified", tintColor: textColor)),
|
||||||
environment: {},
|
environment: {},
|
||||||
containerSize: availableSize
|
containerSize: availableSize
|
||||||
)
|
)
|
||||||
@ -284,7 +296,7 @@ final class FullscreenControlsComponent: Component {
|
|||||||
mode: .animating(loop: false),
|
mode: .animating(loop: false),
|
||||||
range: component.hasBack ? (0.5, 1.0) : (0.0, 0.5)
|
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)
|
size: CGSize(width: 30.0, height: 30.0)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@ -304,7 +316,7 @@ final class FullscreenControlsComponent: Component {
|
|||||||
transition: .immediate,
|
transition: .immediate,
|
||||||
component: AnyComponent(Button(
|
component: AnyComponent(Button(
|
||||||
content: AnyComponent(
|
content: AnyComponent(
|
||||||
BundleIconComponent(name: "Instant View/MinimizeArrow", tintColor: .white)
|
BundleIconComponent(name: "Instant View/MinimizeArrow", tintColor: textColor)
|
||||||
),
|
),
|
||||||
action: { [weak self] in
|
action: { [weak self] in
|
||||||
guard let self, let component = self.component else {
|
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)
|
placeholder = self.context.engine.messages.getAttachMenuBot(botId: controller.botId, cached: true)
|
||||||
|> map(Optional.init)
|
|> map(Optional.init)
|
||||||
|> `catch` { error -> Signal<AttachMenuBot?, NoError> in
|
|> `catch` { error -> Signal<AttachMenuBot?, NoError> in
|
||||||
return .complete()
|
return .single(nil)
|
||||||
}
|
}
|
||||||
|> mapToSignal { bot -> Signal<(FileMediaReference, Bool)?, NoError> in
|
|> mapToSignal { bot -> Signal<(FileMediaReference, Bool)?, NoError> in
|
||||||
if let bot = bot, let peerReference = PeerReference(bot.peer._asPeer()) {
|
if let bot = bot, let peerReference = PeerReference(bot.peer._asPeer()) {
|
||||||
@ -301,14 +301,14 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
return .complete()
|
return .complete()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return .complete()
|
return .single(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let placeholderData = controller.botAppSettings?.placeholderData {
|
if let placeholderData = controller.botAppSettings?.placeholderData {
|
||||||
Queue.mainQueue().justDispatch {
|
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) {
|
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)
|
self.placeholderIcon = (image.withRenderingMode(.alwaysTemplate), false)
|
||||||
if let (layout, navigationBarHeight) = self.validLayout {
|
if let (layout, navigationBarHeight) = self.validLayout {
|
||||||
@ -334,7 +334,6 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
|
|
||||||
if let fileReference = fileReference {
|
if let fileReference = fileReference {
|
||||||
let _ = freeMediaFileInteractiveFetched(account: strongSelf.context.account, userLocation: .other, fileReference: fileReference).start()
|
let _ = freeMediaFileInteractiveFetched(account: strongSelf.context.account, userLocation: .other, fileReference: fileReference).start()
|
||||||
}
|
|
||||||
let _ = (svgIconImageFile(account: strongSelf.context.account, fileReference: fileReference, stickToTop: isPlaceholder)
|
let _ = (svgIconImageFile(account: strongSelf.context.account, fileReference: fileReference, stickToTop: isPlaceholder)
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] transform in
|
|> deliverOnMainQueue).start(next: { [weak self] transform in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
@ -343,7 +342,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
let minSize = min(layout.size.width, layout.size.height)
|
let minSize = min(layout.size.width, layout.size.height)
|
||||||
imageSize = CGSize(width: minSize, height: minSize * 2.0)
|
imageSize = CGSize(width: minSize, height: minSize * 2.0)
|
||||||
} else {
|
} else {
|
||||||
imageSize = CGSize(width: 75.0, height: 75.0)
|
imageSize = CGSize(width: 78.0, height: 78.0)
|
||||||
}
|
}
|
||||||
let arguments = TransformImageArguments(corners: ImageCorners(), imageSize: imageSize, boundingSize: imageSize, intrinsicInsets: UIEdgeInsets())
|
let arguments = TransformImageArguments(corners: ImageCorners(), imageSize: imageSize, boundingSize: imageSize, intrinsicInsets: UIEdgeInsets())
|
||||||
let drawingContext = transform(arguments)
|
let drawingContext = transform(arguments)
|
||||||
@ -356,6 +355,20 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
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
|
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.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.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.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)))
|
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
|
var contentTopInset: CGFloat = 0.0
|
||||||
if controller.isFullscreen {
|
if controller.isFullscreen {
|
||||||
var added = false
|
var added = false
|
||||||
@ -706,9 +720,11 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
component: AnyComponent(
|
component: AnyComponent(
|
||||||
FullscreenControlsComponent(
|
FullscreenControlsComponent(
|
||||||
context: self.context,
|
context: self.context,
|
||||||
|
strings: self.presentationData.strings,
|
||||||
title: controller.botName,
|
title: controller.botName,
|
||||||
isVerified: controller.botVerified,
|
isVerified: controller.botVerified,
|
||||||
insets: UIEdgeInsets(top: 0.0, left: layout.safeInsets.left, bottom: 0.0, right: layout.safeInsets.right),
|
insets: UIEdgeInsets(top: 0.0, left: layout.safeInsets.left, bottom: 0.0, right: layout.safeInsets.right),
|
||||||
|
statusBarStyle: self.fullScreenStatusBarStyle,
|
||||||
hasBack: self.hasBackButton,
|
hasBack: self.hasBackButton,
|
||||||
backPressed: { [weak self] in
|
backPressed: { [weak self] in
|
||||||
guard let self else {
|
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 {
|
if let json = json, let url = json["url"] as? String, let fileName = json["file_name"] as? String {
|
||||||
self.downloadFile(url: url, fileName: fileName)
|
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:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -1479,6 +1499,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
|
|
||||||
fileprivate var needDismissConfirmation = false
|
fileprivate var needDismissConfirmation = false
|
||||||
|
|
||||||
|
fileprivate var fullScreenStatusBarStyle: StatusBarStyle = .White
|
||||||
fileprivate var appBackgroundColor: UIColor?
|
fileprivate var appBackgroundColor: UIColor?
|
||||||
fileprivate var placeholderBackgroundColor: UIColor?
|
fileprivate var placeholderBackgroundColor: UIColor?
|
||||||
fileprivate var headerColor: UIColor?
|
fileprivate var headerColor: UIColor?
|
||||||
@ -1534,6 +1555,23 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
self.updateNavigationBarAlpha(transition: transition)
|
self.updateNavigationBarAlpha(transition: transition)
|
||||||
controller.updateNavigationBarTheme(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.titleView?.updateTextColors(primary: primaryTextColor, secondary: secondaryTextColor, transition: transition)
|
||||||
controller.cancelButtonNode.updateColor(primaryTextColor, transition: transition)
|
controller.cancelButtonNode.updateColor(primaryTextColor, transition: transition)
|
||||||
controller.moreButtonNode.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)
|
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) {
|
private func handleSendData(data string: String) {
|
||||||
guard let controller = self.controller, let buttonText = controller.buttonText, !self.dismissed else {
|
guard let controller = self.controller, let buttonText = controller.buttonText, !self.dismissed else {
|
||||||
return
|
return
|
||||||
@ -2176,14 +2229,15 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
if let refreshRate {
|
if let refreshRate {
|
||||||
self.motionManager.deviceMotionUpdateInterval = refreshRate * 0.001
|
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 {
|
guard let self, let data else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.webView?.sendEvent(
|
self.webView?.sendEvent(
|
||||||
name: "device_orientation_changed",
|
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 {
|
} else {
|
||||||
if self.motionManager.isDeviceMotionActive {
|
if self.motionManager.isDeviceMotionActive {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user