Browser improvements

This commit is contained in:
Ilya Laktyushin
2024-07-25 16:15:45 +02:00
parent 3e99101e07
commit 2eeb3be2b2
15 changed files with 131 additions and 16 deletions

View File

@@ -280,6 +280,7 @@ final class AddressBarContentComponent: Component {
}
title = title.idnaDecoded ?? title
}
self.update(theme: component.theme, strings: component.strings, size: availableSize, isActive: isActive, title: title.lowercased(), isSecure: component.isSecure, collapseFraction: collapseFraction, transition: transition)
return availableSize
@@ -438,7 +439,25 @@ final class AddressBarContentComponent: Component {
textField.addTarget(self, action: #selector(self.textFieldChanged(_:)), for: .editingChanged)
}
textField.text = self.component?.url ?? ""
var address = self.component?.url ?? ""
if let components = URLComponents(string: address) {
if #available(iOS 16.0, *), let encodedHost = components.encodedHost {
if let decodedHost = components.host, encodedHost != decodedHost {
address = address.replacingOccurrences(of: encodedHost, with: decodedHost)
}
} else if let encodedHost = components.host {
if let decodedHost = components.host?.idnaDecoded, encodedHost != decodedHost {
address = address.replacingOccurrences(of: encodedHost, with: decodedHost)
}
}
}
if textField.text != address {
textField.text = address
self.clearIconView.isHidden = address.isEmpty
self.clearIconButton.isHidden = address.isEmpty
self.placeholderContent.view?.isHidden = !address.isEmpty
}
textField.textColor = theme.rootController.navigationSearchBar.inputTextColor
transition.setFrame(view: textField, frame: CGRect(origin: CGPoint(x: backgroundFrame.minX + sideInset, y: backgroundFrame.minY - UIScreenPixel), size: CGSize(width: backgroundFrame.width - sideInset - 32.0, height: backgroundFrame.height)))