mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Various fixes
This commit is contained in:
@@ -80,6 +80,8 @@ private final class BrowserScreenComponent: CombinedComponent {
|
||||
let performAction = context.component.performAction
|
||||
let performHoldAction = context.component.performHoldAction
|
||||
|
||||
let isTablet = environment.metrics.isTablet
|
||||
|
||||
let navigationContent: AnyComponentWithIdentity<BrowserNavigationBarEnvironment>?
|
||||
var navigationLeftItems: [AnyComponentWithIdentity<Empty>]
|
||||
var navigationRightItems: [AnyComponentWithIdentity<Empty>]
|
||||
@@ -106,6 +108,7 @@ private final class BrowserScreenComponent: CombinedComponent {
|
||||
AddressBarContentComponent(
|
||||
theme: environment.theme,
|
||||
strings: environment.strings,
|
||||
metrics: environment.metrics,
|
||||
url: context.component.contentState?.url ?? "",
|
||||
isSecure: context.component.contentState?.isSecure ?? false,
|
||||
isExpanded: context.component.presentationState.addressFocused,
|
||||
@@ -126,7 +129,7 @@ private final class BrowserScreenComponent: CombinedComponent {
|
||||
)
|
||||
}
|
||||
|
||||
if context.component.presentationState.addressFocused {
|
||||
if context.component.presentationState.addressFocused && !isTablet {
|
||||
navigationLeftItems = []
|
||||
navigationRightItems = []
|
||||
} else {
|
||||
@@ -146,6 +149,68 @@ private final class BrowserScreenComponent: CombinedComponent {
|
||||
)
|
||||
]
|
||||
|
||||
if isTablet {
|
||||
navigationLeftItems.append(
|
||||
AnyComponentWithIdentity(
|
||||
id: "minimize",
|
||||
component: AnyComponent(
|
||||
Button(
|
||||
content: AnyComponent(
|
||||
BundleIconComponent(
|
||||
name: "Media Gallery/PictureInPictureButton",
|
||||
tintColor: environment.theme.rootController.navigationBar.accentTextColor
|
||||
)
|
||||
),
|
||||
action: {
|
||||
performAction.invoke(.close)
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
let canGoBack = context.component.contentState?.canGoBack ?? false
|
||||
let canGoForward = context.component.contentState?.canGoForward ?? false
|
||||
|
||||
navigationLeftItems.append(
|
||||
AnyComponentWithIdentity(
|
||||
id: "back",
|
||||
component: AnyComponent(
|
||||
Button(
|
||||
content: AnyComponent(
|
||||
BundleIconComponent(
|
||||
name: "Instant View/Back",
|
||||
tintColor: environment.theme.rootController.navigationBar.accentTextColor.withAlphaComponent(canGoBack ? 1.0 : 0.4)
|
||||
)
|
||||
),
|
||||
action: {
|
||||
performAction.invoke(.navigateBack)
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
navigationLeftItems.append(
|
||||
AnyComponentWithIdentity(
|
||||
id: "forward",
|
||||
component: AnyComponent(
|
||||
Button(
|
||||
content: AnyComponent(
|
||||
BundleIconComponent(
|
||||
name: "Instant View/Forward",
|
||||
tintColor: environment.theme.rootController.navigationBar.accentTextColor.withAlphaComponent(canGoForward ? 1.0 : 0.4)
|
||||
)
|
||||
),
|
||||
action: {
|
||||
performAction.invoke(.navigateForward)
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
navigationRightItems = [
|
||||
AnyComponentWithIdentity(
|
||||
id: "settings",
|
||||
@@ -168,6 +233,65 @@ private final class BrowserScreenComponent: CombinedComponent {
|
||||
)
|
||||
)
|
||||
]
|
||||
|
||||
if isTablet {
|
||||
navigationRightItems.insert(
|
||||
AnyComponentWithIdentity(
|
||||
id: "bookmarks",
|
||||
component: AnyComponent(
|
||||
Button(
|
||||
content: AnyComponent(
|
||||
BundleIconComponent(
|
||||
name: "Instant View/Bookmark",
|
||||
tintColor: environment.theme.rootController.navigationBar.accentTextColor
|
||||
)
|
||||
),
|
||||
action: {
|
||||
performAction.invoke(.openBookmarks)
|
||||
}
|
||||
)
|
||||
)
|
||||
),
|
||||
at: 0
|
||||
)
|
||||
navigationRightItems.insert(
|
||||
AnyComponentWithIdentity(
|
||||
id: "share",
|
||||
component: AnyComponent(
|
||||
Button(
|
||||
content: AnyComponent(
|
||||
BundleIconComponent(
|
||||
name: "Chat List/NavigationShare",
|
||||
tintColor: environment.theme.rootController.navigationBar.accentTextColor
|
||||
)
|
||||
),
|
||||
action: {
|
||||
performAction.invoke(.share)
|
||||
}
|
||||
)
|
||||
)
|
||||
),
|
||||
at: 0
|
||||
)
|
||||
navigationRightItems.append(
|
||||
AnyComponentWithIdentity(
|
||||
id: "openIn",
|
||||
component: AnyComponent(
|
||||
Button(
|
||||
content: AnyComponent(
|
||||
BundleIconComponent(
|
||||
name: "Instant View/Browser",
|
||||
tintColor: environment.theme.rootController.navigationBar.accentTextColor
|
||||
)
|
||||
),
|
||||
action: {
|
||||
performAction.invoke(.openIn)
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +307,7 @@ private final class BrowserScreenComponent: CombinedComponent {
|
||||
topInset: environment.statusBarHeight,
|
||||
height: environment.navigationHeight - environment.statusBarHeight,
|
||||
sideInset: environment.safeInsets.left,
|
||||
metrics: environment.metrics,
|
||||
leftItems: navigationLeftItems,
|
||||
rightItems: navigationRightItems,
|
||||
centerItem: navigationContent,
|
||||
@@ -238,22 +363,36 @@ private final class BrowserScreenComponent: CombinedComponent {
|
||||
toolbarBottomInset = environment.safeInsets.bottom
|
||||
}
|
||||
|
||||
let toolbar = toolbar.update(
|
||||
component: BrowserToolbarComponent(
|
||||
backgroundColor: environment.theme.rootController.navigationBar.blurredBackgroundColor,
|
||||
separatorColor: environment.theme.rootController.navigationBar.separatorColor,
|
||||
textColor: environment.theme.rootController.navigationBar.primaryTextColor,
|
||||
bottomInset: toolbarBottomInset,
|
||||
sideInset: environment.safeInsets.left,
|
||||
item: toolbarContent,
|
||||
collapseFraction: collapseFraction
|
||||
),
|
||||
availableSize: context.availableSize,
|
||||
transition: context.transition
|
||||
)
|
||||
context.add(toolbar
|
||||
.position(CGPoint(x: context.availableSize.width / 2.0, y: context.availableSize.height - toolbar.size.height / 2.0))
|
||||
)
|
||||
var toolbarSize: CGFloat = 0.0
|
||||
if isTablet && !context.component.presentationState.isSearching {
|
||||
|
||||
} else {
|
||||
let toolbar = toolbar.update(
|
||||
component: BrowserToolbarComponent(
|
||||
backgroundColor: environment.theme.rootController.navigationBar.blurredBackgroundColor,
|
||||
separatorColor: environment.theme.rootController.navigationBar.separatorColor,
|
||||
textColor: environment.theme.rootController.navigationBar.primaryTextColor,
|
||||
bottomInset: toolbarBottomInset,
|
||||
sideInset: environment.safeInsets.left,
|
||||
item: toolbarContent,
|
||||
collapseFraction: collapseFraction
|
||||
),
|
||||
availableSize: context.availableSize,
|
||||
transition: context.transition
|
||||
)
|
||||
context.add(toolbar
|
||||
.position(CGPoint(x: context.availableSize.width / 2.0, y: context.availableSize.height - toolbar.size.height / 2.0))
|
||||
.appear(ComponentTransition.Appear { _, view, transition in
|
||||
transition.animatePosition(view: view, from: CGPoint(x: 0.0, y: view.frame.height), to: CGPoint(), additive: true)
|
||||
})
|
||||
.disappear(ComponentTransition.Disappear { view, transition, completion in
|
||||
transition.animatePosition(view: view, from: CGPoint(), to: CGPoint(x: 0.0, y: view.frame.height), additive: true, completion: { _ in
|
||||
completion()
|
||||
})
|
||||
})
|
||||
)
|
||||
toolbarSize = toolbar.size.height
|
||||
}
|
||||
|
||||
if context.component.presentationState.addressFocused {
|
||||
let addressList = addressList.update(
|
||||
@@ -266,7 +405,7 @@ private final class BrowserScreenComponent: CombinedComponent {
|
||||
performAction.invoke(.navigateTo(url))
|
||||
}
|
||||
),
|
||||
availableSize: CGSize(width: context.availableSize.width, height: context.availableSize.height - navigationBar.size.height - toolbar.size.height),
|
||||
availableSize: CGSize(width: context.availableSize.width, height: context.availableSize.height - navigationBar.size.height - toolbarSize),
|
||||
transition: context.transition
|
||||
)
|
||||
context.add(addressList
|
||||
@@ -1241,7 +1380,11 @@ public class BrowserScreen: ViewController, MinimizableController {
|
||||
|
||||
super.containerLayoutUpdated(layout, transition: transition)
|
||||
|
||||
self.node.containerLayoutUpdated(layout: layout, navigationBarHeight: self.navigationLayout(layout: layout).navigationFrame.height, transition: ComponentTransition(transition))
|
||||
var navigationHeight = self.navigationLayout(layout: layout).navigationFrame.height
|
||||
if layout.metrics.isTablet, layout.size.width > layout.size.height {
|
||||
navigationHeight += 6.0
|
||||
}
|
||||
self.node.containerLayoutUpdated(layout: layout, navigationBarHeight: navigationHeight, transition: ComponentTransition(transition))
|
||||
}
|
||||
|
||||
public func requestMinimize(topEdgeOffset: CGFloat?, initialVelocity: CGFloat?) {
|
||||
@@ -1249,6 +1392,15 @@ public class BrowserScreen: ViewController, MinimizableController {
|
||||
self.node.minimize(topEdgeOffset: topEdgeOffset, damping: 180.0, initialVelocity: initialVelocity)
|
||||
}
|
||||
|
||||
private var didPlayAppearanceAnimation = false
|
||||
public override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
if !self.didPlayAppearanceAnimation, let layout = self.validLayout, layout.metrics.isTablet {
|
||||
self.node.layer.animatePosition(from: CGPoint(x: 0.0, y: layout.size.height), to: .zero, duration: 0.4, timingFunction: kCAMediaTimingFunctionSpring, additive: true)
|
||||
}
|
||||
}
|
||||
|
||||
public override func viewWillDisappear(_ animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user