[ADD] WIP: Promoted category cards and app list filter button in BrowseView

This commit is contained in:
Fabian Thies
2022-12-21 17:49:49 +01:00
parent 9206eeb9e3
commit 6b6708e43c
2 changed files with 84 additions and 10 deletions

View File

@@ -62,10 +62,13 @@ class NotificationManager: ObservableObject {
detailText = underlyingError?.localizedDescription ?? error.localizedRecoverySuggestion
}
self.showNotification(title: text, detailText: detailText)
}
func showNotification(title: String, detailText: String?) {
let notificationId = UUID()
self.notifications[notificationId] = Notification(id: notificationId, title: text, message: detailText)
self.notifications[notificationId] = Notification(id: notificationId, title: title, message: detailText)
let dismissWorkItem = DispatchWorkItem {
self.notifications.removeValue(forKey: notificationId)

View File

@@ -31,14 +31,26 @@ struct BrowseView: View {
var body: some View {
ScrollView {
LazyVStack(spacing: 32) {
ForEach(filteredApps, id: \.bundleIdentifier) { app in
NavigationLink {
AppDetailView(storeApp: app)
} label: {
BrowseAppPreviewView(storeApp: app)
VStack(alignment: .leading) {
if searchText.isEmpty {
VStack(alignment: .leading, spacing: 32) {
promotedCategoriesView
Text("All Apps")
.font(.title2)
.bold()
}
}
LazyVStack(spacing: 32) {
ForEach(filteredApps, id: \.bundleIdentifier) { app in
NavigationLink {
AppDetailView(storeApp: app)
} label: {
BrowseAppPreviewView(storeApp: app)
}
.buttonStyle(PlainButtonStyle())
}
.buttonStyle(PlainButtonStyle())
}
}
.padding()
@@ -47,7 +59,7 @@ struct BrowseView: View {
.background(Color(UIColor.systemGroupedBackground).ignoresSafeArea())
.navigationTitle("Browse")
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
ToolbarItem(placement: .navigationBarLeading) {
SwiftUI.Button {
self.isShowingSourcesView = true
} label: {
@@ -59,6 +71,37 @@ struct BrowseView: View {
}
}
}
ToolbarItem(placement: .navigationBarTrailing) {
SwiftUI.Button {
} label: {
Image(systemName: "line.3.horizontal.decrease.circle")
.imageScale(.large)
}
}
}
}
var promotedCategoriesView: some View {
VStack {
HStack {
Text("Promoted Categories")
.font(.title2)
.bold()
Spacer()
SwiftUI.Button(action: {}, label: { Text("Show all") })
.font(.callout)
}
LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible())]) {
PromotedCategoryView()
.shadow(color: .black.opacity(0.1), radius: 8, y: 5)
PromotedCategoryView()
.shadow(color: .black.opacity(0.1), radius: 8, y: 5)
}
}
}
}
@@ -68,3 +111,31 @@ struct BrowseView_Previews: PreviewProvider {
BrowseView()
}
}
struct PromotedCategoryView: View {
var body: some View {
ZStack {
GeometryReader { proxy in
RadialGradient(colors: [
Color(UIColor(hexString: "477E84")!),
Color(UIColor.secondarySystemBackground),
Color(UIColor.secondarySystemBackground),
Color(UIColor(hexString: "C38FF5")!)
], center: .bottomLeading, startRadius: 0, endRadius: proxy.size.width)
}
HStack {
Image(systemName: "dpad.right.filled")
Text("Games &\nEmulators")
.multilineTextAlignment(.leading)
}
.foregroundColor(.accentColor)
.padding()
}
.aspectRatio(21/9, contentMode: .fill)
.frame(maxWidth: .infinity)
.clipShape(RoundedRectangle(cornerRadius: 12))
}
}