From c7e095583d5be055e7cce48b8b943293aefa0c9b Mon Sep 17 00:00:00 2001 From: Fabian Thies Date: Mon, 16 Jan 2023 19:02:58 +0100 Subject: [PATCH] [ADD] Hint for new users who don't have any sources --- AltStore.xcodeproj/project.pbxproj | 12 +++++-- AltStore/View Components/HintView.swift | 42 +++++++++++++++++++++++++ AltStore/Views/Browse/BrowseView.swift | 37 +++++++++++++++++----- AltStore/Views/My Apps/MyAppsView.swift | 18 +++++------ 4 files changed, 90 insertions(+), 19 deletions(-) create mode 100644 AltStore/View Components/HintView.swift diff --git a/AltStore.xcodeproj/project.pbxproj b/AltStore.xcodeproj/project.pbxproj index b69a7792..21e305c6 100644 --- a/AltStore.xcodeproj/project.pbxproj +++ b/AltStore.xcodeproj/project.pbxproj @@ -31,6 +31,8 @@ 1F0DD84129368056007608A4 /* EnvironmentValues.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F0DD84029368056007608A4 /* EnvironmentValues.swift */; }; 1F0DD8432936B0F9007608A4 /* RoundedTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F0DD8422936B0F9007608A4 /* RoundedTextField.swift */; }; 1F0DD8452936B3FE007608A4 /* FilledButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F0DD8442936B3FE007608A4 /* FilledButtonStyle.swift */; }; + 1F44634529744E570070E514 /* HintView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F44634429744E570070E514 /* HintView.swift */; }; + 1F5DF9D82974426300DDAA47 /* AppScreenshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F5DF9D72974426300DDAA47 /* AppScreenshot.swift */; }; 1F6284D5295209DA0060AAD8 /* AppAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F6284D4295209DA0060AAD8 /* AppAction.swift */; }; 1F6284D7295218980060AAD8 /* DocumentPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F6284D6295218980060AAD8 /* DocumentPicker.swift */; }; 1F6284D929523D340060AAD8 /* SideloadingManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F6284D829523D340060AAD8 /* SideloadingManager.swift */; }; @@ -570,6 +572,8 @@ 1F0DD84029368056007608A4 /* EnvironmentValues.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnvironmentValues.swift; sourceTree = ""; }; 1F0DD8422936B0F9007608A4 /* RoundedTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundedTextField.swift; sourceTree = ""; }; 1F0DD8442936B3FE007608A4 /* FilledButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilledButtonStyle.swift; sourceTree = ""; }; + 1F44634429744E570070E514 /* HintView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HintView.swift; sourceTree = ""; }; + 1F5DF9D72974426300DDAA47 /* AppScreenshot.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppScreenshot.swift; sourceTree = ""; }; 1F6284D4295209DA0060AAD8 /* AppAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppAction.swift; sourceTree = ""; }; 1F6284D6295218980060AAD8 /* DocumentPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentPicker.swift; sourceTree = ""; }; 1F6284D829523D340060AAD8 /* SideloadingManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SideloadingManager.swift; sourceTree = ""; }; @@ -1197,9 +1201,11 @@ children = ( 1F6E08D9292806E0005059C0 /* AppRowView.swift */, 1F6E08DB292807D3005059C0 /* AppIconView.swift */, - 1F6E08E529280F4B005059C0 /* RatingStars.swift */, - 1FB96FBD292A20E5007E68D1 /* ObservableScrollView.swift */, 1FB96FBF292A63F2007E68D1 /* AppPillButton.swift */, + 1F5DF9D72974426300DDAA47 /* AppScreenshot.swift */, + 1F44634429744E570070E514 /* HintView.swift */, + 1FB96FBD292A20E5007E68D1 /* ObservableScrollView.swift */, + 1F6E08E529280F4B005059C0 /* RatingStars.swift */, 1F0DD8422936B0F9007608A4 /* RoundedTextField.swift */, ); path = "View Components"; @@ -2833,6 +2839,7 @@ BFC84A4D2421A19100853474 /* SourcesViewController.swift in Sources */, BFF0B696232242D3007A79E1 /* LicensesViewController.swift in Sources */, D57FE84428C7DB7100216002 /* ErrorLogViewController.swift in Sources */, + 1F44634529744E570070E514 /* HintView.swift in Sources */, 1F6E08E429280D1E005059C0 /* PillButtonStyle.swift in Sources */, 1F6284D7295218980060AAD8 /* DocumentPicker.swift in Sources */, BFBE0007250AD0E70080826E /* ViewAppIntentHandler.swift in Sources */, @@ -2845,6 +2852,7 @@ BF6C8FAC242935ED00125131 /* NSAttributedString+Markdown.m in Sources */, BFF00D322501BDA100746320 /* BackgroundRefreshAppsOperation.swift in Sources */, 1F66F5BC2938F03700A910CA /* Modifiers.swift in Sources */, + 1F5DF9D82974426300DDAA47 /* AppScreenshot.swift in Sources */, 1F66F5BA2938CA5700A910CA /* VisualEffectView.swift in Sources */, BF0C4EBD22A1BD8B009A2DD7 /* AppManager.swift in Sources */, BF2901312318F7A800D88A45 /* AppBannerView.swift in Sources */, diff --git a/AltStore/View Components/HintView.swift b/AltStore/View Components/HintView.swift new file mode 100644 index 00000000..ad405c10 --- /dev/null +++ b/AltStore/View Components/HintView.swift @@ -0,0 +1,42 @@ +// +// HintView.swift +// SideStore +// +// Created by Fabian Thies on 15.01.23. +// Copyright © 2023 SideStore. All rights reserved. +// + +import SwiftUI + +struct HintView: View { + + var backgroundColor: Color = Color(.tertiarySystemBackground) + + @ViewBuilder + let content: () -> Content + + var body: some View { + VStack(alignment: .leading, spacing: 8) { + self.content() + } + .padding() + .background(self.backgroundColor) + .clipShape(RoundedRectangle(cornerRadius: 8)) + } +} + +struct HintView_Previews: PreviewProvider { + static var previews: some View { + ZStack { + Color(.secondarySystemBackground).edgesIgnoringSafeArea(.all) + + HintView { + Text("Hint Title") + .bold() + + Text("This hint view can be used to tell the user something about how SideStore works.") + .foregroundColor(.secondary) + } + } + } +} diff --git a/AltStore/Views/Browse/BrowseView.swift b/AltStore/Views/Browse/BrowseView.swift index ec46ea86..e2a11b35 100644 --- a/AltStore/Views/Browse/BrowseView.swift +++ b/AltStore/Views/Browse/BrowseView.swift @@ -42,15 +42,34 @@ struct BrowseView: View { .bold() } } - - LazyVStack(spacing: 32) { - ForEach(filteredApps, id: \.bundleIdentifier) { app in - NavigationLink { - AppDetailView(storeApp: app) + + if searchText.isEmpty, filteredApps.count == 0 { + HintView { + Text("You don't have any apps yet.") + .bold() + + Text("Apps are provided by \"sources\". The specification for them is an open standard, so everyone can create their own source. To get you started, we have compiled a list of \"Trusted Sources\" which you can check out by tapping the button below.") + .font(.callout) + .foregroundColor(.secondary) + + SwiftUI.Button { + self.isShowingSourcesView = true } label: { - BrowseAppPreviewView(storeApp: app) + Label("Add Source", systemSymbol: .plus) + } + .buttonStyle(FilledButtonStyle()) + .padding(.top, 8) + } + } else { + LazyVStack(spacing: 32) { + ForEach(filteredApps, id: \.bundleIdentifier) { app in + NavigationLink { + AppDetailView(storeApp: app) + } label: { + BrowseAppPreviewView(storeApp: app) + } + .buttonStyle(PlainButtonStyle()) } - .buttonStyle(PlainButtonStyle()) } } } @@ -111,7 +130,9 @@ struct BrowseView: View { struct BrowseView_Previews: PreviewProvider { static var previews: some View { - BrowseView() + NavigationView { + BrowseView() + } } } diff --git a/AltStore/Views/My Apps/MyAppsView.swift b/AltStore/Views/My Apps/MyAppsView.swift index cbcb36a7..cd30f0ab 100644 --- a/AltStore/Views/My Apps/MyAppsView.swift +++ b/AltStore/Views/My Apps/MyAppsView.swift @@ -155,19 +155,19 @@ struct MyAppsView: View { } var updatesSection: some View { - VStack(alignment: .leading, spacing: 8) { + HintView { HStack(alignment: .center) { Text("All Apps are Up To Date") .bold() Spacer() - + Menu { SwiftUI.Button { self.dismissUpdatesHint(forever: false) } label: { Label("Dismiss for now", systemSymbol: .zzz) } - + SwiftUI.Button { self.dismissUpdatesHint(forever: true) } label: { @@ -176,15 +176,13 @@ struct MyAppsView: View { } label: { Image(systemSymbol: .xmark) } + .foregroundColor(.secondary) } - + Text("You will be notified once updates for your apps are available. The updates will then be shown here.") .font(.callout) + .foregroundColor(.secondary) } - .foregroundColor(.secondary) - .padding() - .background(Color(.tertiarySystemBackground)) - .clipShape(RoundedRectangle(cornerRadius: 8)) } @ViewBuilder @@ -428,6 +426,8 @@ extension MyAppsView { struct MyAppsView_Previews: PreviewProvider { static var previews: some View { - MyAppsView() + NavigationView { + MyAppsView() + } } }