Files
comaps/iphone/Maps/Classes/CustomAlert/MWMOsmReauthAlert.mm
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

64 lines
2.2 KiB
Plaintext

#import "MWMAlertViewController.h"
#import "MWMOsmReauthAlert.h"
#import "MWMAuthorizationCommon.h"
#include "editor/osm_auth.hpp"
static NSString * const kMap2OsmLoginSegue = @"Map2OsmLogin";
@implementation MWMOsmReauthAlert
+ (instancetype)alert
{
MWMOsmReauthAlert * alert = [NSBundle.mainBundle loadNibNamed:[self className] owner:nil options:nil].firstObject;
alert.messageLabel.attributedText = [self buildAlertMessage];
alert.messageLabel.textAlignment = NSTextAlignmentCenter;
alert.messageLabel.delegate = alert;
return alert;
}
// Build attributed string in format "{alert_reauth_message_ios} {alert_reauth_link_text_ios}"
// where {alert_reauth_link_text_ios} has blue color as a link
+ (NSMutableAttributedString*)buildAlertMessage
{
auto textAttrs = @{NSFontAttributeName : UIFont.regular17};
auto linkAttrs = @{NSForegroundColorAttributeName : UIColor.linkBlue,
NSFontAttributeName : UIFont.regular17,
NSLinkAttributeName : @"https://github.com/organicmaps/organicmaps/issues/6144"};
NSMutableAttributedString *alertMessage =
[[NSMutableAttributedString alloc] initWithString: L(@"alert_reauth_message_ios")
attributes: textAttrs];
// Add space char
[alertMessage appendAttributedString:([[NSMutableAttributedString alloc] initWithString: @" "
attributes: textAttrs])];
NSAttributedString *alertLinkText =
[[NSAttributedString alloc] initWithString: L(@"alert_reauth_link_text_ios")
attributes: linkAttrs];
[alertMessage appendAttributedString:alertLinkText];
return alertMessage;
}
- (IBAction)closeTap
{
[self close:nil];
}
- (IBAction)osmTap
{
[self close:^{
[self.alertController.ownerViewController performSegueWithIdentifier:kMap2OsmLoginSegue sender:nil];
}];
}
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction
{
[[UIApplication sharedApplication] openURL:URL options:@{} completionHandler:nil];
return NO;
}
@end