mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix chat import layout
This commit is contained in:
parent
145c034ad8
commit
ee1f85226b
@ -5957,7 +5957,7 @@ Sorry for the inconvenience.";
|
|||||||
"ChatImportActivity.InProgress" = "Please keep this window open\nduring the import.";
|
"ChatImportActivity.InProgress" = "Please keep this window open\nduring the import.";
|
||||||
"ChatImportActivity.ErrorNotAdmin" = "You need to be an admin.";
|
"ChatImportActivity.ErrorNotAdmin" = "You need to be an admin.";
|
||||||
"ChatImportActivity.ErrorInvalidChatType" = "You can't import this history in this type of chat.";
|
"ChatImportActivity.ErrorInvalidChatType" = "You can't import this history in this type of chat.";
|
||||||
"ChatImportActivity.ErrorUserBlocked" = "You need to be an admin.";
|
"ChatImportActivity.ErrorUserBlocked" = "This user is blocked.";
|
||||||
"ChatImportActivity.ErrorGeneric" = "An error occurred.";
|
"ChatImportActivity.ErrorGeneric" = "An error occurred.";
|
||||||
"ChatImportActivity.Success" = "Chat imported\nsuccessfully.";
|
"ChatImportActivity.Success" = "Chat imported\nsuccessfully.";
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ private final class ImportManager {
|
|||||||
case generic
|
case generic
|
||||||
case chatAdminRequired
|
case chatAdminRequired
|
||||||
case invalidChatType
|
case invalidChatType
|
||||||
|
case userBlocked
|
||||||
}
|
}
|
||||||
|
|
||||||
enum State {
|
enum State {
|
||||||
@ -116,6 +117,8 @@ private final class ImportManager {
|
|||||||
return .invalidChatType
|
return .invalidChatType
|
||||||
case .generic:
|
case .generic:
|
||||||
return .generic
|
return .generic
|
||||||
|
case .userBlocked:
|
||||||
|
return .userBlocked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] session in
|
|> deliverOnMainQueue).start(next: { [weak self] session in
|
||||||
@ -449,12 +452,39 @@ public final class ChatImportActivityScreen: ViewController {
|
|||||||
let isFirstLayout = self.validLayout == nil
|
let isFirstLayout = self.validLayout == nil
|
||||||
self.validLayout = (layout, navigationHeight)
|
self.validLayout = (layout, navigationHeight)
|
||||||
|
|
||||||
let iconSize = CGSize(width: 190.0, height: 190.0)
|
let availableHeight = layout.size.height - navigationHeight
|
||||||
let radialStatusSize = CGSize(width: 186.0, height: 186.0)
|
|
||||||
let maxIconStatusSpacing: CGFloat = 46.0
|
var iconSize = CGSize(width: 190.0, height: 190.0)
|
||||||
let maxProgressTextSpacing: CGFloat = 33.0
|
var radialStatusSize = CGSize(width: 186.0, height: 186.0)
|
||||||
let progressStatusSpacing: CGFloat = 14.0
|
var maxIconStatusSpacing: CGFloat = 46.0
|
||||||
let statusButtonSpacing: CGFloat = 19.0
|
var maxProgressTextSpacing: CGFloat = 33.0
|
||||||
|
var progressStatusSpacing: CGFloat = 14.0
|
||||||
|
var statusButtonSpacing: CGFloat = 19.0
|
||||||
|
|
||||||
|
var maxK: CGFloat = availableHeight / (iconSize.height + maxIconStatusSpacing + 30.0 + maxProgressTextSpacing + 320.0)
|
||||||
|
maxK = max(0.5, min(1.0, maxK))
|
||||||
|
|
||||||
|
iconSize.width = floor(iconSize.width * maxK)
|
||||||
|
iconSize.height = floor(iconSize.height * maxK)
|
||||||
|
radialStatusSize.width = floor(radialStatusSize.width * maxK)
|
||||||
|
radialStatusSize.height = floor(radialStatusSize.height * maxK)
|
||||||
|
maxIconStatusSpacing = floor(maxIconStatusSpacing * maxK)
|
||||||
|
maxProgressTextSpacing = floor(maxProgressTextSpacing * maxK)
|
||||||
|
progressStatusSpacing = floor(progressStatusSpacing * maxK)
|
||||||
|
statusButtonSpacing = floor(statusButtonSpacing * maxK)
|
||||||
|
|
||||||
|
var updateRadialBackround = false
|
||||||
|
if let width = self.radialStatusBackground.image?.size.width {
|
||||||
|
if abs(width - radialStatusSize.width) > 0.01 {
|
||||||
|
updateRadialBackround = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
updateRadialBackround = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if updateRadialBackround {
|
||||||
|
self.radialStatusBackground.image = generateCircleImage(diameter: radialStatusSize.width, lineWidth: 6.0, color: self.presentationData.theme.list.itemAccentColor.withMultipliedAlpha(0.2))
|
||||||
|
}
|
||||||
|
|
||||||
let effectiveProgress: CGFloat
|
let effectiveProgress: CGFloat
|
||||||
switch state {
|
switch state {
|
||||||
@ -470,7 +500,7 @@ public final class ChatImportActivityScreen: ViewController {
|
|||||||
effectiveProgress = 1.0
|
effectiveProgress = 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
self.radialStatusText.attributedText = NSAttributedString(string: "\(Int(effectiveProgress * 100.0))%", font: Font.with(size: 36.0, design: .round, weight: .semibold), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
self.radialStatusText.attributedText = NSAttributedString(string: "\(Int(effectiveProgress * 100.0))%", font: Font.with(size: floor(36.0 * maxK), design: .round, weight: .semibold), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
||||||
let radialStatusTextSize = self.radialStatusText.updateLayout(CGSize(width: 200.0, height: .greatestFiniteMagnitude))
|
let radialStatusTextSize = self.radialStatusText.updateLayout(CGSize(width: 200.0, height: .greatestFiniteMagnitude))
|
||||||
|
|
||||||
self.progressText.attributedText = NSAttributedString(string: "\(dataSizeString(Int(effectiveProgress * CGFloat(self.totalBytes)))) of \(dataSizeString(Int(1.0 * CGFloat(self.totalBytes))))", font: Font.semibold(17.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
self.progressText.attributedText = NSAttributedString(string: "\(dataSizeString(Int(effectiveProgress * CGFloat(self.totalBytes)))) of \(dataSizeString(Int(1.0 * CGFloat(self.totalBytes))))", font: Font.semibold(17.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
||||||
@ -496,6 +526,8 @@ public final class ChatImportActivityScreen: ViewController {
|
|||||||
errorText = self.presentationData.strings.ChatImportActivity_ErrorInvalidChatType
|
errorText = self.presentationData.strings.ChatImportActivity_ErrorInvalidChatType
|
||||||
case .generic:
|
case .generic:
|
||||||
errorText = self.presentationData.strings.ChatImportActivity_ErrorGeneric
|
errorText = self.presentationData.strings.ChatImportActivity_ErrorGeneric
|
||||||
|
case .userBlocked:
|
||||||
|
errorText = self.presentationData.strings.ChatImportActivity_ErrorUserBlocked
|
||||||
}
|
}
|
||||||
self.statusText.attributedText = NSAttributedString(string: errorText, font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemDestructiveColor)
|
self.statusText.attributedText = NSAttributedString(string: errorText, font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemDestructiveColor)
|
||||||
case .done:
|
case .done:
|
||||||
@ -510,7 +542,7 @@ public final class ChatImportActivityScreen: ViewController {
|
|||||||
hideIcon = true
|
hideIcon = true
|
||||||
contentHeight = progressTextSize.height + progressStatusSpacing + 160.0
|
contentHeight = progressTextSize.height + progressStatusSpacing + 160.0
|
||||||
} else {
|
} else {
|
||||||
contentHeight = iconSize.height + maxIconStatusSpacing + radialStatusSize.height + maxProgressTextSpacing + progressTextSize.height + progressStatusSpacing + 100.0
|
contentHeight = iconSize.height + maxIconStatusSpacing + radialStatusSize.height + maxProgressTextSpacing + progressTextSize.height + progressStatusSpacing + 140.0
|
||||||
}
|
}
|
||||||
|
|
||||||
transition.updateAlpha(node: self.radialStatus, alpha: hideIcon ? 0.0 : 1.0)
|
transition.updateAlpha(node: self.radialStatus, alpha: hideIcon ? 0.0 : 1.0)
|
||||||
|
@ -2,7 +2,6 @@ import Foundation
|
|||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
import Postbox
|
||||||
import SyncCore
|
import SyncCore
|
||||||
import TelegramCore
|
|
||||||
import TelegramApi
|
import TelegramApi
|
||||||
|
|
||||||
public enum ChatHistoryImport {
|
public enum ChatHistoryImport {
|
||||||
@ -16,6 +15,7 @@ public enum ChatHistoryImport {
|
|||||||
case generic
|
case generic
|
||||||
case chatAdminRequired
|
case chatAdminRequired
|
||||||
case invalidChatType
|
case invalidChatType
|
||||||
|
case userBlocked
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ParsedInfo {
|
public enum ParsedInfo {
|
||||||
@ -71,6 +71,8 @@ public enum ChatHistoryImport {
|
|||||||
return .chatAdminRequired
|
return .chatAdminRequired
|
||||||
case "IMPORT_PEER_TYPE_INVALID":
|
case "IMPORT_PEER_TYPE_INVALID":
|
||||||
return .invalidChatType
|
return .invalidChatType
|
||||||
|
case "USER_IS_BLOCKED":
|
||||||
|
return .userBlocked
|
||||||
default:
|
default:
|
||||||
return .generic
|
return .generic
|
||||||
}
|
}
|
||||||
|
@ -542,7 +542,7 @@ public class ShareRootControllerImpl {
|
|||||||
super.containerLayoutUpdated(layout, transition: transition)
|
super.containerLayoutUpdated(layout, transition: transition)
|
||||||
|
|
||||||
let indicatorSize = self.activityIndicator.measure(CGSize(width: 100.0, height: 100.0))
|
let indicatorSize = self.activityIndicator.measure(CGSize(width: 100.0, height: 100.0))
|
||||||
transition.updateFrame(node: self.activityIndicator, frame: CGRect(origin: CGPoint(x: floor((layout.size.width - indicatorSize.width) / 2.0), y: floor((layout.size.height - indicatorSize.height - 50.0) / 2.0)), size: indicatorSize))
|
transition.updateFrame(node: self.activityIndicator, frame: CGRect(origin: CGPoint(x: floor((layout.size.width - indicatorSize.width) / 2.0), y: self.navigationHeight + floor((layout.size.height - self.navigationHeight - indicatorSize.height) / 2.0)), size: indicatorSize))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user