diff --git a/submodules/Display/Source/GridNode.swift b/submodules/Display/Source/GridNode.swift index 903c6e82b7..edb85782ee 100644 --- a/submodules/Display/Source/GridNode.swift +++ b/submodules/Display/Source/GridNode.swift @@ -248,6 +248,10 @@ open class GridNode: GridNodeScroller, UIScrollViewDelegate { public override init() { super.init() + if #available(iOS 11.0, *) { + self.scrollView.contentInsetAdjustmentBehavior = .never + } + self.scrollView.showsVerticalScrollIndicator = false self.scrollView.showsHorizontalScrollIndicator = false self.scrollView.scrollsToTop = false diff --git a/submodules/SettingsUI/Sources/Language Selection/LocalizationListController.swift b/submodules/SettingsUI/Sources/Language Selection/LocalizationListController.swift index 71019a4cc9..fc42531e3e 100644 --- a/submodules/SettingsUI/Sources/Language Selection/LocalizationListController.swift +++ b/submodules/SettingsUI/Sources/Language Selection/LocalizationListController.swift @@ -29,6 +29,8 @@ public class LocalizationListController: ViewController { private var searchContentNode: NavigationBarSearchContentNode? + private var previousContentOffset: ListViewVisibleContentOffset? + public init(context: AccountContext) { self.context = context @@ -125,8 +127,29 @@ public class LocalizationListController: ViewController { }) self.controllerNode.listNode.visibleContentOffsetChanged = { [weak self] offset in - if let strongSelf = self, let searchContentNode = strongSelf.searchContentNode { - searchContentNode.updateListVisibleContentOffset(offset) + if let strongSelf = self { + if let searchContentNode = strongSelf.searchContentNode { + searchContentNode.updateListVisibleContentOffset(offset) + } + + var previousContentOffsetValue: CGFloat? + if let previousContentOffset = strongSelf.previousContentOffset, case let .known(value) = previousContentOffset { + previousContentOffsetValue = value + } + switch offset { + case let .known(value): + let transition: ContainedViewLayoutTransition + if let previousContentOffsetValue = previousContentOffsetValue, value <= 0.0, previousContentOffsetValue > 30.0 { + transition = .animated(duration: 0.2, curve: .easeInOut) + } else { + transition = .immediate + } + strongSelf.navigationBar?.updateBackgroundAlpha(min(30.0, max(0.0, value - 54.0)) / 30.0, transition: transition) + case .unknown, .none: + strongSelf.navigationBar?.updateBackgroundAlpha(1.0, transition: .immediate) + } + + strongSelf.previousContentOffset = offset } } @@ -138,6 +161,8 @@ public class LocalizationListController: ViewController { self._ready.set(self.controllerNode._ready.get()) + self.navigationBar?.updateBackgroundAlpha(0.0, transition: .immediate) + self.displayNodeDidLoad() } diff --git a/submodules/SettingsUI/Sources/Language Selection/LocalizationListControllerNode.swift b/submodules/SettingsUI/Sources/Language Selection/LocalizationListControllerNode.swift index 92f4263eae..decd4d028a 100644 --- a/submodules/SettingsUI/Sources/Language Selection/LocalizationListControllerNode.swift +++ b/submodules/SettingsUI/Sources/Language Selection/LocalizationListControllerNode.swift @@ -275,7 +275,7 @@ private func preparedLanguageListNodeTransition(presentationData: PresentationDa final class LocalizationListControllerNode: ViewControllerTracingNode { private let context: AccountContext private var presentationData: PresentationData - private let navigationBar: NavigationBar + private weak var navigationBar: NavigationBar? private let requestActivateSearch: () -> Void private let requestDeactivateSearch: () -> Void private let present: (ViewController, Any?) -> Void @@ -314,7 +314,7 @@ final class LocalizationListControllerNode: ViewControllerTracingNode { self.present = present self.listNode = ListView() - self.listNode.keepTopItemOverscrollBackground = ListViewKeepTopItemOverscrollBackground(color: presentationData.theme.chatList.backgroundColor, direction: true) + self.listNode.keepTopItemOverscrollBackground = ListViewKeepTopItemOverscrollBackground(color: presentationData.theme.list.blocksBackgroundColor, direction: true) self.listNode.accessibilityPageScrolledString = { row, count in return presentationData.strings.VoiceOver_ScrollStatus(row, count).string } @@ -594,8 +594,8 @@ final class LocalizationListControllerNode: ViewControllerTracingNode { if let strongSelf = self, let strongPlaceholderNode = placeholderNode { if isSearchBar { strongPlaceholderNode.supernode?.insertSubnode(subnode, aboveSubnode: strongPlaceholderNode) - } else { - strongSelf.insertSubnode(subnode, belowSubnode: strongSelf.navigationBar) + } else if let navigationBar = strongSelf.navigationBar { + strongSelf.insertSubnode(subnode, belowSubnode: navigationBar) } } }, placeholder: placeholderNode) diff --git a/submodules/SettingsUI/Sources/Privacy and Security/PrivacyIntroControllerNode.swift b/submodules/SettingsUI/Sources/Privacy and Security/PrivacyIntroControllerNode.swift index 83fbd17d5c..f8264cfc43 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/PrivacyIntroControllerNode.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/PrivacyIntroControllerNode.swift @@ -9,23 +9,23 @@ import TelegramPresentationData import AccountContext import AuthorizationUI -private func generateButtonImage(backgroundColor: UIColor, borderColor: UIColor, highlightColor: UIColor?) -> UIImage? { - return generateImage(CGSize(width: 1.0, height: 44.0), contextGenerator: { size, context in +private func generateButtonImage(backgroundColor: UIColor, highlightColor: UIColor?) -> UIImage? { + return generateImage(CGSize(width: 24.0, height: 44.0), contextGenerator: { size, context in let bounds = CGRect(origin: CGPoint(), size: size) context.clear(bounds) + let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: .allCorners, cornerRadii: CGSize(width: 11.0, height: 11.0)) + context.addPath(path.cgPath) + context.clip() + if let highlightColor = highlightColor { context.setFillColor(highlightColor.cgColor) context.fill(bounds) } else { context.setFillColor(backgroundColor.cgColor) context.fill(bounds) - - context.setFillColor(borderColor.cgColor) - context.fill(CGRect(origin: CGPoint(), size: CGSize(width: 1.0, height: UIScreenPixel))) - context.fill(CGRect(origin: CGPoint(x: 0.0, y: size.height - UIScreenPixel), size: CGSize(width: 1.0, height: UIScreenPixel))) } - }) + }, opaque: false)?.stretchableImage(withLeftCapWidth: 11, topCapHeight: 11) } private let titleFont = Font.bold(17.0) @@ -105,8 +105,8 @@ final class PrivacyIntroControllerNode: ViewControllerTracingNode { self.buttonTextNode.attributedText = NSAttributedString(string: self.mode.buttonTitle(strings: presentationData.strings), font: buttonFont, textColor: presentationData.theme.list.itemAccentColor, paragraphAlignment: .center) self.buttonTextNode.isAccessibilityElement = false self.buttonNode.accessibilityLabel = self.buttonTextNode.attributedText?.string - self.buttonBackgroundNode.image = generateButtonImage(backgroundColor: presentationData.theme.list.itemBlocksBackgroundColor, borderColor: presentationData.theme.list.itemBlocksSeparatorColor, highlightColor: nil) - self.buttonHighlightedBackgroundNode.image = generateButtonImage(backgroundColor: presentationData.theme.list.itemBlocksBackgroundColor, borderColor: presentationData.theme.list.itemBlocksSeparatorColor, highlightColor: presentationData.theme.list.itemHighlightedBackgroundColor) + self.buttonBackgroundNode.image = generateButtonImage(backgroundColor: presentationData.theme.list.itemBlocksBackgroundColor, highlightColor: nil) + self.buttonHighlightedBackgroundNode.image = generateButtonImage(backgroundColor: presentationData.theme.list.itemBlocksBackgroundColor, highlightColor: presentationData.theme.list.itemHighlightedBackgroundColor) if let (layout, navigationBarHeight) = self.validLayout { self.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: .immediate) @@ -136,11 +136,18 @@ final class PrivacyIntroControllerNode: ViewControllerTracingNode { let textSize = self.textNode.measure(CGSize(width: layout.size.width - inset * 2.0, height: CGFloat.greatestFiniteMagnitude)) let noticeSize = self.noticeNode.measure(CGSize(width: layout.size.width - inset * 2.0, height: CGFloat.greatestFiniteMagnitude)) + let buttonInset: CGFloat + if layout.size.width >= 375.0 { + buttonInset = max(16.0, floor((layout.size.width - 674.0) / 2.0)) + } else { + buttonInset = 0.0 + } + let items: [AuthorizationLayoutItem] = [ AuthorizationLayoutItem(node: self.iconNode, size: iconSize, spacingBefore: AuthorizationLayoutItemSpacing(weight: 0.0, maxValue: 0.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: 0.0, maxValue: 0.0)), AuthorizationLayoutItem(node: self.titleNode, size: titleSize, spacingBefore: AuthorizationLayoutItemSpacing(weight: 20.0, maxValue: 30.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: 0.0, maxValue: 0.0)), AuthorizationLayoutItem(node: self.textNode, size: textSize, spacingBefore: AuthorizationLayoutItemSpacing(weight: 16.0, maxValue: 16.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: 0.0, maxValue: 0.0)), - AuthorizationLayoutItem(node: self.buttonNode, size: CGSize(width: layout.size.width, height: 44.0), spacingBefore: AuthorizationLayoutItemSpacing(weight: 40.0, maxValue: 40.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: 0.0, maxValue: 0.0)), + AuthorizationLayoutItem(node: self.buttonNode, size: CGSize(width: layout.size.width - buttonInset * 2.0, height: 44.0), spacingBefore: AuthorizationLayoutItemSpacing(weight: 40.0, maxValue: 40.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: 0.0, maxValue: 0.0)), AuthorizationLayoutItem(node: self.noticeNode, size: noticeSize, spacingBefore: AuthorizationLayoutItemSpacing(weight: 44.0, maxValue: 44.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: 20.0, maxValue: 40.0)) ] diff --git a/submodules/SettingsUI/Sources/Privacy and Security/RecentSessionScreen.swift b/submodules/SettingsUI/Sources/Privacy and Security/RecentSessionScreen.swift index 4617e7e5f5..f13300bfb4 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/RecentSessionScreen.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/RecentSessionScreen.swift @@ -774,7 +774,7 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe let locationValueTextFrame = CGRect(origin: CGPoint(x: fieldFrame.maxX - locationValueTextSize.width - inset, y: fieldFrame.minY + fieldItemHeight + fieldItemHeight + floorToScreenPixels((fieldItemHeight - locationValueTextSize.height) / 2.0)), size: locationValueTextSize) transition.updateFrame(node: self.locationValueNode, frame: locationValueTextFrame) - let locationInfoTextSize = self.locationInfoNode.updateLayout(CGSize(width: fieldFrame.width - inset * 2.0, height: fieldItemHeight)) + let locationInfoTextSize = self.locationInfoNode.updateLayout(CGSize(width: fieldFrame.width - inset * 2.0, height: fieldItemHeight * 2.0)) let locationInfoTextFrame = CGRect(origin: CGPoint(x: fieldFrame.minX + inset, y: fieldFrame.maxY + 6.0), size: locationInfoTextSize) transition.updateFrame(node: self.locationInfoNode, frame: locationInfoTextFrame) diff --git a/submodules/SettingsUI/Sources/Themes/ThemeColorsGridController.swift b/submodules/SettingsUI/Sources/Themes/ThemeColorsGridController.swift index 563df18433..f0d120c73f 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeColorsGridController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeColorsGridController.swift @@ -119,6 +119,8 @@ final class ThemeColorsGridController: ViewController { private var validLayout: ContainerViewLayout? + private var previousContentOffset: GridNodeVisibleContentOffset? + init(context: AccountContext) { self.context = context self.presentationData = context.sharedContext.currentPresentationData.with { $0 } @@ -216,9 +218,34 @@ final class ThemeColorsGridController: ViewController { }) } }) + + self.controllerNode.gridNode.visibleContentOffsetChanged = { [weak self] offset in + if let strongSelf = self { + var previousContentOffsetValue: CGFloat? + if let previousContentOffset = strongSelf.previousContentOffset, case let .known(value) = previousContentOffset { + previousContentOffsetValue = value + } + switch offset { + case let .known(value): + let transition: ContainedViewLayoutTransition + if let previousContentOffsetValue = previousContentOffsetValue, value <= 0.0, previousContentOffsetValue > 30.0 { + transition = .animated(duration: 0.2, curve: .easeInOut) + } else { + transition = .immediate + } + strongSelf.navigationBar?.updateBackgroundAlpha(min(30.0, max(0.0, value - 54.0)) / 30.0, transition: transition) + case .unknown, .none: + strongSelf.navigationBar?.updateBackgroundAlpha(1.0, transition: .immediate) + } + + strongSelf.previousContentOffset = offset + } + } self._ready.set(self.controllerNode.ready.get()) + self.navigationBar?.updateBackgroundAlpha(0.0, transition: .immediate) + self.displayNodeDidLoad() } diff --git a/submodules/SettingsUI/Sources/Themes/ThemeColorsGridControllerNode.swift b/submodules/SettingsUI/Sources/Themes/ThemeColorsGridControllerNode.swift index bb37b5bdfa..b093d4428b 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeColorsGridControllerNode.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeColorsGridControllerNode.swift @@ -94,7 +94,7 @@ final class ThemeColorsGridControllerNode: ASDisplayNode { self.presentColorPicker = presentColorPicker self.gridNode = GridNode() - self.gridNode.showVerticalScrollIndicator = true + self.gridNode.showVerticalScrollIndicator = false self.leftOverlayNode = ASDisplayNode() self.leftOverlayNode.backgroundColor = presentationData.theme.list.blocksBackgroundColor self.rightOverlayNode = ASDisplayNode() @@ -271,8 +271,8 @@ final class ThemeColorsGridControllerNode: ASDisplayNode { let spacing = floor((layout.size.width - CGFloat(imageCount) * imageSize.width) / CGFloat(imageCount + 1)) var listInsets = insets - if layout.size.width > 480.0 { - let inset = max(20.0, floor((layout.size.width - 674.0) / 2.0)) + if layout.size.width >= 375.0 { + let inset = max(16.0, floor((layout.size.width - 674.0) / 2.0)) listInsets.left += inset listInsets.right += inset @@ -307,8 +307,8 @@ final class ThemeColorsGridControllerNode: ASDisplayNode { transition.updateFrame(node: self.separatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: -buttonOffset + buttonInset - UIScreenPixel), size: CGSize(width: layout.size.width, height: UIScreenPixel))) transition.updateFrame(node: self.customColorItemNode, frame: CGRect(origin: CGPoint(x: 0.0, y: -buttonOffset + buttonTopInset), size: colorLayout.contentSize)) - self.leftOverlayNode.frame = CGRect(x: 0.0, y: -buttonOffset, width: listInsets.left, height: buttonTopInset + colorLayout.contentSize.height) - self.rightOverlayNode.frame = CGRect(x: layout.size.width - listInsets.right, y: -buttonOffset, width: listInsets.right, height: buttonTopInset + colorLayout.contentSize.height) + self.leftOverlayNode.frame = CGRect(x: 0.0, y: -buttonOffset, width: listInsets.left, height: buttonTopInset + colorLayout.contentSize.height + UIScreenPixel) + self.rightOverlayNode.frame = CGRect(x: layout.size.width - listInsets.right, y: -buttonOffset, width: listInsets.right, height: buttonTopInset + colorLayout.contentSize.height + UIScreenPixel) insets.top += spacing + buttonInset diff --git a/submodules/SettingsUI/Sources/Themes/ThemeGridController.swift b/submodules/SettingsUI/Sources/Themes/ThemeGridController.swift index b39af5c582..de77491fc9 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeGridController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeGridController.swift @@ -42,6 +42,8 @@ final class ThemeGridController: ViewController { return false } + private var previousContentOffset: GridNodeVisibleContentOffset? + init(context: AccountContext) { self.context = context self.presentationData = context.sharedContext.currentPresentationData.with { $0 } @@ -322,8 +324,29 @@ final class ThemeGridController: ViewController { } self.controllerNode.gridNode.visibleContentOffsetChanged = { [weak self] offset in - if let strongSelf = self, let searchContentNode = strongSelf.searchContentNode { - searchContentNode.updateGridVisibleContentOffset(offset) + if let strongSelf = self { + if let searchContentNode = strongSelf.searchContentNode { + searchContentNode.updateGridVisibleContentOffset(offset) + } + + var previousContentOffsetValue: CGFloat? + if let previousContentOffset = strongSelf.previousContentOffset, case let .known(value) = previousContentOffset { + previousContentOffsetValue = value + } + switch offset { + case let .known(value): + let transition: ContainedViewLayoutTransition + if let previousContentOffsetValue = previousContentOffsetValue, value <= 0.0, previousContentOffsetValue > 30.0 { + transition = .animated(duration: 0.2, curve: .easeInOut) + } else { + transition = .immediate + } + strongSelf.navigationBar?.updateBackgroundAlpha(min(30.0, max(0.0, value - 54.0)) / 30.0, transition: transition) + case .unknown, .none: + strongSelf.navigationBar?.updateBackgroundAlpha(1.0, transition: .immediate) + } + + strongSelf.previousContentOffset = offset } } @@ -335,6 +358,8 @@ final class ThemeGridController: ViewController { self._ready.set(self.controllerNode.ready.get()) + self.navigationBar?.updateBackgroundAlpha(0.0, transition: .immediate) + self.displayNodeDidLoad() } diff --git a/submodules/SettingsUI/Sources/Themes/ThemeGridControllerNode.swift b/submodules/SettingsUI/Sources/Themes/ThemeGridControllerNode.swift index 47906302d9..0e5c284b63 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeGridControllerNode.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeGridControllerNode.swift @@ -202,7 +202,7 @@ final class ThemeGridControllerNode: ASDisplayNode { self.resetWallpapers = resetWallpapers self.gridNode = GridNode() - self.gridNode.showVerticalScrollIndicator = true + self.gridNode.showVerticalScrollIndicator = false self.leftOverlayNode = ASDisplayNode() self.leftOverlayNode.backgroundColor = presentationData.theme.list.blocksBackgroundColor self.rightOverlayNode = ASDisplayNode() @@ -609,6 +609,7 @@ final class ThemeGridControllerNode: ASDisplayNode { insets.top += navigationBarHeight insets.left = layout.safeInsets.left insets.right = layout.safeInsets.right + var scrollIndicatorInsets = insets let minSpacing: CGFloat = 8.0 @@ -628,8 +629,8 @@ final class ThemeGridControllerNode: ASDisplayNode { let makeDescriptionLayout = self.descriptionItemNode.asyncLayout() var listInsets = insets - if layout.size.width > 480.0 { - let inset = max(20.0, floor((layout.size.width - 674.0) / 2.0)) + if layout.size.width >= 375.0 { + let inset = max(16.0, floor((layout.size.width - 674.0) / 2.0)) listInsets.left += inset listInsets.right += inset