From c7ce32a5628ea7f52f03e70c85e1e2ca8fbce33b Mon Sep 17 00:00:00 2001 From: Fabian Thies Date: Wed, 21 Dec 2022 17:49:49 +0100 Subject: [PATCH] [ADD] WIP: Promoted category cards and app list filter button in BrowseView --- AltStore/Manager/NotificationManager.swift | 7 +- AltStore/Views/Browse/BrowseView.swift | 87 ++++++++++++++++++++-- 2 files changed, 84 insertions(+), 10 deletions(-) diff --git a/AltStore/Manager/NotificationManager.swift b/AltStore/Manager/NotificationManager.swift index 1fad0452..30ae6068 100644 --- a/AltStore/Manager/NotificationManager.swift +++ b/AltStore/Manager/NotificationManager.swift @@ -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) diff --git a/AltStore/Views/Browse/BrowseView.swift b/AltStore/Views/Browse/BrowseView.swift index cd9fbba2..684823c4 100644 --- a/AltStore/Views/Browse/BrowseView.swift +++ b/AltStore/Views/Browse/BrowseView.swift @@ -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)) + } +}