Various Fixes

This commit is contained in:
Ilya Laktyushin 2021-10-28 01:17:28 +04:00
parent c6b89a31cc
commit a9289f03e4
3 changed files with 39 additions and 40 deletions

View File

@ -386,7 +386,7 @@ private func inviteLinkEditControllerEntries(invite: ExportedInvitation?, state:
}
entries.append(.timeInfo(presentationData.theme, presentationData.strings.InviteLink_Create_TimeLimitInfo))
if !state.requestApproval {
if !state.requestApproval || isPublic {
entries.append(.usageHeader(presentationData.theme, presentationData.strings.InviteLink_Create_UsersLimit.uppercased()))
entries.append(.usagePicker(presentationData.theme, presentationData.dateTimeFormat, state.usage))
@ -524,6 +524,8 @@ public func inviteLinkEditController(context: AccountContext, updatedPresentatio
))
|> deliverOnMainQueue
|> map { presentationData, state, peer -> (ItemListControllerState, (ItemListNodeState, Any)) in
let isPublic = !(peer?.addressName?.isEmpty ?? true)
let leftNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Common_Cancel), style: .regular, enabled: true, action: {
dismissImpl?()
})
@ -548,7 +550,7 @@ public func inviteLinkEditController(context: AccountContext, updatedPresentatio
let titleString = state.title.trimmingCharacters(in: .whitespacesAndNewlines)
let title = titleString.isEmpty ? nil : titleString
let usageLimit = state.usage.value
let requestNeeded = state.requestApproval
let requestNeeded = state.requestApproval && !isPublic
if invite == nil {
let _ = (context.engine.peers.createPeerExportedInvitation(peerId: peerId, title: title, expireDate: expireDate, usageLimit: requestNeeded ? 0 : usageLimit, requestNeeded: requestNeeded)
@ -600,7 +602,7 @@ public func inviteLinkEditController(context: AccountContext, updatedPresentatio
}
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(invite == nil ? presentationData.strings.InviteLink_Create_Title : presentationData.strings.InviteLink_Create_EditTitle), leftNavigationButton: leftNavigationButton, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: true)
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: inviteLinkEditControllerEntries(invite: invite, state: state, isGroup: isGroup, isPublic: !(peer?.addressName?.isEmpty ?? true), presentationData: presentationData), style: .blocks, emptyStateItem: nil, crossfadeState: false, animateChanges: animateChanges)
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: inviteLinkEditControllerEntries(invite: invite, state: state, isGroup: isGroup, isPublic: isPublic, presentationData: presentationData), style: .blocks, emptyStateItem: nil, crossfadeState: false, animateChanges: animateChanges)
return (controllerState, (listState, arguments))
}

View File

@ -253,7 +253,9 @@ public func inviteRequestsController(context: AccountContext, updatedPresentatio
}, action: { _, f in
f(.dismissWithoutContent)
denyRequestImpl(peer)
Queue.mainQueue().after(0.3, {
denyRequestImpl(peer)
})
})))
let dismissPromise = ValuePromise<Bool>(false)

View File

@ -2,6 +2,7 @@ import Foundation
import UIKit
import SwiftSignalKit
import Display
import CoreImage
import Postbox
import TelegramCore
import MediaResources
@ -1425,7 +1426,7 @@ public func themeIconImage(account: Account, accountManager: AccountManager<Tele
let imageArguments = TransformImageArguments(corners: ImageCorners(), imageSize: imageSize, boundingSize: imageSize, intrinsicInsets: UIEdgeInsets(), emptyColor: nil, custom: arguments)
let context = generator?(imageArguments)
let image = context?.generateImage()
if !file.settings.colors.isEmpty {
return .single((effectiveBackgroundColor, incomingColors, outgoingColors, image, false, isMask, alpha, rotation))
} else {
@ -1475,24 +1476,7 @@ public func themeIconImage(account: Account, accountManager: AccountManager<Tele
}
}
}
var masking = false
if let image = colors.3, colors.5 {
c.setFillColor(UIColor.black.cgColor)
c.fill(drawingRect)
if let cgImage = image.cgImage {
let fittedSize = image.size.aspectFilled(CGSize(width: drawingRect.size.width + 1.0, height: drawingRect.size.height + 1.0))
c.saveGState()
c.translateBy(x: drawingRect.width / 2.0, y: drawingRect.height / 2.0)
c.scaleBy(x: 1.0, y: -1.0)
c.translateBy(x: -drawingRect.width / 2.0, y: -drawingRect.height / 2.0)
c.clip(to: CGRect(origin: CGPoint(x: (drawingRect.size.width - fittedSize.width) / 2.0, y: (drawingRect.size.height - fittedSize.height) / 2.0), size: fittedSize), mask: cgImage)
masking = true
}
}
if colors.0.2.count >= 3 {
let image = GradientBackgroundNode.generatePreview(size: CGSize(width: 60.0, height: 60.0), colors: colors.0.2.map(UIColor.init(rgb:)))
c.draw(image.cgImage!, in: drawingRect)
@ -1513,12 +1497,8 @@ public func themeIconImage(account: Account, accountManager: AccountManager<Tele
c.setFillColor(colors.0.0.cgColor)
c.fill(drawingRect)
}
if masking {
c.restoreGState()
}
if let image = colors.3, !colors.5 {
if let image = colors.3 {
if colors.4 {
let initialThumbnailContextFittingSize = arguments.imageSize.fitted(CGSize(width: 90.0, height: 90.0))
let thumbnailContextSize = image.size.aspectFilled(initialThumbnailContextFittingSize)
@ -1538,18 +1518,33 @@ public func themeIconImage(account: Account, accountManager: AccountManager<Tele
c.restoreGState()
}
} else if let cgImage = image.cgImage {
let fittedSize = image.size.aspectFilled(CGSize(width: drawingRect.size.width + 1.0, height: drawingRect.size.height + 1.0))
c.saveGState()
if !isBlack && patternIntensity > 0.0 {
c.setBlendMode(.softLight)
if colors.5 {
let fittedSize = image.size.aspectFilled(CGSize(width: drawingRect.size.width + 1.0, height: drawingRect.size.height + 1.0))
c.saveGState()
c.translateBy(x: drawingRect.width / 2.0, y: drawingRect.height / 2.0)
c.scaleBy(x: 1.0, y: -1.0)
c.translateBy(x: -drawingRect.width / 2.0, y: -drawingRect.height / 2.0)
c.clip(to: CGRect(origin: CGPoint(x: (drawingRect.size.width - fittedSize.width) / 2.0, y: (drawingRect.size.height - fittedSize.height) / 2.0), size: fittedSize), mask: cgImage)
c.setFillColor(UIColor.black.cgColor)
c.fill(drawingRect)
c.restoreGState()
} else {
let fittedSize = image.size.aspectFilled(CGSize(width: drawingRect.size.width + 1.0, height: drawingRect.size.height + 1.0))
c.saveGState()
if !isBlack && patternIntensity > 0.0 {
c.setBlendMode(.softLight)
}
c.setAlpha(colors.6)
c.translateBy(x: drawingRect.width / 2.0, y: drawingRect.height / 2.0)
c.scaleBy(x: 1.0, y: -1.0)
c.translateBy(x: -drawingRect.width / 2.0, y: -drawingRect.height / 2.0)
c.draw(cgImage, in: CGRect(origin: CGPoint(x: (drawingRect.size.width - fittedSize.width) / 2.0, y: (drawingRect.size.height - fittedSize.height) / 2.0), size: fittedSize))
c.restoreGState()
}
c.setAlpha(colors.6)
c.translateBy(x: drawingRect.width / 2.0, y: drawingRect.height / 2.0)
c.scaleBy(x: 1.0, y: -1.0)
c.translateBy(x: -drawingRect.width / 2.0, y: -drawingRect.height / 2.0)
c.draw(cgImage, in: CGRect(origin: CGPoint(x: (drawingRect.size.width - fittedSize.width) / 2.0, y: (drawingRect.size.height - fittedSize.height) / 2.0), size: fittedSize))
c.restoreGState()
}
}