Skip to content

Commit

Permalink
Merge pull request #4094 from osmandapp/add-monospaced-digits-font-to…
Browse files Browse the repository at this point in the history
…-another-downloading-screens

add monospaced digits font to another downloading screens
  • Loading branch information
alex-osm authored Nov 5, 2024
2 parents 5262bdf + b22ad73 commit 409242f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
17 changes: 12 additions & 5 deletions Sources/FirstUsage/OAFirstUsageWizardController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ - (void)viewDidLoad
[_btnDownload setTitle:OALocalizedString(@"shared_string_download") forState:UIControlStateNormal];

// Init progress view
[_btnGoToMap setTitle:OALocalizedString(@"show_region_on_map_go") forState:UIControlStateNormal];
[self setDownloadingButtonTitle:OALocalizedString(@"show_region_on_map_go")];

_bottomTextView.textContainerInset = UIEdgeInsetsZero;
_bottomTextView.textContainer.lineFragmentPadding = 0;
Expand Down Expand Up @@ -312,6 +312,13 @@ -(void)viewWillLayoutSubviews
}
}

- (void) setDownloadingButtonTitle:(NSString *)title
{
NSMutableAttributedString *attributedTitle = [[NSMutableAttributedString alloc] initWithString:title];
[attributedTitle addAttribute:NSFontAttributeName value:[UIFont monospacedFontAt:15 withTextStyle:UIFontTextStyleBody] range:NSMakeRange(0, attributedTitle.string.length)];
[_btnGoToMap setAttributedTitle:attributedTitle forState:UIControlStateNormal];
}

- (void)showCard:(UIView *)cardView
{
[self clearSubViews];
Expand Down Expand Up @@ -525,8 +532,7 @@ - (void) initWizard:(WizardType)wizardType
OARepositoryResourceItem *item = _indexItems[0];
_lbMapName1.text = item.title;

[_btnGoToMap setTitle:[OALocalizedString(@"downloading") stringByAppendingFormat:@" %@", [NSByteCountFormatter stringFromByteCount:item.sizePkg countStyle:NSByteCountFormatterCountStyleFile]] forState:UIControlStateNormal];

[self setDownloadingButtonTitle:[OALocalizedString(@"downloading") stringByAppendingFormat:@" %@", [NSByteCountFormatter stringFromByteCount:item.sizePkg countStyle:NSByteCountFormatterCountStyleFile]]];
if (_mapDownloadCancelled)
{
_progress1.hidden = YES;
Expand Down Expand Up @@ -901,7 +907,8 @@ - (void)onDownloadTaskProgressChanged:(id<OAObservableProtocol>)observer withKey
uint64_t size = _indexItems[0].size;
float progress = [value floatValue];
NSString *progressStr = [OAResourcesUISwiftHelper formatedDownloadingProgressString:size progress:progress addZero:YES combineViaSlash:YES];
[_btnGoToMap setTitle:[OALocalizedString(@"downloading") stringByAppendingFormat:@" %@", progressStr] forState:UIControlStateNormal];
[self setDownloadingButtonTitle:[OALocalizedString(@"downloading") stringByAppendingFormat:@" %@", progressStr]];

[_progress1 setProgress:[value floatValue]];
}
});
Expand All @@ -919,7 +926,7 @@ - (void)onDownloadTaskFinished:(id<OAObservableProtocol>)observer withKey:(id)ke

if (_indexItems.count > 0)
{
[_btnGoToMap setTitle:OALocalizedString(@"show_region_on_map_go") forState:UIControlStateNormal];
[self setDownloadingButtonTitle:OALocalizedString(@"show_region_on_map_go")];
}

if (task.progressCompleted < 1.0)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftExtensions/UIFont+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

extension UIFont {
static func monospacedFont(at size: CGFloat, withTextStyle style: TextStyle) -> UIFont {
@objc static func monospacedFont(at size: CGFloat, withTextStyle style: TextStyle) -> UIFont {
let bodyFontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: style)
let bodyMonospacedNumbersFontDescriptor = bodyFontDescriptor.addingAttributes(
[
Expand Down
1 change: 1 addition & 0 deletions Sources/Views/OATargetPointView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2401,6 +2401,7 @@ - (void) showProgressBar

[_downloadProgressBar setProgress:0.];
_downloadProgressLabel.text = OALocalizedString(@"download_pending");
_downloadProgressLabel.font = [UIFont monospacedFontAt:15 withTextStyle:UIFontTextStyleBody];

[self doLayoutSubviews:YES];
}
Expand Down

0 comments on commit 409242f

Please sign in to comment.