Skip to content

Commit

Permalink
Add FXIOS-9636 [Native Error Page] UI for No internet connection (#2…
Browse files Browse the repository at this point in the history
…1629)

* Add FXIOS-9636 [Native Error Page] No Internet Connection UI

* Add FXIOS-9636 [Native Error Page] Test cases for native error page view controllers.

---------

Co-authored-by: cyndichin <[email protected]>
  • Loading branch information
tusharC95 and cyndichin authored Aug 30, 2024
1 parent e31e169 commit 01b23e1
Show file tree
Hide file tree
Showing 14 changed files with 384 additions and 5 deletions.
40 changes: 40 additions & 0 deletions firefox-ios/Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,11 @@
602B3D6729B0E1DB0066DEF8 /* ConversionValueUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 602B3D6629B0E1DB0066DEF8 /* ConversionValueUtil.swift */; };
60CE80C12667780D004026C7 /* CredentialListPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60CE80C02667780C004026C7 /* CredentialListPresenter.swift */; };
60D71AEC26AAF45E00355588 /* UIColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60D71AEB26AAF45E00355588 /* UIColorExtension.swift */; };
630FE1342C7FB42500D9D6B2 /* NativeErrorPageMockModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 630FE1302C7FB42500D9D6B2 /* NativeErrorPageMockModel.swift */; };
630FE1352C7FB42500D9D6B2 /* NativeErrorPageViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 630FE1322C7FB42500D9D6B2 /* NativeErrorPageViewControllerTests.swift */; };
63306D3921103EAE00F25400 /* LegacySavedTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63306D3821103EAE00F25400 /* LegacySavedTab.swift */; };
63F7A9AA2C7529ED005846F5 /* NativeErrorPageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63F7A9A92C7529ED005846F5 /* NativeErrorPageModel.swift */; };
63F7A9AC2C752BB0005846F5 /* NativeErrorPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63F7A9AB2C752BB0005846F5 /* NativeErrorPageViewController.swift */; };
6669B5E2211418A200CA117B /* WebsiteDataSearchResultsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6669B5E1211418A200CA117B /* WebsiteDataSearchResultsViewController.swift */; };
66CE54A820FCF6CF00CC310B /* WebsiteDataManagementViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CE54A720FCF6CF00CC310B /* WebsiteDataManagementViewController.swift */; };
6A3E5D8A283831D1001E706E /* DownloadQueueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A3E5D89283831D0001E706E /* DownloadQueueTests.swift */; };
Expand Down Expand Up @@ -6098,9 +6102,13 @@
62C1428C920701180BCD4C47 /* anp */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = anp; path = anp.lproj/InfoPlist.strings; sourceTree = "<group>"; };
62DF49B9976D5863CADF6EAA /* ca */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ca; path = ca.lproj/Menu.strings; sourceTree = "<group>"; };
63094229AA6EC744599B77A4 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/ClearPrivateData.strings; sourceTree = "<group>"; };
630FE1302C7FB42500D9D6B2 /* NativeErrorPageMockModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NativeErrorPageMockModel.swift; sourceTree = "<group>"; };
630FE1322C7FB42500D9D6B2 /* NativeErrorPageViewControllerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NativeErrorPageViewControllerTests.swift; sourceTree = "<group>"; };
63306D3821103EAE00F25400 /* LegacySavedTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacySavedTab.swift; sourceTree = "<group>"; };
634148899F41CAA3BCF71E8B /* or */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = or; path = or.lproj/Localizable.strings; sourceTree = "<group>"; };
63B04BE882C41584580E0E59 /* fa */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fa; path = "fa.lproj/Default Browser.strings"; sourceTree = "<group>"; };
63F7A9A92C7529ED005846F5 /* NativeErrorPageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeErrorPageModel.swift; sourceTree = "<group>"; };
63F7A9AB2C752BB0005846F5 /* NativeErrorPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeErrorPageViewController.swift; sourceTree = "<group>"; };
63FE433D87018CDDFCF592E3 /* sk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sk; path = sk.lproj/ErrorPages.strings; sourceTree = "<group>"; };
644B4A02BCAF40DE5B7B9EBB /* lv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = lv; path = lv.lproj/FindInPage.strings; sourceTree = "<group>"; };
646F49B3BD7C595E05EEA7C5 /* en-GB */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "en-GB"; path = "en-GB.lproj/Today.strings"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -9934,6 +9942,32 @@
path = Generated;
sourceTree = "<group>";
};
630FE1312C7FB42500D9D6B2 /* Mock */ = {
isa = PBXGroup;
children = (
630FE1302C7FB42500D9D6B2 /* NativeErrorPageMockModel.swift */,
);
path = Mock;
sourceTree = "<group>";
};
630FE1332C7FB42500D9D6B2 /* NativeErrorPage */ = {
isa = PBXGroup;
children = (
630FE1312C7FB42500D9D6B2 /* Mock */,
630FE1322C7FB42500D9D6B2 /* NativeErrorPageViewControllerTests.swift */,
);
path = NativeErrorPage;
sourceTree = "<group>";
};
63F7A9A82C752999005846F5 /* NativeErrorPage */ = {
isa = PBXGroup;
children = (
63F7A9A92C7529ED005846F5 /* NativeErrorPageModel.swift */,
63F7A9AB2C752BB0005846F5 /* NativeErrorPageViewController.swift */,
);
path = NativeErrorPage;
sourceTree = "<group>";
};
7A352B722C4F190F00359D51 /* Tabs */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -12837,6 +12871,7 @@
C83DE54529DF3579006E1B69 /* Messaging */,
8A8482ED2BE15FEF00F9007B /* Microsurvey */,
C889D7D22858C85200121E1D /* Mocks */,
630FE1332C7FB42500D9D6B2 /* NativeErrorPage */,
C8B41E0B29F034D500FE218A /* Nimbus */,
E1312FCF29D23775008DDA85 /* NotificationSurface */,
C8B41E0C29F034E400FE218A /* OnboardingTests */,
Expand Down Expand Up @@ -12972,6 +13007,7 @@
EBC486972195F46A00CDA48D /* InternalSchemeHandler */,
D05434F3225FDA3400FDE4EF /* Library */,
8A6A3D452BD038EF00BFDB64 /* Microsurvey */,
63F7A9A82C752999005846F5 /* NativeErrorPage */,
E1FE132D29C0B334002A65FF /* NotificationSurface */,
C8BD875D2A0C23F500CD803A /* Onboarding */,
E63ED8DF1BFD254E0097D08E /* PasswordManagement */,
Expand Down Expand Up @@ -15102,6 +15138,8 @@
8A01891C275E9C2A00923EFE /* ClearHistorySheetProvider.swift in Sources */,
8A4EA0DD2C0117F200E4E4F1 /* MicrosurveyModel.swift in Sources */,
8C44A9D22A6A99FE009A1AA7 /* ShoppingProduct.swift in Sources */,
63F7A9AA2C7529ED005846F5 /* NativeErrorPageModel.swift in Sources */,
63F7A9AC2C752BB0005846F5 /* NativeErrorPageViewController.swift in Sources */,
C88E7A572A0553360072E638 /* OnboardingButtonInfoModel.swift in Sources */,
AB9A0C012C6CBC9100BFA22A /* TrackingProtectionDetailsViewController.swift in Sources */,
21B548952B1E5F1400DC1DF8 /* InactiveTabsManager.swift in Sources */,
Expand Down Expand Up @@ -15763,6 +15801,7 @@
8A5604F829DF0D2600035CA3 /* BrowserCoordinatorTests.swift in Sources */,
C787D8C32C1CB77900940123 /* FirefoxAccountSignInViewControllerTests.swift in Sources */,
39236E721FCC600200A38F1B /* TabEventHandlerTests.swift in Sources */,
630FE1352C7FB42500D9D6B2 /* NativeErrorPageViewControllerTests.swift in Sources */,
8AAEB9FE2BF50718000C02B5 /* MicrosurveyViewControllerTests.swift in Sources */,
C8E531CC29E72A2F00E03FEF /* ShortcutRouteTests.swift in Sources */,
C83B7DD629BBB49D005565C2 /* SurveySurfaceManagerTests.swift in Sources */,
Expand Down Expand Up @@ -15822,6 +15861,7 @@
C869915428917803007ACC5C /* WallpaperTestDataProvider.swift in Sources */,
0AC659292BF493CE005C614A /* MockFxAWebViewModel.swift in Sources */,
8A5604F629DF09FA00035CA3 /* MockLaunchCoordinatorDelegate.swift in Sources */,
630FE1342C7FB42500D9D6B2 /* NativeErrorPageMockModel.swift in Sources */,
C807CCCC28367446008E6A5A /* FeatureFlagManagerTests.swift in Sources */,
8A5C3BC5282ABF8E003A8CCF /* LegacyRemoteTabsPanelTests.swift in Sources */,
8AABBD032A001CBC0089941E /* MockApplicationHelper.swift in Sources */,
Expand Down
4 changes: 4 additions & 0 deletions firefox-ios/Client/Application/ImageIdentifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ public struct ImageIdentifiers {
public static let fingerprintersTrackers = "fingerprintersTrackersImage"
public static let crossSiteTrackers = "crossSiteTrackersImage"
}

public struct NativeErrorPage {
public static let noInternetConnection = "noInternetConnection"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "noInternetConnection.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
14 changes: 14 additions & 0 deletions firefox-ios/Client/Coordinators/Browser/BrowserCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class BrowserCoordinator: BaseCoordinator,
var webviewController: WebviewViewController?
var homepageViewController: HomepageViewController?
var privateViewController: PrivateHomepageViewController?
var errorViewController: NativeErrorPageViewController?

private var profile: Profile
private let tabManager: TabManager
Expand Down Expand Up @@ -715,6 +716,19 @@ class BrowserCoordinator: BaseCoordinator,
present(navigationController)
}

func showNativeErrorPage(overlayManager: OverlayModeManager) {
// TODO: FXIOS-9641 #21239 Integration with Redux - presenting view
let errorPageModel = ErrorPageModel(errorTitle: "", errorDecription: "", errorCode: "")
let errorpageController = NativeErrorPageViewController(model: errorPageModel,
windowUUID: windowUUID,
overlayManager: overlayManager)
guard browserViewController.embedContent(errorpageController) else {
logger.log("Unable to embed private homepage", level: .debug, category: .coordinator)
return
}
self.errorViewController = errorpageController
}

private func setiPadLayoutDetents(for controller: UIViewController) {
guard controller.shouldUseiPadSetup() else { return }
controller.sheetPresentationController?.selectedDetentIdentifier = .large
Expand Down
3 changes: 3 additions & 0 deletions firefox-ios/Client/Coordinators/Browser/BrowserDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ protocol BrowserDelegate: AnyObject {
/// This is called the browser is ready to start navigating,
/// ensuring we are in the required state to perform deeplinks
func browserHasLoaded()

/// Show the Error page to the user
func showNativeErrorPage(overlayManager: OverlayModeManager)
}
Original file line number Diff line number Diff line change
Expand Up @@ -1389,8 +1389,13 @@ class BrowserViewController: UIViewController,

// MARK: - Native Error Page

private func setupNativeErrorPage() {
guard featureFlags.isFeatureEnabled(.nativeErrorPage, checking: .buildOnly) else { return }
private func isNativeErrorPage() -> Bool {
featureFlags.isFeatureEnabled(.nativeErrorPage, checking: .buildOnly)
}

func showEmbeddedNativeErrorPage() {
// TODO: FXIOS-9641 #21239 Implement Redux for Native Error Pages
browserDelegate?.showNativeErrorPage(overlayManager: overlayManager)
}

// MARK: - Update content
Expand Down Expand Up @@ -1420,6 +1425,9 @@ class BrowserViewController: UIViewController,

func updateInContentHomePanel(_ url: URL?, focusUrlBar: Bool = false) {
let isAboutHomeURL = url.flatMap { InternalURL($0)?.isAboutHomeURL } ?? false

let isErrorURL = url.flatMap { InternalURL($0)?.isErrorPage } ?? false

guard url != nil else {
showEmbeddedWebview()
if !isToolbarRefactorEnabled {
Expand All @@ -1430,6 +1438,8 @@ class BrowserViewController: UIViewController,

if isAboutHomeURL {
showEmbeddedHomepage(inline: true, isPrivate: tabManager.selectedTab?.isPrivate ?? false)
} else if isErrorURL && isNativeErrorPage() {
showEmbeddedNativeErrorPage()
} else {
showEmbeddedWebview()
if !isToolbarRefactorEnabled {
Expand Down
3 changes: 3 additions & 0 deletions firefox-ios/Client/Frontend/Components/ContentContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ enum ContentType {
case webview
case homepage
case privateHomepage
case nativeErrorPage
}

protocol ContentContainable: UIViewController {
Expand Down Expand Up @@ -43,6 +44,8 @@ class ContentContainer: UIView {
switch type {
case .homepage:
return !(content is HomepageViewController)
case .nativeErrorPage:
return !(content is NativeErrorPageViewController)
case .privateHomepage:
return !(content is PrivateHomepageViewController)
case .webview:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/

import Foundation

struct ErrorPageModel {
let errorTitle: String
let errorDecription: String
let errorCode: String
}
Loading

0 comments on commit 01b23e1

Please sign in to comment.