From a6ca73f8fcfc6b007b9f745cd5b54aef263e880c Mon Sep 17 00:00:00 2001 From: Fabian Thies Date: Fri, 13 Jan 2023 12:02:06 +0100 Subject: [PATCH] [WIP] AppIDs view in My Apps section --- AltStore.xcodeproj/project.pbxproj | 4 ++ AltStore/Views/My Apps/AppIDsView.swift | 58 +++++++++++++++++++++++++ AltStore/Views/My Apps/MyAppsView.swift | 23 +++++++--- 3 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 AltStore/Views/My Apps/AppIDsView.swift diff --git a/AltStore.xcodeproj/project.pbxproj b/AltStore.xcodeproj/project.pbxproj index 5201a004..43f4a39f 100644 --- a/AltStore.xcodeproj/project.pbxproj +++ b/AltStore.xcodeproj/project.pbxproj @@ -22,6 +22,7 @@ 1F07F5672955D16A00F7BE95 /* SFSafeSymbols in Frameworks */ = {isa = PBXBuildFile; productRef = 1F07F5662955D16A00F7BE95 /* SFSafeSymbols */; }; 1F07F5692955D3EC00F7BE95 /* SFSafeSymbols in Frameworks */ = {isa = PBXBuildFile; productRef = 1F07F5682955D3EC00F7BE95 /* SFSafeSymbols */; }; 1F07F56B2955F11500F7BE95 /* AppScreenshotsPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F07F56A2955F11500F7BE95 /* AppScreenshotsPreview.swift */; }; + 1F07F56F2955FB2000F7BE95 /* AppIDsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F07F56E2955FB2000F7BE95 /* AppIDsView.swift */; }; 1F0DD81C2932D2FF007608A4 /* AppScreenshotsScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F0DD81B2932D2FF007608A4 /* AppScreenshotsScrollView.swift */; }; 1F0DD81F2932D84C007608A4 /* ExpandableText in Frameworks */ = {isa = PBXBuildFile; productRef = 1F0DD81E2932D84C007608A4 /* ExpandableText */; }; 1F0DD8212933B749007608A4 /* AppPermissionsGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F0DD8202933B749007608A4 /* AppPermissionsGrid.swift */; }; @@ -559,6 +560,7 @@ 1920B04E2924AC8300744F60 /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = ""; }; 19B9B7442845E6DF0076EF69 /* SelectTeamViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectTeamViewController.swift; sourceTree = ""; }; 1F07F56A2955F11500F7BE95 /* AppScreenshotsPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppScreenshotsPreview.swift; sourceTree = ""; }; + 1F07F56E2955FB2000F7BE95 /* AppIDsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIDsView.swift; sourceTree = ""; }; 1F0DD81B2932D2FF007608A4 /* AppScreenshotsScrollView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppScreenshotsScrollView.swift; sourceTree = ""; }; 1F0DD8202933B749007608A4 /* AppPermissionsGrid.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppPermissionsGrid.swift; sourceTree = ""; }; 1F0DD83E29367F6C007608A4 /* ConnectAppleIDView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectAppleIDView.swift; sourceTree = ""; }; @@ -1154,6 +1156,7 @@ 1FAFC5BD2927E10D00B8D837 /* MyAppsView.swift */, 1FA1C8C9294906890083119D /* MyAppsViewModel.swift */, 1F6284D4295209DA0060AAD8 /* AppAction.swift */, + 1F07F56E2955FB2000F7BE95 /* AppIDsView.swift */, ); path = "My Apps"; sourceTree = ""; @@ -2792,6 +2795,7 @@ 1F6284D7295218980060AAD8 /* DocumentPicker.swift in Sources */, BFBE0007250AD0E70080826E /* ViewAppIntentHandler.swift in Sources */, 1F0DD83F29367F6C007608A4 /* ConnectAppleIDView.swift in Sources */, + 1F07F56F2955FB2000F7BE95 /* AppIDsView.swift in Sources */, BFDB6A0822AAED73007EA6D6 /* ResignAppOperation.swift in Sources */, D593F1942717749A006E82DE /* PatchAppOperation.swift in Sources */, BF770E5122BB1CF6002A40FE /* InstallAppOperation.swift in Sources */, diff --git a/AltStore/Views/My Apps/AppIDsView.swift b/AltStore/Views/My Apps/AppIDsView.swift new file mode 100644 index 00000000..8aebbb17 --- /dev/null +++ b/AltStore/Views/My Apps/AppIDsView.swift @@ -0,0 +1,58 @@ +// +// AppIDsView.swift +// SideStore +// +// Created by Fabian Thies on 23.12.22. +// Copyright © 2022 SideStore. All rights reserved. +// + +import SwiftUI +import AltStoreCore + +struct AppIDsView: View { + + @Environment(\.dismiss) var dismiss + + @SwiftUI.FetchRequest(sortDescriptors: [ + NSSortDescriptor(keyPath: \AppID.name, ascending: true), + NSSortDescriptor(keyPath: \AppID.bundleIdentifier, ascending: true), + NSSortDescriptor(keyPath: \AppID.expirationDate, ascending: true) + ], predicate: NSPredicate(format: "%K == %@", #keyPath(AppID.team), DatabaseManager.shared.activeTeam() ?? Team())) + var appIDs: FetchedResults + + + var body: some View { + ScrollView { + LazyVStack(alignment: .leading) { + Text("Each app and app extension installed with SideStore must register an App ID with Apple.\n\nApp IDs for paid developer accounts never expire, and there is no limit to how many you can create.") + .foregroundColor(.secondary) + + ForEach(appIDs, id: \.identifier) { appId in + VStack { + Text(appId.name) + + Text(appId.identifier) + .font(.callout) + .foregroundColor(.secondary) + } + .padding() + .tintedBackground(.accentColor) + .clipShape(RoundedRectangle(cornerRadius: 30, style: .circular)) + } + } + .padding() + } + .navigationTitle("App IDs") + .toolbar { + ToolbarItem(placement: .navigationBarTrailing) { + SwiftUI.Button("Done", action: self.dismiss) + } + } + } +} + +struct AppIDsView_Previews: PreviewProvider { + static var previews: some View { + AppIDsView() + } +} diff --git a/AltStore/Views/My Apps/MyAppsView.swift b/AltStore/Views/My Apps/MyAppsView.swift index 5f70dbbe..9a48c5dd 100644 --- a/AltStore/Views/My Apps/MyAppsView.swift +++ b/AltStore/Views/My Apps/MyAppsView.swift @@ -39,6 +39,8 @@ struct MyAppsView: View { @State var isShowingFilePicker: Bool = false @State var selectedSideloadingIpaURL: URL? + @State var isShowingAppIDsView: Bool = false + var remainingAppIDs: Int { guard let team = DatabaseManager.shared.activeTeam() else { return 0 @@ -77,7 +79,7 @@ struct MyAppsView: View { if updates.isEmpty { if shouldShowAppUpdateHint { - updatesSection + updatesSection } } @@ -108,14 +110,21 @@ struct MyAppsView: View { } VStack { - Text("\(remainingAppIDs) App IDs Remaining") - .foregroundColor(.secondary) + if DatabaseManager.shared.activeTeam()?.type == .free { + Text("\(remainingAppIDs) App IDs Remaining") + .foregroundColor(.secondary) + } SwiftUI.Button { - + self.isShowingAppIDsView = true } label: { Text("View App IDs") } + .sheet(isPresented: self.$isShowingAppIDsView) { + NavigationView { + AppIDsView() + } + } } } .padding(.horizontal) @@ -149,7 +158,7 @@ struct MyAppsView: View { VStack(alignment: .leading, spacing: 8) { HStack(alignment: .center) { Text("All Apps are Up To Date") - .bold() + .bold() Spacer() Menu { @@ -172,8 +181,8 @@ struct MyAppsView: View { Text("You will be notified once updates for your apps are available. The updates will then be shown here.") .font(.callout) } - .foregroundColor(.secondary) - .padding() + .foregroundColor(.secondary) + .padding() .background(Color(.tertiarySystemBackground)) .clipShape(RoundedRectangle(cornerRadius: 8)) }