From 8970231381dc267e35ac9d6de07a1672b4c74754 Mon Sep 17 00:00:00 2001 From: jk234ert Date: Sat, 20 Feb 2021 13:56:24 +0800 Subject: [PATCH 1/6] feat: add welcome view --- Mastodon.xcodeproj/project.pbxproj | 24 ++ Mastodon/Coordinator/SceneCoordinator.swift | 25 +- Mastodon/Generated/Assets.swift | 1 + Mastodon/Generated/Strings.swift | 4 + .../Assets.xcassets/Welcome/Contents.json | 6 + .../welcome.logo.imageset/Contents.json | 12 + .../Logotype (Full) 1.pdf | 335 ++++++++++++++++++ .../Resources/en.lproj/Localizable.strings | 1 + .../Scene/Welcome/WelcomeViewController.swift | 56 +++ Mastodon/Supporting Files/SceneDelegate.swift | 33 +- Mastodon/stylesheet/FontStyle.swift | 50 +++ 11 files changed, 526 insertions(+), 21 deletions(-) create mode 100644 Mastodon/Resources/Assets.xcassets/Welcome/Contents.json create mode 100644 Mastodon/Resources/Assets.xcassets/Welcome/welcome.logo.imageset/Contents.json create mode 100644 Mastodon/Resources/Assets.xcassets/Welcome/welcome.logo.imageset/Logotype (Full) 1.pdf create mode 100644 Mastodon/Scene/Welcome/WelcomeViewController.swift create mode 100644 Mastodon/stylesheet/FontStyle.swift diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index 4d26a731..fbcc6dee 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 0FAA0FDF25E0B57E0017CCDE /* WelcomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FAA0FDE25E0B57E0017CCDE /* WelcomeViewController.swift */; }; + 0FAA0FE625E0C7700017CCDE /* FontStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FAA0FE525E0C7700017CCDE /* FontStyle.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 /* TimelinePostView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D152A8B25C295CC009AA50C /* TimelinePostView.swift */; }; @@ -181,6 +183,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 0FAA0FDE25E0B57E0017CCDE /* WelcomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeViewController.swift; sourceTree = ""; }; + 0FAA0FE525E0C7700017CCDE /* FontStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontStyle.swift; sourceTree = ""; }; 2D04F42425C255B9003F936F /* APIService+PublicTimeline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "APIService+PublicTimeline.swift"; sourceTree = ""; }; 2D152A8B25C295CC009AA50C /* TimelinePostView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelinePostView.swift; sourceTree = ""; }; 2D152A9125C2980C009AA50C /* UIFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIFont.swift; sourceTree = ""; }; @@ -365,6 +369,22 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 0FAA0FDD25E0B5700017CCDE /* Welcome */ = { + isa = PBXGroup; + children = ( + 0FAA0FDE25E0B57E0017CCDE /* WelcomeViewController.swift */, + ); + path = Welcome; + sourceTree = ""; + }; + 0FAA0FE425E0C7610017CCDE /* stylesheet */ = { + isa = PBXGroup; + children = ( + 0FAA0FE525E0C7700017CCDE /* FontStyle.swift */, + ); + path = stylesheet; + sourceTree = ""; + }; 1EBA4F56E920856A3FC84ACB /* Pods */ = { isa = PBXGroup; children = ( @@ -637,6 +657,7 @@ DB427DD425BAA00100D1B89D /* Mastodon */ = { isa = PBXGroup; children = ( + 0FAA0FE425E0C7610017CCDE /* stylesheet */, DB427DE325BAA00100D1B89D /* Info.plist */, DB89BA1025C10FF5008580ED /* Mastodon.entitlements */, 2D5A3D0125CF8640002347D6 /* Vender */, @@ -800,6 +821,7 @@ DB8AF55525C1379F002E6C99 /* Scene */ = { isa = PBXGroup; children = ( + 0FAA0FDD25E0B5700017CCDE /* Welcome */, 2D38F1D325CD463600561493 /* HomeTimeline */, 2D7631A425C1532200929FB9 /* Share */, DB8AF54E25C13703002E6C99 /* MainTab */, @@ -1210,6 +1232,7 @@ 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 */, @@ -1282,6 +1305,7 @@ DB01409625C40B6700F9F3CF /* AuthenticationViewController.swift in Sources */, DB427DD825BAA00100D1B89D /* SceneDelegate.swift in Sources */, DB5086AB25CC0BBB00C2C187 /* AvatarConfigurableView.swift in Sources */, + 0FAA0FE625E0C7700017CCDE /* FontStyle.swift in Sources */, DB0140AE25C40C7300F9F3CF /* MastodonPinBasedAuthenticationViewModel.swift in Sources */, 2D32EAAC25CB96DC00C9ED86 /* TimelineMiddleLoaderTableViewCell.swift in Sources */, 2D5A3D6225CFD9CB002347D6 /* HomeTimelineViewController+DebugAction.swift in Sources */, diff --git a/Mastodon/Coordinator/SceneCoordinator.swift b/Mastodon/Coordinator/SceneCoordinator.swift index 6bdf135a..d59279dc 100644 --- a/Mastodon/Coordinator/SceneCoordinator.swift +++ b/Mastodon/Coordinator/SceneCoordinator.swift @@ -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) @@ -48,8 +50,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 @@ -113,6 +131,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 diff --git a/Mastodon/Generated/Assets.swift b/Mastodon/Generated/Assets.swift index ba540499..53dc6169 100644 --- a/Mastodon/Generated/Assets.swift +++ b/Mastodon/Generated/Assets.swift @@ -71,6 +71,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 diff --git a/Mastodon/Generated/Strings.swift b/Mastodon/Generated/Strings.swift index 3399d735..0c0c3741 100644 --- a/Mastodon/Generated/Strings.swift +++ b/Mastodon/Generated/Strings.swift @@ -18,6 +18,10 @@ internal enum L10n { internal static let loadMore = L10n.tr("Localizable", "Common.Controls.Timeline.LoadMore") } } + internal enum Label { + /// Social networking\nback in your hands. + internal static let slogon = L10n.tr("Localizable", "Common.Label.Slogon") + } } } // swiftlint:enable explicit_type_interface function_parameter_count identifier_name line_length diff --git a/Mastodon/Resources/Assets.xcassets/Welcome/Contents.json b/Mastodon/Resources/Assets.xcassets/Welcome/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/Mastodon/Resources/Assets.xcassets/Welcome/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Mastodon/Resources/Assets.xcassets/Welcome/welcome.logo.imageset/Contents.json b/Mastodon/Resources/Assets.xcassets/Welcome/welcome.logo.imageset/Contents.json new file mode 100644 index 00000000..bcfd775d --- /dev/null +++ b/Mastodon/Resources/Assets.xcassets/Welcome/welcome.logo.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "Logotype (Full) 1.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Mastodon/Resources/Assets.xcassets/Welcome/welcome.logo.imageset/Logotype (Full) 1.pdf b/Mastodon/Resources/Assets.xcassets/Welcome/welcome.logo.imageset/Logotype (Full) 1.pdf new file mode 100644 index 00000000..8aa4523a --- /dev/null +++ b/Mastodon/Resources/Assets.xcassets/Welcome/welcome.logo.imageset/Logotype (Full) 1.pdf @@ -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 \ No newline at end of file diff --git a/Mastodon/Resources/en.lproj/Localizable.strings b/Mastodon/Resources/en.lproj/Localizable.strings index caa87e95..53c50d24 100644 --- a/Mastodon/Resources/en.lproj/Localizable.strings +++ b/Mastodon/Resources/en.lproj/Localizable.strings @@ -6,3 +6,4 @@ */ "Common.Controls.Timeline.LoadMore" = "Load More"; +"Common.Label.Slogon" = "Social networking\nback in your hands."; diff --git a/Mastodon/Scene/Welcome/WelcomeViewController.swift b/Mastodon/Scene/Welcome/WelcomeViewController.swift new file mode 100644 index 00000000..a2568133 --- /dev/null +++ b/Mastodon/Scene/Welcome/WelcomeViewController.swift @@ -0,0 +1,56 @@ +// +// 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 = .preferredFont(forTextStyle: .largeTitle) + label.textColor = .black + label.text = L10n.Common.Label.slogon + label.adjustsFontForContentSizeCategory = true + label.translatesAutoresizingMaskIntoConstraints = false + label.numberOfLines = 0 + return label + }() +} + +extension WelcomeViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + view.backgroundColor = .white + + view.addSubview(logoImageView) + NSLayoutConstraint.activate([ + logoImageView.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor, constant: 35), + logoImageView.trailingAnchor.constraint(equalTo: view.readableContentGuide.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), + sloganLabel.trailingAnchor.constraint(equalTo: view.readableContentGuide.trailingAnchor, constant: -16), + sloganLabel.topAnchor.constraint(equalTo: logoImageView.bottomAnchor, constant: 168), + ]) + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + navigationController?.setNavigationBarHidden(true, animated: false) + } +} diff --git a/Mastodon/Supporting Files/SceneDelegate.swift b/Mastodon/Supporting Files/SceneDelegate.swift index 82bc645b..934c115c 100644 --- a/Mastodon/Supporting Files/SceneDelegate.swift +++ b/Mastodon/Supporting Files/SceneDelegate.swift @@ -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() } diff --git a/Mastodon/stylesheet/FontStyle.swift b/Mastodon/stylesheet/FontStyle.swift new file mode 100644 index 00000000..b351a78d --- /dev/null +++ b/Mastodon/stylesheet/FontStyle.swift @@ -0,0 +1,50 @@ +// +// FontStyle.swift +// Mastodon +// +// Created by 高原 on 2021/2/20. +// + +import UIKit + +fileprivate extension UIFont.TextStyle { + var masFont: UIFont { + switch self { + case .headline: + return UIFont(descriptor: UIFont.CustomFontDescriptor.SFProText, size: 34).bolded + default: + return UIFont(descriptor: UIFont.CustomFontDescriptor.SFProText, size: 16) + } + } +} + +extension UIFont { + + fileprivate struct CustomFontDescriptor { + static var fontFamily = "Avenir" + static var SFProText = UIFontDescriptor(name: "SFProText", size: 0) + } + + /// Returns a bold version of `self` + public var bolded: UIFont { + return fontDescriptor.withSymbolicTraits(.traitBold) + .map { UIFont(descriptor: $0, size: 0) } ?? self + } + + /// Returns an italic version of `self` + public var italicized: UIFont { + return fontDescriptor.withSymbolicTraits(.traitItalic) + .map { UIFont(descriptor: $0, size: 0) } ?? self + } + + /// Returns a scaled version of `self` + func scaled(scaleFactor: CGFloat) -> UIFont { + let newDescriptor = fontDescriptor.withSize(fontDescriptor.pointSize * scaleFactor) + return UIFont(descriptor: newDescriptor, size: 0) + } + + class func preferredFont(forTextStyle textStyle: UIFont.TextStyle) -> UIFont { + let masFontMetrics = UIFontMetrics(forTextStyle: textStyle) + return masFontMetrics.scaledFont(for: textStyle.masFont) + } +} From 9fefdccef249bf1b30be70b40796dd22c4e642df Mon Sep 17 00:00:00 2001 From: jk234ert Date: Sat, 20 Feb 2021 20:23:29 +0800 Subject: [PATCH 2/6] feat: add welcome view; feat: modify window.rootViewController logic when app launches; feat: enable ViewController-based status bar --- Mastodon.xcodeproj/project.pbxproj | 22 +++++--- Mastodon/Extension/UIFont.swift | 23 +++++++++ Mastodon/Extension/UIView.swift | 12 +++++ Mastodon/Generated/Strings.swift | 7 +++ Mastodon/Info.plist | 6 ++- .../Resources/en.lproj/Localizable.strings | 4 ++ .../PickServer/PickServerViewController.swift | 21 ++++++++ .../Share/View/Button/MasActionButton.swift | 30 +++++++++++ .../Scene/Welcome/WelcomeViewController.swift | 39 +++++++++++++-- Mastodon/stylesheet/FontStyle.swift | 50 ------------------- 10 files changed, 152 insertions(+), 62 deletions(-) create mode 100644 Mastodon/Extension/UIFont.swift create mode 100644 Mastodon/Scene/PickServer/PickServerViewController.swift create mode 100644 Mastodon/Scene/Share/View/Button/MasActionButton.swift delete mode 100644 Mastodon/stylesheet/FontStyle.swift diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index fbcc6dee..2874a263 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -8,7 +8,9 @@ /* Begin PBXBuildFile section */ 0FAA0FDF25E0B57E0017CCDE /* WelcomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FAA0FDE25E0B57E0017CCDE /* WelcomeViewController.swift */; }; - 0FAA0FE625E0C7700017CCDE /* FontStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FAA0FE525E0C7700017CCDE /* FontStyle.swift */; }; + 0FAA101225E105390017CCDE /* MasActionButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FAA101125E105390017CCDE /* MasActionButton.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 /* TimelinePostView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D152A8B25C295CC009AA50C /* TimelinePostView.swift */; }; @@ -184,7 +186,9 @@ /* Begin PBXFileReference section */ 0FAA0FDE25E0B57E0017CCDE /* WelcomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeViewController.swift; sourceTree = ""; }; - 0FAA0FE525E0C7700017CCDE /* FontStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontStyle.swift; sourceTree = ""; }; + 0FAA101125E105390017CCDE /* MasActionButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasActionButton.swift; sourceTree = ""; }; + 0FAA101B25E10E760017CCDE /* UIFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIFont.swift; sourceTree = ""; }; + 0FAA102625E1126A0017CCDE /* PickServerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickServerViewController.swift; sourceTree = ""; }; 2D04F42425C255B9003F936F /* APIService+PublicTimeline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "APIService+PublicTimeline.swift"; sourceTree = ""; }; 2D152A8B25C295CC009AA50C /* TimelinePostView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelinePostView.swift; sourceTree = ""; }; 2D152A9125C2980C009AA50C /* UIFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIFont.swift; sourceTree = ""; }; @@ -377,12 +381,12 @@ path = Welcome; sourceTree = ""; }; - 0FAA0FE425E0C7610017CCDE /* stylesheet */ = { + 0FAA102525E1125D0017CCDE /* PickServer */ = { isa = PBXGroup; children = ( - 0FAA0FE525E0C7700017CCDE /* FontStyle.swift */, + 0FAA102625E1126A0017CCDE /* PickServerViewController.swift */, ); - path = stylesheet; + path = PickServer; sourceTree = ""; }; 1EBA4F56E920856A3FC84ACB /* Pods */ = { @@ -445,6 +449,7 @@ DB5086A425CC0B7000C2C187 /* AvatarBarButtonItem.swift */, 2D42FF8425C8224F004A627A /* HitTestExpandedButton.swift */, 2D5A3D1025CF87AA002347D6 /* AvatarBarButtonItem.swift */, + 0FAA101125E105390017CCDE /* MasActionButton.swift */, ); path = Button; sourceTree = ""; @@ -657,7 +662,6 @@ DB427DD425BAA00100D1B89D /* Mastodon */ = { isa = PBXGroup; children = ( - 0FAA0FE425E0C7610017CCDE /* stylesheet */, DB427DE325BAA00100D1B89D /* Info.plist */, DB89BA1025C10FF5008580ED /* Mastodon.entitlements */, 2D5A3D0125CF8640002347D6 /* Vender */, @@ -821,6 +825,7 @@ DB8AF55525C1379F002E6C99 /* Scene */ = { isa = PBXGroup; children = ( + 0FAA102525E1125D0017CCDE /* PickServer */, 0FAA0FDD25E0B5700017CCDE /* Welcome */, 2D38F1D325CD463600561493 /* HomeTimeline */, 2D7631A425C1532200929FB9 /* Share */, @@ -846,6 +851,7 @@ 2D42FF8E25C8228A004A627A /* UIButton.swift */, DB45FAD625CA6C76005A8AC7 /* UIBarButtonItem.swift */, 2D32EAB925CB9B0500C9ED86 /* UIView.swift */, + 0FAA101B25E10E760017CCDE /* UIFont.swift */, ); path = Extension; sourceTree = ""; @@ -1238,16 +1244,19 @@ 2D61335E25C1894B00CAE157 /* APIService.swift in Sources */, 2D38F1F725CD47AC00561493 /* HomeTimelineViewModel+LoadOldestState.swift in Sources */, 2D5A3D3825CF8D9F002347D6 /* ScrollViewContainer.swift in Sources */, + 0FAA101225E105390017CCDE /* MasActionButton.swift in Sources */, DB8AF53025C13561002E6C99 /* AppContext.swift in Sources */, 2D38F1F125CD477D00561493 /* HomeTimelineViewModel+LoadMiddleState.swift in Sources */, DB45FAD725CA6C76005A8AC7 /* UIBarButtonItem.swift in Sources */, 2D152A8C25C295CC009AA50C /* TimelinePostView.swift in Sources */, 2D42FF8525C8224F004A627A /* HitTestExpandedButton.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 */, @@ -1305,7 +1314,6 @@ DB01409625C40B6700F9F3CF /* AuthenticationViewController.swift in Sources */, DB427DD825BAA00100D1B89D /* SceneDelegate.swift in Sources */, DB5086AB25CC0BBB00C2C187 /* AvatarConfigurableView.swift in Sources */, - 0FAA0FE625E0C7700017CCDE /* FontStyle.swift in Sources */, DB0140AE25C40C7300F9F3CF /* MastodonPinBasedAuthenticationViewModel.swift in Sources */, 2D32EAAC25CB96DC00C9ED86 /* TimelineMiddleLoaderTableViewCell.swift in Sources */, 2D5A3D6225CFD9CB002347D6 /* HomeTimelineViewController+DebugAction.swift in Sources */, diff --git a/Mastodon/Extension/UIFont.swift b/Mastodon/Extension/UIFont.swift new file mode 100644 index 00000000..63f70866 --- /dev/null +++ b/Mastodon/Extension/UIFont.swift @@ -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) + } +} diff --git a/Mastodon/Extension/UIView.swift b/Mastodon/Extension/UIView.swift index ee09a278..41d4edc5 100644 --- a/Mastodon/Extension/UIView.swift +++ b/Mastodon/Extension/UIView.swift @@ -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 + } +} diff --git a/Mastodon/Generated/Strings.swift b/Mastodon/Generated/Strings.swift index 0c0c3741..557e4c77 100644 --- a/Mastodon/Generated/Strings.swift +++ b/Mastodon/Generated/Strings.swift @@ -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 Timeline { diff --git a/Mastodon/Info.plist b/Mastodon/Info.plist index 47f90b99..3455e683 100644 --- a/Mastodon/Info.plist +++ b/Mastodon/Info.plist @@ -2,8 +2,6 @@ - UIUserInterfaceStyle - Dark CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable @@ -64,5 +62,9 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UIUserInterfaceStyle + Dark + UIViewControllerBasedStatusBarAppearance + diff --git a/Mastodon/Resources/en.lproj/Localizable.strings b/Mastodon/Resources/en.lproj/Localizable.strings index 53c50d24..f12ca95d 100644 --- a/Mastodon/Resources/en.lproj/Localizable.strings +++ b/Mastodon/Resources/en.lproj/Localizable.strings @@ -7,3 +7,7 @@ */ "Common.Controls.Timeline.LoadMore" = "Load More"; "Common.Label.Slogon" = "Social networking\nback in your hands."; +"Common.Label.PickAServer" = "Pick a server,\nany server."; + +"Button.SignUp" = "Sign Up"; +"Button.SignIn" = "Sign In"; diff --git a/Mastodon/Scene/PickServer/PickServerViewController.swift b/Mastodon/Scene/PickServer/PickServerViewController.swift new file mode 100644 index 00000000..8bff4edb --- /dev/null +++ b/Mastodon/Scene/PickServer/PickServerViewController.swift @@ -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.black.color + label.text = L10n.Common.Label.slogon + label.adjustsFontForContentSizeCategory = true + label.translatesAutoresizingMaskIntoConstraints = false + label.numberOfLines = 0 + return label + }() +} diff --git a/Mastodon/Scene/Share/View/Button/MasActionButton.swift b/Mastodon/Scene/Share/View/Button/MasActionButton.swift new file mode 100644 index 00000000..3808a9dc --- /dev/null +++ b/Mastodon/Scene/Share/View/Button/MasActionButton.swift @@ -0,0 +1,30 @@ +// +// MasActionButton.swift +// Mastodon +// +// Created by 高原 on 2021/2/20. +// + +import UIKit + +class MasActionButton: UIButton { + override init(frame: CGRect) { + super.init(frame: frame) + _init() + } + + required init?(coder: NSCoder) { + super.init(coder: coder) + _init() + } +} + +extension MasActionButton { + 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) + } +} diff --git a/Mastodon/Scene/Welcome/WelcomeViewController.swift b/Mastodon/Scene/Welcome/WelcomeViewController.swift index a2568133..4aa3f030 100644 --- a/Mastodon/Scene/Welcome/WelcomeViewController.swift +++ b/Mastodon/Scene/Welcome/WelcomeViewController.swift @@ -16,22 +16,43 @@ final class WelcomeViewController: UIViewController { let sloganLabel: UILabel = { let label = UILabel() - label.font = .preferredFont(forTextStyle: .largeTitle) - label.textColor = .black + label.font = .boldSystemFont(ofSize: 34) + label.textColor = Asset.Colors.Label.black.color label.text = L10n.Common.Label.slogon label.adjustsFontForContentSizeCategory = true label.translatesAutoresizingMaskIntoConstraints = false label.numberOfLines = 0 return label }() + + let signUpButton: MasActionButton = { + let button = MasActionButton(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 = .white + view.backgroundColor = Asset.Colors.Background.signUpSystemBackground.color view.addSubview(logoImageView) NSLayoutConstraint.activate([ @@ -47,6 +68,18 @@ extension WelcomeViewController { sloganLabel.trailingAnchor.constraint(equalTo: view.readableContentGuide.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), + signInButton.trailingAnchor.constraint(equalTo: view.readableContentGuide.trailingAnchor, constant: -12), + signInButton.bottomAnchor.constraint(equalTo: view.readableContentGuide.bottomAnchor, constant: -11), + + signUpButton.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor, constant: 12), + signUpButton.trailingAnchor.constraint(equalTo: view.readableContentGuide.trailingAnchor, constant: -12), + signUpButton.bottomAnchor.constraint(equalTo: signInButton.topAnchor, constant: -5) + ]) } override func viewWillAppear(_ animated: Bool) { diff --git a/Mastodon/stylesheet/FontStyle.swift b/Mastodon/stylesheet/FontStyle.swift deleted file mode 100644 index b351a78d..00000000 --- a/Mastodon/stylesheet/FontStyle.swift +++ /dev/null @@ -1,50 +0,0 @@ -// -// FontStyle.swift -// Mastodon -// -// Created by 高原 on 2021/2/20. -// - -import UIKit - -fileprivate extension UIFont.TextStyle { - var masFont: UIFont { - switch self { - case .headline: - return UIFont(descriptor: UIFont.CustomFontDescriptor.SFProText, size: 34).bolded - default: - return UIFont(descriptor: UIFont.CustomFontDescriptor.SFProText, size: 16) - } - } -} - -extension UIFont { - - fileprivate struct CustomFontDescriptor { - static var fontFamily = "Avenir" - static var SFProText = UIFontDescriptor(name: "SFProText", size: 0) - } - - /// Returns a bold version of `self` - public var bolded: UIFont { - return fontDescriptor.withSymbolicTraits(.traitBold) - .map { UIFont(descriptor: $0, size: 0) } ?? self - } - - /// Returns an italic version of `self` - public var italicized: UIFont { - return fontDescriptor.withSymbolicTraits(.traitItalic) - .map { UIFont(descriptor: $0, size: 0) } ?? self - } - - /// Returns a scaled version of `self` - func scaled(scaleFactor: CGFloat) -> UIFont { - let newDescriptor = fontDescriptor.withSize(fontDescriptor.pointSize * scaleFactor) - return UIFont(descriptor: newDescriptor, size: 0) - } - - class func preferredFont(forTextStyle textStyle: UIFont.TextStyle) -> UIFont { - let masFontMetrics = UIFontMetrics(forTextStyle: textStyle) - return masFontMetrics.scaledFont(for: textStyle.masFont) - } -} From 9d0c0fae9049c0376f1329e70cf5d5337e1d1df5 Mon Sep 17 00:00:00 2001 From: jk234ert Date: Sat, 20 Feb 2021 21:00:11 +0800 Subject: [PATCH 3/6] chore: apply large title style to slogan title --- Mastodon/Scene/Welcome/WelcomeViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mastodon/Scene/Welcome/WelcomeViewController.swift b/Mastodon/Scene/Welcome/WelcomeViewController.swift index 4aa3f030..fa27d5a0 100644 --- a/Mastodon/Scene/Welcome/WelcomeViewController.swift +++ b/Mastodon/Scene/Welcome/WelcomeViewController.swift @@ -16,7 +16,7 @@ final class WelcomeViewController: UIViewController { let sloganLabel: UILabel = { let label = UILabel() - label.font = .boldSystemFont(ofSize: 34) + label.font = UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: UIFont.boldSystemFont(ofSize: 34)) label.textColor = Asset.Colors.Label.black.color label.text = L10n.Common.Label.slogon label.adjustsFontForContentSizeCategory = true From 85ceb480034579eb190587a815a0289ec2333c91 Mon Sep 17 00:00:00 2001 From: jk234ert Date: Mon, 22 Feb 2021 23:16:13 +0800 Subject: [PATCH 4/6] chore: resolve requested changes --- Mastodon.xcodeproj/project.pbxproj | 8 ++++---- Mastodon/Extension/UIView.swift | 4 ++-- Mastodon/Generated/Strings.swift | 4 +++- Mastodon/Resources/en.lproj/Localizable.strings | 2 +- Mastodon/Scene/PickServer/PickServerViewController.swift | 2 +- .../{MasActionButton.swift => PrimaryActionButton.swift} | 6 +++--- Mastodon/Scene/Welcome/WelcomeViewController.swift | 6 +++--- 7 files changed, 17 insertions(+), 15 deletions(-) rename Mastodon/Scene/Share/View/Button/{MasActionButton.swift => PrimaryActionButton.swift} (86%) diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index 2874a263..35f11ada 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -8,7 +8,7 @@ /* Begin PBXBuildFile section */ 0FAA0FDF25E0B57E0017CCDE /* WelcomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FAA0FDE25E0B57E0017CCDE /* WelcomeViewController.swift */; }; - 0FAA101225E105390017CCDE /* MasActionButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FAA101125E105390017CCDE /* MasActionButton.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 */; }; @@ -186,7 +186,7 @@ /* Begin PBXFileReference section */ 0FAA0FDE25E0B57E0017CCDE /* WelcomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeViewController.swift; sourceTree = ""; }; - 0FAA101125E105390017CCDE /* MasActionButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasActionButton.swift; sourceTree = ""; }; + 0FAA101125E105390017CCDE /* PrimaryActionButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimaryActionButton.swift; sourceTree = ""; }; 0FAA101B25E10E760017CCDE /* UIFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIFont.swift; sourceTree = ""; }; 0FAA102625E1126A0017CCDE /* PickServerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickServerViewController.swift; sourceTree = ""; }; 2D04F42425C255B9003F936F /* APIService+PublicTimeline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "APIService+PublicTimeline.swift"; sourceTree = ""; }; @@ -449,7 +449,7 @@ DB5086A425CC0B7000C2C187 /* AvatarBarButtonItem.swift */, 2D42FF8425C8224F004A627A /* HitTestExpandedButton.swift */, 2D5A3D1025CF87AA002347D6 /* AvatarBarButtonItem.swift */, - 0FAA101125E105390017CCDE /* MasActionButton.swift */, + 0FAA101125E105390017CCDE /* PrimaryActionButton.swift */, ); path = Button; sourceTree = ""; @@ -1244,7 +1244,7 @@ 2D61335E25C1894B00CAE157 /* APIService.swift in Sources */, 2D38F1F725CD47AC00561493 /* HomeTimelineViewModel+LoadOldestState.swift in Sources */, 2D5A3D3825CF8D9F002347D6 /* ScrollViewContainer.swift in Sources */, - 0FAA101225E105390017CCDE /* MasActionButton.swift in Sources */, + 0FAA101225E105390017CCDE /* PrimaryActionButton.swift in Sources */, DB8AF53025C13561002E6C99 /* AppContext.swift in Sources */, 2D38F1F125CD477D00561493 /* HomeTimelineViewModel+LoadMiddleState.swift in Sources */, DB45FAD725CA6C76005A8AC7 /* UIBarButtonItem.swift in Sources */, diff --git a/Mastodon/Extension/UIView.swift b/Mastodon/Extension/UIView.swift index 41d4edc5..7e1ba379 100644 --- a/Mastodon/Extension/UIView.swift +++ b/Mastodon/Extension/UIView.swift @@ -7,7 +7,7 @@ import UIKit -// MARK: -Convinience view creation method +// MARK: - Convinience view creation method extension UIView { static var separatorLine: UIView { @@ -26,7 +26,7 @@ extension UIView { } -// MARK: -Convinience view appearance modification method +// MARK: - Convinience view appearance modification method extension UIView { @discardableResult func applyCornerRadius(radius: CGFloat) -> Self { diff --git a/Mastodon/Generated/Strings.swift b/Mastodon/Generated/Strings.swift index 557e4c77..57eb6b5d 100644 --- a/Mastodon/Generated/Strings.swift +++ b/Mastodon/Generated/Strings.swift @@ -26,8 +26,10 @@ internal enum L10n { } } internal enum Label { + /// Pick a server,\nany server. + internal static let pickAServer = L10n.tr("Localizable", "Common.Label.PickAServer") /// Social networking\nback in your hands. - internal static let slogon = L10n.tr("Localizable", "Common.Label.Slogon") + internal static let slogan = L10n.tr("Localizable", "Common.Label.Slogan") } } } diff --git a/Mastodon/Resources/en.lproj/Localizable.strings b/Mastodon/Resources/en.lproj/Localizable.strings index f12ca95d..75f94b5a 100644 --- a/Mastodon/Resources/en.lproj/Localizable.strings +++ b/Mastodon/Resources/en.lproj/Localizable.strings @@ -6,7 +6,7 @@ */ "Common.Controls.Timeline.LoadMore" = "Load More"; -"Common.Label.Slogon" = "Social networking\nback in your hands."; +"Common.Label.Slogan" = "Social networking\nback in your hands."; "Common.Label.PickAServer" = "Pick a server,\nany server."; "Button.SignUp" = "Sign Up"; diff --git a/Mastodon/Scene/PickServer/PickServerViewController.swift b/Mastodon/Scene/PickServer/PickServerViewController.swift index 8bff4edb..10027fdc 100644 --- a/Mastodon/Scene/PickServer/PickServerViewController.swift +++ b/Mastodon/Scene/PickServer/PickServerViewController.swift @@ -12,7 +12,7 @@ class PickServerViewController: UIViewController { let label = UILabel() label.font = .boldSystemFont(ofSize: 34) label.textColor = Asset.Colors.Label.black.color - label.text = L10n.Common.Label.slogon + label.text = L10n.Common.Label.slogan label.adjustsFontForContentSizeCategory = true label.translatesAutoresizingMaskIntoConstraints = false label.numberOfLines = 0 diff --git a/Mastodon/Scene/Share/View/Button/MasActionButton.swift b/Mastodon/Scene/Share/View/Button/PrimaryActionButton.swift similarity index 86% rename from Mastodon/Scene/Share/View/Button/MasActionButton.swift rename to Mastodon/Scene/Share/View/Button/PrimaryActionButton.swift index 3808a9dc..5a68a800 100644 --- a/Mastodon/Scene/Share/View/Button/MasActionButton.swift +++ b/Mastodon/Scene/Share/View/Button/PrimaryActionButton.swift @@ -1,5 +1,5 @@ // -// MasActionButton.swift +// PrimaryActionButton.swift // Mastodon // // Created by 高原 on 2021/2/20. @@ -7,7 +7,7 @@ import UIKit -class MasActionButton: UIButton { +class PrimaryActionButton: UIButton { override init(frame: CGRect) { super.init(frame: frame) _init() @@ -19,7 +19,7 @@ class MasActionButton: UIButton { } } -extension MasActionButton { +extension PrimaryActionButton { private func _init() { titleLabel?.font = .preferredFont(forTextStyle: .headline) setTitleColor(Asset.Colors.lightWhite.color, for: .normal) diff --git a/Mastodon/Scene/Welcome/WelcomeViewController.swift b/Mastodon/Scene/Welcome/WelcomeViewController.swift index fa27d5a0..898dc1ce 100644 --- a/Mastodon/Scene/Welcome/WelcomeViewController.swift +++ b/Mastodon/Scene/Welcome/WelcomeViewController.swift @@ -18,15 +18,15 @@ final class WelcomeViewController: UIViewController { let label = UILabel() label.font = UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: UIFont.boldSystemFont(ofSize: 34)) label.textColor = Asset.Colors.Label.black.color - label.text = L10n.Common.Label.slogon + label.text = L10n.Common.Label.slogan label.adjustsFontForContentSizeCategory = true label.translatesAutoresizingMaskIntoConstraints = false label.numberOfLines = 0 return label }() - let signUpButton: MasActionButton = { - let button = MasActionButton(type: .system) + let signUpButton: PrimaryActionButton = { + let button = PrimaryActionButton(type: .system) button.setTitle(L10n.Button.signUp, for: .normal) button.translatesAutoresizingMaskIntoConstraints = false return button From 4fafb3835d5a85bc50f7a9be867d929c249464b5 Mon Sep 17 00:00:00 2001 From: jk234ert Date: Tue, 23 Feb 2021 11:19:10 +0800 Subject: [PATCH 5/6] chore: update constraints --- Mastodon/Scene/Welcome/WelcomeViewController.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Mastodon/Scene/Welcome/WelcomeViewController.swift b/Mastodon/Scene/Welcome/WelcomeViewController.swift index 898dc1ce..0787f2ab 100644 --- a/Mastodon/Scene/Welcome/WelcomeViewController.swift +++ b/Mastodon/Scene/Welcome/WelcomeViewController.swift @@ -57,7 +57,7 @@ extension WelcomeViewController { view.addSubview(logoImageView) NSLayoutConstraint.activate([ logoImageView.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor, constant: 35), - logoImageView.trailingAnchor.constraint(equalTo: view.readableContentGuide.trailingAnchor, 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), ]) @@ -65,7 +65,7 @@ extension WelcomeViewController { view.addSubview(sloganLabel) NSLayoutConstraint.activate([ sloganLabel.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor, constant: 16), - sloganLabel.trailingAnchor.constraint(equalTo: view.readableContentGuide.trailingAnchor, constant: -16), + view.readableContentGuide.trailingAnchor.constraint(equalTo: sloganLabel.trailingAnchor, constant: 16), sloganLabel.topAnchor.constraint(equalTo: logoImageView.bottomAnchor, constant: 168), ]) @@ -73,12 +73,12 @@ extension WelcomeViewController { view.addSubview(signUpButton) NSLayoutConstraint.activate([ signInButton.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor, constant: 12), - signInButton.trailingAnchor.constraint(equalTo: view.readableContentGuide.trailingAnchor, constant: -12), - signInButton.bottomAnchor.constraint(equalTo: view.readableContentGuide.bottomAnchor, constant: -11), + 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), - signUpButton.trailingAnchor.constraint(equalTo: view.readableContentGuide.trailingAnchor, constant: -12), - signUpButton.bottomAnchor.constraint(equalTo: signInButton.topAnchor, constant: -5) + view.readableContentGuide.trailingAnchor.constraint(equalTo: signUpButton.trailingAnchor, constant: 12), + signInButton.topAnchor.constraint(equalTo: signUpButton.bottomAnchor, constant: 5) ]) } From 2fa11b659515e60988508b0e8edf5c7bdb92e8e5 Mon Sep 17 00:00:00 2001 From: jk234ert Date: Tue, 23 Feb 2021 12:41:56 +0800 Subject: [PATCH 6/6] chore: resolve conflicts --- Mastodon/Resources/en.lproj/Localizable.strings | 3 --- Mastodon/Scene/PickServer/PickServerViewController.swift | 2 +- Mastodon/Scene/Welcome/WelcomeViewController.swift | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Mastodon/Resources/en.lproj/Localizable.strings b/Mastodon/Resources/en.lproj/Localizable.strings index 3eec2fce..9ef82436 100644 --- a/Mastodon/Resources/en.lproj/Localizable.strings +++ b/Mastodon/Resources/en.lproj/Localizable.strings @@ -15,9 +15,6 @@ "Common.Controls.Actions.TakePhoto" = "Take photo"; "Common.Controls.Timeline.LoadMore" = "Load More"; -"Common.Label.Slogan" = "Social networking\nback in your hands."; -"Common.Label.PickAServer" = "Pick a server,\nany server."; - "Button.SignUp" = "Sign Up"; "Button.SignIn" = "Sign In"; "Common.Countable.Photo.Multiple" = "photos"; diff --git a/Mastodon/Scene/PickServer/PickServerViewController.swift b/Mastodon/Scene/PickServer/PickServerViewController.swift index 10027fdc..97cfd395 100644 --- a/Mastodon/Scene/PickServer/PickServerViewController.swift +++ b/Mastodon/Scene/PickServer/PickServerViewController.swift @@ -12,7 +12,7 @@ class PickServerViewController: UIViewController { let label = UILabel() label.font = .boldSystemFont(ofSize: 34) label.textColor = Asset.Colors.Label.black.color - label.text = L10n.Common.Label.slogan + label.text = L10n.Scene.ServerPicker.title label.adjustsFontForContentSizeCategory = true label.translatesAutoresizingMaskIntoConstraints = false label.numberOfLines = 0 diff --git a/Mastodon/Scene/Welcome/WelcomeViewController.swift b/Mastodon/Scene/Welcome/WelcomeViewController.swift index 0787f2ab..f8a7136b 100644 --- a/Mastodon/Scene/Welcome/WelcomeViewController.swift +++ b/Mastodon/Scene/Welcome/WelcomeViewController.swift @@ -18,7 +18,7 @@ final class WelcomeViewController: UIViewController { let label = UILabel() label.font = UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: UIFont.boldSystemFont(ofSize: 34)) label.textColor = Asset.Colors.Label.black.color - label.text = L10n.Common.Label.slogan + label.text = L10n.Scene.Welcome.slogan label.adjustsFontForContentSizeCategory = true label.translatesAutoresizingMaskIntoConstraints = false label.numberOfLines = 0 @@ -52,7 +52,7 @@ extension WelcomeViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = Asset.Colors.Background.signUpSystemBackground.color + view.backgroundColor = Asset.Colors.Background.onboardingBackground.color view.addSubview(logoImageView) NSLayoutConstraint.activate([