Various iPad fixes

This commit is contained in:
Ilya Laktyushin 2022-08-15 21:18:56 +03:00
parent 0b791a5579
commit a1e2dd0b0e
8 changed files with 58 additions and 4 deletions

View File

@ -514,6 +514,9 @@ public class AttachmentTextInputPanelNode: ASDisplayNode, TGCaptionPanelView, AS
textInputNode.view.disablesInteractiveTransitionGestureRecognizer = true
self.textInputNode = textInputNode
textInputNode.textView.inputAssistantItem.leadingBarButtonGroups = []
textInputNode.textView.inputAssistantItem.trailingBarButtonGroups = []
if let presentationInterfaceState = self.presentationInterfaceState {
refreshChatTextInputTypingAttributes(textInputNode, theme: presentationInterfaceState.theme, baseFontSize: baseFontSize)
textInputNode.textContainerInset = calculateTextFieldRealInsets(presentationInterfaceState)

View File

@ -180,7 +180,7 @@ public enum DeviceMetrics: CaseIterable, Equatable {
}
}
func onScreenNavigationHeight(inLandscape: Bool, systemOnScreenNavigationHeight: CGFloat?) -> CGFloat? {
public func onScreenNavigationHeight(inLandscape: Bool, systemOnScreenNavigationHeight: CGFloat?) -> CGFloat? {
switch self {
case .iPhoneX, .iPhoneXSMax, .iPhoneXr, .iPhone12Mini, .iPhone12, .iPhone12ProMax, .iPhone13Mini, .iPhone13, .iPhone13Pro, .iPhone13ProMax:
return inLandscape ? 21.0 : 34.0

View File

@ -65,6 +65,8 @@ typedef enum
- (void)setEditButtonsHighlighted:(TGPhotoEditorTab)buttons;
- (void)setEditButtonsDisabled:(TGPhotoEditorTab)buttons;
- (void)setAllButtonsHidden:(bool)hidden animated:(bool)animated;
@property (nonatomic, readonly) TGPhotoEditorTab currentTabs;
- (void)setToolbarTabs:(TGPhotoEditorTab)tabs animated:(bool)animated;

View File

@ -333,6 +333,12 @@
if (strongSelf == nil)
return;
if (keyboardHeight > 0) {
[strongSelf->_portraitToolbarView setAllButtonsHidden:true animated:true];
} else {
[strongSelf->_portraitToolbarView setAllButtonsHidden:false animated:true];
}
CGFloat offset = 0.0f;
if (keyboardHeight > 0)
offset = -keyboardHeight / 2.0f;

View File

@ -239,7 +239,7 @@
if (_keyboardHeight > 0.0) {
backgroundHeight += _keyboardHeight - edgeInsets.bottom;
}
_backgroundView.frame = CGRectMake(edgeInsets.left, y, frame.size.width, backgroundHeight);
_backgroundView.frame = CGRectMake(edgeInsets.left, y, frame.size.width, backgroundHeight + 1.0);
}
@end

View File

@ -54,7 +54,6 @@
[_cancelButton addTarget:self action:@selector(cancelButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[_backgroundView addSubview:_cancelButton];
_doneButton = [[TGModernButton alloc] initWithFrame:CGRectMake(0, 0, buttonSize.width, buttonSize.height)];
_doneButton.exclusiveTouch = true;
_doneButton.adjustsImageWhenHighlighted = false;
@ -495,6 +494,40 @@
}
}
- (void)setAllButtonsHidden:(bool)hidden animated:(bool)animated
{
CGFloat targetAlpha = hidden ? 0.0f : 1.0f;
if (animated)
{
_buttonsWrapperView.hidden = false;
_cancelButton.hidden = false;
_doneButton.hidden = false;
[UIView animateWithDuration:0.2f
animations:^
{
_buttonsWrapperView.alpha = targetAlpha;
_cancelButton.alpha = targetAlpha;
_doneButton.alpha = targetAlpha;
} completion:^(__unused BOOL finished)
{
_buttonsWrapperView.hidden = hidden;
_cancelButton.hidden = hidden;
_doneButton.hidden = hidden;
}];
}
else
{
_buttonsWrapperView.alpha = targetAlpha;
_cancelButton.alpha = targetAlpha;
_doneButton.alpha = targetAlpha;
_buttonsWrapperView.hidden = hidden;
_cancelButton.hidden = hidden;
_doneButton.hidden = hidden;
}
}
- (TGPhotoEditorButton *)buttonForTab:(TGPhotoEditorTab)tab
{
for (TGPhotoEditorButton *button in _buttonsWrapperView.subviews)

View File

@ -287,6 +287,12 @@ public final class LegacyControllerContext: NSObject, LegacyComponentsContext {
safeInsets.bottom = 21.0
} else if validLayout.intrinsicInsets.bottom.isEqual(to: 34.0) {
safeInsets.bottom = 34.0
} else {
if let knownSafeInset = validLayout.deviceMetrics.onScreenNavigationHeight(inLandscape: validLayout.size.width > validLayout.size.height, systemOnScreenNavigationHeight: nil) {
if knownSafeInset > 0.0 {
safeInsets.bottom = knownSafeInset
}
}
}
if controller.navigationPresentation == .modal {
safeInsets.top = 0.0

View File

@ -1482,7 +1482,11 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
let inputBackgroundInset: CGFloat
if cleanInsets.bottom < insets.bottom {
inputBackgroundInset = 0.0
if case .regular = layout.metrics.widthClass, let inputHeight = layout.inputHeight, inputHeight < 88.0 {
inputBackgroundInset = insets.bottom
} else {
inputBackgroundInset = 0.0
}
} else {
inputBackgroundInset = cleanInsets.bottom
}