-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8a7b46
commit aaf0cee
Showing
10 changed files
with
238 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
Core/Core/View/Base/FullScreenErrorView/FullScreenErrorView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// | ||
// FullScreenErrorView.swift | ||
// Course | ||
// | ||
// Created by Shafqat Muneer on 5/14/24. | ||
// | ||
|
||
import SwiftUI | ||
import Theme | ||
|
||
public struct FullScreenErrorView: View { | ||
|
||
public enum ErrorType { | ||
case noInternet | ||
case noInternetWithReload | ||
case generic | ||
} | ||
|
||
private let errorType: ErrorType | ||
private var reloadAction: () -> Void = {} | ||
|
||
public init( | ||
type: ErrorType | ||
) { | ||
self.errorType = type | ||
} | ||
|
||
public init( | ||
type: ErrorType, | ||
reloadAction: @escaping () -> Void | ||
) { | ||
self.errorType = type | ||
self.reloadAction = reloadAction | ||
} | ||
|
||
public var body: some View { | ||
GeometryReader { proxy in | ||
VStack(spacing: 28) { | ||
Spacer() | ||
switch errorType { | ||
case .noInternet, .noInternetWithReload: | ||
CoreAssets.noWifi.swiftUIImage | ||
.renderingMode(.template) | ||
.foregroundStyle(Color.primary) | ||
.scaledToFit() | ||
|
||
Text(CoreLocalization.Error.Internet.noInternetTitle) | ||
.font(Theme.Fonts.titleLarge) | ||
.foregroundColor(Theme.Colors.textPrimary) | ||
|
||
Text(CoreLocalization.Error.Internet.noInternetDescription) | ||
.font(Theme.Fonts.bodyLarge) | ||
.foregroundColor(Theme.Colors.textPrimary) | ||
.multilineTextAlignment(.center) | ||
.padding(.horizontal, 50) | ||
case .generic: | ||
CoreAssets.notAvaliable.swiftUIImage | ||
.renderingMode(.template) | ||
.foregroundStyle(Color.primary) | ||
.scaledToFit() | ||
|
||
Text(CoreLocalization.View.Snackbar.tryAgainBtn) | ||
.font(Theme.Fonts.titleLarge) | ||
.foregroundColor(Theme.Colors.textPrimary) | ||
|
||
Text(CoreLocalization.Error.unknownError) | ||
.font(Theme.Fonts.bodyLarge) | ||
.foregroundColor(Theme.Colors.textPrimary) | ||
.multilineTextAlignment(.center) | ||
.padding(.horizontal, 50) | ||
} | ||
|
||
if errorType != .noInternet { | ||
UnitButtonView(type: .reload, action: { | ||
self.reloadAction() | ||
}) | ||
} | ||
Spacer() | ||
} | ||
.frame(maxWidth: .infinity, maxHeight: proxy.size.height) | ||
.background( | ||
Theme.Colors.background | ||
) | ||
} | ||
} | ||
} | ||
|
||
#if DEBUG | ||
//swiftlint:disable all | ||
struct FullScreenErrorView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
FullScreenErrorView(type: .noInternetWithReload) | ||
} | ||
} | ||
//swiftlint:enable all | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.