From cca8432fb6c4c9eae7f6e8677ef4623c319357df Mon Sep 17 00:00:00 2001 From: CMK Date: Tue, 6 Jul 2021 11:59:28 +0800 Subject: [PATCH] fix: vector assert not correct rendered issue --- .../xcschemes/xcschememanagement.plist | 4 ++-- .../Asset/email.imageset/Contents.json | 2 +- .../{mastodon.with.mail.svg => c1 1.svg} | 0 .../HomeTimelineViewController+DebugAction.swift | 11 ++++++++++- .../MastodonConfirmEmailViewModel.swift | 13 +++++++++++++ .../Entity/Mastodon+Entity+Application.swift | 11 ++++++++++- .../MastodonSDK/Entity/Mastodon+Entity+Token.swift | 8 ++++++++ 7 files changed, 44 insertions(+), 5 deletions(-) rename Mastodon/Resources/Assets.xcassets/Asset/email.imageset/{mastodon.with.mail.svg => c1 1.svg} (100%) diff --git a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist index 0f3da3a13..ecde1bcc5 100644 --- a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist @@ -12,7 +12,7 @@ CoreDataStack.xcscheme_^#shared#^_ orderHint - 21 + 20 Mastodon - ASDK.xcscheme_^#shared#^_ @@ -37,7 +37,7 @@ NotificationService.xcscheme_^#shared#^_ orderHint - 20 + 21 SuppressBuildableAutocreation diff --git a/Mastodon/Resources/Assets.xcassets/Asset/email.imageset/Contents.json b/Mastodon/Resources/Assets.xcassets/Asset/email.imageset/Contents.json index ae4670472..ba3df05b6 100644 --- a/Mastodon/Resources/Assets.xcassets/Asset/email.imageset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/Asset/email.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "mastodon.with.mail.svg", + "filename" : "c1 1.svg", "idiom" : "universal" } ], diff --git a/Mastodon/Resources/Assets.xcassets/Asset/email.imageset/mastodon.with.mail.svg b/Mastodon/Resources/Assets.xcassets/Asset/email.imageset/c1 1.svg similarity index 100% rename from Mastodon/Resources/Assets.xcassets/Asset/email.imageset/mastodon.with.mail.svg rename to Mastodon/Resources/Assets.xcassets/Asset/email.imageset/c1 1.svg diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewController+DebugAction.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewController+DebugAction.swift index 69eff4a82..7c1f79dbd 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewController+DebugAction.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewController+DebugAction.swift @@ -31,7 +31,11 @@ extension HomeTimelineViewController { guard let self = self else { return } self.showWelcomeAction(action) }, - UIAction(title: "Show Or Remove EmptyView", image: UIImage(systemName: "clear"), attributes: []) { [weak self] action in + UIAction(title: "Show Confirm Email", image: UIImage(systemName: "envelope"), attributes: []) { [weak self] action in + guard let self = self else { return } + self.showConfirmEmail(action) + }, + UIAction(title: "Toggle EmptyView", image: UIImage(systemName: "clear"), attributes: []) { [weak self] action in guard let self = self else { return } if self.emptyView.superview != nil { self.emptyView.removeFromSuperview() @@ -310,6 +314,11 @@ extension HomeTimelineViewController { @objc private func showWelcomeAction(_ sender: UIAction) { coordinator.present(scene: .welcome, from: self, transition: .modal(animated: true, completion: nil)) } + + @objc private func showConfirmEmail(_ sender: UIAction) { + let mastodonConfirmEmailViewModel = MastodonConfirmEmailViewModel() + coordinator.present(scene: .mastodonConfirmEmail(viewModel: mastodonConfirmEmailViewModel), from: nil, transition: .modal(animated: true, completion: nil)) + } @objc private func showPublicTimelineAction(_ sender: UIAction) { coordinator.present(scene: .publicTimeline, from: self, transition: .show) diff --git a/Mastodon/Scene/Onboarding/ConfirmEmail/MastodonConfirmEmailViewModel.swift b/Mastodon/Scene/Onboarding/ConfirmEmail/MastodonConfirmEmailViewModel.swift index 9fbd24eda..7ddcefbbf 100644 --- a/Mastodon/Scene/Onboarding/ConfirmEmail/MastodonConfirmEmailViewModel.swift +++ b/Mastodon/Scene/Onboarding/ConfirmEmail/MastodonConfirmEmailViewModel.swift @@ -37,4 +37,17 @@ final class MastodonConfirmEmailViewModel { self.userToken = userToken self.updateCredentialQuery = updateCredentialQuery } + + #if DEBUG + init() { + self.context = AppContext.shared + self.email = "example.com" + self.authenticateInfo = AuthenticationViewModel.AuthenticateInfo( + domain: "", + application: Mastodon.Entity.Application(name: "", website: nil, vapidKey: nil, redirectURI: nil, clientID: "clientID", clientSecret: "clientSecret") + )! + self.userToken = Mastodon.Entity.Token(accessToken: "", tokenType: "", scope: "", createdAt: Date()) + self.updateCredentialQuery = Mastodon.API.Account.UpdateCredentialQuery(discoverable: nil, bot: nil, displayName: nil, note: nil, avatar: nil, header: nil, locked: nil, source: nil, fieldsAttributes: nil) + } + #endif } diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Application.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Application.swift index d7d4dda4d..e6f6300e6 100644 --- a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Application.swift +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Application.swift @@ -17,7 +17,7 @@ extension Mastodon.Entity { /// # Reference /// [Document](https://docs.joinmastodon.org/entities/application/) public struct Application: Codable { - + public let name: String public let website: String? @@ -27,6 +27,15 @@ extension Mastodon.Entity { public let redirectURI: String? // undocumented public let clientID: String? public let clientSecret: String? + + public init(name: String, website: String?, vapidKey: String?, redirectURI: String?, clientID: String?, clientSecret: String?) { + self.name = name + self.website = website + self.vapidKey = vapidKey + self.redirectURI = redirectURI + self.clientID = clientID + self.clientSecret = clientSecret + } enum CodingKeys: String, CodingKey { case name diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Token.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Token.swift index e7f18b518..ff305e104 100644 --- a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Token.swift +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Token.swift @@ -17,10 +17,18 @@ extension Mastodon.Entity { /// # Reference /// [Document](https://docs.joinmastodon.org/entities/token/) public struct Token: Codable { + public let accessToken: String public let tokenType: String public let scope: String public let createdAt: Date + + public init(accessToken: String, tokenType: String, scope: String, createdAt: Date) { + self.accessToken = accessToken + self.tokenType = tokenType + self.scope = scope + self.createdAt = createdAt + } enum CodingKeys: String, CodingKey { case accessToken = "access_token"