Merge commit '73a068e6ffb707a7689427bd355190a82a4bc8be'

This commit is contained in:
Ali 2023-07-18 00:53:54 +04:00
commit 9d07e31c8c
11 changed files with 336 additions and 35 deletions

View File

@ -392,6 +392,7 @@ final class MediaEditorScreenComponent: Component {
}
}
private var nextTransitionUserData: Any?
@objc private func deactivateInput() {
guard let view = self.inputPanel.view as? MessageInputPanelComponent.View else {
return
@ -400,7 +401,12 @@ final class MediaEditorScreenComponent: Component {
self.currentInputMode = .text
if hasFirstResponder(self) {
if let view = self.inputPanel.view as? MessageInputPanelComponent.View {
view.deactivateInput()
self.nextTransitionUserData = TextFieldComponent.AnimationHint(kind: .textFocusChanged)
if view.isActive {
view.deactivateInput()
} else {
self.endEditing(true)
}
}
} else {
self.state?.updated(transition: .spring(duration: 0.4).withUserData(TextFieldComponent.AnimationHint(kind: .textFocusChanged)))
@ -644,6 +650,12 @@ final class MediaEditorScreenComponent: Component {
let environment = environment[ViewControllerComponentContainer.Environment.self].value
self.environment = environment
var transition = transition
if let nextTransitionUserData = self.nextTransitionUserData {
self.nextTransitionUserData = nil
transition = transition.withUserData(nextTransitionUserData)
}
var isEditingStory = false
if let controller = environment.controller() as? MediaEditorScreen {
isEditingStory = controller.isEditingStory
@ -1077,8 +1089,6 @@ final class MediaEditorScreenComponent: Component {
})
}
keyboardHeight = inputHeight
let nextInputMode: MessageInputPanelComponent.InputMode
switch self.currentInputMode {
case .text:
@ -1209,6 +1219,7 @@ final class MediaEditorScreenComponent: Component {
inputHeight = max(inputHeight, environment.deviceMetrics.standardInputHeight(inLandscape: false))
}
}
keyboardHeight = inputHeight
let fadeTransition = Transition(animation: .curve(duration: 0.3, curve: .easeInOut))
if self.inputPanelExternalState.isEditing {
@ -2806,7 +2817,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
}
self.containerLayoutUpdated(layout: layout, forceUpdate: forceUpdate, hasAppeared: self.hasAppeared, transition: transition)
}
func containerLayoutUpdated(layout: ContainerViewLayout, forceUpdate: Bool = false, hasAppeared: Bool = false, transition: Transition) {
guard let controller = self.controller, !self.isDismissed else {
return

View File

@ -400,6 +400,14 @@ public final class MessageInputPanelComponent: Component {
}
}
public var isActive: Bool {
if let textFieldView = self.textField.view as? TextFieldComponent.View {
return textFieldView.isActive
} else {
return false
}
}
public func deactivateInput() {
if self.canDeactivateInput() {
if let textFieldView = self.textField.view as? TextFieldComponent.View {

View File

@ -370,7 +370,7 @@ public final class StoryItemSetContainerComponent: Component {
var videoRecordingBackgroundView: UIVisualEffectView?
let inputPanel = ComponentView<Empty>()
let inputPanelExternalState = MessageInputPanelComponent.ExternalState()
private let inputPanelContainer = UIView()
let inputPanelContainer = SparseContainerView()
private let inputPanelBackground = ComponentView<Empty>()
var preparingToDisplayViewList: Bool = false
@ -451,8 +451,7 @@ public final class StoryItemSetContainerComponent: Component {
self.transitionCloneContainerView = UIView()
self.inputPanelContainer.isUserInteractionEnabled = false
self.inputPanelContainer.layer.cornerRadius = 11.0
self.inputPanelContainer.clipsToBounds = true
self.viewListsContainer = SparseContainerView()
self.viewListsContainer.clipsToBounds = true
@ -1944,16 +1943,18 @@ public final class StoryItemSetContainerComponent: Component {
containerSize: CGSize(width: inputPanelAvailableWidth, height: 200.0)
)
var inputPanelInset: CGFloat = component.containerInsets.bottom
var inputHeight = component.inputHeight
if self.inputPanelExternalState.isEditing {
if self.sendMessageContext.currentInputMode == .media || (inputHeight.isZero && keyboardWasHidden) {
inputHeight = component.deviceMetrics.standardInputHeight(inLandscape: false)
}
}
let inputMediaNodeHeight = self.sendMessageContext.updateInputMediaNode(inputPanel: self.inputPanel, availableSize: availableSize, bottomInset: component.safeInsets.bottom, bottomContainerInset: component.containerInsets.bottom, inputHeight: component.inputHeight, effectiveInputHeight: inputHeight, metrics: component.metrics, deviceMetrics: component.deviceMetrics, transition: transition)
let inputMediaNodeHeight = self.sendMessageContext.updateInputMediaNode(view: self, availableSize: availableSize, bottomInset: component.safeInsets.bottom, bottomContainerInset: component.containerInsets.bottom, inputHeight: component.inputHeight, effectiveInputHeight: inputHeight, metrics: component.metrics, deviceMetrics: component.deviceMetrics, transition: transition)
if inputMediaNodeHeight > 0.0 {
inputHeight = inputMediaNodeHeight
inputPanelInset = 0.0
}
keyboardHeight = inputHeight
@ -1982,16 +1983,17 @@ public final class StoryItemSetContainerComponent: Component {
})
}
let inputPanelBackgroundHeight = keyboardHeight + 60.0 - inputPanelInset
let inputPanelBackgroundSize = self.inputPanelBackground.update(
transition: transition,
component: AnyComponent(BlurredGradientComponent(position: .bottom, dark: true, tag: nil)),
environment: {},
containerSize: CGSize(width: availableSize.width, height: max(0.0, keyboardHeight + 100.0 - component.containerInsets.bottom))
containerSize: CGSize(width: availableSize.width, height: max(0.0, inputPanelBackgroundHeight))
)
if let inputPanelBackgroundView = self.inputPanelBackground.view {
if inputPanelBackgroundView.superview == nil {
self.addSubview(self.inputPanelContainer)
self.inputPanelContainer.addSubview(inputPanelBackgroundView)
self.inputPanelContainer.insertSubview(inputPanelBackgroundView, at: 0)
}
let isVisible = inputHeight > 44.0 && !hasRecordingBlurBackground
transition.setFrame(view: inputPanelBackgroundView, frame: CGRect(origin: CGPoint(x: 0.0, y: isVisible ? availableSize.height - inputPanelBackgroundSize.height : availableSize.height), size: inputPanelBackgroundSize))
@ -2012,7 +2014,7 @@ public final class StoryItemSetContainerComponent: Component {
inputPanelIsOverlay = false
} else {
bottomContentInset += 44.0
inputPanelBottomInset = inputHeight - component.containerInsets.bottom
inputPanelBottomInset = inputHeight - inputPanelInset
inputPanelIsOverlay = true
}
@ -2280,7 +2282,7 @@ public final class StoryItemSetContainerComponent: Component {
}
transition.setCornerRadius(layer: self.viewListsContainer.layer, cornerRadius: viewListsRadius)
transition.setFrame(view: self.inputPanelContainer, frame: contentFrame)
transition.setFrame(view: self.inputPanelContainer, frame: CGRect(origin: .zero, size: availableSize))
let itemLayout = ItemLayout(
containerSize: availableSize,
@ -3841,7 +3843,7 @@ public final class StoryItemSetContainerComponent: Component {
items.append(.separator)
items.append(.action(ContextMenuActionItem(text: component.slice.item.storyItem.isPinned ? component.strings.Story_Context_RemoveFromProfile : component.strings.Story_Context_SaveToProfile, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: component.slice.item.storyItem.isPinned ? "Chat/Context Menu/Check" : "Chat/Context Menu/Add"), color: theme.contextMenu.primaryColor)
return generateTintedImage(image: UIImage(bundleImageName: component.slice.item.storyItem.isPinned ? "Stories/Context Menu/Unpin" : "Stories/Context Menu/Pin"), color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, a in
a(.default)

View File

@ -203,11 +203,11 @@ final class StoryItemSetContainerSendMessage {
}
}
func updateInputMediaNode(inputPanel: ComponentView<Empty>, availableSize: CGSize, bottomInset: CGFloat, bottomContainerInset: CGFloat, inputHeight: CGFloat, effectiveInputHeight: CGFloat, metrics: LayoutMetrics, deviceMetrics: DeviceMetrics, transition: Transition) -> CGFloat {
guard let context = self.context, let inputPanelView = inputPanel.view as? MessageInputPanelComponent.View else {
func updateInputMediaNode(view: StoryItemSetContainerComponent.View, availableSize: CGSize, bottomInset: CGFloat, bottomContainerInset: CGFloat, inputHeight: CGFloat, effectiveInputHeight: CGFloat, metrics: LayoutMetrics, deviceMetrics: DeviceMetrics, transition: Transition) -> CGFloat {
guard let context = self.context, let inputPanelView = view.inputPanel.view as? MessageInputPanelComponent.View else {
return 0.0
}
var height: CGFloat = 0.0
if let component = self.view?.component, case .media = self.currentInputMode, let inputData = self.inputMediaNodeData {
let inputMediaNode: ChatEntityKeyboardInputNode
@ -229,7 +229,7 @@ final class StoryItemSetContainerSendMessage {
if inputMediaNode.view.superview == nil {
self.inputMediaNodeBackground.removeAllAnimations()
self.inputMediaNodeBackground.backgroundColor = UIColor(rgb: 0x000000, alpha: 0.7).cgColor
inputPanelView.superview?.insertSubview(inputMediaNode.view, belowSubview: inputPanelView)
view.inputPanelContainer.addSubview(inputMediaNode.view)
}
self.inputMediaNode = inputMediaNode
}
@ -2466,7 +2466,7 @@ final class StoryItemSetContainerSendMessage {
})
}
func openPeerMention(view: StoryItemSetContainerComponent.View, name: String, navigation: ChatControllerInteractionNavigateToPeer = .default, sourceMessageId: MessageId? = nil) {
func openPeerMention(view: StoryItemSetContainerComponent.View, name: String, sourceMessageId: MessageId? = nil) {
guard let component = view.component, let parentController = component.controller() else {
return
}
@ -2512,11 +2512,11 @@ final class StoryItemSetContainerSendMessage {
return
}
if let peer = peer {
var navigation = navigation
if case .default = navigation {
if let peer = peer as? TelegramUser, peer.botInfo != nil {
navigation = .chat(textInputState: nil, subject: nil, peekData: nil)
}
var navigation: ChatControllerInteractionNavigateToPeer
if let peer = peer as? TelegramUser, peer.botInfo == nil {
navigation = .info
} else {
navigation = .chat(textInputState: nil, subject: nil, peekData: nil)
}
self.openResolved(view: view, result: .peer(peer, navigation))
} else {

View File

@ -505,6 +505,10 @@ public final class TextFieldComponent: Component {
self.textView.resignFirstResponder()
}
public var isActive: Bool {
return self.textView.isFirstResponder
}
private var spoilersRevealed = false
private var spoilerIsDisappearing = false
private func updateSpoilersRevealed(animated: Bool = true) {

View File

@ -1,10 +0,0 @@
<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="22" height="22" rx="11" fill="url(#paint0_linear_0_3)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.8351 15.3336C11.1171 15.1638 11.4698 15.1638 11.7519 15.3336L14.5953 17.045C15.2688 17.4504 16.0983 16.8463 15.9193 16.081L15.1664 12.8627C15.0911 12.5408 15.2007 12.2037 15.4508 11.9876L17.9565 9.82292C18.5521 9.30844 18.2346 8.3309 17.4504 8.26456L14.1484 7.9852C13.8202 7.95742 13.5342 7.75036 13.4053 7.44716L12.1115 4.40309C11.8049 3.68149 10.7821 3.68149 10.4754 4.40309L9.18166 7.44716C9.05279 7.75036 8.7668 7.95742 8.43852 7.9852L5.13659 8.26456C4.3524 8.3309 4.0349 9.30844 4.63043 9.82292L7.13613 11.9876C7.3863 12.2037 7.49586 12.5408 7.42056 12.8627L6.6677 16.081C6.48866 16.8463 7.31817 17.4504 7.99161 17.045L10.8351 15.3336Z" fill="white"/>
<defs>
<linearGradient id="paint0_linear_0_3" x1="18.3333" y1="2.93333" x2="3.3" y2="18.7" gradientUnits="userSpaceOnUse">
<stop stop-color="#7CD636"/>
<stop offset="1" stop-color="#26B470"/>
</linearGradient>
</defs>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,9 @@
{
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"provides-namespace" : true
}
}

View File

@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "StoryCloseIcon.svg",
"filename" : "addtoprofile_24.pdf",
"idiom" : "universal"
}
],

View File

@ -0,0 +1,128 @@
%PDF-1.7
1 0 obj
<< >>
endobj
2 0 obj
<< /Length 3 0 R >>
stream
/DeviceRGB CS
/DeviceRGB cs
q
1.000000 0.000000 -0.000000 1.000000 1.334961 1.334961 cm
0.000000 0.000000 0.000000 scn
8.665000 16.000078 m
8.585878 16.000078 8.507050 15.998825 8.428533 15.996339 c
6.574670 15.937625 4.894375 15.190994 3.634481 14.003281 c
3.539012 13.913280 3.445957 13.820748 3.355423 13.725791 c
2.154264 12.465940 1.396924 10.779177 1.334222 8.916321 c
1.331415 8.832918 1.330000 8.749164 1.330000 8.665078 c
1.330000 8.585957 1.331253 8.507128 1.333739 8.428611 c
1.389887 6.655775 2.075132 5.041667 3.173611 3.802148 c
3.369240 3.581401 3.577975 3.372535 3.798597 3.176768 c
5.035632 2.079101 6.646379 1.393277 8.415907 1.334229 c
8.498598 1.331470 8.581636 1.330078 8.665000 1.330078 c
8.892531 1.330078 9.117473 1.340418 9.339401 1.360624 c
9.705157 1.393927 10.028658 1.124420 10.061960 0.758663 c
10.095263 0.392906 9.825754 0.069405 9.459998 0.036102 c
9.198030 0.012253 8.932849 0.000076 8.665000 0.000076 c
8.534145 0.000076 8.403968 0.002975 8.274529 0.008717 c
6.207896 0.100368 4.329456 0.915930 2.886619 2.207991 c
2.664084 2.407270 2.451912 2.617886 2.251010 2.838927 c
0.852419 4.377721 0.000000 6.421853 0.000000 8.665078 c
0.000000 10.964348 0.895544 13.054451 2.356854 14.605612 c
2.463804 14.719137 2.573785 14.829777 2.686666 14.937400 c
4.241588 16.419884 6.347001 17.330078 8.665000 17.330078 c
8.932849 17.330078 9.198030 17.317905 9.459998 17.294052 c
9.825754 17.260752 10.095262 16.937250 10.061960 16.571493 c
10.028658 16.205738 9.705157 15.936230 9.339400 15.969532 c
9.117473 15.989738 8.892531 16.000078 8.665000 16.000078 c
h
13.267694 15.242804 m
13.502611 15.525116 13.921908 15.563538 14.204222 15.328621 c
14.612415 14.988956 14.988877 14.612494 15.328542 14.204301 c
15.563459 13.921988 15.525038 13.502689 15.242724 13.267773 c
14.960412 13.032855 14.541114 13.071277 14.306196 13.353589 c
14.018392 13.699459 13.699380 14.018471 13.353510 14.306275 c
13.071198 14.541193 13.032776 14.960491 13.267694 15.242804 c
h
16.571415 10.062038 m
16.937172 10.095341 17.260674 9.825832 17.293976 9.460076 c
17.317825 9.198109 17.330002 8.932927 17.330002 8.665078 c
17.330002 8.397229 17.317825 8.132049 17.293976 7.870080 c
17.260674 7.504324 16.937172 7.234817 16.571415 7.268118 c
16.205658 7.301420 15.936152 7.624921 15.969454 7.990678 c
15.989660 8.212605 16.000000 8.437547 16.000000 8.665078 c
16.000000 8.892610 15.989660 9.117550 15.969454 9.339479 c
15.936152 9.705235 16.205658 10.028736 16.571415 10.062038 c
h
15.242725 4.062385 m
15.525038 3.827467 15.563459 3.408170 15.328543 3.125856 c
14.988877 2.717663 14.612415 2.341201 14.204223 2.001536 c
13.921909 1.766619 13.502612 1.805040 13.267694 2.087354 c
13.032777 2.369666 13.071198 2.788964 13.353511 3.023882 c
13.699381 3.311687 14.018393 3.630698 14.306197 3.976568 c
14.541114 4.258881 14.960412 4.297302 15.242725 4.062385 c
h
9.033317 4.905672 m
8.914505 4.830424 8.767970 4.755177 8.665000 4.755177 c
8.565990 4.755177 8.419456 4.830424 8.296683 4.905672 c
6.082822 6.331415 4.665000 8.002702 4.665000 9.697752 c
4.665000 11.151217 5.670940 12.165078 6.934307 12.165078 c
7.722426 12.165078 8.316485 11.725474 8.665000 11.075970 c
9.021436 11.729435 9.611535 12.165078 10.399653 12.165078 c
11.663020 12.165078 12.665000 11.151217 12.665000 9.697752 c
12.665000 8.002702 11.247178 6.331415 9.033317 4.905672 c
h
f*
n
Q
endstream
endobj
3 0 obj
3346
endobj
4 0 obj
<< /Annots []
/Type /Page
/MediaBox [ 0.000000 0.000000 20.000000 20.000000 ]
/Resources 1 0 R
/Contents 2 0 R
/Parent 5 0 R
>>
endobj
5 0 obj
<< /Kids [ 4 0 R ]
/Count 1
/Type /Pages
>>
endobj
6 0 obj
<< /Pages 5 0 R
/Type /Catalog
>>
endobj
xref
0 7
0000000000 65535 f
0000000010 00000 n
0000000034 00000 n
0000003436 00000 n
0000003459 00000 n
0000003632 00000 n
0000003706 00000 n
trailer
<< /ID [ (some) (id) ]
/Root 6 0 R
/Size 7
>>
startxref
3765
%%EOF

View File

@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "removefromprofile_24.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,137 @@
%PDF-1.7
1 0 obj
<< >>
endobj
2 0 obj
<< /Length 3 0 R >>
stream
/DeviceRGB CS
/DeviceRGB cs
q
1.000000 0.000000 -0.000000 1.000000 1.334961 1.205078 cm
0.000000 0.000000 0.000000 scn
8.665000 16.129961 m
8.585878 16.129961 8.507050 16.128708 8.428533 16.126221 c
6.734623 16.072573 5.185623 15.444596 3.969827 14.430586 c
6.220166 12.180247 l
6.444257 12.255239 6.684239 12.294961 6.934307 12.294961 c
7.722426 12.294961 8.316485 11.855357 8.665000 11.205853 c
9.021436 11.859318 9.611535 12.294961 10.399653 12.294961 c
11.663020 12.294961 12.665000 11.281099 12.665000 9.827635 c
12.665000 8.863123 12.205938 7.906306 11.402369 6.998043 c
14.300636 4.099776 l
14.302491 4.102000 14.304345 4.104225 14.306197 4.106451 c
14.541114 4.388763 14.960412 4.427185 15.242725 4.192267 c
15.525038 3.957350 15.563459 3.538053 15.328543 3.255739 c
15.300720 3.222304 15.272652 3.189081 15.244339 3.156075 c
17.135265 1.265148 l
17.394964 1.005449 17.394964 0.584394 17.135265 0.324696 c
16.875566 0.064997 16.454512 0.064997 16.194813 0.324696 c
0.194813 16.324696 l
-0.064886 16.584394 -0.064886 17.005449 0.194813 17.265148 c
0.454512 17.524847 0.875566 17.524847 1.135265 17.265148 c
3.026105 15.374308 l
4.541660 16.674438 6.511596 17.459961 8.665000 17.459961 c
8.932849 17.459961 9.198030 17.447788 9.459998 17.423935 c
9.825754 17.390635 10.095262 17.067133 10.061960 16.701376 c
10.028658 16.335621 9.705157 16.066113 9.339400 16.099415 c
9.117473 16.119621 8.892531 16.129961 8.665000 16.129961 c
h
1.439749 13.579760 m
2.402960 12.616549 l
1.763171 11.570429 1.378159 10.351548 1.334222 9.046204 c
1.331415 8.962801 1.330000 8.879046 1.330000 8.794961 c
1.330000 8.715839 1.331253 8.637011 1.333739 8.558494 c
1.389887 6.785658 2.075132 5.171550 3.173611 3.932031 c
3.369240 3.711284 3.577975 3.502418 3.798597 3.306651 c
5.035632 2.208983 6.646379 1.523160 8.415907 1.464111 c
8.498598 1.461352 8.581636 1.459961 8.665000 1.459961 c
8.892531 1.459961 9.117473 1.470301 9.339401 1.490507 c
9.705157 1.523809 10.028658 1.254303 10.061960 0.888546 c
10.095263 0.522789 9.825754 0.199287 9.459998 0.165985 c
9.198030 0.142136 8.932849 0.129959 8.665000 0.129959 c
8.534145 0.129959 8.403968 0.132858 8.274529 0.138599 c
6.207896 0.230251 4.329456 1.045813 2.886619 2.337873 c
2.664084 2.537153 2.451912 2.747768 2.251010 2.968810 c
0.852419 4.507604 0.000000 6.551736 0.000000 8.794961 c
0.000000 10.563714 0.529958 12.208689 1.439749 13.579760 c
h
9.600698 5.418810 m
4.704478 10.315031 l
4.678550 10.159084 4.665000 9.996321 4.665000 9.827635 c
4.665000 8.132585 6.082822 6.461298 8.296683 5.035555 c
8.419456 4.960307 8.565990 4.885060 8.665000 4.885060 c
8.767970 4.885060 8.914505 4.960307 9.033317 5.035555 c
9.228793 5.161443 9.418062 5.289246 9.600698 5.418810 c
h
13.267694 15.372686 m
13.502611 15.654999 13.921908 15.693420 14.204222 15.458504 c
14.612415 15.118839 14.988877 14.742376 15.328542 14.334184 c
15.563459 14.051870 15.525038 13.632572 15.242724 13.397655 c
14.960412 13.162738 14.541114 13.201159 14.306196 13.483472 c
14.018392 13.829342 13.699380 14.148354 13.353510 14.436158 c
13.071198 14.671076 13.032776 15.090374 13.267694 15.372686 c
h
16.571415 10.191921 m
16.937172 10.225224 17.260674 9.955715 17.293976 9.589959 c
17.317825 9.327991 17.330002 9.062810 17.330002 8.794961 c
17.330002 8.527112 17.317825 8.261931 17.293976 7.999963 c
17.260674 7.634207 16.937172 7.364699 16.571415 7.398001 c
16.205658 7.431303 15.936152 7.754804 15.969454 8.120561 c
15.989660 8.342488 16.000000 8.567430 16.000000 8.794961 c
16.000000 9.022492 15.989660 9.247433 15.969454 9.469362 c
15.936152 9.835118 16.205658 10.158619 16.571415 10.191921 c
h
f*
n
Q
endstream
endobj
3 0 obj
3609
endobj
4 0 obj
<< /Annots []
/Type /Page
/MediaBox [ 0.000000 0.000000 20.000000 20.000000 ]
/Resources 1 0 R
/Contents 2 0 R
/Parent 5 0 R
>>
endobj
5 0 obj
<< /Kids [ 4 0 R ]
/Count 1
/Type /Pages
>>
endobj
6 0 obj
<< /Pages 5 0 R
/Type /Catalog
>>
endobj
xref
0 7
0000000000 65535 f
0000000010 00000 n
0000000034 00000 n
0000003699 00000 n
0000003722 00000 n
0000003895 00000 n
0000003969 00000 n
trailer
<< /ID [ (some) (id) ]
/Root 6 0 R
/Size 7
>>
startxref
4028
%%EOF