mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 09:20:08 +00:00
Tune account deletion layout
This commit is contained in:
parent
17c61062b8
commit
59ab7bce00
@ -18,15 +18,17 @@ public class InviteLinkHeaderItem: ListViewItem, ItemListItem {
|
|||||||
public let title: String?
|
public let title: String?
|
||||||
public let text: String
|
public let text: String
|
||||||
public let animationName: String
|
public let animationName: String
|
||||||
|
public let hideOnSmallScreens: Bool
|
||||||
public let sectionId: ItemListSectionId
|
public let sectionId: ItemListSectionId
|
||||||
public let linkAction: ((ItemListTextItemLinkAction) -> Void)?
|
public let linkAction: ((ItemListTextItemLinkAction) -> Void)?
|
||||||
|
|
||||||
public init(context: AccountContext, theme: PresentationTheme, title: String? = nil, text: String, animationName: String, sectionId: ItemListSectionId, linkAction: ((ItemListTextItemLinkAction) -> Void)? = nil) {
|
public init(context: AccountContext, theme: PresentationTheme, title: String? = nil, text: String, animationName: String, hideOnSmallScreens: Bool = false, sectionId: ItemListSectionId, linkAction: ((ItemListTextItemLinkAction) -> Void)? = nil) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
self.title = title
|
self.title = title
|
||||||
self.text = text
|
self.text = text
|
||||||
self.animationName = animationName
|
self.animationName = animationName
|
||||||
|
self.hideOnSmallScreens = hideOnSmallScreens
|
||||||
self.sectionId = sectionId
|
self.sectionId = sectionId
|
||||||
self.linkAction = linkAction
|
self.linkAction = linkAction
|
||||||
}
|
}
|
||||||
@ -117,9 +119,13 @@ class InviteLinkHeaderItemNode: ListViewItemNode {
|
|||||||
let iconSize: CGSize
|
let iconSize: CGSize
|
||||||
if params.width > params.availableHeight && params.width > 320.0 {
|
if params.width > params.availableHeight && params.width > 320.0 {
|
||||||
iconSize = CGSize(width: 140.0, height: 140.0)
|
iconSize = CGSize(width: 140.0, height: 140.0)
|
||||||
|
} else {
|
||||||
|
if item.hideOnSmallScreens {
|
||||||
|
iconSize = .zero
|
||||||
} else {
|
} else {
|
||||||
iconSize = CGSize(width: 124.0, height: 124.0)
|
iconSize = CGSize(width: 124.0, height: 124.0)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
let topInset: CGFloat = iconSize.height - 4.0
|
let topInset: CGFloat = iconSize.height - 4.0
|
||||||
let spacing: CGFloat = 5.0
|
let spacing: CGFloat = 5.0
|
||||||
|
|
||||||
@ -137,6 +143,7 @@ class InviteLinkHeaderItemNode: ListViewItemNode {
|
|||||||
if let _ = item.title {
|
if let _ = item.title {
|
||||||
contentSize.height += titleLayout.size.height + spacing
|
contentSize.height += titleLayout.size.height + spacing
|
||||||
}
|
}
|
||||||
|
|
||||||
let insets = itemListNeighborsGroupedInsets(neighbors, params)
|
let insets = itemListNeighborsGroupedInsets(neighbors, params)
|
||||||
|
|
||||||
let layout = ListViewItemNodeLayout(contentSize: contentSize, insets: insets)
|
let layout = ListViewItemNodeLayout(contentSize: contentSize, insets: insets)
|
||||||
|
|||||||
@ -44,7 +44,7 @@ private enum DeleteAccountEntryTag: Equatable, ItemListItemTag {
|
|||||||
|
|
||||||
|
|
||||||
private enum DeleteAccountDataEntry: ItemListNodeEntry, Equatable {
|
private enum DeleteAccountDataEntry: ItemListNodeEntry, Equatable {
|
||||||
case header(PresentationTheme, String, String, String)
|
case header(PresentationTheme, String, String, String, Bool)
|
||||||
case peers(PresentationTheme, [EnginePeer])
|
case peers(PresentationTheme, [EnginePeer])
|
||||||
case phone(PresentationTheme, PresentationStrings)
|
case phone(PresentationTheme, PresentationStrings)
|
||||||
case password(PresentationTheme, String)
|
case password(PresentationTheme, String)
|
||||||
@ -76,8 +76,8 @@ private enum DeleteAccountDataEntry: ItemListNodeEntry, Equatable {
|
|||||||
|
|
||||||
static func == (lhs: DeleteAccountDataEntry, rhs: DeleteAccountDataEntry) -> Bool {
|
static func == (lhs: DeleteAccountDataEntry, rhs: DeleteAccountDataEntry) -> Bool {
|
||||||
switch lhs {
|
switch lhs {
|
||||||
case let .header(lhsTheme, lhsAnimation, lhsTitle, lhsText):
|
case let .header(lhsTheme, lhsAnimation, lhsTitle, lhsText, lhsHideOnSmallScreens):
|
||||||
if case let .header(rhsTheme, rhsAnimation, rhsTitle, rhsText) = rhs, lhsTheme === rhsTheme, lhsAnimation == rhsAnimation, lhsTitle == rhsTitle, lhsText == rhsText {
|
if case let .header(rhsTheme, rhsAnimation, rhsTitle, rhsText, rhsHideOnSmallScreens) = rhs, lhsTheme === rhsTheme, lhsAnimation == rhsAnimation, lhsTitle == rhsTitle, lhsText == rhsText, lhsHideOnSmallScreens == rhsHideOnSmallScreens {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
@ -117,8 +117,8 @@ private enum DeleteAccountDataEntry: ItemListNodeEntry, Equatable {
|
|||||||
func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem {
|
func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem {
|
||||||
let arguments = arguments as! DeleteAccountDataArguments
|
let arguments = arguments as! DeleteAccountDataArguments
|
||||||
switch self {
|
switch self {
|
||||||
case let .header(theme, animation, title, text):
|
case let .header(theme, animation, title, text, hideOnSmallScreens):
|
||||||
return InviteLinkHeaderItem(context: arguments.context, theme: theme, title: title, text: text, animationName: animation, sectionId: self.section, linkAction: nil)
|
return InviteLinkHeaderItem(context: arguments.context, theme: theme, title: title, text: text, animationName: animation, hideOnSmallScreens: hideOnSmallScreens, sectionId: self.section, linkAction: nil)
|
||||||
case let .peers(_, peers):
|
case let .peers(_, peers):
|
||||||
return DeleteAccountPeersItem(context: arguments.context, theme: presentationData.theme, strings: presentationData.strings, peers: peers, sectionId: self.section)
|
return DeleteAccountPeersItem(context: arguments.context, theme: presentationData.theme, strings: presentationData.strings, peers: peers, sectionId: self.section)
|
||||||
case let .info(_, text):
|
case let .info(_, text):
|
||||||
@ -145,6 +145,7 @@ private func deleteAccountDataEntries(presentationData: PresentationData, mode:
|
|||||||
let headerTitle: String
|
let headerTitle: String
|
||||||
let headerText: String
|
let headerText: String
|
||||||
let headerAnimation: String
|
let headerAnimation: String
|
||||||
|
var hideOnSmallScreen = false
|
||||||
|
|
||||||
switch mode {
|
switch mode {
|
||||||
case .peers:
|
case .peers:
|
||||||
@ -163,13 +164,15 @@ private func deleteAccountDataEntries(presentationData: PresentationData, mode:
|
|||||||
headerAnimation = "Delete4"
|
headerAnimation = "Delete4"
|
||||||
headerTitle = presentationData.strings.DeleteAccount_EnterPhoneNumber
|
headerTitle = presentationData.strings.DeleteAccount_EnterPhoneNumber
|
||||||
headerText = ""
|
headerText = ""
|
||||||
|
hideOnSmallScreen = true
|
||||||
case .password:
|
case .password:
|
||||||
headerAnimation = "Delete5"
|
headerAnimation = "Delete5"
|
||||||
headerTitle = presentationData.strings.DeleteAccount_EnterPassword
|
headerTitle = presentationData.strings.DeleteAccount_EnterPassword
|
||||||
headerText = ""
|
headerText = ""
|
||||||
|
hideOnSmallScreen = true
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.append(.header(presentationData.theme, headerAnimation, headerTitle, headerText))
|
entries.append(.header(presentationData.theme, headerAnimation, headerTitle, headerText, hideOnSmallScreen))
|
||||||
|
|
||||||
switch mode {
|
switch mode {
|
||||||
case .peers:
|
case .peers:
|
||||||
|
|||||||
@ -118,8 +118,17 @@ final class DeleteAccountFooterItemNode: ItemListControllerFooterItemNode {
|
|||||||
let buttonWidth = layout.size.width - layout.safeInsets.left - layout.safeInsets.right - buttonInset * 2.0
|
let buttonWidth = layout.size.width - layout.safeInsets.left - layout.safeInsets.right - buttonInset * 2.0
|
||||||
let buttonHeight = self.buttonNode.updateLayout(width: buttonWidth, transition: transition)
|
let buttonHeight = self.buttonNode.updateLayout(width: buttonWidth, transition: transition)
|
||||||
let topInset: CGFloat = 9.0
|
let topInset: CGFloat = 9.0
|
||||||
let bottomInset: CGFloat = 23.0
|
|
||||||
let spacing: CGFloat = 23.0
|
let bottomInset: CGFloat
|
||||||
|
let spacing: CGFloat
|
||||||
|
|
||||||
|
if layout.size.width > 320.0 {
|
||||||
|
bottomInset = 23.0
|
||||||
|
spacing = 23.0
|
||||||
|
} else {
|
||||||
|
bottomInset = 16.0
|
||||||
|
spacing = 16.0
|
||||||
|
}
|
||||||
|
|
||||||
let insets = layout.insets(options: [.input])
|
let insets = layout.insets(options: [.input])
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user