From 57213fbf0c65f529a30fa7a33cdc97b82a69b086 Mon Sep 17 00:00:00 2001 From: Fabian Thies Date: Sat, 4 Feb 2023 12:46:43 +0100 Subject: [PATCH] [ADD] App report button and trusted source badge in app detail view --- AltStore.xcodeproj/project.pbxproj | 8 ++++++++ AltStore/Extensions/Source+Trusted.swift | 19 +++++++++++++++++++ AltStore/Extensions/StoreApp+Trusted.swift | 19 +++++++++++++++++++ AltStore/Views/App Detail/AppDetailView.swift | 18 +++++++++++++++++- 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 AltStore/Extensions/Source+Trusted.swift create mode 100644 AltStore/Extensions/StoreApp+Trusted.swift diff --git a/AltStore.xcodeproj/project.pbxproj b/AltStore.xcodeproj/project.pbxproj index 3b2166e3..f04d4866 100644 --- a/AltStore.xcodeproj/project.pbxproj +++ b/AltStore.xcodeproj/project.pbxproj @@ -33,6 +33,8 @@ 1F0DD8432936B0F9007608A4 /* RoundedTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F0DD8422936B0F9007608A4 /* RoundedTextField.swift */; }; 1F0DD8452936B3FE007608A4 /* FilledButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F0DD8442936B3FE007608A4 /* FilledButtonStyle.swift */; }; 1F1295812989B51F0048FCB9 /* ExpandableText in Frameworks */ = {isa = PBXBuildFile; productRef = 1F1295802989B51F0048FCB9 /* ExpandableText */; }; + 1F180F92298E7A1B00D1C98B /* StoreApp+Trusted.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F180F91298E7A1B00D1C98B /* StoreApp+Trusted.swift */; }; + 1F180F94298E7A2500D1C98B /* Source+Trusted.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F180F93298E7A2500D1C98B /* Source+Trusted.swift */; }; 1F2EF787297C4D40002FD839 /* LicensesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F2EF786297C4D40002FD839 /* LicensesView.swift */; }; 1F44634529744E570070E514 /* HintView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F44634429744E570070E514 /* HintView.swift */; }; 1F5DF9D82974426300DDAA47 /* AppScreenshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F5DF9D72974426300DDAA47 /* AppScreenshot.swift */; }; @@ -576,6 +578,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 = ""; }; + 1F180F91298E7A1B00D1C98B /* StoreApp+Trusted.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "StoreApp+Trusted.swift"; sourceTree = ""; }; + 1F180F93298E7A2500D1C98B /* Source+Trusted.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Source+Trusted.swift"; sourceTree = ""; }; 1F2EF786297C4D40002FD839 /* LicensesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LicensesView.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 = ""; }; @@ -1922,6 +1926,8 @@ D57F2C9326E01BC700B9FA39 /* UIDevice+Vibration.swift */, B376FE3D29258C8900E18883 /* OSLog+SideStore.swift */, 1F66F5BD2938F06100A910CA /* StoreApp+Filterable.swift */, + 1F180F91298E7A1B00D1C98B /* StoreApp+Trusted.swift */, + 1F180F93298E7A2500D1C98B /* Source+Trusted.swift */, ); path = Extensions; sourceTree = ""; @@ -2742,6 +2748,7 @@ 1F943C6D2927F90400ABE095 /* NewsViewModel.swift in Sources */, 1FB96FF3292D0539007E68D1 /* PillButtonProgressViewStyle.swift in Sources */, 1F6E08E829282174005059C0 /* ConfirmAddSourceView.swift in Sources */, + 1F180F92298E7A1B00D1C98B /* StoreApp+Trusted.swift in Sources */, 1F6284D929523D340060AAD8 /* SideloadingManager.swift in Sources */, BFE6073A231ADF82002B0E8E /* SettingsViewController.swift in Sources */, 1F943C6A2927F8F700ABE095 /* ViewModel.swift in Sources */, @@ -2836,6 +2843,7 @@ 1F5DF9D82974426300DDAA47 /* AppScreenshot.swift in Sources */, 1F66F5BA2938CA5700A910CA /* VisualEffectView.swift in Sources */, BF0C4EBD22A1BD8B009A2DD7 /* AppManager.swift in Sources */, + 1F180F94298E7A2500D1C98B /* Source+Trusted.swift in Sources */, BF2901312318F7A800D88A45 /* AppBannerView.swift in Sources */, BFF00D342501BDCF00746320 /* IntentHandler.swift in Sources */, 1F0DD81C2932D2FF007608A4 /* AppScreenshotsScrollView.swift in Sources */, diff --git a/AltStore/Extensions/Source+Trusted.swift b/AltStore/Extensions/Source+Trusted.swift new file mode 100644 index 00000000..66a337f9 --- /dev/null +++ b/AltStore/Extensions/Source+Trusted.swift @@ -0,0 +1,19 @@ +// +// Source+Trusted.swift +// SideStore +// +// Created by Fabian Thies on 04.02.23. +// Copyright © 2023 SideStore. All rights reserved. +// + +import AltStoreCore + +extension Source { + var isOfficial: Bool { + self.identifier == Source.altStoreIdentifier + } + + var isTrusted: Bool { + UserDefaults.shared.trustedSourceIDs?.contains(self.identifier) ?? false + } +} diff --git a/AltStore/Extensions/StoreApp+Trusted.swift b/AltStore/Extensions/StoreApp+Trusted.swift new file mode 100644 index 00000000..90c80d87 --- /dev/null +++ b/AltStore/Extensions/StoreApp+Trusted.swift @@ -0,0 +1,19 @@ +// +// StoreApp+Trusted.swift +// SideStore +// +// Created by Fabian Thies on 04.02.23. +// Copyright © 2023 SideStore. All rights reserved. +// + +import AltStoreCore + +extension StoreApp { + var isFromOfficialSource: Bool { + self.source?.isOfficial ?? false + } + + var isFromTrustedSource: Bool { + self.source?.isTrusted ?? false + } +} diff --git a/AltStore/Views/App Detail/AppDetailView.swift b/AltStore/Views/App Detail/AppDetailView.swift index 89e47374..18ff75ec 100644 --- a/AltStore/Views/App Detail/AppDetailView.swift +++ b/AltStore/Views/App Detail/AppDetailView.swift @@ -88,8 +88,10 @@ struct AppDetailView: View { var contentView: some View { VStack(alignment: .leading) { VStack(alignment: .leading, spacing: 32) { - if storeApp.sourceIdentifier == Source.altStoreIdentifier { + if storeApp.isFromOfficialSource { officialAppBadge + } else if storeApp.isFromTrustedSource { + trustedAppBadge } if let subtitle = storeApp.subtitle { @@ -159,6 +161,12 @@ struct AppDetailView: View { Divider() informationView + + if !(storeApp.isFromOfficialSource || storeApp.isFromTrustedSource) { + Divider() + + reportButton + } } .padding(.horizontal) } @@ -398,4 +406,12 @@ struct AppDetailView: View { } } } + + var reportButton: some View { + SwiftUI.Button { + + } label: { + Label("Report this App", systemSymbol: .exclamationmarkBubble) + } + } }