mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Browser improvements
This commit is contained in:
parent
2eeb3be2b2
commit
e0f95989d4
@ -13,17 +13,20 @@ final class BrowserAddressListComponent: Component {
|
|||||||
let context: AccountContext
|
let context: AccountContext
|
||||||
let theme: PresentationTheme
|
let theme: PresentationTheme
|
||||||
let strings: PresentationStrings
|
let strings: PresentationStrings
|
||||||
|
let insets: UIEdgeInsets
|
||||||
let navigateTo: (String) -> Void
|
let navigateTo: (String) -> Void
|
||||||
|
|
||||||
init(
|
init(
|
||||||
context: AccountContext,
|
context: AccountContext,
|
||||||
theme: PresentationTheme,
|
theme: PresentationTheme,
|
||||||
strings: PresentationStrings,
|
strings: PresentationStrings,
|
||||||
|
insets: UIEdgeInsets,
|
||||||
navigateTo: @escaping (String) -> Void
|
navigateTo: @escaping (String) -> Void
|
||||||
) {
|
) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
self.strings = strings
|
self.strings = strings
|
||||||
|
self.insets = insets
|
||||||
self.navigateTo = navigateTo
|
self.navigateTo = navigateTo
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +40,9 @@ final class BrowserAddressListComponent: Component {
|
|||||||
if lhs.strings !== rhs.strings {
|
if lhs.strings !== rhs.strings {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if lhs.insets != rhs.insets {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,6 +217,7 @@ final class BrowserAddressListComponent: Component {
|
|||||||
theme: component.theme,
|
theme: component.theme,
|
||||||
style: .plain,
|
style: .plain,
|
||||||
title: sectionTitle,
|
title: sectionTitle,
|
||||||
|
insets: component.insets,
|
||||||
actionTitle: section.id == 0 ? "Clear" : nil,
|
actionTitle: section.id == 0 ? "Clear" : nil,
|
||||||
action: { [weak self] in
|
action: { [weak self] in
|
||||||
if let self, let component = self.component {
|
if let self, let component = self.component {
|
||||||
@ -292,6 +299,7 @@ final class BrowserAddressListComponent: Component {
|
|||||||
webPage: webPage!,
|
webPage: webPage!,
|
||||||
message: itemMessage,
|
message: itemMessage,
|
||||||
hasNext: true,
|
hasNext: true,
|
||||||
|
insets: component.insets,
|
||||||
action: {
|
action: {
|
||||||
if let url = webPage?.content.url {
|
if let url = webPage?.content.url {
|
||||||
navigateTo(url)
|
navigateTo(url)
|
||||||
@ -393,6 +401,7 @@ final class BrowserAddressListComponent: Component {
|
|||||||
webPage: TelegramMediaWebpage(webpageId: EngineMedia.Id(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: "https://telegram.org", displayUrl: "https://telegram.org", hash: 0, type: nil, websiteName: "Telegram", title: "Telegram Telegram", text: "Telegram", embedUrl: nil, embedType: nil, embedSize: nil, duration: nil, author: nil, isMediaLargeByDefault: nil, image: nil, file: nil, story: nil, attributes: [], instantPage: nil))),
|
webPage: TelegramMediaWebpage(webpageId: EngineMedia.Id(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: "https://telegram.org", displayUrl: "https://telegram.org", hash: 0, type: nil, websiteName: "Telegram", title: "Telegram Telegram", text: "Telegram", embedUrl: nil, embedType: nil, embedSize: nil, duration: nil, author: nil, isMediaLargeByDefault: nil, image: nil, file: nil, story: nil, attributes: [], instantPage: nil))),
|
||||||
message: nil,
|
message: nil,
|
||||||
hasNext: true,
|
hasNext: true,
|
||||||
|
insets: .zero,
|
||||||
action: {}
|
action: {}
|
||||||
)),
|
)),
|
||||||
environment: {},
|
environment: {},
|
||||||
|
@ -16,6 +16,7 @@ final class BrowserAddressListItemComponent: Component {
|
|||||||
let webPage: TelegramMediaWebpage
|
let webPage: TelegramMediaWebpage
|
||||||
var message: Message?
|
var message: Message?
|
||||||
let hasNext: Bool
|
let hasNext: Bool
|
||||||
|
let insets: UIEdgeInsets
|
||||||
let action: () -> Void
|
let action: () -> Void
|
||||||
|
|
||||||
init(
|
init(
|
||||||
@ -24,6 +25,7 @@ final class BrowserAddressListItemComponent: Component {
|
|||||||
webPage: TelegramMediaWebpage,
|
webPage: TelegramMediaWebpage,
|
||||||
message: Message?,
|
message: Message?,
|
||||||
hasNext: Bool,
|
hasNext: Bool,
|
||||||
|
insets: UIEdgeInsets,
|
||||||
action: @escaping () -> Void
|
action: @escaping () -> Void
|
||||||
) {
|
) {
|
||||||
self.context = context
|
self.context = context
|
||||||
@ -31,6 +33,7 @@ final class BrowserAddressListItemComponent: Component {
|
|||||||
self.webPage = webPage
|
self.webPage = webPage
|
||||||
self.message = message
|
self.message = message
|
||||||
self.hasNext = hasNext
|
self.hasNext = hasNext
|
||||||
|
self.insets = insets
|
||||||
self.action = action
|
self.action = action
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,6 +47,9 @@ final class BrowserAddressListItemComponent: Component {
|
|||||||
if lhs.hasNext != rhs.hasNext {
|
if lhs.hasNext != rhs.hasNext {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if lhs.insets != rhs.insets {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +98,7 @@ final class BrowserAddressListItemComponent: Component {
|
|||||||
|
|
||||||
let iconSize = CGSize(width: 40.0, height: 40.0)
|
let iconSize = CGSize(width: 40.0, height: 40.0)
|
||||||
let height: CGFloat = 60.0
|
let height: CGFloat = 60.0
|
||||||
let leftInset: CGFloat = 11.0 + iconSize.width + 11.0
|
let leftInset: CGFloat = component.insets.left + 11.0 + iconSize.width + 11.0
|
||||||
let rightInset: CGFloat = 16.0
|
let rightInset: CGFloat = 16.0
|
||||||
let titleSpacing: CGFloat = 2.0
|
let titleSpacing: CGFloat = 2.0
|
||||||
|
|
||||||
@ -181,7 +187,7 @@ final class BrowserAddressListItemComponent: Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let iconFrame = CGRect(origin: CGPoint(x: 11.0, y: floorToScreenPixels((height - iconSize.height) / 2.0)), size: iconSize)
|
let iconFrame = CGRect(origin: CGPoint(x: 11.0 + component.insets.left, y: floorToScreenPixels((height - iconSize.height) / 2.0)), size: iconSize)
|
||||||
|
|
||||||
let iconImageLayout = self.icon.asyncLayout()
|
let iconImageLayout = self.icon.asyncLayout()
|
||||||
var iconImageApply: (() -> Void)?
|
var iconImageApply: (() -> Void)?
|
||||||
|
@ -188,7 +188,7 @@ protocol BrowserContent: UIView {
|
|||||||
|
|
||||||
func addToRecentlyVisited()
|
func addToRecentlyVisited()
|
||||||
|
|
||||||
func updateLayout(size: CGSize, insets: UIEdgeInsets, fullInsets: UIEdgeInsets, transition: ComponentTransition)
|
func updateLayout(size: CGSize, insets: UIEdgeInsets, fullInsets: UIEdgeInsets, safeInsets: UIEdgeInsets, transition: ComponentTransition)
|
||||||
|
|
||||||
func makeContentSnapshotView() -> UIView?
|
func makeContentSnapshotView() -> UIView?
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ final class BrowserDocumentContent: UIView, BrowserContent, WKNavigationDelegate
|
|||||||
self.webView.underPageBackgroundColor = presentationData.theme.list.plainBackgroundColor
|
self.webView.underPageBackgroundColor = presentationData.theme.list.plainBackgroundColor
|
||||||
}
|
}
|
||||||
if let (size, insets, fullInsets) = self.validLayout {
|
if let (size, insets, fullInsets) = self.validLayout {
|
||||||
self.updateLayout(size: size, insets: insets, fullInsets: fullInsets, transition: .immediate)
|
self.updateLayout(size: size, insets: insets, fullInsets: fullInsets, safeInsets: .zero, transition: .immediate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ final class BrowserDocumentContent: UIView, BrowserContent, WKNavigationDelegate
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var validLayout: (CGSize, UIEdgeInsets, UIEdgeInsets)?
|
private var validLayout: (CGSize, UIEdgeInsets, UIEdgeInsets)?
|
||||||
func updateLayout(size: CGSize, insets: UIEdgeInsets, fullInsets: UIEdgeInsets, transition: ComponentTransition) {
|
func updateLayout(size: CGSize, insets: UIEdgeInsets, fullInsets: UIEdgeInsets, safeInsets: UIEdgeInsets, transition: ComponentTransition) {
|
||||||
self.validLayout = (size, insets, fullInsets)
|
self.validLayout = (size, insets, fullInsets)
|
||||||
|
|
||||||
self.previousScrollingOffset = ScrollingOffsetState(value: self.webView.scrollView.contentOffset.y, isDraggingOrDecelerating: self.webView.scrollView.isDragging || self.webView.scrollView.isDecelerating)
|
self.previousScrollingOffset = ScrollingOffsetState(value: self.webView.scrollView.contentOffset.y, isDraggingOrDecelerating: self.webView.scrollView.isDragging || self.webView.scrollView.isDecelerating)
|
||||||
|
@ -301,7 +301,7 @@ final class BrowserInstantPageContent: UIView, BrowserContent, UIScrollViewDeleg
|
|||||||
guard let (size, insets, fullInsets) = self.containerLayout else {
|
guard let (size, insets, fullInsets) = self.containerLayout else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.updateLayout(size: size, insets: insets, fullInsets: fullInsets, transition: transition)
|
self.updateLayout(size: size, insets: insets, fullInsets: fullInsets, safeInsets: .zero, transition: transition)
|
||||||
}
|
}
|
||||||
|
|
||||||
func reload() {
|
func reload() {
|
||||||
@ -375,11 +375,11 @@ final class BrowserInstantPageContent: UIView, BrowserContent, UIScrollViewDeleg
|
|||||||
scrollView.setContentOffset(CGPoint(x: 0.0, y: -scrollView.contentInset.top), animated: true)
|
scrollView.setContentOffset(CGPoint(x: 0.0, y: -scrollView.contentInset.top), animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateLayout(size: CGSize, insets: UIEdgeInsets, fullInsets: UIEdgeInsets, transition: ComponentTransition) {
|
func updateLayout(size: CGSize, insets: UIEdgeInsets, fullInsets: UIEdgeInsets, safeInsets: UIEdgeInsets, transition: ComponentTransition) {
|
||||||
self.updateLayout(size: size, insets: insets, fullInsets: fullInsets, transition: transition.containedViewLayoutTransition)
|
self.updateLayout(size: size, insets: insets, fullInsets: fullInsets, safeInsets: safeInsets, transition: transition.containedViewLayoutTransition)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateLayout(size: CGSize, insets: UIEdgeInsets, fullInsets: UIEdgeInsets, transition: ContainedViewLayoutTransition) {
|
func updateLayout(size: CGSize, insets: UIEdgeInsets, fullInsets: UIEdgeInsets, safeInsets: UIEdgeInsets, transition: ContainedViewLayoutTransition) {
|
||||||
self.containerLayout = (size, insets, fullInsets)
|
self.containerLayout = (size, insets, fullInsets)
|
||||||
|
|
||||||
var updateVisibleItems = false
|
var updateVisibleItems = false
|
||||||
|
@ -111,7 +111,7 @@ final class BrowserPdfContent: UIView, BrowserContent, WKNavigationDelegate, WKU
|
|||||||
self.backgroundColor = presentationData.theme.list.plainBackgroundColor
|
self.backgroundColor = presentationData.theme.list.plainBackgroundColor
|
||||||
}
|
}
|
||||||
if let (size, insets, fullInsets) = self.validLayout {
|
if let (size, insets, fullInsets) = self.validLayout {
|
||||||
self.updateLayout(size: size, insets: insets, fullInsets: fullInsets, transition: .immediate)
|
self.updateLayout(size: size, insets: insets, fullInsets: fullInsets, safeInsets: .zero, transition: .immediate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ final class BrowserPdfContent: UIView, BrowserContent, WKNavigationDelegate, WKU
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var validLayout: (CGSize, UIEdgeInsets, UIEdgeInsets)?
|
private var validLayout: (CGSize, UIEdgeInsets, UIEdgeInsets)?
|
||||||
func updateLayout(size: CGSize, insets: UIEdgeInsets, fullInsets: UIEdgeInsets, transition: ComponentTransition) {
|
func updateLayout(size: CGSize, insets: UIEdgeInsets, fullInsets: UIEdgeInsets, safeInsets: UIEdgeInsets, transition: ComponentTransition) {
|
||||||
self.validLayout = (size, insets, fullInsets)
|
self.validLayout = (size, insets, fullInsets)
|
||||||
|
|
||||||
self.previousScrollingOffset = ScrollingOffsetState(value: self.scrollView.contentOffset.y, isDraggingOrDecelerating: self.scrollView.isDragging || self.scrollView.isDecelerating)
|
self.previousScrollingOffset = ScrollingOffsetState(value: self.scrollView.contentOffset.y, isDraggingOrDecelerating: self.scrollView.isDragging || self.scrollView.isDecelerating)
|
||||||
|
@ -261,6 +261,7 @@ private final class BrowserScreenComponent: CombinedComponent {
|
|||||||
context: context.component.context,
|
context: context.component.context,
|
||||||
theme: environment.theme,
|
theme: environment.theme,
|
||||||
strings: environment.strings,
|
strings: environment.strings,
|
||||||
|
insets: UIEdgeInsets(top: 0.0, left: environment.safeInsets.left, bottom: 0.0, right: environment.safeInsets.right),
|
||||||
navigateTo: { url in
|
navigateTo: { url in
|
||||||
performAction.invoke(.navigateTo(url))
|
performAction.invoke(.navigateTo(url))
|
||||||
}
|
}
|
||||||
@ -1371,7 +1372,7 @@ private final class BrowserContentComponent: Component {
|
|||||||
let insets = UIEdgeInsets(top: topInset, left: component.insets.left, bottom: bottomInset, right: component.insets.right)
|
let insets = UIEdgeInsets(top: topInset, left: component.insets.left, bottom: bottomInset, right: component.insets.right)
|
||||||
let fullInsets = UIEdgeInsets(top: component.insets.top + component.navigationBarHeight, left: component.insets.left, bottom: 49.0 + component.insets.bottom, right: component.insets.right)
|
let fullInsets = UIEdgeInsets(top: component.insets.top + component.navigationBarHeight, left: component.insets.left, bottom: 49.0 + component.insets.bottom, right: component.insets.right)
|
||||||
|
|
||||||
component.content.updateLayout(size: availableSize, insets: insets, fullInsets: fullInsets, transition: transition)
|
component.content.updateLayout(size: availableSize, insets: insets, fullInsets: fullInsets, safeInsets: component.insets, transition: transition)
|
||||||
transition.setFrame(view: component.content, frame: CGRect(origin: .zero, size: availableSize))
|
transition.setFrame(view: component.content, frame: CGRect(origin: .zero, size: availableSize))
|
||||||
|
|
||||||
return availableSize
|
return availableSize
|
||||||
|
@ -117,11 +117,23 @@ private final class TonSchemeHandler: NSObject, WKURLSchemeHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final class WebView: WKWebView {
|
||||||
|
var customBottomInset: CGFloat = 0.0 {
|
||||||
|
didSet {
|
||||||
|
self.setNeedsLayout()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override var safeAreaInsets: UIEdgeInsets {
|
||||||
|
return UIEdgeInsets(top: 0.0, left: 0.0, bottom: self.customBottomInset, right: 0.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKUIDelegate, UIScrollViewDelegate {
|
final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKUIDelegate, UIScrollViewDelegate {
|
||||||
private let context: AccountContext
|
private let context: AccountContext
|
||||||
private var presentationData: PresentationData
|
private var presentationData: PresentationData
|
||||||
|
|
||||||
let webView: WKWebView
|
let webView: WebView
|
||||||
|
|
||||||
private let errorView: ComponentHostView<Empty>
|
private let errorView: ComponentHostView<Empty>
|
||||||
private var currentError: Error?
|
private var currentError: Error?
|
||||||
@ -170,7 +182,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
|
|||||||
configuration.mediaPlaybackRequiresUserAction = false
|
configuration.mediaPlaybackRequiresUserAction = false
|
||||||
}
|
}
|
||||||
|
|
||||||
self.webView = WKWebView(frame: CGRect(), configuration: configuration)
|
self.webView = WebView(frame: CGRect(), configuration: configuration)
|
||||||
self.webView.allowsLinkPreview = true
|
self.webView.allowsLinkPreview = true
|
||||||
|
|
||||||
if #available(iOS 11.0, *) {
|
if #available(iOS 11.0, *) {
|
||||||
@ -245,8 +257,8 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
|
|||||||
self.backgroundColor = presentationData.theme.list.plainBackgroundColor
|
self.backgroundColor = presentationData.theme.list.plainBackgroundColor
|
||||||
self.webView.underPageBackgroundColor = presentationData.theme.list.plainBackgroundColor
|
self.webView.underPageBackgroundColor = presentationData.theme.list.plainBackgroundColor
|
||||||
}
|
}
|
||||||
if let (size, insets, fullInsets) = self.validLayout {
|
if let (size, insets, fullInsets, safeInsets) = self.validLayout {
|
||||||
self.updateLayout(size: size, insets: insets, fullInsets: fullInsets, transition: .immediate)
|
self.updateLayout(size: size, insets: insets, fullInsets: fullInsets, safeInsets: safeInsets, transition: .immediate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,13 +446,13 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
|
|||||||
self.webView.scrollView.setContentOffset(CGPoint(x: 0.0, y: -self.webView.scrollView.contentInset.top), animated: true)
|
self.webView.scrollView.setContentOffset(CGPoint(x: 0.0, y: -self.webView.scrollView.contentInset.top), animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var validLayout: (CGSize, UIEdgeInsets, UIEdgeInsets)?
|
private var validLayout: (CGSize, UIEdgeInsets, UIEdgeInsets, UIEdgeInsets)?
|
||||||
func updateLayout(size: CGSize, insets: UIEdgeInsets, fullInsets: UIEdgeInsets, transition: ComponentTransition) {
|
func updateLayout(size: CGSize, insets: UIEdgeInsets, fullInsets: UIEdgeInsets, safeInsets: UIEdgeInsets, transition: ComponentTransition) {
|
||||||
self.validLayout = (size, insets, fullInsets)
|
self.validLayout = (size, insets, fullInsets, safeInsets)
|
||||||
|
|
||||||
self.previousScrollingOffset = ScrollingOffsetState(value: self.webView.scrollView.contentOffset.y, isDraggingOrDecelerating: self.webView.scrollView.isDragging || self.webView.scrollView.isDecelerating)
|
self.previousScrollingOffset = ScrollingOffsetState(value: self.webView.scrollView.contentOffset.y, isDraggingOrDecelerating: self.webView.scrollView.isDragging || self.webView.scrollView.isDecelerating)
|
||||||
|
|
||||||
let webViewFrame = CGRect(origin: CGPoint(x: insets.left, y: insets.top), size: CGSize(width: size.width - insets.left - insets.right, height: size.height - insets.top - fullInsets.bottom))
|
let webViewFrame = CGRect(origin: CGPoint(x: insets.left, y: insets.top), size: CGSize(width: size.width - insets.left - insets.right, height: size.height - insets.top))
|
||||||
var refresh = false
|
var refresh = false
|
||||||
if self.webView.frame.width > 0 && webViewFrame.width != self.webView.frame.width {
|
if self.webView.frame.width > 0 && webViewFrame.width != self.webView.frame.width {
|
||||||
refresh = true
|
refresh = true
|
||||||
@ -451,6 +463,9 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
|
|||||||
self.webView.reloadInputViews()
|
self.webView.reloadInputViews()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.webView.scrollView.contentInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: fullInsets.bottom, right: 0.0)
|
||||||
|
self.webView.customBottomInset = max(insets.bottom, safeInsets.bottom)
|
||||||
|
// self.webView.scrollView.contentInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: 34.0, right: 0.0)
|
||||||
self.webView.scrollView.scrollIndicatorInsets = UIEdgeInsets(top: 0.0, left: -insets.left, bottom: 0.0, right: -insets.right)
|
self.webView.scrollView.scrollIndicatorInsets = UIEdgeInsets(top: 0.0, left: -insets.left, bottom: 0.0, right: -insets.right)
|
||||||
self.webView.scrollView.horizontalScrollIndicatorInsets = UIEdgeInsets(top: 0.0, left: -insets.left, bottom: 0.0, right: -insets.right)
|
self.webView.scrollView.horizontalScrollIndicatorInsets = UIEdgeInsets(top: 0.0, left: -insets.left, bottom: 0.0, right: -insets.right)
|
||||||
|
|
||||||
@ -646,8 +661,8 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
|
|||||||
} else {
|
} else {
|
||||||
self.currentError = nil
|
self.currentError = nil
|
||||||
}
|
}
|
||||||
if let (size, insets, fullInsets) = self.validLayout {
|
if let (size, insets, fullInsets, safeInsets) = self.validLayout {
|
||||||
self.updateLayout(size: size, insets: insets, fullInsets: fullInsets, transition: .immediate)
|
self.updateLayout(size: size, insets: insets, fullInsets: fullInsets, safeInsets: safeInsets, transition: .immediate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ final class SectionHeaderComponent: Component {
|
|||||||
let theme: PresentationTheme
|
let theme: PresentationTheme
|
||||||
let style: Style
|
let style: Style
|
||||||
let title: String
|
let title: String
|
||||||
|
let insets: UIEdgeInsets
|
||||||
let actionTitle: String?
|
let actionTitle: String?
|
||||||
let action: (() -> Void)?
|
let action: (() -> Void)?
|
||||||
|
|
||||||
@ -20,12 +21,14 @@ final class SectionHeaderComponent: Component {
|
|||||||
theme: PresentationTheme,
|
theme: PresentationTheme,
|
||||||
style: Style,
|
style: Style,
|
||||||
title: String,
|
title: String,
|
||||||
|
insets: UIEdgeInsets,
|
||||||
actionTitle: String?,
|
actionTitle: String?,
|
||||||
action: (() -> Void)?
|
action: (() -> Void)?
|
||||||
) {
|
) {
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
self.style = style
|
self.style = style
|
||||||
self.title = title
|
self.title = title
|
||||||
|
self.insets = insets
|
||||||
self.actionTitle = actionTitle
|
self.actionTitle = actionTitle
|
||||||
self.action = action
|
self.action = action
|
||||||
}
|
}
|
||||||
@ -40,6 +43,9 @@ final class SectionHeaderComponent: Component {
|
|||||||
if lhs.title != rhs.title {
|
if lhs.title != rhs.title {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if lhs.insets != rhs.insets {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if lhs.actionTitle != rhs.actionTitle {
|
if lhs.actionTitle != rhs.actionTitle {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -73,7 +79,7 @@ final class SectionHeaderComponent: Component {
|
|||||||
self.state = state
|
self.state = state
|
||||||
|
|
||||||
let height: CGFloat = 28.0
|
let height: CGFloat = 28.0
|
||||||
let leftInset: CGFloat = 16.0
|
let leftInset: CGFloat = 16.0 + component.insets.left
|
||||||
let rightInset: CGFloat = 0.0
|
let rightInset: CGFloat = 0.0
|
||||||
|
|
||||||
let previousTitleFrame = self.title.view?.frame
|
let previousTitleFrame = self.title.view?.frame
|
||||||
|
Loading…
x
Reference in New Issue
Block a user