forked from zelo72/mastodon-ios
chore: display illustration in welcome scene
This commit is contained in:
parent
29e3d10e97
commit
cd9d7982bc
|
@ -7,17 +7,17 @@
|
|||
<key>AppShared.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>38</integer>
|
||||
<integer>36</integer>
|
||||
</dict>
|
||||
<key>CoreDataStack.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>37</integer>
|
||||
<integer>38</integer>
|
||||
</dict>
|
||||
<key>Mastodon - ASDK.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>3</integer>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
<key>Mastodon - RTL.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
|
@ -27,7 +27,7 @@
|
|||
<key>Mastodon - Release.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>2</integer>
|
||||
<integer>3</integer>
|
||||
</dict>
|
||||
<key>Mastodon - ar.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
|
@ -37,18 +37,23 @@
|
|||
<key>Mastodon - ca.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>17</integer>
|
||||
<integer>18</integer>
|
||||
</dict>
|
||||
<key>Mastodon - de.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>12</integer>
|
||||
</dict>
|
||||
<key>Mastodon - en.xcscheme_^#shared#^_</key>
|
||||
<key>Mastodon - double length.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<key>Mastodon - en.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>2</integer>
|
||||
</dict>
|
||||
<key>Mastodon - es-419.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
|
@ -117,7 +122,7 @@
|
|||
<key>ShareActionExtension.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>41</integer>
|
||||
<integer>37</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
|
|
|
@ -802,23 +802,48 @@ extension MastodonRegisterViewController {
|
|||
let password = viewModel.password.value
|
||||
|
||||
let locale: String = {
|
||||
let fallbackLanguageCode = Locale.current.languageCode ?? "en"
|
||||
guard let url = Bundle.main.url(forResource: "local-codes", withExtension: "json"),
|
||||
let data = try? Data(contentsOf: url),
|
||||
let localCode = try? JSONDecoder().decode(MastodonLocalCode.self, from: data)
|
||||
else {
|
||||
assertionFailure()
|
||||
return "en"
|
||||
}
|
||||
let fallbackLanguageCode: String = {
|
||||
let code = Locale.current.languageCode ?? "en"
|
||||
guard localCode[code] != nil else { return "en" }
|
||||
return code
|
||||
}()
|
||||
|
||||
// pick device preferred language
|
||||
guard let identifier = Locale.preferredLanguages.first else {
|
||||
return fallbackLanguageCode
|
||||
}
|
||||
// prepare languageCode and validate then return fallback if needs
|
||||
let local = Locale(identifier: identifier)
|
||||
guard let languageCode = local.languageCode else {
|
||||
guard let languageCode = local.languageCode,
|
||||
localCode[languageCode] != nil
|
||||
else {
|
||||
return fallbackLanguageCode
|
||||
}
|
||||
switch languageCode {
|
||||
case "zh":
|
||||
// Check Simplified Chinese / Traditional Chinese
|
||||
// https://github.com/gunchleoc/mastodon/blob/ed6153b8f24d3a8f5a124cc95683bd1f20aec882/app/helpers/settings_helper.rb
|
||||
guard let regionCode = local.regionCode else { return languageCode }
|
||||
return "zh" + "-" + regionCode
|
||||
default:
|
||||
// prepare extendCode and validate then return fallback if needs
|
||||
let extendCodes: [String] = {
|
||||
let locales = Locale.preferredLanguages.map { Locale(identifier: $0) }
|
||||
return locales.compactMap { locale in
|
||||
guard let languageCode = locale.languageCode,
|
||||
let regionCode = locale.regionCode
|
||||
else { return nil }
|
||||
return languageCode + "-" + regionCode
|
||||
}
|
||||
}()
|
||||
let _firstMatchExtendCode = extendCodes.first { code in
|
||||
localCode[code] != nil
|
||||
}
|
||||
guard let firstMatchExtendCode = _firstMatchExtendCode else {
|
||||
return languageCode
|
||||
}
|
||||
return firstMatchExtendCode
|
||||
|
||||
}()
|
||||
let query = Mastodon.API.Account.RegisterQuery(
|
||||
reason: viewModel.reason.value,
|
||||
|
@ -828,6 +853,8 @@ extension MastodonRegisterViewController {
|
|||
agreement: true, // user confirmed in the server rules scene
|
||||
locale: locale
|
||||
)
|
||||
|
||||
var retryCount = 0
|
||||
|
||||
// register without show server rules
|
||||
context.apiService.accountRegister(
|
||||
|
@ -835,6 +862,32 @@ extension MastodonRegisterViewController {
|
|||
query: query,
|
||||
authorization: viewModel.applicationAuthorization
|
||||
)
|
||||
.tryCatch { [weak self] error -> AnyPublisher<Mastodon.Response.Content<Mastodon.Entity.Token>, Error> in
|
||||
guard let self = self else { throw error }
|
||||
guard let error = self.viewModel.error.value as? Mastodon.API.Error,
|
||||
case let .generic(errorEntity) = error.mastodonError,
|
||||
errorEntity.error == "Validation failed: Locale is not included in the list"
|
||||
else {
|
||||
throw error
|
||||
}
|
||||
guard retryCount == 0 else {
|
||||
throw error
|
||||
}
|
||||
let retryQuery = Mastodon.API.Account.RegisterQuery(
|
||||
reason: query.reason,
|
||||
username: query.username,
|
||||
email: query.email,
|
||||
password: query.password,
|
||||
agreement: query.agreement,
|
||||
locale: self.viewModel.instance.languages?.first ?? "en"
|
||||
)
|
||||
retryCount += 1
|
||||
return self.context.apiService.accountRegister(
|
||||
domain: self.viewModel.domain,
|
||||
query: retryQuery,
|
||||
authorization: self.viewModel.applicationAuthorization
|
||||
)
|
||||
}
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] completion in
|
||||
guard let self = self else { return }
|
||||
|
|
|
@ -80,8 +80,8 @@ extension OnboardingViewControllerAppearance {
|
|||
extension OnboardingViewControllerAppearance {
|
||||
static var viewEdgeMargin: CGFloat {
|
||||
guard UIDevice.current.userInterfaceIdiom == .pad else { return .zero }
|
||||
|
||||
let shortEdgeWidth = min(UIScreen.main.bounds.height, UIScreen.main.bounds.width)
|
||||
return shortEdgeWidth * 0.17 // magic
|
||||
return 20
|
||||
// let shortEdgeWidth = min(UIScreen.main.bounds.height, UIScreen.main.bounds.width)
|
||||
// return shortEdgeWidth * 0.17 // magic
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue