mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-16 10:13:27 +01:00
[FIX] AppIDsView and authentication workflow
This commit is contained in:
committed by
Joe Mattiello
parent
5af6f825ee
commit
0239dfcd6d
@@ -39,8 +39,8 @@ final class AuthenticationOperation: ResultOperation<(ALTTeam, ALTCertificate, A
|
|||||||
{
|
{
|
||||||
let context: AuthenticatedOperationContext
|
let context: AuthenticatedOperationContext
|
||||||
|
|
||||||
// private weak var presentingViewController: UIViewController?
|
private weak var presentingViewController: UIViewController?
|
||||||
//
|
|
||||||
// private lazy var navigationController: UINavigationController = {
|
// private lazy var navigationController: UINavigationController = {
|
||||||
// let navigationController = self.storyboard.instantiateViewController(withIdentifier: "navigationController") as! UINavigationController
|
// let navigationController = self.storyboard.instantiateViewController(withIdentifier: "navigationController") as! UINavigationController
|
||||||
// if #available(iOS 13.0, *)
|
// if #available(iOS 13.0, *)
|
||||||
@@ -63,7 +63,7 @@ final class AuthenticationOperation: ResultOperation<(ALTTeam, ALTCertificate, A
|
|||||||
init(context: AuthenticatedOperationContext, presentingViewController: UIViewController?)
|
init(context: AuthenticatedOperationContext, presentingViewController: UIViewController?)
|
||||||
{
|
{
|
||||||
self.context = context
|
self.context = context
|
||||||
// self.presentingViewController = presentingViewController
|
self.presentingViewController = presentingViewController
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
@@ -312,7 +312,10 @@ private extension AuthenticationOperation
|
|||||||
}
|
}
|
||||||
|
|
||||||
func dismiss() {
|
func dismiss() {
|
||||||
UIApplication.shared.keyWindow?.rootViewController?.presentedViewController?.dismiss(animated: true)
|
if let presentingViewController {
|
||||||
|
presentingViewController.dismiss(animated: true)
|
||||||
|
}
|
||||||
|
// UIApplication.shared.keyWindow?.rootViewController?.presentedViewController?.dismiss(animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ struct AppIDsView: View {
|
|||||||
NSSortDescriptor(keyPath: \AppID.expirationDate, ascending: true)
|
NSSortDescriptor(keyPath: \AppID.expirationDate, ascending: true)
|
||||||
], predicate: NSPredicate(format: "%K == %@", #keyPath(AppID.team), DatabaseManager.shared.activeTeam() ?? Team()))
|
], predicate: NSPredicate(format: "%K == %@", #keyPath(AppID.team), DatabaseManager.shared.activeTeam() ?? Team()))
|
||||||
var appIDs: FetchedResults<AppID>
|
var appIDs: FetchedResults<AppID>
|
||||||
|
|
||||||
|
@State var isLoading: Bool = false
|
||||||
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@@ -28,31 +30,90 @@ struct AppIDsView: View {
|
|||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
|
|
||||||
ForEach(appIDs, id: \.identifier) { appId in
|
ForEach(appIDs, id: \.identifier) { appId in
|
||||||
VStack {
|
HStack {
|
||||||
Text(appId.name)
|
VStack(alignment: .leading) {
|
||||||
|
Text(appId.name)
|
||||||
Text(appId.identifier)
|
.bold()
|
||||||
.font(.callout)
|
|
||||||
.foregroundColor(.secondary)
|
Text(appId.bundleIdentifier)
|
||||||
|
.font(.footnote)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
if let expirationDate = appId.expirationDate {
|
||||||
|
VStack(spacing: 4) {
|
||||||
|
Text("Expires in")
|
||||||
|
.font(.caption)
|
||||||
|
.foregroundColor(.accentColor)
|
||||||
|
|
||||||
|
SwiftUI.Button {
|
||||||
|
|
||||||
|
} label: {
|
||||||
|
Text(DateFormatterHelper.string(forExpirationDate: expirationDate).uppercased())
|
||||||
|
.bold()
|
||||||
|
}
|
||||||
|
.buttonStyle(PillButtonStyle(tintColor: .altPrimary))
|
||||||
|
.disabled(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
.tintedBackground(.accentColor)
|
.tintedBackground(.accentColor)
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 30, style: .circular))
|
.clipShape(RoundedRectangle(cornerRadius: 24, style: .circular))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
.navigationTitle(L10n.AppIDsView.title)
|
.navigationTitle(L10n.AppIDsView.title)
|
||||||
.toolbar {
|
.toolbar {
|
||||||
|
ToolbarItem(placement: .cancellationAction) {
|
||||||
|
if self.isLoading {
|
||||||
|
ProgressView()
|
||||||
|
.progressViewStyle(.circular)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ToolbarItem(placement: .confirmationAction) {
|
ToolbarItem(placement: .confirmationAction) {
|
||||||
SwiftUI.Button(L10n.Action.done, action: self.dismiss)
|
SwiftUI.Button(L10n.Action.done, action: self.dismiss)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.onAppear(performAsync: self.updateAppIDs)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func updateAppIDs() async {
|
||||||
|
self.isLoading = true
|
||||||
|
defer { self.isLoading = false }
|
||||||
|
|
||||||
|
await withCheckedContinuation { continuation in
|
||||||
|
AppManager.shared.fetchAppIDs { result in
|
||||||
|
do {
|
||||||
|
let (_, context) = try result.get()
|
||||||
|
try context.save()
|
||||||
|
} catch {
|
||||||
|
print(error)
|
||||||
|
NotificationManager.shared.reportError(error: error)
|
||||||
|
}
|
||||||
|
|
||||||
|
continuation.resume()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AppIDsView_Previews: PreviewProvider {
|
extension View {
|
||||||
static var previews: some View {
|
|
||||||
AppIDsView()
|
func onAppear(performAsync task: @escaping () async -> Void) -> some View {
|
||||||
|
self.onAppear(perform: { Task { await task() } })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AppIDsView_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
NavigationView {
|
||||||
|
AppIDsView()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user