diff --git a/Localization/app.json b/Localization/app.json index 5ebc02a8e..c277a3127 100644 --- a/Localization/app.json +++ b/Localization/app.json @@ -408,6 +408,11 @@ "description": "We just sent you an email. Check your junk folder if you haven’t.", "mail": "Mail", "open_email_client": "Open Email Client" + }, + "didnt_get_link": { + "prefix": "Didn't get a Link?", + "resend_in": "Resend (%@)", + "resend_now": "Resend now." } }, "home_timeline": { diff --git a/Mastodon/Scene/Onboarding/ConfirmEmail/MastodonConfirmEmailViewController.swift b/Mastodon/Scene/Onboarding/ConfirmEmail/MastodonConfirmEmailViewController.swift index bf8f222fb..411c0eddb 100644 --- a/Mastodon/Scene/Onboarding/ConfirmEmail/MastodonConfirmEmailViewController.swift +++ b/Mastodon/Scene/Onboarding/ConfirmEmail/MastodonConfirmEmailViewController.swift @@ -43,8 +43,18 @@ final class MastodonConfirmEmailViewController: UIViewController, NeedsDependenc }() let resendEmailButton: UIButton = { + + let boldFont = UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .systemFont(ofSize: 15, weight: .bold)) + let regularFont = UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .systemFont(ofSize: 15, weight: .regular)) + var buttonConfiguration = UIButton.Configuration.plain() - buttonConfiguration.attributedTitle = try! AttributedString(markdown: "Didn't get a link? **Resend (10)**") + var boldResendString = AttributedString(L10n.Scene.ConfirmEmail.DidntGetLink.resendIn(60), attributes: .init([.font: boldFont])) + var attributedTitle = AttributedString(L10n.Scene.ConfirmEmail.DidntGetLink.prefix, attributes: .init([.font: regularFont])) + + attributedTitle.append(AttributedString(" ")) + attributedTitle.append(boldResendString) + + buttonConfiguration.attributedTitle = attributedTitle let button = UIButton(configuration: buttonConfiguration) button.translatesAutoresizingMaskIntoConstraints = false @@ -141,16 +151,21 @@ extension MastodonConfirmEmailViewController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - // start timer - let nowIn60Seconds = Date().addingTimeInterval(10) + let nowIn60Seconds = Date().addingTimeInterval(60) + let boldFont = UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .systemFont(ofSize: 15, weight: .bold)) + let regularFont = UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .systemFont(ofSize: 15, weight: .regular)) let timer = Timer(timeInterval: 1.0, repeats: true) { [weak self] in guard Date() < nowIn60Seconds else { - // enable button self?.resendEmailButton.isEnabled = true var configuration = self?.resendEmailButton.configuration - let attributedTitle = try! AttributedString(markdown: "Didn't get a link? **Resend**") + + let boldResendString = AttributedString(L10n.Scene.ConfirmEmail.DidntGetLink.resendNow, attributes: .init([.font: boldFont])) + var attributedTitle = AttributedString(L10n.Scene.ConfirmEmail.DidntGetLink.prefix, attributes: .init([.font: regularFont])) + + attributedTitle.append(AttributedString(" ")) + attributedTitle.append(boldResendString) configuration?.attributedTitle = attributedTitle self?.resendEmailButton.configuration = configuration @@ -160,10 +175,13 @@ extension MastodonConfirmEmailViewController { return } - //TODO: @zeitschlag Add localization - //TODO: @zeitschlag Add styling var configuration = self?.resendEmailButton.configuration - let attributedTitle = try! AttributedString(markdown: "Didn't get a link? **Resend (\(Int(nowIn60Seconds.timeIntervalSinceNow) + 1))**") + + let boldResendString = AttributedString(L10n.Scene.ConfirmEmail.DidntGetLink.resendIn(Int(nowIn60Seconds.timeIntervalSinceNow) + 1), attributes: .init([.font: boldFont])) + var attributedTitle = AttributedString(L10n.Scene.ConfirmEmail.DidntGetLink.prefix, attributes: .init([.font: regularFont])) + + attributedTitle.append(AttributedString(" ")) + attributedTitle.append(boldResendString) configuration?.attributedTitle = attributedTitle self?.resendEmailButton.configuration = configuration @@ -171,7 +189,6 @@ extension MastodonConfirmEmailViewController { } RunLoop.main.add(timer, forMode: .default) -// self.resendButtonTimer = timer } } diff --git a/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift b/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift index 71deccbc3..cd143b57e 100644 --- a/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift +++ b/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift @@ -630,6 +630,16 @@ public enum L10n { /// Resend public static let resend = L10n.tr("Localizable", "Scene.ConfirmEmail.Button.Resend", fallback: "Resend") } + public enum DidntGetLink { + /// Didn't get a Link? + public static let `prefix` = L10n.tr("Localizable", "Scene.ConfirmEmail.DidntGetLink.Prefix", fallback: "Didn't get a Link?") + /// Resend (%@) + public static func resendIn(_ p1: Any) -> String { + return L10n.tr("Localizable", "Scene.ConfirmEmail.DidntGetLink.ResendIn", String(describing: p1), fallback: "Resend (%@)") + } + /// Resend now. + public static let resendNow = L10n.tr("Localizable", "Scene.ConfirmEmail.DidntGetLink.ResendNow", fallback: "Resend now.") + } public enum DontReceiveEmail { /// Check if your email address is correct as well as your junk folder if you haven’t. public static let description = L10n.tr("Localizable", "Scene.ConfirmEmail.DontReceiveEmail.Description", fallback: "Check if your email address is correct as well as your junk folder if you haven’t.") diff --git a/MastodonSDK/Sources/MastodonLocalization/Resources/Base.lproj/Localizable.strings b/MastodonSDK/Sources/MastodonLocalization/Resources/Base.lproj/Localizable.strings index a858ac7d4..1f1035550 100644 --- a/MastodonSDK/Sources/MastodonLocalization/Resources/Base.lproj/Localizable.strings +++ b/MastodonSDK/Sources/MastodonLocalization/Resources/Base.lproj/Localizable.strings @@ -234,6 +234,9 @@ uploaded to Mastodon."; "Scene.ConfirmEmail.OpenEmailApp.Title" = "Check your inbox."; "Scene.ConfirmEmail.TapTheLinkWeEmailedToYouToVerifyYourAccount" = "Tap the link we sent you to verify %@. We'll wait right here."; "Scene.ConfirmEmail.Title" = "Check Your Inbox"; +"Scene.ConfirmEmail.DidntGetLink.Prefix" = "Didn't get a Link?"; +"Scene.ConfirmEmail.DidntGetLink.ResendIn" = "Resend (%@)"; +"Scene.ConfirmEmail.DidntGetLink.ResendNow" = "Resend now."; "Scene.Discovery.Intro" = "These are the posts gaining traction in your corner of Mastodon."; "Scene.Discovery.Tabs.Community" = "Community"; "Scene.Discovery.Tabs.ForYou" = "For You"; diff --git a/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.strings b/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.strings index 53922ac0b..05ece71bc 100644 --- a/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.strings +++ b/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.strings @@ -230,6 +230,9 @@ uploaded to Mastodon."; "Scene.ConfirmEmail.Subtitle" = "Tap the link we emailed to you to verify your account."; "Scene.ConfirmEmail.TapTheLinkWeEmailedToYouToVerifyYourAccount" = "Tap the link we sent you to verify %@. We'll wait right here."; "Scene.ConfirmEmail.Title" = "Check Your Inbox"; +"Scene.ConfirmEmail.DidntGetLink.Prefix" = "Didn't get a Link?"; +"Scene.ConfirmEmail.DidntGetLink.ResendIn" = "Resend (%@)"; +"Scene.ConfirmEmail.DidntGetLink.ResendNow" = "Resend now."; "Scene.Discovery.Intro" = "These are the posts gaining traction in your corner of Mastodon."; "Scene.Discovery.Tabs.Community" = "Community"; "Scene.Discovery.Tabs.ForYou" = "For You";