mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-04 11:53:47 +00:00
Merge commit 'eb264889e3' into traffic
This commit is contained in:
@@ -80,7 +80,7 @@ class DownloadMapsViewController: MWMViewController {
|
||||
tableView.registerNib(cell: MWMMapDownloaderButtonTableViewCell.self)
|
||||
title = dataSource.title
|
||||
if mode == .downloaded {
|
||||
let addMapsButton = button(with: UIImage(named: "ic_nav_bar_add"), action: #selector(onAddMaps))
|
||||
let addMapsButton = button(with: UIImage(systemName: "plus"), action: #selector(onAddMaps))
|
||||
navigationItem.rightBarButtonItem = addMapsButton
|
||||
}
|
||||
noMapsContainer.isHidden = !dataSource.isEmpty || Storage.shared().downloadInProgress()
|
||||
|
||||
@@ -37,7 +37,7 @@ NSString * const kCategoryEditorSegue = @"Editor2CategoryEditorSegue";
|
||||
|
||||
NSString * const kUDEditorPersonalInfoWarninWasShown = @"PersonalInfoWarningAlertWasShown";
|
||||
|
||||
CGFloat constexpr kDefaultHeaderHeight = 28.;
|
||||
CGFloat constexpr kDefaultHeaderHeight = 36.;
|
||||
CGFloat constexpr kDefaultFooterHeight = 32.;
|
||||
|
||||
typedef NS_ENUM(NSUInteger, MWMEditorSection) {
|
||||
|
||||
@@ -42,7 +42,7 @@ class PlacePageHeaderPresenter {
|
||||
|
||||
extension PlacePageHeaderPresenter: PlacePageHeaderPresenterProtocol {
|
||||
func configure() {
|
||||
view?.setTitle(placePagePreviewData.title, secondaryTitle: placePagePreviewData.secondaryTitle)
|
||||
view?.setTitle(placePagePreviewData.title, secondaryTitle: placePagePreviewData.secondaryTitle, branch: placePagePreviewData.branch)
|
||||
switch headerType {
|
||||
case .flexible:
|
||||
view?.isExpandViewHidden = false
|
||||
|
||||
@@ -3,7 +3,7 @@ protocol PlacePageHeaderViewProtocol: AnyObject {
|
||||
var isExpandViewHidden: Bool { get set }
|
||||
var isShadowViewHidden: Bool { get set }
|
||||
|
||||
func setTitle(_ title: String?, secondaryTitle: String?)
|
||||
func setTitle(_ title: String?, secondaryTitle: String?, branch: String?)
|
||||
func showShareTrackMenu()
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ class PlacePageHeaderViewController: UIViewController {
|
||||
|
||||
private var titleText: String?
|
||||
private var secondaryText: String?
|
||||
private var branchText: String?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
@@ -37,6 +38,9 @@ class PlacePageHeaderViewController: UIViewController {
|
||||
if presenter?.objectType == .track {
|
||||
configureTrackSharingMenu()
|
||||
}
|
||||
|
||||
let interaction = UIContextMenuInteraction(delegate: self)
|
||||
titleLabel?.addInteraction(interaction)
|
||||
}
|
||||
|
||||
@objc func onExpandPressed(sender: UITapGestureRecognizer) {
|
||||
@@ -54,7 +58,7 @@ class PlacePageHeaderViewController: UIViewController {
|
||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||
super.traitCollectionDidChange(previousTraitCollection)
|
||||
guard traitCollection.userInterfaceStyle != previousTraitCollection?.userInterfaceStyle else { return }
|
||||
setTitle(titleText, secondaryTitle: secondaryText)
|
||||
setTitle(titleText, secondaryTitle: secondaryText, branch: branchText)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,9 +81,11 @@ extension PlacePageHeaderViewController: PlacePageHeaderViewProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func setTitle(_ title: String?, secondaryTitle: String?) {
|
||||
func setTitle(_ title: String?, secondaryTitle: String?, branch: String? = nil) {
|
||||
titleText = title
|
||||
secondaryText = secondaryTitle
|
||||
branchText = branch
|
||||
|
||||
// XCode 13 is not smart enough to detect that title is used below, and requires explicit unwrapped variable.
|
||||
guard let unwrappedTitle = title else {
|
||||
titleLabel?.attributedText = nil
|
||||
@@ -87,11 +93,20 @@ extension PlacePageHeaderViewController: PlacePageHeaderViewProtocol {
|
||||
}
|
||||
|
||||
let titleAttributes: [NSAttributedString.Key: Any] = [
|
||||
.font: StyleManager.shared.theme!.fonts.medium20,
|
||||
.font: StyleManager.shared.theme!.fonts.semibold20,
|
||||
.foregroundColor: UIColor.blackPrimaryText()
|
||||
]
|
||||
|
||||
let attributedText = NSMutableAttributedString(string: unwrappedTitle, attributes: titleAttributes)
|
||||
|
||||
// Add branch with thinner font weight if present and not already in title
|
||||
if let branch = branch, !branch.isEmpty, !unwrappedTitle.contains(branch) {
|
||||
let branchAttributes: [NSAttributedString.Key: Any] = [
|
||||
.font: StyleManager.shared.theme!.fonts.regular20,
|
||||
.foregroundColor: UIColor.blackPrimaryText()
|
||||
]
|
||||
attributedText.append(NSAttributedString(string: " \(branch)", attributes: branchAttributes))
|
||||
}
|
||||
|
||||
guard let unwrappedSecondaryTitle = secondaryTitle else {
|
||||
titleLabel?.attributedText = attributedText
|
||||
@@ -129,3 +144,14 @@ extension PlacePageHeaderViewController: PlacePageHeaderViewProtocol {
|
||||
shareButton.showsMenuAsPrimaryAction = true
|
||||
}
|
||||
}
|
||||
|
||||
extension PlacePageHeaderViewController: UIContextMenuInteractionDelegate {
|
||||
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
|
||||
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil, actionProvider: { suggestedActions in
|
||||
let copyAction = UIAction(title: L("copy_to_clipboard"), image: UIImage(systemName: "document.on.clipboard")) { action in
|
||||
UIPasteboard.general.string = self.titleLabel?.text
|
||||
}
|
||||
return UIMenu(title: "", children: [copyAction])
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23727" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="bX8-ZQ-XDA">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="24127" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="bX8-ZQ-XDA">
|
||||
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23721"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24063"/>
|
||||
<capability name="Named colors" minToolsVersion="9.0"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="Stack View standard spacing" minToolsVersion="9.0"/>
|
||||
@@ -1347,9 +1347,9 @@
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Divider"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</view>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="750" text="Хинкальная" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lR4-to-4wX">
|
||||
<label opaque="NO" contentMode="left" verticalHuggingPriority="750" text="Хинкальная" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lR4-to-4wX">
|
||||
<rect key="frame" x="16" y="20" width="267" height="25"/>
|
||||
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="20"/>
|
||||
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="20"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
@@ -1451,19 +1451,19 @@
|
||||
<image name="ic_arrow_gray_down" width="28" height="28"/>
|
||||
<image name="ic_placepage_open_hours" width="28" height="28"/>
|
||||
<namedColor name="Press Background Color">
|
||||
<color red="0.96078431372549022" green="0.96078431372549022" blue="0.96078431372549022" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color red="0.96100002527236938" green="0.96100002527236938" blue="0.96100002527236938" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</namedColor>
|
||||
<systemColor name="secondaryLabelColor">
|
||||
<color red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
<systemColor name="separatorColor">
|
||||
<color red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.28999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.12" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
<systemColor name="systemBackgroundColor">
|
||||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</systemColor>
|
||||
<systemColor name="systemRedColor">
|
||||
<color red="1" green="0.23137254900000001" blue="0.18823529410000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color red="1" green="0.2196078431372549" blue="0.23529411764705882" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
</resources>
|
||||
</document>
|
||||
|
||||
@@ -17,29 +17,40 @@
|
||||
self.titleLabel.text = @"";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool hasBranchName = (result.branchText && result.branchText.length > 0 && ![title containsString:result.branchText]);
|
||||
|
||||
NSDictionary * selectedTitleAttributes = [self selectedTitleAttributes];
|
||||
NSDictionary * unselectedTitleAttributes = [self unselectedTitleAttributes];
|
||||
if (!selectedTitleAttributes || !unselectedTitleAttributes)
|
||||
if ((!selectedTitleAttributes || !unselectedTitleAttributes) && !hasBranchName)
|
||||
{
|
||||
self.titleLabel.text = title;
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableAttributedString * attributedTitle =
|
||||
[[NSMutableAttributedString alloc] initWithString:title];
|
||||
NSDictionary * titleAttributes = isPartialMatching ? unselectedTitleAttributes : selectedTitleAttributes;
|
||||
|
||||
NSArray<NSValue *> *highlightRanges = result.highlightRanges;
|
||||
[attributedTitle addAttributes:titleAttributes range:NSMakeRange(0, title.length)];
|
||||
[attributedTitle addAttributes:unselectedTitleAttributes range:NSMakeRange(0, title.length)];
|
||||
|
||||
// Add branch with thinner font weight if present and not already in title
|
||||
if (hasBranchName) {
|
||||
NSMutableDictionary * branchAttributes = [unselectedTitleAttributes mutableCopy];
|
||||
[branchAttributes setValue:[UIFont regular17] forKey:NSFontAttributeName];
|
||||
NSAttributedString * branchString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@", result.branchText] attributes:branchAttributes];
|
||||
[attributedTitle appendAttributedString:branchString];
|
||||
}
|
||||
|
||||
for (NSValue *rangeValue in highlightRanges) {
|
||||
NSRange range = [rangeValue rangeValue];
|
||||
if (NSMaxRange(range) <= result.titleText.length) {
|
||||
[attributedTitle addAttributes:selectedTitleAttributes range:range];
|
||||
if (NSMaxRange(range) <= attributedTitle.string.length) {
|
||||
[attributedTitle setAttributes:selectedTitleAttributes range:range];
|
||||
} else {
|
||||
NSLog(@"Incorrect range: %@ for string: %@", NSStringFromRange(range), result.titleText);
|
||||
NSLog(@"Incorrect range: %@ for string: %@", NSStringFromRange(range), attributedTitle.string);
|
||||
}
|
||||
}
|
||||
|
||||
self.titleLabel.attributedText = attributedTitle;
|
||||
[self.titleLabel sizeToFit];
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
- (NSDictionary *)selectedTitleAttributes {
|
||||
return @{
|
||||
NSForegroundColorAttributeName : [UIColor blackPrimaryText],
|
||||
NSForegroundColorAttributeName : [UIColor black],
|
||||
NSFontAttributeName : [UIFont bold17]
|
||||
};
|
||||
}
|
||||
@@ -52,7 +52,7 @@
|
||||
- (NSDictionary *)unselectedTitleAttributes {
|
||||
return @{
|
||||
NSForegroundColorAttributeName : [UIColor blackPrimaryText],
|
||||
NSFontAttributeName : [UIFont regular17]
|
||||
NSFontAttributeName : [UIFont medium17]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" verticalCompressionResistancePriority="752" text="New York Cafe" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4FD-RE-ffF">
|
||||
<rect key="frame" x="56" y="12" width="181" height="20.5"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="searchTitle"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
|
||||
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="17"/>
|
||||
<color key="textColor" red="0.12941176470588234" green="0.12941176470588234" blue="0.12941176470588234" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
|
||||
Reference in New Issue
Block a user