-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Course Level Error Handling for Empty States #477
Changes from 1 commit
e6f8e74
58dcf71
4ddfc7d
b8b3abc
d061772
aea50e7
422c1ed
3e8518a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "noVideos.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "campaign_24dp_FILL0_wght400_GRAD0_opsz24.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "noHandouts.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Vector.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,15 @@ import Theme | |
|
||
public struct FullScreenErrorView: View { | ||
|
||
public enum ErrorType { | ||
public enum ErrorType: Equatable { | ||
case noInternet | ||
case noInternetWithReload | ||
case generic | ||
case noVideos(error: String, image: SwiftUI.Image) | ||
case noHandouts(error: String, image: SwiftUI.Image) | ||
case noAnnouncements(error: String, image: SwiftUI.Image) | ||
case noCourseDates(error: String, image: SwiftUI.Image) | ||
case noCourseware(error: String, image: SwiftUI.Image) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are passing the same data in all the cases, how about defining a single case for all the cases and use that? Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking the same thing, but I opted for this approach to accommodate any future type-specific UI requirements. We can opt for single case for now. Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opting for a single case is good at the moment. We will update it in the future as per the need. |
||
} | ||
|
||
private let errorType: ErrorType | ||
|
@@ -34,56 +39,87 @@ public struct FullScreenErrorView: View { | |
} | ||
|
||
public var body: some View { | ||
GeometryReader { proxy in | ||
VStack(spacing: 28) { | ||
Spacer() | ||
switch errorType { | ||
case .noInternet, .noInternetWithReload: | ||
CoreAssets.noWifi.swiftUIImage | ||
switch errorType { | ||
case .noVideos(error: let error, image: let image), | ||
.noHandouts(error: let error, image: let image), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the extra indentation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. XCode indenting it like this way. |
||
.noAnnouncements(error: let error, image: let image), | ||
.noCourseDates(error: let error, image: let image), | ||
.noCourseware(error: let error, image: let image): | ||
GeometryReader { proxy in | ||
VStack(spacing: 20) { | ||
Spacer() | ||
image | ||
.resizable() | ||
.renderingMode(.template) | ||
.foregroundStyle(Color.primary) | ||
.scaledToFit() | ||
.foregroundStyle(Theme.Colors.textSecondary) | ||
.aspectRatio(contentMode: .fit) | ||
.frame(maxWidth: 72, maxHeight: 80) | ||
|
||
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) | ||
Text(error) | ||
.font(Theme.Fonts.labelLarge) | ||
.foregroundColor(Theme.Colors.textPrimary) | ||
.multilineTextAlignment(.center) | ||
.padding(.horizontal, 50) | ||
Spacer() | ||
} | ||
|
||
if errorType != .noInternet { | ||
UnitButtonView( | ||
type: .reload, | ||
action: { | ||
self.action() | ||
} | ||
) | ||
.frame(maxWidth: .infinity, maxHeight: proxy.size.height) | ||
.background( | ||
Theme.Colors.background | ||
) | ||
} | ||
default: | ||
GeometryReader { proxy in | ||
VStack(spacing: 20) { | ||
Spacer() | ||
switch errorType { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems bit odd to use the switch again under a case of the same switch. How about using a single There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for pointing that out. I have fixed it. |
||
case .noInternet, .noInternetWithReload: | ||
CoreAssets.noWifi.swiftUIImage | ||
.renderingMode(.template) | ||
.foregroundStyle(Theme.Colors.textSecondary) | ||
.scaledToFit() | ||
|
||
Text(CoreLocalization.Error.Internet.noInternetTitle) | ||
.font(Theme.Fonts.labelLarge) | ||
.foregroundColor(Theme.Colors.textPrimary) | ||
|
||
Text(CoreLocalization.Error.Internet.noInternetDescription) | ||
.font(Theme.Fonts.labelLarge) | ||
.foregroundColor(Theme.Colors.textPrimary) | ||
.multilineTextAlignment(.center) | ||
.padding(.horizontal, 50) | ||
case .generic: | ||
CoreAssets.notAvaliable.swiftUIImage | ||
.renderingMode(.template) | ||
.foregroundStyle(Theme.Colors.textSecondary) | ||
.scaledToFit() | ||
|
||
Text(CoreLocalization.View.Snackbar.tryAgainBtn) | ||
.font(Theme.Fonts.labelLarge) | ||
.foregroundColor(Theme.Colors.textPrimary) | ||
|
||
Text(CoreLocalization.Error.unknownError) | ||
.font(Theme.Fonts.labelLarge) | ||
.foregroundColor(Theme.Colors.textPrimary) | ||
.multilineTextAlignment(.center) | ||
.padding(.horizontal, 50) | ||
default: EmptyView() | ||
} | ||
|
||
if errorType != .noInternet { | ||
UnitButtonView( | ||
type: .reload, | ||
action: { | ||
self.action() | ||
} | ||
) | ||
} | ||
Spacer() | ||
} | ||
Spacer() | ||
.frame(maxWidth: .infinity, maxHeight: proxy.size.height) | ||
.background( | ||
Theme.Colors.background | ||
) | ||
} | ||
.frame(maxWidth: .infinity, maxHeight: proxy.size.height) | ||
.background( | ||
Theme.Colors.background | ||
) | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please change the file name as per the asset name?