Skip to content

Commit

Permalink
- AppRootViewController + InitialSetupViewController: move initial se…
Browse files Browse the repository at this point in the history
…tup view into own view controller

- InitialSetupViewController: implement status bar style support for consistent status bar colors also pre-iOS 17
  • Loading branch information
felix-schwarz committed Aug 28, 2023
1 parent 069feb8 commit d511896
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 37 deletions.
4 changes: 4 additions & 0 deletions ownCloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@
DCD864122811FC5700CA6631 /* GradientView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCD864112811FC5700CA6631 /* GradientView.swift */; };
DCD954DF247D62FA00E184E6 /* MessageTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCD954DE247D62FA00E184E6 /* MessageTableViewController.swift */; };
DCD9B87B2379612B00691929 /* OCLicenseManager+Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = DCD9B873237960E600691929 /* OCLicenseManager+Internal.h */; };
DCDA83852A9CE6C300BFF393 /* InitialSetupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCDA83842A9CE6C300BFF393 /* InitialSetupViewController.swift */; };
DCDBB60A2525305600FAD707 /* NotificationAuthErrorForwarder.h in Headers */ = {isa = PBXBuildFile; fileRef = DCDBB60225252FDA00FAD707 /* NotificationAuthErrorForwarder.h */; settings = {ATTRIBUTES = (Public, ); }; };
DCDBB60B2525306000FAD707 /* NotificationAuthErrorForwarder.m in Sources */ = {isa = PBXBuildFile; fileRef = DCDBB60325252FDA00FAD707 /* NotificationAuthErrorForwarder.m */; };
DCDC0ACF23CD186400DFE36D /* ownCloudApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCC0855C2293F1FD008CC05C /* ownCloudApp.framework */; };
Expand Down Expand Up @@ -1525,6 +1526,7 @@
DCD864112811FC5700CA6631 /* GradientView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GradientView.swift; sourceTree = "<group>"; };
DCD954DE247D62FA00E184E6 /* MessageTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageTableViewController.swift; sourceTree = "<group>"; };
DCD9B873237960E600691929 /* OCLicenseManager+Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OCLicenseManager+Internal.h"; sourceTree = "<group>"; };
DCDA83842A9CE6C300BFF393 /* InitialSetupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitialSetupViewController.swift; sourceTree = "<group>"; };
DCDBB60225252FDA00FAD707 /* NotificationAuthErrorForwarder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationAuthErrorForwarder.h; sourceTree = "<group>"; };
DCDBB60325252FDA00FAD707 /* NotificationAuthErrorForwarder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationAuthErrorForwarder.m; sourceTree = "<group>"; };
DCDC0AD023CD18D200DFE36D /* OCLicenseManager+Setup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OCLicenseManager+Setup.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2946,6 +2948,7 @@
DCB6B1EA292B7C2400D27573 /* AppRootViewController+ItemActions.swift */,
DCB6B1F4292CC46B00D27573 /* AccountController+ItemActions.swift */,
DCB6B20B292E428000D27573 /* AccountController+ExtraItems.swift */,
DCDA83842A9CE6C300BFF393 /* InitialSetupViewController.swift */,
);
path = "App Controllers";
sourceTree = "<group>";
Expand Down Expand Up @@ -4419,6 +4422,7 @@
DCD1301123A23F4E00255779 /* OCLicenseManager+AppStore.swift in Sources */,
DC62514C225D254500736874 /* UploadBaseAction.swift in Sources */,
4C6B78102226B83300C5F3DB /* PhotoAlbumTableViewController.swift in Sources */,
DCDA83852A9CE6C300BFF393 /* InitialSetupViewController.swift in Sources */,
23EC77592137F3DD0032D4E6 /* DisplayExtension.swift in Sources */,
DCDF58B323CE82E100080BEB /* LicenseInAppPurchaseFeatureView.swift in Sources */,
DC33939622E0747400DD3DA4 /* MakeAvailableOfflineAction.swift in Sources */,
Expand Down
38 changes: 1 addition & 37 deletions ownCloud/App Controllers/AppRootViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,43 +121,7 @@ open class AppRootViewController: EmbeddingViewController, BrowserNavigationView
noBookmarkCondition = DataSourceCondition(.empty, with: OCBookmarkManager.shared.bookmarksDatasource, initial: true, action: { [weak self] condition in
if condition.fulfilled == true {
// No account available

var addAccountTitle = "Add account".localized
if !VendorServices.shared.canAddAccount {
addAccountTitle = "Login".localized
}

let messageView = ComposedMessageView.infoBox(additionalElements: [
.image(AccountSettingsProvider.shared.logo, size: CGSize(width: 128, height: 128), cssSelectors: [.icon]),
.title(String(format: "Welcome to %@".localized, VendorServices.shared.appName), alignment: .centered, cssSelectors: [.title], insets: NSDirectionalEdgeInsets(top: 25, leading: 0, bottom: 25, trailing: 0)),
.button(addAccountTitle, action: UIAction(handler: { [weak self] action in
if let self = self {
BookmarkViewController.showBookmarkUI(on: self, attemptLoginOnSuccess: true)
}
}), image: UIImage(systemName: "plus.circle"), cssSelectors: [.welcome]),
.button("Settings".localized ,action: UIAction(handler: { [weak self] action in
if let self = self {
self.present(ThemeNavigationController(rootViewController: SettingsViewController()), animated: true)
}
}), image: UIImage(systemName: "gearshape"), cssSelectors: [.welcome])
])
messageView.elementInsets = NSDirectionalEdgeInsets(top: 25, leading: 50, bottom: 50, trailing: 50)

let rootView = ThemeCSSView(withSelectors: [.modal, .welcome])

if let image = Branding.shared.brandedImageNamed(.loginBackground) {
messageView.isOpaque = false
let backgroundImageView = UIImageView(image: image)
backgroundImageView.contentMode = .scaleAspectFill
rootView.embed(toFillWith: backgroundImageView)
}

rootView.embed(centered: messageView, minimumInsets: NSDirectionalEdgeInsets(top: 20, leading: 20, bottom: 20, trailing: 20))

let messageViewController = UIViewController()
messageViewController.view = rootView

self?.contentViewController = messageViewController
self?.contentViewController = InitialSetupViewController()
} else {
// Account already available
self?.contentViewController = self?.contentBrowserController
Expand Down
65 changes: 65 additions & 0 deletions ownCloud/App Controllers/InitialSetupViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// InitialSetupViewController.swift
// ownCloud
//
// Created by Felix Schwarz on 28.08.23.
// Copyright © 2023 ownCloud GmbH. All rights reserved.
//

/*
* Copyright (C) 2023, ownCloud GmbH.
*
* This code is covered by the GNU Public License Version 3.
*
* For distribution utilizing Apple mechanisms please see https://owncloud.org/contribute/iOS-license-exception/
* You should have received a copy of this license along with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.en.html>.
*
*/

import UIKit
import ownCloudApp
import ownCloudAppShared

class InitialSetupViewController: UIViewController {
override var preferredStatusBarStyle : UIStatusBarStyle {
return Theme.shared.activeCollection.css.getStatusBarStyle(for: self) ?? .default
}

override func loadView() {
cssSelectors = [.modal, .welcome]

var addAccountTitle = "Add account".localized
if !VendorServices.shared.canAddAccount {
addAccountTitle = "Login".localized
}

let messageView = ComposedMessageView.infoBox(additionalElements: [
.image(AccountSettingsProvider.shared.logo, size: CGSize(width: 128, height: 128), cssSelectors: [.icon]),
.title(String(format: "Welcome to %@".localized, VendorServices.shared.appName), alignment: .centered, cssSelectors: [.title], insets: NSDirectionalEdgeInsets(top: 25, leading: 0, bottom: 25, trailing: 0)),
.button(addAccountTitle, action: UIAction(handler: { [weak self] action in
if let self = self {
BookmarkViewController.showBookmarkUI(on: self, attemptLoginOnSuccess: true)
}
}), image: UIImage(systemName: "plus.circle"), cssSelectors: [.welcome]),
.button("Settings".localized ,action: UIAction(handler: { [weak self] action in
if let self = self {
self.present(ThemeNavigationController(rootViewController: SettingsViewController()), animated: true)
}
}), image: UIImage(systemName: "gearshape"), cssSelectors: [.welcome])
])
messageView.elementInsets = NSDirectionalEdgeInsets(top: 25, leading: 50, bottom: 50, trailing: 50)

let rootView = ThemeCSSView(withSelectors: [])

if let image = Branding.shared.brandedImageNamed(.loginBackground) {
messageView.isOpaque = false
let backgroundImageView = UIImageView(image: image)
backgroundImageView.contentMode = .scaleAspectFill
rootView.embed(toFillWith: backgroundImageView)
}

rootView.embed(centered: messageView, minimumInsets: NSDirectionalEdgeInsets(top: 20, leading: 20, bottom: 20, trailing: 20))

view = rootView
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ public class ThemeCollection : NSObject {
ThemeCSSRecord(selectors: [.welcome, .message, .title], property: .stroke, value: darkBrandSet.labelColor),
ThemeCSSRecord(selectors: [.welcome, .message, .button], property: .stroke, value: darkBrandSet.labelColor),
ThemeCSSRecord(selectors: [.welcome, .message, .button], property: .fill, value: darkBrandColor),
ThemeCSSRecord(selectors: [.welcome], property: .statusBarStyle, value: UIStatusBarStyle.lightContent),

// Side Bar
// - Interface Style
Expand Down

0 comments on commit d511896

Please sign in to comment.