Empty Sheet fallback view

This commit is contained in:
Lumaa 2024-01-27 08:56:22 +01:00
parent 1b1ee9ea4d
commit 9ef5101d70
1 changed files with 24 additions and 5 deletions

View File

@ -37,6 +37,8 @@ public enum TabDestination: Identifiable {
public enum SheetDestination: Identifiable { public enum SheetDestination: Identifiable {
case welcome case welcome
case shop
case mastodonLogin(logged: Binding<Bool>) case mastodonLogin(logged: Binding<Bool>)
case post(content: String = "", replyId: String? = nil, editId: String? = nil) case post(content: String = "", replyId: String? = nil, editId: String? = nil)
case safari(url: URL) case safari(url: URL)
@ -46,6 +48,9 @@ public enum SheetDestination: Identifiable {
switch self { switch self {
case .welcome: case .welcome:
return "welcome" return "welcome"
case .shop:
return "shop"
case .mastodonLogin: case .mastodonLogin:
return "login" return "login"
case .post: case .post:
@ -61,16 +66,15 @@ public enum SheetDestination: Identifiable {
switch self { switch self {
case .welcome: case .welcome:
return true return true
case .shop:
return true
case .mastodonLogin: case .mastodonLogin:
return false return false
case .post: case .post:
return false return false
case .safari: case .safari:
return false return false
case .shareImage: case .shareImage:
return false return false
} }
@ -124,8 +128,10 @@ extension View {
switch destination { switch destination {
case .welcome: case .welcome:
ConnectView() ConnectView()
case .shop:
ShopView()
default: default:
EmptyView() EmptySheetView(destId: destination.id)
} }
} else { } else {
switch destination { switch destination {
@ -143,9 +149,22 @@ extension View {
case let .shareImage(image, status): case let .shareImage(image, status):
ShareSheet(image: image, status: status) ShareSheet(image: image, status: status)
default: default:
EmptyView() EmptySheetView(destId: destination.id)
} }
} }
} }
} }
} }
private struct EmptySheetView: View {
var destId: String = "???"
var body: some View {
ZStack {
ContentUnavailableView(String("Missing view for \"\(destId.isEmpty ? "[EMPTY_DEST_ID]" : destId)\""), systemImage: "exclamationmark.triangle.fill", description: Text(String("Please notify Lumaa as soon as possible!\n\nThreadedApp v\(AppInfo.appVersion)")))
.ignoresSafeArea()
.background(Color.red.gradient)
.foregroundStyle(.white)
}
}
}