Merge commit 'ea79ca771d441f1d0af2cd19872e3bdd227838e7' into feature/home

# Conflicts:
#	Mastodon.xcodeproj/project.pbxproj
This commit is contained in:
CMK 2021-02-23 15:25:48 +08:00
commit e6ad839d3c
15 changed files with 613 additions and 22 deletions

View File

@ -7,6 +7,10 @@
objects = {
/* Begin PBXBuildFile section */
0FAA0FDF25E0B57E0017CCDE /* WelcomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FAA0FDE25E0B57E0017CCDE /* WelcomeViewController.swift */; };
0FAA101225E105390017CCDE /* PrimaryActionButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FAA101125E105390017CCDE /* PrimaryActionButton.swift */; };
0FAA101C25E10E760017CCDE /* UIFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FAA101B25E10E760017CCDE /* UIFont.swift */; };
0FAA102725E1126A0017CCDE /* PickServerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FAA102625E1126A0017CCDE /* PickServerViewController.swift */; };
18BC7629F65E6DB12CB8416D /* Pods_Mastodon_MastodonUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C030226D3C73DCC23D67452 /* Pods_Mastodon_MastodonUITests.framework */; };
2D04F42525C255B9003F936F /* APIService+PublicTimeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D04F42425C255B9003F936F /* APIService+PublicTimeline.swift */; };
2D152A8C25C295CC009AA50C /* StatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D152A8B25C295CC009AA50C /* StatusView.swift */; };
@ -188,6 +192,10 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
0FAA0FDE25E0B57E0017CCDE /* WelcomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeViewController.swift; sourceTree = "<group>"; };
0FAA101125E105390017CCDE /* PrimaryActionButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimaryActionButton.swift; sourceTree = "<group>"; };
0FAA101B25E10E760017CCDE /* UIFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIFont.swift; sourceTree = "<group>"; };
0FAA102625E1126A0017CCDE /* PickServerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickServerViewController.swift; sourceTree = "<group>"; };
2D04F42425C255B9003F936F /* APIService+PublicTimeline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "APIService+PublicTimeline.swift"; sourceTree = "<group>"; };
2D152A8B25C295CC009AA50C /* StatusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusView.swift; sourceTree = "<group>"; };
2D152A9125C2980C009AA50C /* UIFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIFont.swift; sourceTree = "<group>"; };
@ -379,6 +387,22 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0FAA0FDD25E0B5700017CCDE /* Welcome */ = {
isa = PBXGroup;
children = (
0FAA0FDE25E0B57E0017CCDE /* WelcomeViewController.swift */,
);
path = Welcome;
sourceTree = "<group>";
};
0FAA102525E1125D0017CCDE /* PickServer */ = {
isa = PBXGroup;
children = (
0FAA102625E1126A0017CCDE /* PickServerViewController.swift */,
);
path = PickServer;
sourceTree = "<group>";
};
1EBA4F56E920856A3FC84ACB /* Pods */ = {
isa = PBXGroup;
children = (
@ -439,6 +463,7 @@
DB5086A425CC0B7000C2C187 /* AvatarBarButtonItem.swift */,
2D42FF8425C8224F004A627A /* HitTestExpandedButton.swift */,
DB118A8B25E4BFB500FAB162 /* HighlightDimmableButton.swift */,
0FAA101125E105390017CCDE /* PrimaryActionButton.swift */,
);
path = Button;
sourceTree = "<group>";
@ -828,6 +853,8 @@
DB8AF55525C1379F002E6C99 /* Scene */ = {
isa = PBXGroup;
children = (
0FAA102525E1125D0017CCDE /* PickServer */,
0FAA0FDD25E0B5700017CCDE /* Welcome */,
2D7631A425C1532200929FB9 /* Share */,
DB8AF54E25C13703002E6C99 /* MainTab */,
DB01409B25C40BB600F9F3CF /* Authentication */,
@ -852,6 +879,7 @@
2D42FF8E25C8228A004A627A /* UIButton.swift */,
DB45FAD625CA6C76005A8AC7 /* UIBarButtonItem.swift */,
2D32EAB925CB9B0500C9ED86 /* UIView.swift */,
0FAA101B25E10E760017CCDE /* UIFont.swift */,
);
path = Extension;
sourceTree = "<group>";
@ -1233,11 +1261,13 @@
buildActionMask = 2147483647;
files = (
DB98337125C9443200AD9700 /* APIService+Authentication.swift in Sources */,
0FAA0FDF25E0B57E0017CCDE /* WelcomeViewController.swift in Sources */,
DB45FB1D25CA9D23005A8AC7 /* APIService+HomeTimeline.swift in Sources */,
2D7631B325C159F700929FB9 /* Item.swift in Sources */,
2D61335E25C1894B00CAE157 /* APIService.swift in Sources */,
2D38F1F725CD47AC00561493 /* HomeTimelineViewModel+LoadOldestState.swift in Sources */,
2D5A3D3825CF8D9F002347D6 /* ScrollViewContainer.swift in Sources */,
0FAA101225E105390017CCDE /* PrimaryActionButton.swift in Sources */,
DB8AF53025C13561002E6C99 /* AppContext.swift in Sources */,
DB72602725E36A6F00235243 /* MastodonServerRulesViewModel.swift in Sources */,
2D38F1F125CD477D00561493 /* HomeTimelineViewModel+LoadMiddleState.swift in Sources */,
@ -1246,10 +1276,12 @@
2D42FF8525C8224F004A627A /* HitTestExpandedButton.swift in Sources */,
DB72601C25E36A2100235243 /* MastodonServerRulesViewController.swift in Sources */,
2D42FF8F25C8228A004A627A /* UIButton.swift in Sources */,
0FAA102725E1126A0017CCDE /* PickServerViewController.swift in Sources */,
2D61335825C188A000CAE157 /* APIService+Persist+Timeline.swift in Sources */,
DB45FAE325CA7181005A8AC7 /* MastodonUser.swift in Sources */,
DB0AC6FC25CD02E600D75117 /* APIService+Instance.swift in Sources */,
2D69D00A25CAA00300C3A1B2 /* APIService+CoreData+Toot.swift in Sources */,
0FAA101C25E10E760017CCDE /* UIFont.swift in Sources */,
2D38F1D525CD465300561493 /* HomeTimelineViewController.swift in Sources */,
DB98338825C945ED00AD9700 /* Assets.swift in Sources */,
2DA7D04425CA52B200804E11 /* TimelineLoaderTableViewCell.swift in Sources */,

View File

@ -6,6 +6,7 @@
import UIKit
import SafariServices
import CoreDataStack
final public class SceneCoordinator {
@ -37,6 +38,7 @@ extension SceneCoordinator {
}
enum Scene {
case welcome
case authentication(viewModel: AuthenticationViewModel)
case mastodonPinBasedAuthentication(viewModel: MastodonPinBasedAuthenticationViewModel)
case mastodonRegister(viewModel: MastodonRegisterViewModel)
@ -49,8 +51,24 @@ extension SceneCoordinator {
extension SceneCoordinator {
func setup() {
let viewController = MainTabBarController(context: appContext, coordinator: self)
sceneDelegate.window?.rootViewController = viewController
// Check user authentication status
let request = MastodonAuthentication.sortedFetchRequest
do {
let fetchResult = try appContext.managedObjectContext.fetch(request)
DispatchQueue.main.async {
var rootViewController: UIViewController
if fetchResult.isEmpty {
let welcomeNaviVC = UINavigationController(rootViewController: WelcomeViewController())
rootViewController = welcomeNaviVC
} else {
rootViewController = MainTabBarController(context: self.appContext, coordinator: self)
}
self.sceneDelegate.window?.rootViewController = rootViewController
}
} catch {
assertionFailure("CoreDataStack error at app launch!")
}
}
@discardableResult
@ -114,6 +132,9 @@ private extension SceneCoordinator {
let viewController: UIViewController?
switch scene {
case .welcome:
let _viewController = WelcomeViewController()
viewController = _viewController
case .authentication(let viewModel):
let _viewController = AuthenticationViewController()
_viewController.viewModel = viewModel

View File

@ -0,0 +1,23 @@
//
// UIFont.swift
// Mastodon
//
// Created by on 2021/2/20.
//
import UIKit
extension UIFont {
private func withTraits(traits: UIFontDescriptor.SymbolicTraits) -> UIFont {
let descriptor = fontDescriptor.withSymbolicTraits(traits)
return UIFont(descriptor: descriptor!, size: 0) //size 0 means keep the size as it is
}
func bold() -> UIFont {
return withTraits(traits: .traitBold)
}
func italic() -> UIFont {
return withTraits(traits: .traitItalic)
}
}

View File

@ -7,6 +7,7 @@
import UIKit
// MARK: - Convinience view creation method
extension UIView {
static var separatorLine: UIView {
@ -24,3 +25,14 @@ extension UIView {
}
}
// MARK: - Convinience view appearance modification method
extension UIView {
@discardableResult
func applyCornerRadius(radius: CGFloat) -> Self {
layer.masksToBounds = true
layer.cornerRadius = radius
layer.cornerCurve = .continuous
return self
}
}

View File

@ -78,6 +78,7 @@ internal enum Asset {
internal static let lock = ImageAsset(name: "TootTimeline/lock")
internal static let unlock = ImageAsset(name: "TootTimeline/unlock")
}
internal static let welcomeLogo = ImageAsset(name: "welcome.logo")
}
// swiftlint:enable identifier_name line_length nesting type_body_length type_name

View File

@ -11,6 +11,13 @@ import Foundation
// swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
internal enum L10n {
internal enum Button {
/// Sign In
internal static let signIn = L10n.tr("Localizable", "Button.SignIn")
/// Sign Up
internal static let signUp = L10n.tr("Localizable", "Button.SignUp")
}
internal enum Common {
internal enum Controls {
internal enum Actions {

View File

@ -62,5 +62,9 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIUserInterfaceStyle</key>
<string>Dark</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "Logotype (Full) 1.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,335 @@
%PDF-1.7
1 0 obj
<< /BBox [ 0.000000 0.000000 265.139893 65.366211 ]
/Resources << >>
/Subtype /Form
/Length 2 0 R
/Group << /Type /Group
/S /Transparency
>>
/Type /XObject
>>
stream
/DeviceRGB CS
/DeviceRGB cs
q
1.000000 0.000000 -0.000000 1.000000 0.000000 -0.161102 cm
0.188235 0.533333 0.831373 scn
59.674690 26.340824 m
58.778019 21.729694 51.647373 16.683701 43.456982 15.705723 c
39.185936 15.195595 34.981327 14.727741 30.497496 14.933094 c
23.164286 15.269001 17.378185 16.683697 17.378185 16.683697 c
17.378185 15.969608 17.422323 15.289906 17.510132 14.654335 c
18.463486 7.417763 24.686306 6.983833 30.580656 6.781731 c
36.529831 6.578239 41.826706 8.248928 41.826706 8.248928 c
42.071552 2.869816 l
42.071552 2.869816 37.910149 0.635567 30.497496 0.224861 c
26.409500 0.000000 21.334234 0.327538 15.422230 1.891842 c
2.601194 5.285728 0.396213 18.952328 0.058915 32.819641 c
-0.044226 36.936905 0.019424 40.819546 0.019424 44.066154 c
0.019424 58.246605 9.309983 62.402893 9.309983 62.402893 c
13.994521 64.554443 22.032990 65.459015 30.389708 65.527313 c
30.595058 65.527313 l
38.951778 65.459015 46.995354 64.554443 51.679893 62.402893 c
51.679893 62.402893 60.970455 58.246605 60.970455 44.066154 c
60.970455 44.066154 61.086605 33.604343 59.674690 26.340824 c
h
f
n
Q
q
1.000000 0.000000 -0.000000 1.000000 12.881470 25.370911 cm
0.121569 0.137255 0.168627 scn
0.000000 21.971138 m
0.000000 24.035347 1.673481 25.708363 3.737223 25.708363 c
5.801430 25.708363 7.474446 24.035347 7.474446 21.971138 c
7.474446 19.907396 5.801430 18.233915 3.737223 18.233915 c
1.673481 18.233915 0.000000 19.907396 0.000000 21.971138 c
h
53.598671 17.434528 m
53.598671 0.264858 l
46.796501 0.264858 l
46.796501 16.929976 l
46.796501 20.443262 45.318153 22.225924 42.361454 22.225924 c
39.093010 22.225924 37.454372 20.110611 37.454372 15.928303 c
37.454372 6.806858 l
30.692154 6.806858 l
30.692154 15.928303 l
30.692154 20.110611 29.053518 22.225924 25.785074 22.225924 c
22.828375 22.225924 21.350027 20.443262 21.350027 16.929976 c
21.350027 0.264858 l
14.547852 0.264858 l
14.547852 17.434528 l
14.547852 20.943634 15.441275 23.732149 17.236015 25.795427 c
19.086971 27.858242 21.510775 28.915665 24.519045 28.915665 c
28.000275 28.915665 30.636404 27.578087 32.378643 24.902004 c
34.073498 22.061457 l
35.767883 24.902004 l
37.510586 27.578087 40.146252 28.915665 43.627945 28.915665 c
46.636215 28.915665 49.059559 27.858242 50.910519 25.795427 c
52.705257 23.732149 53.598671 20.943634 53.598671 17.434528 c
53.598671 17.434528 l
h
77.032234 8.899359 m
78.435783 10.382355 79.111771 12.250038 79.111771 14.502407 c
79.111771 16.754778 78.435783 18.622458 77.032234 20.050631 c
75.680717 21.534092 73.964493 22.247713 71.884956 22.247713 c
69.804955 22.247713 68.089188 21.534092 66.737679 20.050631 c
65.385696 18.622458 64.709709 16.754778 64.709709 14.502407 c
64.709709 12.250038 65.385696 10.382355 66.737679 8.899359 c
68.089188 7.471186 69.804955 6.757099 71.884956 6.757099 c
73.964493 6.757099 75.680717 7.471186 77.032234 8.899359 c
h
79.111771 28.235912 m
85.819176 28.235912 l
85.819176 0.768902 l
79.111771 0.768902 l
79.111771 4.010399 l
77.084267 1.318520 74.276245 -0.000008 70.637054 -0.000008 c
67.153496 -0.000008 64.189835 1.373341 61.694012 4.175331 c
59.250694 6.976852 58.002777 10.437643 58.002777 14.502407 c
58.002777 18.512350 59.250694 21.973600 61.694012 24.775124 c
64.189835 27.576649 67.153496 29.004822 70.637054 29.004822 c
74.276245 29.004822 77.084267 27.686295 79.111771 24.994881 c
79.111771 28.235912 l
79.111771 28.235912 l
h
108.385788 14.996740 m
110.361259 13.513744 111.349464 11.426306 111.297432 8.789715 c
111.297432 5.987724 110.309227 3.790642 108.281723 2.252361 c
106.253754 0.768898 103.810432 -0.000008 100.846764 -0.000008 c
95.491348 -0.000008 91.851685 2.197540 89.927788 6.537346 c
95.751526 9.997667 l
96.531120 7.636118 98.246872 6.427235 100.846764 6.427235 c
103.238045 6.427235 104.434395 7.196609 104.434395 8.789715 c
104.434395 9.943310 102.874275 10.986797 99.702927 11.810530 c
98.506592 12.140394 97.518852 12.469793 96.739258 12.744835 c
95.647453 13.183880 94.711761 13.678675 93.931702 14.282652 c
92.007797 15.765648 91.020058 17.743904 91.020058 20.270386 c
91.020058 22.962265 91.955765 25.104525 93.827629 26.642807 c
95.751526 28.235912 98.090775 29.004822 100.898804 29.004822 c
105.370094 29.004822 108.645966 27.082315 110.777069 23.182018 c
105.058350 19.886164 l
104.226250 21.753380 102.822701 22.687222 100.898804 22.687222 c
98.870834 22.687222 97.883102 21.918314 97.883102 20.435318 c
97.883102 19.281721 99.442749 18.238235 102.614563 17.414040 c
105.058342 16.864885 106.981773 16.040691 108.385788 14.996740 c
108.385788 14.996740 l
h
129.704178 21.423981 m
123.828873 21.423981 l
123.828873 9.997667 l
123.828873 8.624317 124.349236 7.800587 125.336967 7.416365 c
126.064987 7.141323 127.520576 7.086502 129.704178 7.196609 c
129.704178 0.768902 l
125.181328 0.219746 121.905449 0.659256 119.981552 2.142715 c
118.058113 3.570889 117.121948 6.207481 117.121948 9.997667 c
117.121948 21.423981 l
112.598618 21.423981 l
112.598618 28.235912 l
117.121948 28.235912 l
117.121948 33.784138 l
123.828873 35.926395 l
123.828873 28.235912 l
129.704178 28.235912 l
129.704178 21.423981 l
129.704178 21.423981 l
h
151.075012 9.064060 m
152.427002 10.492699 153.102524 12.305557 153.102524 14.502640 c
153.102524 16.699722 152.427002 18.512581 151.075012 19.940754 c
149.723038 21.369392 148.059311 22.083014 146.031342 22.083014 c
144.003845 22.083014 142.340118 21.369392 140.988144 19.940754 c
139.688202 18.457758 139.012207 16.644899 139.012207 14.502640 c
139.012207 12.359917 139.688202 10.547056 140.988144 9.064060 c
142.340118 7.635887 144.003845 6.921799 146.031342 6.921799 c
148.059311 6.921799 149.723038 7.635887 151.075012 9.064060 c
151.075012 9.064060 l
h
136.256683 4.175098 m
133.605225 6.976620 132.305267 10.382589 132.305267 14.502640 c
132.305267 18.567869 133.605225 21.973368 136.256683 24.774891 c
138.908142 27.576416 142.184006 29.004589 146.031342 29.004589 c
149.879135 29.004589 153.154556 27.576416 155.806488 24.774891 c
158.458405 21.973368 159.809921 18.512583 159.809921 14.502640 c
159.809921 10.437410 158.458405 6.976620 155.806488 4.175098 c
153.154556 1.373108 149.931168 0.000225 146.031342 0.000225 c
142.131973 0.000225 138.908142 1.373108 136.256683 4.175098 c
h
182.220291 8.899359 m
183.572281 10.382355 184.247803 12.250038 184.247803 14.502407 c
184.247803 16.754778 183.572281 18.622458 182.220291 20.050631 c
180.868774 21.534092 179.152557 22.247713 177.073013 22.247713 c
174.993011 22.247713 173.277252 21.534092 171.873703 20.050631 c
170.522202 18.622458 169.845734 16.754778 169.845734 14.502407 c
169.845734 12.250038 170.522202 10.382355 171.873703 8.899359 c
173.277252 7.471186 175.045044 6.757099 177.073013 6.757099 c
179.152557 6.757099 180.868774 7.471186 182.220291 8.899359 c
h
184.247803 39.222717 m
190.955170 39.222717 l
190.955170 0.768902 l
184.247803 0.768902 l
184.247803 4.010399 l
182.272339 1.318520 179.464294 -0.000008 175.825104 -0.000008 c
172.341553 -0.000008 169.326324 1.373341 166.830505 4.175331 c
164.386719 6.976852 163.138809 10.437643 163.138809 14.502407 c
163.138809 18.512350 164.386719 21.973600 166.830505 24.775124 c
169.326324 27.576649 172.341553 29.004822 175.825104 29.004822 c
179.464294 29.004822 182.272339 27.686295 184.247803 24.994881 c
184.247803 39.222717 l
184.247803 39.222717 l
h
214.509811 9.064060 m
215.861328 10.492699 216.537323 12.305557 216.537323 14.502640 c
216.537323 16.699722 215.861328 18.512581 214.509811 19.940754 c
213.157837 21.369392 211.494110 22.083014 209.466141 22.083014 c
207.438644 22.083014 205.774460 21.369392 204.422943 19.940754 c
203.122543 18.457758 202.447006 16.644899 202.447006 14.502640 c
202.447006 12.359917 203.122543 10.547056 204.422943 9.064060 c
205.774460 7.635887 207.438644 6.921799 209.466141 6.921799 c
211.494110 6.921799 213.157837 7.635887 214.509811 9.064060 c
214.509811 9.064060 l
h
199.691467 4.175098 m
197.039551 6.976620 195.740082 10.382589 195.740082 14.502640 c
195.740082 18.567869 197.039551 21.973368 199.691467 24.774891 c
202.343399 27.576416 205.618805 29.004589 209.466141 29.004589 c
213.313934 29.004589 216.589355 27.576416 219.241272 24.774891 c
221.893204 21.973368 223.244705 18.512583 223.244705 14.502640 c
223.244705 10.437410 221.893204 6.976620 219.241272 4.175098 c
216.589355 1.373108 213.365982 0.000225 209.466141 0.000225 c
205.566772 0.000225 202.343399 1.373108 199.691467 4.175098 c
h
252.258377 17.633701 m
252.258377 0.769272 l
245.550980 0.769272 l
245.550980 16.754683 l
245.550980 18.567543 245.083130 19.940893 244.147430 20.984379 c
243.263290 21.918221 242.015381 22.413017 240.403702 22.413017 c
236.607925 22.413017 234.684494 20.160648 234.684494 15.601088 c
234.684494 0.769272 l
227.977112 0.769272 l
227.977112 28.235821 l
234.684494 28.235821 l
234.684494 25.159718 l
236.296188 27.741486 238.843567 29.004728 242.431656 29.004728 c
245.291260 29.004728 247.630966 28.016064 249.450806 25.983450 c
251.322205 23.950836 252.258377 21.204134 252.258377 17.633701 c
f
n
Q
endstream
endobj
2 0 obj
8987
endobj
3 0 obj
<< /BBox [ 0.000000 0.000000 265.139893 65.366211 ]
/Resources << >>
/Subtype /Form
/Length 4 0 R
/Group << /Type /Group
/S /Transparency
>>
/Type /XObject
>>
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
0.000000 65.366211 m
265.139862 65.366211 l
265.139862 0.000000 l
0.000000 0.000000 l
0.000000 65.366211 l
h
f
n
Q
endstream
endobj
4 0 obj
234
endobj
5 0 obj
<< /XObject << /X1 1 0 R >>
/ExtGState << /E1 << /SMask << /Type /Mask
/G 3 0 R
/S /Alpha
>>
/Type /ExtGState
>> >>
>>
endobj
6 0 obj
<< /Length 7 0 R >>
stream
/DeviceRGB CS
/DeviceRGB cs
q
/E1 gs
/X1 Do
Q
endstream
endobj
7 0 obj
46
endobj
8 0 obj
<< /Annots []
/Type /Page
/MediaBox [ 0.000000 0.000000 265.139893 65.366211 ]
/Resources 5 0 R
/Contents 6 0 R
/Parent 9 0 R
>>
endobj
9 0 obj
<< /Kids [ 8 0 R ]
/Count 1
/Type /Pages
>>
endobj
10 0 obj
<< /Type /Catalog
/Pages 9 0 R
>>
endobj
xref
0 11
0000000000 65535 f
0000000010 00000 n
0000009246 00000 n
0000009269 00000 n
0000009752 00000 n
0000009774 00000 n
0000010072 00000 n
0000010174 00000 n
0000010195 00000 n
0000010369 00000 n
0000010443 00000 n
trailer
<< /ID [ (some) (id) ]
/Root 10 0 R
/Size 11
>>
startxref
10503
%%EOF

View File

@ -15,6 +15,9 @@
"Common.Controls.Actions.TakePhoto" = "Take photo";
"Common.Controls.Status.Userboosted" = "%@ boosted";
"Common.Controls.Timeline.LoadMore" = "Load More";
"Button.SignUp" = "Sign Up";
"Button.SignIn" = "Sign In";
"Common.Countable.Photo.Multiple" = "photos";
"Common.Countable.Photo.Single" = "photo";
"Scene.HomeTimeline.Title" = "Home";

View File

@ -0,0 +1,21 @@
//
// PickServerViewController.swift
// Mastodon
//
// Created by on 2021/2/20.
//
import UIKit
class PickServerViewController: UIViewController {
let titleLabel: UILabel = {
let label = UILabel()
label.font = .boldSystemFont(ofSize: 34)
label.textColor = Asset.Colors.Label.primary.color
label.text = L10n.Scene.ServerPicker.title
label.adjustsFontForContentSizeCategory = true
label.translatesAutoresizingMaskIntoConstraints = false
label.numberOfLines = 0
return label
}()
}

View File

@ -0,0 +1,30 @@
//
// PrimaryActionButton.swift
// Mastodon
//
// Created by on 2021/2/20.
//
import UIKit
class PrimaryActionButton: UIButton {
override init(frame: CGRect) {
super.init(frame: frame)
_init()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
_init()
}
}
extension PrimaryActionButton {
private func _init() {
titleLabel?.font = .preferredFont(forTextStyle: .headline)
setTitleColor(Asset.Colors.lightWhite.color, for: .normal)
backgroundColor = Asset.Colors.lightBrandBlue.color
applyCornerRadius(radius: 10)
setInsets(forContentPadding: UIEdgeInsets(top: 12, left: 0, bottom: 12, right: 0), imageTitlePadding: 0)
}
}

View File

@ -0,0 +1,89 @@
//
// WelcomeViewController.swift
// Mastodon
//
// Created by on 2021/2/20.
//
import UIKit
final class WelcomeViewController: UIViewController {
let logoImageView: UIImageView = {
let imageView = UIImageView(image: Asset.welcomeLogo.image)
imageView.translatesAutoresizingMaskIntoConstraints = false
return imageView
}()
let sloganLabel: UILabel = {
let label = UILabel()
label.font = UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: UIFont.boldSystemFont(ofSize: 34))
label.textColor = Asset.Colors.Label.primary.color
label.text = L10n.Scene.Welcome.slogan
label.adjustsFontForContentSizeCategory = true
label.translatesAutoresizingMaskIntoConstraints = false
label.numberOfLines = 0
return label
}()
let signUpButton: PrimaryActionButton = {
let button = PrimaryActionButton(type: .system)
button.setTitle(L10n.Button.signUp, for: .normal)
button.translatesAutoresizingMaskIntoConstraints = false
return button
}()
let signInButton: UIButton = {
let button = UIButton(type: .system)
button.setTitle(L10n.Button.signIn, for: .normal)
button.setTitleColor(Asset.Colors.lightBrandBlue.color, for: .normal)
button.titleLabel?.font = .preferredFont(forTextStyle: .subheadline)
button.setInsets(forContentPadding: UIEdgeInsets(top: 12, left: 0, bottom: 12, right: 0), imageTitlePadding: 0)
button.translatesAutoresizingMaskIntoConstraints = false
return button
}()
}
extension WelcomeViewController {
override var preferredStatusBarStyle: UIStatusBarStyle {
return .darkContent
}
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Asset.Colors.Background.onboardingBackground.color
view.addSubview(logoImageView)
NSLayoutConstraint.activate([
logoImageView.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor, constant: 35),
view.readableContentGuide.trailingAnchor.constraint(equalTo: logoImageView.trailingAnchor, constant: 35),
logoImageView.topAnchor.constraint(equalTo: view.readableContentGuide.topAnchor, constant: 46),
logoImageView.heightAnchor.constraint(equalTo: logoImageView.widthAnchor, multiplier: 65.4/265.1),
])
view.addSubview(sloganLabel)
NSLayoutConstraint.activate([
sloganLabel.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor, constant: 16),
view.readableContentGuide.trailingAnchor.constraint(equalTo: sloganLabel.trailingAnchor, constant: 16),
sloganLabel.topAnchor.constraint(equalTo: logoImageView.bottomAnchor, constant: 168),
])
view.addSubview(signInButton)
view.addSubview(signUpButton)
NSLayoutConstraint.activate([
signInButton.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor, constant: 12),
view.readableContentGuide.trailingAnchor.constraint(equalTo: signInButton.trailingAnchor, constant: 12),
view.readableContentGuide.bottomAnchor.constraint(equalTo: signInButton.bottomAnchor, constant: 11),
signUpButton.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor, constant: 12),
view.readableContentGuide.trailingAnchor.constraint(equalTo: signUpButton.trailingAnchor, constant: 12),
signInButton.topAnchor.constraint(equalTo: signUpButton.bottomAnchor, constant: 5)
])
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(true, animated: false)
}
}

View File

@ -26,25 +26,20 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
sceneCoordinator.setup()
do {
let request = MastodonAuthentication.sortedFetchRequest
if try appContext.managedObjectContext.fetch(request).isEmpty {
DispatchQueue.main.async {
let authenticationViewModel = AuthenticationViewModel(
context: appContext,
coordinator: sceneCoordinator,
isAuthenticationExist: false
)
sceneCoordinator.present(
scene: .authentication(viewModel: authenticationViewModel),
from: nil,
transition: .modal(animated: false, completion: nil)
)
}
}
} catch {
assertionFailure(error.localizedDescription)
}
// do {
// let request = MastodonAuthentication.sortedFetchRequest
// if try appContext.managedObjectContext.fetch(request).isEmpty {
// DispatchQueue.main.async {
// sceneCoordinator.present(
// scene: .welcome,
// from: nil,
// transition: .modal(animated: false, completion: nil)
// )
// }
// }
// } catch {
// assertionFailure(error.localizedDescription)
// }
window.makeKeyAndVisible()
}