Fix UI issues

This commit is contained in:
Ali 2019-11-28 22:30:32 +04:00
parent 5e620dc318
commit a037b4d491
12 changed files with 101 additions and 12 deletions

View File

@ -69,6 +69,7 @@ public final class AppLockContextImpl: AppLockContext {
private let accountManager: AccountManager
private let presentationDataSignal: Signal<PresentationData, NoError>
private let window: Window1?
private let rootController: UIViewController?
private var coveringView: LockedWindowCoveringView?
private var passcodeController: PasscodeEntryController?
@ -89,7 +90,7 @@ public final class AppLockContextImpl: AppLockContext {
private var lastActiveTimestamp: Double?
private var lastActiveValue: Bool = false
public init(rootPath: String, window: Window1?, applicationBindings: TelegramApplicationBindings, accountManager: AccountManager, presentationDataSignal: Signal<PresentationData, NoError>, lockIconInitialFrame: @escaping () -> CGRect?) {
public init(rootPath: String, window: Window1?, rootController: UIViewController?, applicationBindings: TelegramApplicationBindings, accountManager: AccountManager, presentationDataSignal: Signal<PresentationData, NoError>, lockIconInitialFrame: @escaping () -> CGRect?) {
assert(Queue.mainQueue().isCurrent())
self.applicationBindings = applicationBindings
@ -97,6 +98,7 @@ public final class AppLockContextImpl: AppLockContext {
self.presentationDataSignal = presentationDataSignal
self.rootPath = rootPath
self.window = window
self.rootController = rootController
if let data = try? Data(contentsOf: URL(fileURLWithPath: appLockStatePath(rootPath: self.rootPath))), let current = try? JSONDecoder().decode(LockState.self, from: data) {
self.currentStateValue = current
@ -185,6 +187,9 @@ public final class AppLockContextImpl: AppLockContext {
}
passcodeController.presentedOverCoveringView = true
strongSelf.passcodeController = passcodeController
if let rootViewController = strongSelf.rootController {
rootViewController.dismiss(animated: false, completion: nil)
}
strongSelf.window?.present(passcodeController, on: .passcode)
}
} else if let passcodeController = strongSelf.passcodeController {
@ -202,6 +207,10 @@ public final class AppLockContextImpl: AppLockContext {
coveringView.updateSnapshot(getCoveringViewSnaphot(window: window))
strongSelf.coveringView = coveringView
window.coveringView = coveringView
if let rootViewController = strongSelf.rootController {
rootViewController.dismiss(animated: false, completion: nil)
}
}
} else {
if let coveringView = strongSelf.coveringView {

View File

@ -1420,7 +1420,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
strongSelf.secretIconNode = iconNode
}
iconNode.image = currentSecretIconImage
transition.updateFrame(node: iconNode, frame: CGRect(origin: CGPoint(x: contentRect.origin.x, y: contentRect.origin.y + floor((strongSelf.titleNode.frame.height - currentSecretIconImage.size.height) / 2.0)), size: currentSecretIconImage.size))
transition.updateFrame(node: iconNode, frame: CGRect(origin: CGPoint(x: contentRect.origin.x, y: contentRect.origin.y + floor((titleLayout.size.height - currentSecretIconImage.size.height) / 2.0)), size: currentSecretIconImage.size))
titleOffset += currentSecretIconImage.size.width + 3.0
} else if let secretIconNode = strongSelf.secretIconNode {
strongSelf.secretIconNode = nil

View File

@ -61,7 +61,7 @@ public class ActionSheetTextNode: ActionSheetItemNode {
func setItem(_ item: ActionSheetTextItem) {
self.item = item
let defaultFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0))
let defaultFont = Font.regular(floor(theme.baseFontSize * 13.0 / 17.0))
self.label.attributedText = NSAttributedString(string: item.title, font: defaultFont, textColor: self.theme.secondaryTextColor, paragraphAlignment: .center)
self.accessibilityArea.accessibilityLabel = item.title

View File

@ -425,7 +425,10 @@ class TabBarNode: ASDisplayNode {
}
if !container.badgeContainerNode.isHidden {
let hasSingleLetterValue = container.badgeTextNode.attributedText?.string.count == 1
var hasSingleLetterValue: Bool = false
if let string = container.badgeTextNode.attributedText?.string {
hasSingleLetterValue = string.count == 1
}
let badgeSize = container.badgeTextNode.updateLayout(CGSize(width: 200.0, height: 100.0))
let backgroundSize = CGSize(width: hasSingleLetterValue ? 18.0 : max(18.0, badgeSize.width + 10.0 + 1.0), height: 18.0)
let backgroundFrame: CGRect

View File

@ -318,6 +318,8 @@ private func makeSubtreeSnapshot(layer: CALayer, keepTransform: Bool = false) ->
maskLayer.contentsScale = mask.contentsScale
maskLayer.contentsCenter = mask.contentsCenter
maskLayer.contentsGravity = mask.contentsGravity
maskLayer.frame = mask.frame
maskLayer.bounds = mask.bounds
view.layer.mask = maskLayer
}
view.layer.cornerRadius = layer.cornerRadius

View File

@ -10,6 +10,7 @@ private enum MetadataPrefix: Int8 {
case GroupFeedIndexInitialized = 7
case ShouldReindexUnreadCounts = 8
case PeerHistoryInitialized = 9
case ShouldReindexUnreadCountsState = 10
}
public struct ChatListTotalUnreadCounters: PostboxCoding, Equatable {
@ -148,6 +149,21 @@ final class MessageHistoryMetadataTable: Table {
}
}
func setShouldReindexUnreadCountsState(value: Int32) {
var value = value
self.valueBox.set(self.table, key: self.key(MetadataPrefix.ShouldReindexUnreadCountsState), value: MemoryBuffer(memory: &value, capacity: 4, length: 4, freeWhenDone: false))
}
func getShouldReindexUnreadCountsState() -> Int32? {
if let value = self.valueBox.get(self.table, key: self.key(MetadataPrefix.ShouldReindexUnreadCountsState)) {
var version: Int32 = 0
value.read(&version, offset: 0, length: 4)
return version
} else {
return nil
}
}
func setInitialized(_ peerId: PeerId) {
self.initializedHistoryPeerIds.insert(peerId)
self.sharedBuffer.reset()

View File

@ -919,6 +919,11 @@ public final class Transaction {
assert(!self.disposed)
self.postbox?.addHolesEverywhere(peerNamespaces: peerNamespaces, holeNamespace: holeNamespace)
}
public func reindexUnreadCounters() {
assert(!self.disposed)
self.postbox?.reindexUnreadCounters()
}
}
public enum PostboxResult {
@ -1341,6 +1346,12 @@ public final class Postbox {
print("(Postbox initialization took \((CFAbsoluteTimeGetCurrent() - startTime) * 1000.0) ms")
let _ = self.transaction({ transaction -> Void in
let reindexUnreadVersion: Int32 = 1
if self.messageHistoryMetadataTable.getShouldReindexUnreadCountsState() != reindexUnreadVersion {
self.messageHistoryMetadataTable.setShouldReindexUnreadCounts(value: true)
self.messageHistoryMetadataTable.setShouldReindexUnreadCountsState(value: reindexUnreadVersion)
}
if self.messageHistoryMetadataTable.shouldReindexUnreadCounts() {
self.groupMessageStatsTable.removeAll()
let startTime = CFAbsoluteTimeGetCurrent()
@ -3158,4 +3169,17 @@ public final class Postbox {
}
}
}
fileprivate func reindexUnreadCounters() {
self.groupMessageStatsTable.removeAll()
let startTime = CFAbsoluteTimeGetCurrent()
let (rootState, summaries) = self.chatListIndexTable.debugReindexUnreadCounts(postbox: self)
self.messageHistoryMetadataTable.setChatListTotalUnreadState(rootState)
self.currentUpdatedTotalUnreadState = rootState
for (groupId, summary) in summaries {
self.groupMessageStatsTable.set(groupId: groupId, summary: summary)
self.currentUpdatedGroupTotalUnreadSummaries[groupId] = summary
}
}
}

View File

@ -68,6 +68,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
case resetData(PresentationTheme)
case resetDatabase(PresentationTheme)
case resetHoles(PresentationTheme)
case reindexUnread(PresentationTheme)
case resetBiometricsData(PresentationTheme)
case optimizeDatabase(PresentationTheme)
case photoPreview(PresentationTheme, Bool)
@ -85,7 +86,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
return DebugControllerSection.logging.rawValue
case .enableRaiseToSpeak, .keepChatNavigationStack, .skipReadHistory, .crashOnSlowQueries:
return DebugControllerSection.experiments.rawValue
case .clearTips, .reimport, .resetData, .resetDatabase, .resetHoles, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper:
case .clearTips, .reimport, .resetData, .resetDatabase, .resetHoles, .reindexUnread, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper:
return DebugControllerSection.experiments.rawValue
case .hostInfo, .versionInfo:
return DebugControllerSection.info.rawValue
@ -128,8 +129,10 @@ private enum DebugControllerEntry: ItemListNodeEntry {
return 15
case .resetHoles:
return 16
case .resetBiometricsData:
case .reindexUnread:
return 17
case .resetBiometricsData:
return 18
case .optimizeDatabase:
return 20
case .photoPreview:
@ -462,6 +465,21 @@ private enum DebugControllerEntry: ItemListNodeEntry {
controller.dismiss()
})
})
case let .reindexUnread(theme):
return ItemListActionItem(presentationData: presentationData, title: "Reindex Unread Counters", kind: .destructive, alignment: .natural, sectionId: self.section, style: .blocks, action: {
guard let context = arguments.context else {
return
}
let presentationData = arguments.sharedContext.currentPresentationData.with { $0 }
let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: nil))
arguments.presentController(controller, nil)
let _ = (context.account.postbox.transaction { transaction -> Void in
transaction.reindexUnreadCounters()
}
|> deliverOnMainQueue).start(completed: {
controller.dismiss()
})
})
case let .resetBiometricsData(theme):
return ItemListActionItem(presentationData: presentationData, title: "Reset Biometrics Data", kind: .destructive, alignment: .natural, sectionId: self.section, style: .blocks, action: {
let _ = updatePresentationPasscodeSettingsInteractively(accountManager: arguments.sharedContext.accountManager, { settings in
@ -542,6 +560,7 @@ private func debugControllerEntries(presentationData: PresentationData, loggingS
entries.append(.resetData(presentationData.theme))
entries.append(.resetDatabase(presentationData.theme))
entries.append(.resetHoles(presentationData.theme))
entries.append(.reindexUnread(presentationData.theme))
entries.append(.optimizeDatabase(presentationData.theme))
entries.append(.photoPreview(presentationData.theme, experimentalSettings.chatListPhotos))
entries.append(.knockoutWallpaper(presentationData.theme, experimentalSettings.knockoutWallpaper))

View File

@ -753,7 +753,7 @@ final class SharedApplicationContext {
let legacyCache = LegacyCache(path: legacyBasePath + "/Caches")
let presentationDataPromise = Promise<PresentationData>()
let appLockContext = AppLockContextImpl(rootPath: rootPath, window: self.mainWindow!, applicationBindings: applicationBindings, accountManager: accountManager, presentationDataSignal: presentationDataPromise.get(), lockIconInitialFrame: {
let appLockContext = AppLockContextImpl(rootPath: rootPath, window: self.mainWindow!, rootController: self.window?.rootViewController, applicationBindings: applicationBindings, accountManager: accountManager, presentationDataSignal: presentationDataPromise.get(), lockIconInitialFrame: {
return (self.mainWindow?.viewController as? TelegramRootController)?.chatListController?.lockViewFrame
})

View File

@ -2503,14 +2503,30 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePrevewItemNode
return (nil, nil)
}
if strongSelf.backgroundNode.supernode != nil, let backgroundView = strongSelf.backgroundNode.view.snapshotContentTree(unhide: true) {
let backgroundContainer = UIView()
let backdropView = strongSelf.backgroundWallpaperNode.view.snapshotContentTree(unhide: true)
if let backdropView = backdropView {
backdropView.backgroundColor = .green
let backdropFrame = strongSelf.backgroundWallpaperNode.layer.convert(strongSelf.backgroundWallpaperNode.bounds, to: strongSelf.backgroundNode.layer)
backdropView.frame = backdropFrame
}
if let backdropView = backdropView {
backgroundContainer.addSubview(backdropView)
}
backgroundContainer.addSubview(backgroundView)
let backgroundFrame = strongSelf.backgroundNode.layer.convert(strongSelf.backgroundNode.bounds, to: result.0.layer)
backgroundView.frame = backgroundFrame
backgroundView.frame = CGRect(origin: CGPoint(), size: backgroundFrame.size)
backgroundContainer.frame = backgroundFrame
let viewWithBackground = UIView()
viewWithBackground.addSubview(backgroundView)
viewWithBackground.addSubview(backgroundContainer)
viewWithBackground.frame = resultView.frame
resultView.frame = CGRect(origin: CGPoint(), size: resultView.frame.size)
viewWithBackground.addSubview(resultView)
return (viewWithBackground, backgroundView)
return (viewWithBackground, backgroundContainer)
}
return (resultView, nil)
})

View File

@ -150,7 +150,7 @@ public final class NotificationViewControllerImpl {
let presentationDataPromise = Promise<PresentationData>()
let appLockContext = AppLockContextImpl(rootPath: rootPath, window: nil, applicationBindings: applicationBindings, accountManager: accountManager, presentationDataSignal: presentationDataPromise.get(), lockIconInitialFrame: {
let appLockContext = AppLockContextImpl(rootPath: rootPath, window: nil, rootController: nil, applicationBindings: applicationBindings, accountManager: accountManager, presentationDataSignal: presentationDataPromise.get(), lockIconInitialFrame: {
return nil
})

View File

@ -188,7 +188,7 @@ public class ShareRootControllerImpl {
let presentationDataPromise = Promise<PresentationData>()
let appLockContext = AppLockContextImpl(rootPath: rootPath, window: nil, applicationBindings: applicationBindings, accountManager: accountManager, presentationDataSignal: presentationDataPromise.get(), lockIconInitialFrame: {
let appLockContext = AppLockContextImpl(rootPath: rootPath, window: nil, rootController: nil, applicationBindings: applicationBindings, accountManager: accountManager, presentationDataSignal: presentationDataPromise.get(), lockIconInitialFrame: {
return nil
})