Skip to content

Commit

Permalink
Early implementation of download monitor view, accessible by clicking…
Browse files Browse the repository at this point in the history
… download progressview
  • Loading branch information
vapidinfinity committed Dec 7, 2023
1 parent 93f6ed0 commit 5657748
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 9 deletions.
8 changes: 6 additions & 2 deletions Mythic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
6A00F20D2AC5F8F90054858A /* ProgressViewWithError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A00F20C2AC5F8F90054858A /* ProgressViewWithError.swift */; };
6A0585482ADEC17300165C3C /* WhiskyInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A0585472ADEC17300165C3C /* WhiskyInterface.swift */; };
6A0C66852ABC4092004B0755 /* CachedAsyncImage in Frameworks */ = {isa = PBXBuildFile; productRef = 6A0C66842ABC4092004B0755 /* CachedAsyncImage */; };
6A1322382B1C98AE0049BB64 /* InstallStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A1322372B1C98AE0049BB64 /* InstallStatus.swift */; };
6A1417B82AF7CCD80022DE24 /* FileLocations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A1417B72AF7CCD80022DE24 /* FileLocations.swift */; };
6A1C6F422AEFD95900F89AE7 /* WineInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A1C6F412AEFD95900F89AE7 /* WineInterface.swift */; };
6A1C6F462AEFD9B100F89AE7 /* WineExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A1C6F452AEFD9B100F89AE7 /* WineExt.swift */; };
Expand Down Expand Up @@ -61,6 +62,7 @@
6A00F20A2AC5F8730054858A /* Auth.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Auth.swift; sourceTree = "<group>"; };
6A00F20C2AC5F8F90054858A /* ProgressViewWithError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressViewWithError.swift; sourceTree = "<group>"; };
6A0585472ADEC17300165C3C /* WhiskyInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhiskyInterface.swift; sourceTree = "<group>"; };
6A1322372B1C98AE0049BB64 /* InstallStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallStatus.swift; sourceTree = "<group>"; };
6A1417B72AF7CCD80022DE24 /* FileLocations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileLocations.swift; sourceTree = "<group>"; };
6A1C6F412AEFD95900F89AE7 /* WineInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WineInterface.swift; sourceTree = "<group>"; };
6A1C6F452AEFD9B100F89AE7 /* WineExt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WineExt.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -249,6 +251,7 @@
6A00F20A2AC5F8730054858A /* Auth.swift */,
6A371B502AE7A4870054BF7A /* Onboarding */,
6A00F2082AC5F7DE0054858A /* ProgressView */,
6A1322372B1C98AE0049BB64 /* InstallStatus.swift */,
);
path = Base;
sourceTree = "<group>";
Expand Down Expand Up @@ -540,6 +543,7 @@
6A1C6F462AEFD9B100F89AE7 /* WineExt.swift in Sources */,
6AA6CCE72AD571C500F664A5 /* LegendaryExt.swift in Sources */,
6AD5065C2AAFF6F0008A28C1 /* Support.swift in Sources */,
6A1322382B1C98AE0049BB64 /* InstallStatus.swift in Sources */,
6AD5065A2AAFF6E2008A28C1 /* Wine.swift in Sources */,
6AF0EB1F2AAD4E0A0044C09C /* Onboarding.swift in Sources */,
6AC25CBD2AAED24700D395CF /* Settings.swift in Sources */,
Expand Down Expand Up @@ -695,7 +699,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2008;
CURRENT_PROJECT_VERSION = 2014;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Mythic/Preview Content\"";
DEVELOPMENT_TEAM = 67ZBY275P8;
Expand Down Expand Up @@ -734,7 +738,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2008;
CURRENT_PROJECT_VERSION = 2014;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Mythic/Preview Content\"";
DEVELOPMENT_TEAM = 67ZBY275P8;
Expand Down
23 changes: 17 additions & 6 deletions Mythic/Views/Base/GameList/GameList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ struct GameListView: View {
@State private var installableGames: [Legendary.Game] = Array()
@State private var installedGames: [Legendary.Game] = Array()
@StateObject private var installing = Legendary.Installing.shared

@State private var isInstallStatusViewPresented: Bool = false

@State private var gameThumbnails: [String: String] = Dictionary()
@State private var optionalPacks: [String: String] = Dictionary()
Expand Down Expand Up @@ -181,13 +183,18 @@ struct GameListView: View {
.controlSize(.large)
} else {
if installing._value && installing._game == game {
if installing._status.progress?.percentage == nil {
ProgressView()
.progressViewStyle(.linear)
} else {
ProgressView(value: installing._status.progress?.percentage, total: 100)
.progressViewStyle(.linear)
Button {
isInstallStatusViewPresented = true
} label: {
if installing._status.progress?.percentage == nil {
ProgressView()
.progressViewStyle(.linear)
} else {
ProgressView(value: installing._status.progress?.percentage, total: 100)
.progressViewStyle(.linear)
}
}
.buttonStyle(.plain)

Button {
Logger.app.warning("Stop install not implemented yet; execute \"killall cli\" lol")
Expand Down Expand Up @@ -315,6 +322,10 @@ struct GameListView: View {
isGameListRefreshCalled: $isRefreshCalled
)
}

.sheet(isPresented: $isInstallStatusViewPresented) {
InstallStatusView(isPresented: $isInstallStatusViewPresented)
}

.alert(isPresented: $isAlertPresented) {
switch activeAlert {
Expand Down
7 changes: 6 additions & 1 deletion Mythic/Views/Navigation/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import CachedAsyncImage

struct MainView: View {
@State private var isAuthViewPresented: Bool = false
@State private var isInstallStatusViewPresented: Bool = false

@State private var epicUserAsync: String = "Loading..."
@State private var signedIn: Bool = false
Expand Down Expand Up @@ -109,7 +110,7 @@ struct MainView: View {

HStack {
Button {
// Not implemented
isInstallStatusViewPresented = true
} label: {
if installing._status.progress?.percentage == nil {
ProgressView()
Expand Down Expand Up @@ -194,6 +195,10 @@ struct MainView: View {
updateLegendaryAccountState()
}
}

.sheet(isPresented: $isInstallStatusViewPresented) {
InstallStatusView(isPresented: $isInstallStatusViewPresented)
}
.listStyle(SidebarListStyle())
.frame(minWidth: 150, idealWidth: 250, maxWidth: 300)
.toolbar {
Expand Down
38 changes: 38 additions & 0 deletions Mythic/Views/Sheets/Base/InstallStatus.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// InstallStatus.swift
// Mythic
//
// Created by Esiayo Alegbe on 3/12/2023.
//

import SwiftUI
import Foundation
import Charts // TBA

struct InstallStatusView: View {
private let status: Legendary.InstallStatus = Legendary.Installing.installStatus
@Binding var isPresented: Bool

var body: some View {
VStack {
Text("Downloading \(Legendary.Installing.game?.title ?? "[unknown]")")
.font(.title)

GroupBox {
Text("Progress: \(Int(status.progress?.percentage ?? 0))% (\(status.progress?.downloaded ?? 0)/\(status.progress?.total ?? 0) objects)")
Text("Downloaded \(status.download?.downloaded ?? 0) MiB, Written \(status.download?.written ?? 0)")
Text("Elapsed: \("\(status.progress?.runtime ?? "[unknown]")"), ETA: \("\(status.progress?.eta ?? "[unknown]")")")
}
.fixedSize()

Button("Close") { isPresented = false }
.buttonStyle(.borderedProminent)
.foregroundStyle(.accent)
}
.padding()
}
}

#Preview {
InstallStatusView(isPresented: .constant(true))
}

0 comments on commit 5657748

Please sign in to comment.