Merge branch 'develop' into feature/poll

# Conflicts:
#	Mastodon.xcodeproj/project.pbxproj
This commit is contained in:
CMK 2021-03-05 15:55:29 +08:00
commit a3f9b8c2ef
17 changed files with 385 additions and 46 deletions

View File

@ -128,8 +128,7 @@
}, },
"password": { "password": {
"placeholder": "password", "placeholder": "password",
"prompt": "Your password needs at least:", "hint": "Your password needs at least Eight characters"
"prompt_eight_characters": "Eight characters"
}, },
"invite": { "invite": {
"registration_user_invite_request": "Why do you want to join?" "registration_user_invite_request": "Why do you want to join?"

View File

@ -72,6 +72,8 @@
2D927F0E25C7E9C9004F19B8 /* History.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D927F0D25C7E9C9004F19B8 /* History.swift */; }; 2D927F0E25C7E9C9004F19B8 /* History.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D927F0D25C7E9C9004F19B8 /* History.swift */; };
2D927F1425C7EDD9004F19B8 /* Emoji.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D927F1325C7EDD9004F19B8 /* Emoji.swift */; }; 2D927F1425C7EDD9004F19B8 /* Emoji.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D927F1325C7EDD9004F19B8 /* Emoji.swift */; };
2D939AB525EDD8A90076FA61 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D939AB425EDD8A90076FA61 /* String.swift */; }; 2D939AB525EDD8A90076FA61 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D939AB425EDD8A90076FA61 /* String.swift */; };
2D939AC825EE14620076FA61 /* CropViewController in Frameworks */ = {isa = PBXBuildFile; productRef = 2D939AC725EE14620076FA61 /* CropViewController */; };
2D939AE825EE1CF80076FA61 /* MastodonRegisterViewController+Avatar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D939AE725EE1CF80076FA61 /* MastodonRegisterViewController+Avatar.swift */; };
2DA7D04425CA52B200804E11 /* TimelineLoaderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DA7D04325CA52B200804E11 /* TimelineLoaderTableViewCell.swift */; }; 2DA7D04425CA52B200804E11 /* TimelineLoaderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DA7D04325CA52B200804E11 /* TimelineLoaderTableViewCell.swift */; };
2DA7D04A25CA52CB00804E11 /* TimelineBottomLoaderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DA7D04925CA52CB00804E11 /* TimelineBottomLoaderTableViewCell.swift */; }; 2DA7D04A25CA52CB00804E11 /* TimelineBottomLoaderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DA7D04925CA52CB00804E11 /* TimelineBottomLoaderTableViewCell.swift */; };
2DA7D05725CA693F00804E11 /* Application.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DA7D05625CA693F00804E11 /* Application.swift */; }; 2DA7D05725CA693F00804E11 /* Application.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DA7D05625CA693F00804E11 /* Application.swift */; };
@ -291,6 +293,7 @@
2D927F0D25C7E9C9004F19B8 /* History.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = History.swift; sourceTree = "<group>"; }; 2D927F0D25C7E9C9004F19B8 /* History.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = History.swift; sourceTree = "<group>"; };
2D927F1325C7EDD9004F19B8 /* Emoji.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Emoji.swift; sourceTree = "<group>"; }; 2D927F1325C7EDD9004F19B8 /* Emoji.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Emoji.swift; sourceTree = "<group>"; };
2D939AB425EDD8A90076FA61 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = "<group>"; }; 2D939AB425EDD8A90076FA61 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = "<group>"; };
2D939AE725EE1CF80076FA61 /* MastodonRegisterViewController+Avatar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MastodonRegisterViewController+Avatar.swift"; sourceTree = "<group>"; };
2DA7D04325CA52B200804E11 /* TimelineLoaderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineLoaderTableViewCell.swift; sourceTree = "<group>"; }; 2DA7D04325CA52B200804E11 /* TimelineLoaderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineLoaderTableViewCell.swift; sourceTree = "<group>"; };
2DA7D04925CA52CB00804E11 /* TimelineBottomLoaderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineBottomLoaderTableViewCell.swift; sourceTree = "<group>"; }; 2DA7D04925CA52CB00804E11 /* TimelineBottomLoaderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineBottomLoaderTableViewCell.swift; sourceTree = "<group>"; };
2DA7D05025CA545E00804E11 /* LoadMoreConfigurableTableViewContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadMoreConfigurableTableViewContainer.swift; sourceTree = "<group>"; }; 2DA7D05025CA545E00804E11 /* LoadMoreConfigurableTableViewContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadMoreConfigurableTableViewContainer.swift; sourceTree = "<group>"; };
@ -419,6 +422,7 @@
DB0140BD25C40D7500F9F3CF /* CommonOSLog in Frameworks */, DB0140BD25C40D7500F9F3CF /* CommonOSLog in Frameworks */,
DB89BA0325C10FD0008580ED /* CoreDataStack.framework in Frameworks */, DB89BA0325C10FD0008580ED /* CoreDataStack.framework in Frameworks */,
2D42FF6125C8177C004A627A /* ActiveLabel in Frameworks */, 2D42FF6125C8177C004A627A /* ActiveLabel in Frameworks */,
2D939AC825EE14620076FA61 /* CropViewController in Frameworks */,
5D526FE225BE9AC400460CB9 /* MastodonSDK in Frameworks */, 5D526FE225BE9AC400460CB9 /* MastodonSDK in Frameworks */,
DB5086B825CC0D6400C2C187 /* Kingfisher in Frameworks */, DB5086B825CC0D6400C2C187 /* Kingfisher in Frameworks */,
2D61336925C18A4F00CAE157 /* AlamofireNetworkActivityIndicator in Frameworks */, 2D61336925C18A4F00CAE157 /* AlamofireNetworkActivityIndicator in Frameworks */,
@ -1131,6 +1135,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
DBE0821425CD382600FD6BBD /* MastodonRegisterViewController.swift */, DBE0821425CD382600FD6BBD /* MastodonRegisterViewController.swift */,
2D939AE725EE1CF80076FA61 /* MastodonRegisterViewController+Avatar.swift */,
DBE0822325CD3F1E00FD6BBD /* MastodonRegisterViewModel.swift */, DBE0822325CD3F1E00FD6BBD /* MastodonRegisterViewModel.swift */,
); );
path = Register; path = Register;
@ -1176,6 +1181,7 @@
DB0140BC25C40D7500F9F3CF /* CommonOSLog */, DB0140BC25C40D7500F9F3CF /* CommonOSLog */,
DB5086B725CC0D6400C2C187 /* Kingfisher */, DB5086B725CC0D6400C2C187 /* Kingfisher */,
2D5981B925E4D7F8000FB903 /* ThirdPartyMailer */, 2D5981B925E4D7F8000FB903 /* ThirdPartyMailer */,
2D939AC725EE14620076FA61 /* CropViewController */,
); );
productName = Mastodon; productName = Mastodon;
productReference = DB427DD225BAA00100D1B89D /* Mastodon.app */; productReference = DB427DD225BAA00100D1B89D /* Mastodon.app */;
@ -1304,6 +1310,7 @@
DB0140BB25C40D7500F9F3CF /* XCRemoteSwiftPackageReference "CommonOSLog" */, DB0140BB25C40D7500F9F3CF /* XCRemoteSwiftPackageReference "CommonOSLog" */,
DB5086B625CC0D6400C2C187 /* XCRemoteSwiftPackageReference "Kingfisher" */, DB5086B625CC0D6400C2C187 /* XCRemoteSwiftPackageReference "Kingfisher" */,
2D5981B825E4D7F8000FB903 /* XCRemoteSwiftPackageReference "ThirdPartyMailer" */, 2D5981B825E4D7F8000FB903 /* XCRemoteSwiftPackageReference "ThirdPartyMailer" */,
2D939AC625EE14620076FA61 /* XCRemoteSwiftPackageReference "TOCropViewController" */,
); );
productRefGroup = DB427DD325BAA00100D1B89D /* Products */; productRefGroup = DB427DD325BAA00100D1B89D /* Products */;
projectDirPath = ""; projectDirPath = "";
@ -1553,6 +1560,7 @@
DB59F10E25EF724F001F1DAB /* APIService+Poll.swift in Sources */, DB59F10E25EF724F001F1DAB /* APIService+Poll.swift in Sources */,
2D42FF7E25C82218004A627A /* ActionToolBarContainer.swift in Sources */, 2D42FF7E25C82218004A627A /* ActionToolBarContainer.swift in Sources */,
DB0140A125C40C0600F9F3CF /* MastodonPinBasedAuthenticationViewController.swift in Sources */, DB0140A125C40C0600F9F3CF /* MastodonPinBasedAuthenticationViewController.swift in Sources */,
2D939AE825EE1CF80076FA61 /* MastodonRegisterViewController+Avatar.swift in Sources */,
DB1D186C25EF5BA7003F1F23 /* PollTableView.swift in Sources */, DB1D186C25EF5BA7003F1F23 /* PollTableView.swift in Sources */,
2D5981A125E4A593000FB903 /* MastodonConfirmEmailViewModel.swift in Sources */, 2D5981A125E4A593000FB903 /* MastodonConfirmEmailViewModel.swift in Sources */,
DB8AF55025C13703002E6C99 /* MainTabBarController.swift in Sources */, DB8AF55025C13703002E6C99 /* MainTabBarController.swift in Sources */,
@ -2163,6 +2171,14 @@
minimumVersion = 3.1.0; minimumVersion = 3.1.0;
}; };
}; };
2D939AC625EE14620076FA61 /* XCRemoteSwiftPackageReference "TOCropViewController" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/TimOliver/TOCropViewController.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.6.0;
};
};
DB0140BB25C40D7500F9F3CF /* XCRemoteSwiftPackageReference "CommonOSLog" */ = { DB0140BB25C40D7500F9F3CF /* XCRemoteSwiftPackageReference "CommonOSLog" */ = {
isa = XCRemoteSwiftPackageReference; isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/MainasuK/CommonOSLog"; repositoryURL = "https://github.com/MainasuK/CommonOSLog";
@ -2205,6 +2221,11 @@
package = 2D61336725C18A4F00CAE157 /* XCRemoteSwiftPackageReference "AlamofireNetworkActivityIndicator" */; package = 2D61336725C18A4F00CAE157 /* XCRemoteSwiftPackageReference "AlamofireNetworkActivityIndicator" */;
productName = AlamofireNetworkActivityIndicator; productName = AlamofireNetworkActivityIndicator;
}; };
2D939AC725EE14620076FA61 /* CropViewController */ = {
isa = XCSwiftPackageProductDependency;
package = 2D939AC625EE14620076FA61 /* XCRemoteSwiftPackageReference "TOCropViewController" */;
productName = CropViewController;
};
5D526FE125BE9AC400460CB9 /* MastodonSDK */ = { 5D526FE125BE9AC400460CB9 /* MastodonSDK */ = {
isa = XCSwiftPackageProductDependency; isa = XCSwiftPackageProductDependency;
productName = MastodonSDK; productName = MastodonSDK;

View File

@ -7,7 +7,7 @@
<key>CoreDataStack.xcscheme_^#shared#^_</key> <key>CoreDataStack.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>10</integer> <integer>13</integer>
</dict> </dict>
<key>Mastodon - RTL.xcscheme_^#shared#^_</key> <key>Mastodon - RTL.xcscheme_^#shared#^_</key>
<dict> <dict>

View File

@ -90,6 +90,15 @@
"revision": "923c60ee7588da47db8cfc4e0f5b96e5e605ef84", "revision": "923c60ee7588da47db8cfc4e0f5b96e5e605ef84",
"version": "1.7.1" "version": "1.7.1"
} }
},
{
"package": "TOCropViewController",
"repositoryURL": "https://github.com/TimOliver/TOCropViewController.git",
"state": {
"branch": null,
"revision": "dad97167bf1be16aeecd109130900995dd01c515",
"version": "2.6.0"
}
} }
] ]
}, },

View File

@ -28,6 +28,9 @@ internal enum Asset {
internal enum Asset { internal enum Asset {
internal static let mastodonTextLogo = ImageAsset(name: "Asset/mastodon.text.logo") internal static let mastodonTextLogo = ImageAsset(name: "Asset/mastodon.text.logo")
} }
internal enum Circles {
internal static let plusCircleFill = ImageAsset(name: "Circles/plus.circle.fill")
}
internal enum Colors { internal enum Colors {
internal enum Background { internal enum Background {
internal enum Poll { internal enum Poll {
@ -70,6 +73,7 @@ internal enum Asset {
internal static let lightSecondaryText = ColorAsset(name: "Colors/lightSecondaryText") internal static let lightSecondaryText = ColorAsset(name: "Colors/lightSecondaryText")
internal static let lightSuccessGreen = ColorAsset(name: "Colors/lightSuccessGreen") internal static let lightSuccessGreen = ColorAsset(name: "Colors/lightSuccessGreen")
internal static let lightWhite = ColorAsset(name: "Colors/lightWhite") internal static let lightWhite = ColorAsset(name: "Colors/lightWhite")
internal static let plusCircleFill = ImageAsset(name: "Colors/plus.circle.fill")
internal static let systemOrange = ColorAsset(name: "Colors/system.orange") internal static let systemOrange = ColorAsset(name: "Colors/system.orange")
} }
internal enum Welcome { internal enum Welcome {

View File

@ -234,12 +234,10 @@ internal enum L10n {
internal static let registrationUserInviteRequest = L10n.tr("Localizable", "Scene.Register.Input.Invite.RegistrationUserInviteRequest") internal static let registrationUserInviteRequest = L10n.tr("Localizable", "Scene.Register.Input.Invite.RegistrationUserInviteRequest")
} }
internal enum Password { internal enum Password {
/// Your password needs at least Eight characters
internal static let hint = L10n.tr("Localizable", "Scene.Register.Input.Password.Hint")
/// password /// password
internal static let placeholder = L10n.tr("Localizable", "Scene.Register.Input.Password.Placeholder") internal static let placeholder = L10n.tr("Localizable", "Scene.Register.Input.Password.Placeholder")
/// Your password needs at least:
internal static let prompt = L10n.tr("Localizable", "Scene.Register.Input.Password.Prompt")
/// Eight characters
internal static let promptEightCharacters = L10n.tr("Localizable", "Scene.Register.Input.Password.PromptEightCharacters")
} }
internal enum Username { internal enum Username {
/// This username is taken. /// This username is taken.

View File

@ -0,0 +1,9 @@
{
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"provides-namespace" : true
}
}

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "plus.circle.fill.pdf",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,89 @@
%PDF-1.7
1 0 obj
<< >>
endobj
2 0 obj
<< /Length 3 0 R >>
stream
/DeviceRGB CS
/DeviceRGB cs
q
1.000000 0.000000 -0.000000 1.000000 0.000000 0.000000 cm
0.000000 0.000000 0.000000 scn
12.007203 -0.000002 m
18.586674 -0.000002 24.000000 5.413311 24.000000 12.007201 c
24.000000 18.586702 18.586674 24.000000 11.992814 24.000000 c
5.413314 24.000000 0.000000 18.586702 0.000000 12.007201 c
0.000000 5.413311 5.413314 -0.000002 12.007203 -0.000002 c
h
6.478707 12.007201 m
6.478707 12.827837 7.068974 13.432522 7.875220 13.432522 c
10.567494 13.432522 l
10.567494 16.124798 l
10.567494 16.931015 11.172179 17.535698 11.992814 17.535698 c
12.813449 17.535698 13.418134 16.931015 13.418134 16.124798 c
13.418134 13.432522 l
16.110380 13.432522 l
16.931015 13.432522 17.521311 12.827837 17.521311 12.007201 c
17.521311 11.186566 16.931015 10.581882 16.110380 10.581882 c
13.418134 10.581882 l
13.418134 7.889637 l
13.418134 7.083389 12.813449 6.478704 11.992814 6.478704 c
11.172179 6.478704 10.567494 7.083389 10.567494 7.889637 c
10.567494 10.581882 l
7.875220 10.581882 l
7.068974 10.581882 6.478707 11.186566 6.478707 12.007201 c
h
f
n
Q
endstream
endobj
3 0 obj
1071
endobj
4 0 obj
<< /Annots []
/Type /Page
/MediaBox [ 0.000000 0.000000 24.000000 24.000000 ]
/Resources 1 0 R
/Contents 2 0 R
/Parent 5 0 R
>>
endobj
5 0 obj
<< /Kids [ 4 0 R ]
/Count 1
/Type /Pages
>>
endobj
6 0 obj
<< /Type /Catalog
/Pages 5 0 R
>>
endobj
xref
0 7
0000000000 65535 f
0000000010 00000 n
0000000034 00000 n
0000001161 00000 n
0000001184 00000 n
0000001357 00000 n
0000001431 00000 n
trailer
<< /ID [ (some) (id) ]
/Root 6 0 R
/Size 7
>>
startxref
1490
%%EOF

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "plus.circle.fill.pdf",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,101 @@
%PDF-1.7
1 0 obj
<< >>
endobj
2 0 obj
<< /Length 3 0 R >>
stream
/DeviceRGB CS
/DeviceRGB cs
q
1.000000 0.000000 -0.000000 1.000000 0.000000 0.000000 cm
1.000000 1.000000 1.000000 scn
30.000000 15.000000 m
30.000000 6.715729 23.284271 0.000000 15.000000 0.000000 c
6.715729 0.000000 0.000000 6.715729 0.000000 15.000000 c
0.000000 23.284271 6.715729 30.000000 15.000000 30.000000 c
23.284271 30.000000 30.000000 23.284271 30.000000 15.000000 c
h
f
n
Q
q
1.000000 0.000000 -0.000000 1.000000 0.000000 0.000000 cm
0.000000 0.000000 0.000000 scn
15.009004 0.000000 m
23.233341 0.000000 30.000000 6.766640 30.000000 15.009003 c
30.000000 23.233379 23.233341 30.000000 14.991017 30.000000 c
6.766642 30.000000 0.000000 23.233379 0.000000 15.009003 c
0.000000 6.766640 6.766643 0.000000 15.009004 0.000000 c
h
8.098384 15.009003 m
8.098384 16.034798 8.836217 16.790653 9.844025 16.790653 c
13.209368 16.790653 l
13.209368 20.155996 l
13.209368 21.163769 13.965223 21.919624 14.991017 21.919624 c
16.016811 21.919624 16.772667 21.163769 16.772667 20.155996 c
16.772667 16.790653 l
20.137974 16.790653 l
21.163769 16.790653 21.901638 16.034798 21.901638 15.009003 c
21.901638 13.983208 21.163769 13.227352 20.137974 13.227352 c
16.772667 13.227352 l
16.772667 9.862047 l
16.772667 8.854239 16.016811 8.098381 14.991017 8.098381 c
13.965223 8.098381 13.209368 8.854239 13.209368 9.862047 c
13.209368 13.227352 l
9.844025 13.227352 l
8.836217 13.227352 8.098384 13.983208 8.098384 15.009003 c
h
f
n
Q
endstream
endobj
3 0 obj
1426
endobj
4 0 obj
<< /Annots []
/Type /Page
/MediaBox [ 0.000000 0.000000 30.000000 30.000000 ]
/Resources 1 0 R
/Contents 2 0 R
/Parent 5 0 R
>>
endobj
5 0 obj
<< /Kids [ 4 0 R ]
/Count 1
/Type /Pages
>>
endobj
6 0 obj
<< /Type /Catalog
/Pages 5 0 R
>>
endobj
xref
0 7
0000000000 65535 f
0000000010 00000 n
0000000034 00000 n
0000001516 00000 n
0000001539 00000 n
0000001712 00000 n
0000001786 00000 n
trailer
<< /ID [ (some) (id) ]
/Root 6 0 R
/Size 7
>>
startxref
1845
%%EOF

View File

@ -72,9 +72,8 @@ tap the link to confirm your account.";
"Scene.Register.Input.DisplayName.Placeholder" = "display name"; "Scene.Register.Input.DisplayName.Placeholder" = "display name";
"Scene.Register.Input.Email.Placeholder" = "email"; "Scene.Register.Input.Email.Placeholder" = "email";
"Scene.Register.Input.Invite.RegistrationUserInviteRequest" = "Why do you want to join?"; "Scene.Register.Input.Invite.RegistrationUserInviteRequest" = "Why do you want to join?";
"Scene.Register.Input.Password.Hint" = "Your password needs at least Eight characters";
"Scene.Register.Input.Password.Placeholder" = "password"; "Scene.Register.Input.Password.Placeholder" = "password";
"Scene.Register.Input.Password.Prompt" = "Your password needs at least:";
"Scene.Register.Input.Password.PromptEightCharacters" = "Eight characters";
"Scene.Register.Input.Username.DuplicatePrompt" = "This username is taken."; "Scene.Register.Input.Username.DuplicatePrompt" = "This username is taken.";
"Scene.Register.Input.Username.Placeholder" = "username"; "Scene.Register.Input.Username.Placeholder" = "username";
"Scene.Register.Success" = "Success"; "Scene.Register.Success" = "Success";

View File

@ -8,6 +8,7 @@
import UIKit import UIKit
import MastodonSDK import MastodonSDK
import Kingfisher import Kingfisher
import Kanna
protocol PickServerCellDelegate: class { protocol PickServerCellDelegate: class {
func pickServerCell(modeChange server: Mastodon.Entity.Server, newMode: PickServerCell.Mode, updates: (() -> Void)) func pickServerCell(modeChange server: Mastodon.Entity.Server, newMode: PickServerCell.Mode, updates: (() -> Void))
@ -326,7 +327,13 @@ extension PickServerCell {
private func updateServerInfo() { private func updateServerInfo() {
guard let serverInfo = server else { return } guard let serverInfo = server else { return }
domainLabel.text = serverInfo.domain domainLabel.text = serverInfo.domain
descriptionLabel.text = serverInfo.description descriptionLabel.text = {
guard let html = try? HTML(html: serverInfo.description, encoding: .utf8) else {
return serverInfo.description
}
return html.text ?? serverInfo.description
}()
let processor = RoundCornerImageProcessor(cornerRadius: 3) let processor = RoundCornerImageProcessor(cornerRadius: 3)
thumbImageView.kf.indicatorType = .activity thumbImageView.kf.indicatorType = .activity
thumbImageView.kf.setImage(with: URL(string: serverInfo.proxiedThumbnail ?? "")!, placeholder: UIImage.placeholder(color: Asset.Colors.lightBackground.color), options: [ thumbImageView.kf.setImage(with: URL(string: serverInfo.proxiedThumbnail ?? "")!, placeholder: UIImage.placeholder(color: Asset.Colors.lightBackground.color), options: [

View File

@ -0,0 +1,57 @@
//
// MastodonRegisterViewController+Avatar.swift
// Mastodon
//
// Created by sxiaojian on 2021/3/2.
//
import CropViewController
import Foundation
import PhotosUI
import UIKit
extension MastodonRegisterViewController: CropViewControllerDelegate, PHPickerViewControllerDelegate {
func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
guard let itemProvider = results.first?.itemProvider, itemProvider.canLoadObject(ofClass: UIImage.self) else {
picker.dismiss(animated: true, completion: {})
return
}
itemProvider.loadObject(ofClass: UIImage.self) { [weak self] image, error in
guard let self = self else { return }
guard let image = image as? UIImage else {
guard let error = error else { return }
let alertController = UIAlertController(for: error, title: "", preferredStyle: .alert)
let okAction = UIAlertAction(title: L10n.Common.Controls.Actions.ok, style: .default, handler: nil)
alertController.addAction(okAction)
DispatchQueue.main.async {
self.coordinator.present(
scene: .alertController(alertController: alertController),
from: nil,
transition: .alertController(animated: true, completion: nil)
)
}
return
}
DispatchQueue.main.async {
let cropController = CropViewController(croppingStyle: .default, image: image)
cropController.delegate = self
cropController.setAspectRatioPreset(.presetSquare, animated: true)
cropController.aspectRatioPickerButtonHidden = true
cropController.aspectRatioLockEnabled = true
picker.dismiss(animated: true, completion: {
self.present(cropController, animated: true, completion: nil)
})
}
}
}
public func cropViewController(_ cropViewController: CropViewController, didCropToImage image: UIImage, withRect cropRect: CGRect, angle: Int) {
self.viewModel.avatarImage.value = image
self.photoButton.setImage(image, for: .normal)
cropViewController.dismiss(animated: true, completion: nil)
}
@objc func avatarButtonPressed(_ sender: UIButton) {
self.present(imagePicker, animated: true, completion: nil)
}
}

View File

@ -8,6 +8,7 @@
import Combine import Combine
import MastodonSDK import MastodonSDK
import os.log import os.log
import PhotosUI
import UIKit import UIKit
import UITextField_Shake import UITextField_Shake
@ -19,6 +20,15 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O
var viewModel: MastodonRegisterViewModel! var viewModel: MastodonRegisterViewModel!
lazy var imagePicker: PHPickerViewController = {
var configuration = PHPickerConfiguration()
configuration.filter = .images
let imagePicker = PHPickerViewController(configuration: configuration)
imagePicker.delegate = self
return imagePicker
}()
let tapGestureRecognizer = UITapGestureRecognizer.singleTapGestureRecognizer let tapGestureRecognizer = UITapGestureRecognizer.singleTapGestureRecognizer
let scrollView: UIScrollView = { let scrollView: UIScrollView = {
@ -26,7 +36,7 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O
scrollview.showsVerticalScrollIndicator = false scrollview.showsVerticalScrollIndicator = false
scrollview.keyboardDismissMode = .interactive scrollview.keyboardDismissMode = .interactive
scrollview.alwaysBounceVertical = true scrollview.alwaysBounceVertical = true
scrollview.clipsToBounds = false // make content could display over bleeding scrollview.clipsToBounds = false // make content could display over bleeding
scrollview.translatesAutoresizingMaskIntoConstraints = false scrollview.translatesAutoresizingMaskIntoConstraints = false
return scrollview return scrollview
}() }()
@ -56,26 +66,18 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O
button.backgroundColor = .white button.backgroundColor = .white
button.layer.cornerRadius = 45 button.layer.cornerRadius = 45
button.clipsToBounds = true button.clipsToBounds = true
return button
}()
let plusIconBackground: UIImageView = { button.addTarget(self, action: #selector(MastodonRegisterViewController.avatarButtonPressed(_:)), for: .touchUpInside)
let icon = UIImageView() return button
let boldFont = UIFont.systemFont(ofSize: 24)
let configuration = UIImage.SymbolConfiguration(font: boldFont)
let image = UIImage(systemName: "plus.circle", withConfiguration: configuration)
icon.image = image
icon.tintColor = .white
return icon
}() }()
let plusIcon: UIImageView = { let plusIcon: UIImageView = {
let icon = UIImageView() let icon = UIImageView()
let boldFont = UIFont.systemFont(ofSize: 24)
let configuration = UIImage.SymbolConfiguration(font: boldFont) let image = Asset.Circles.plusCircleFill.image.withRenderingMode(.alwaysTemplate)
let image = UIImage(systemName: "plus.circle.fill", withConfiguration: configuration)
icon.image = image icon.image = image
icon.tintColor = Asset.Colors.Icon.plus.color icon.tintColor = Asset.Colors.Icon.plus.color
icon.backgroundColor = .white
return icon return icon
}() }()
@ -204,19 +206,28 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O
}() }()
deinit { deinit {
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", (#file as NSString).lastPathComponent, #line, #function)
} }
} }
extension MastodonRegisterViewController { extension MastodonRegisterViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
setupOnboardingAppearance() setupOnboardingAppearance()
defer { setupNavigationBarBackgroundView() } defer { setupNavigationBarBackgroundView() }
photoButton.publisher(for: \.isHighlighted, options: .new)
.receive(on: DispatchQueue.main)
.sink { [weak self] isHighlighted in
guard let self = self else { return }
let alpha: CGFloat = isHighlighted ? 0.8 : 1
self.plusIcon.alpha = alpha
self.photoButton.alpha = alpha
}
.store(in: &disposeBag)
domainLabel.text = "@" + viewModel.domain + " " domainLabel.text = "@" + viewModel.domain + " "
domainLabel.sizeToFit() domainLabel.sizeToFit()
passwordCheckLabel.attributedText = viewModel.attributeStringForPassword() passwordCheckLabel.attributedText = viewModel.attributeStringForPassword()
@ -283,12 +294,7 @@ extension MastodonRegisterViewController {
photoButton.centerXAnchor.constraint(equalTo: photoView.centerXAnchor), photoButton.centerXAnchor.constraint(equalTo: photoView.centerXAnchor),
photoButton.centerYAnchor.constraint(equalTo: photoView.centerYAnchor), photoButton.centerYAnchor.constraint(equalTo: photoView.centerYAnchor),
]) ])
plusIconBackground.translatesAutoresizingMaskIntoConstraints = false
photoView.addSubview(plusIconBackground)
NSLayoutConstraint.activate([
plusIconBackground.trailingAnchor.constraint(equalTo: photoButton.trailingAnchor),
plusIconBackground.bottomAnchor.constraint(equalTo: photoButton.bottomAnchor),
])
plusIcon.translatesAutoresizingMaskIntoConstraints = false plusIcon.translatesAutoresizingMaskIntoConstraints = false
photoView.addSubview(plusIcon) photoView.addSubview(plusIcon)
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
@ -403,7 +409,7 @@ extension MastodonRegisterViewController {
viewModel.isUsernameTaken viewModel.isUsernameTaken
.receive(on: DispatchQueue.main) .receive(on: DispatchQueue.main)
.sink {[weak self] isUsernameTaken in .sink { [weak self] isUsernameTaken in
guard let self = self else { return } guard let self = self else { return }
if isUsernameTaken { if isUsernameTaken {
self.usernameIsTakenLabel.isHidden = false self.usernameIsTakenLabel.isHidden = false
@ -480,10 +486,9 @@ extension MastodonRegisterViewController {
.store(in: &disposeBag) .store(in: &disposeBag)
if viewModel.approvalRequired { if viewModel.approvalRequired {
inviteTextField.delegate = self inviteTextField.delegate = self
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
inviteTextField.heightAnchor.constraint(equalToConstant: 50).priority(.defaultHigh) inviteTextField.heightAnchor.constraint(equalToConstant: 50).priority(.defaultHigh),
]) ])
viewModel.inviteValidateState viewModel.inviteValidateState
@ -491,7 +496,6 @@ extension MastodonRegisterViewController {
.sink { [weak self] validateState in .sink { [weak self] validateState in
guard let self = self else { return } guard let self = self else { return }
self.setTextFieldValidAppearance(self.inviteTextField, validateState: validateState) self.setTextFieldValidAppearance(self.inviteTextField, validateState: validateState)
} }
.store(in: &disposeBag) .store(in: &disposeBag)
NotificationCenter.default NotificationCenter.default
@ -506,11 +510,14 @@ extension MastodonRegisterViewController {
signUpButton.addTarget(self, action: #selector(MastodonRegisterViewController.signUpButtonPressed(_:)), for: .touchUpInside) signUpButton.addTarget(self, action: #selector(MastodonRegisterViewController.signUpButtonPressed(_:)), for: .touchUpInside)
} }
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
plusIcon.layer.cornerRadius = plusIcon.frame.width/2
plusIcon.clipsToBounds = true
}
} }
extension MastodonRegisterViewController: UITextFieldDelegate { extension MastodonRegisterViewController: UITextFieldDelegate {
func textFieldDidBeginEditing(_ textField: UITextField) { func textFieldDidBeginEditing(_ textField: UITextField) {
let text = textField.text?.trimmingCharacters(in: .whitespacesAndNewlines) ?? "" let text = textField.text?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
@ -552,7 +559,6 @@ extension MastodonRegisterViewController: UITextFieldDelegate {
} }
extension MastodonRegisterViewController { extension MastodonRegisterViewController {
@objc private func tapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) { @objc private func tapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) {
view.endEditing(true) view.endEditing(true)
} }
@ -599,6 +605,5 @@ extension MastodonRegisterViewController {
self.coordinator.present(scene: .mastodonConfirmEmail(viewModel: viewModel), from: self, transition: .show) self.coordinator.present(scene: .mastodonConfirmEmail(viewModel: viewModel), from: self, transition: .show)
} }
.store(in: &disposeBag) .store(in: &disposeBag)
} }
} }

View File

@ -24,6 +24,7 @@ final class MastodonRegisterViewModel {
let email = CurrentValueSubject<String, Never>("") let email = CurrentValueSubject<String, Never>("")
let password = CurrentValueSubject<String, Never>("") let password = CurrentValueSubject<String, Never>("")
let reason = CurrentValueSubject<String, Never>("") let reason = CurrentValueSubject<String, Never>("")
let avatarImage = CurrentValueSubject<UIImage?, Never>(nil)
// output // output
let approvalRequired: Bool let approvalRequired: Bool
@ -160,11 +161,8 @@ extension MastodonRegisterViewModel {
let falseColor = UIColor.clear let falseColor = UIColor.clear
let attributeString = NSMutableAttributedString() let attributeString = NSMutableAttributedString()
let start = NSAttributedString(string: "Your password needs at least:", attributes: [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: color])
attributeString.append(start)
attributeString.append(checkmarkImage(color: eightCharacters ? color : falseColor)) attributeString.append(checkmarkImage(color: eightCharacters ? color : falseColor))
let eightCharactersDescription = NSAttributedString(string: " Eight characters\n", attributes: [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: color]) let eightCharactersDescription = NSAttributedString(string: L10n.Scene.Register.Input.Password.hint, attributes: [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: color])
attributeString.append(eightCharactersDescription) attributeString.append(eightCharactersDescription)
return attributeString return attributeString

View File

@ -13,11 +13,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
let appContext = AppContext() let appContext = AppContext()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
// Update app version info. See: `Settings.bundle` // Update app version info. See: `Settings.bundle`
UserDefaults.standard.setValue(UIApplication.appVersion(), forKey: "Mastodon.appVersion") UserDefaults.standard.setValue(UIApplication.appVersion(), forKey: "Mastodon.appVersion")
UserDefaults.standard.setValue(UIApplication.appBuild(), forKey: "Mastodon.appBundle") UserDefaults.standard.setValue(UIApplication.appBuild(), forKey: "Mastodon.appBundle")
return true
} }
// MARK: UISceneSession Lifecycle // MARK: UISceneSession Lifecycle