Skip to content

Commit

Permalink
Add more settings and view fixes (#591)
Browse files Browse the repository at this point in the history
  • Loading branch information
cuba authored Nov 3, 2023
1 parent 31ace8e commit 8f3ad21
Show file tree
Hide file tree
Showing 12 changed files with 295 additions and 311 deletions.
4 changes: 4 additions & 0 deletions Whisky.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
6EFDF6662AAE303300EF622F /* Icons.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6EFDF6652AAE303300EF622F /* Icons.xcassets */; };
8C2AEFC82AED79B700CB568F /* WhiskyKit in Frameworks */ = {isa = PBXBuildFile; productRef = 8C2AEFC72AED79B700CB568F /* WhiskyKit */; };
8C2AEFCA2AED79CD00CB568F /* WhiskyKit in Frameworks */ = {isa = PBXBuildFile; productRef = 8C2AEFC92AED79CD00CB568F /* WhiskyKit */; };
8C73E1342AF472FC00B6FB45 /* ProgramMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C73E1332AF472FC00B6FB45 /* ProgramMenuView.swift */; };
8CB681E52AED7C6F0018D319 /* WhiskyKit in Resources */ = {isa = PBXBuildFile; fileRef = 8CB681E42AED7C6F0018D319 /* WhiskyKit */; };
8CB681E72AED7CD00018D319 /* WhiskyKit in Frameworks */ = {isa = PBXBuildFile; productRef = 8CB681E62AED7CD00018D319 /* WhiskyKit */; };
AB66A8642A4195B10006D238 /* Rosetta2.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB66A8632A4195B10006D238 /* Rosetta2.swift */; };
Expand Down Expand Up @@ -147,6 +148,7 @@
6EFDF6522AAE2DA800EF622F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6EFDF6532AAE2DA800EF622F /* WhiskyThumbnail.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WhiskyThumbnail.entitlements; sourceTree = "<group>"; };
6EFDF6652AAE303300EF622F /* Icons.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Icons.xcassets; sourceTree = "<group>"; };
8C73E1332AF472FC00B6FB45 /* ProgramMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgramMenuView.swift; sourceTree = "<group>"; };
8CB681E42AED7C6F0018D319 /* WhiskyKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = WhiskyKit; sourceTree = "<group>"; };
AB66A8632A4195B10006D238 /* Rosetta2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Rosetta2.swift; sourceTree = "<group>"; };
EEA5A2452A31DD65008274AE /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -211,6 +213,7 @@
6E355E5929D782B2002D83BE /* ProgramsView.swift */,
6E355E5D29D7D85D002D83BE /* ProgramView.swift */,
6E17B6482AF4118F00831173 /* EnvironmentArgView.swift */,
8C73E1332AF472FC00B6FB45 /* ProgramMenuView.swift */,
);
path = Programs;
sourceTree = "<group>";
Expand Down Expand Up @@ -580,6 +583,7 @@
6E17B6462AF3FDC100831173 /* PinsView.swift in Sources */,
6E064B1429DD331F00D9A2D2 /* SparkleView.swift in Sources */,
6E40495629CCA19C006E3F1B /* WhiskyApp.swift in Sources */,
8C73E1342AF472FC00B6FB45 /* ProgramMenuView.swift in Sources */,
6E50D98329CD6066008C39F6 /* BottleVM.swift in Sources */,
6E6915452A3265BB0085BBB7 /* Logger.swift in Sources */,
6E49E0212AECB7DB00009CAC /* SettingsView.swift in Sources */,
Expand Down
168 changes: 50 additions & 118 deletions Whisky/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,16 @@
}
}
},
"button.pin" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Pin"
}
}
}
},
"button.refresh" : {
"localizations" : {
"da" : {
Expand Down Expand Up @@ -2125,6 +2135,16 @@
}
}
},
"button.unpin" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Unpin"
}
}
}
},
"button.winetricks" : {
"localizations" : {
"da" : {
Expand Down Expand Up @@ -8262,124 +8282,6 @@
}
}
},
"pin.unpin" : {
"localizations" : {
"da" : {
"stringUnit" : {
"state" : "translated",
"value" : "Unpin Program"
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Programm lösen"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Unpin Program"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Unpin Program"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Poista ohjelman kiinnitys"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Unpin Program"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "Sblocca Programma"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "ピン留めを解除"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
"value" : "프로그램 고정 해제"
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Pin verwijderen"
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Odepnij program"
}
},
"pt-BR" : {
"stringUnit" : {
"state" : "translated",
"value" : "Desafixar programa"
}
},
"pt-PT" : {
"stringUnit" : {
"state" : "translated",
"value" : "Unpin Program"
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Открепить программу"
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Sabitlenmiş Programı Kaldır"
}
},
"uk" : {
"stringUnit" : {
"state" : "translated",
"value" : "Відкріпити програму"
}
},
"vi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Unpin Program"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "取消固定此应用"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "取消程式釘選"
}
}
}
},
"program.add.blocklist" : {
"localizations" : {
"da" : {
Expand Down Expand Up @@ -8498,6 +8400,16 @@
}
}
},
"program.add.selected.blocklist" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Add Selected to Blocklist"
}
}
}
},
"program.args" : {
"localizations" : {
"da" : {
Expand Down Expand Up @@ -9088,6 +9000,26 @@
}
}
},
"program.remove.selected.blocklist" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Remove Selected from Blocklist"
}
}
}
},
"program.settings" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Settings"
}
}
}
},
"program.title" : {
"localizations" : {
"da" : {
Expand Down
14 changes: 0 additions & 14 deletions Whisky/Models/Program.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,4 @@ extension Program {
}
}
}

func togglePinned() -> Bool {
if pinned {
bottle.settings.pins.removeAll(where: { $0.url == url })
pinned = false
} else {
bottle.settings.pins.append(PinnedProgram(name: name
.replacingOccurrences(of: ".exe", with: ""),
url: url))
pinned = true
}

return pinned
}
}
44 changes: 20 additions & 24 deletions Whisky/Views/Bottle/BottleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,23 @@ enum BottleStage {
}

struct BottleView: View {
@Binding var bottle: Bottle
@ObservedObject var bottle: Bottle
@State private var path = NavigationPath()
@State var programLoading: Bool = false
@State var pins: [PinnedProgram] = []
// We don't actually care about the value
// This just provides a way to trigger a refresh
@State var loadStartMenu: Bool = false
@State var showWinetricksSheet: Bool = false

private let gridLayout = [GridItem(.adaptive(minimum: 100, maximum: .infinity))]

var body: some View {
NavigationStack(path: $path) {
ScrollView {
if pins.count > 0 {
let pinnedPrograms = bottle.programs.pinned
if pinnedPrograms.count > 0 {
LazyVGrid(columns: gridLayout, alignment: .center) {
ForEach(pins, id: \.url) { pin in
PinsView(bottle: bottle,
pin: pin,
loadStartMenu: $loadStartMenu,
path: $path)
ForEach(bottle.settings.pins, id: \.url) { pin in
PinsView(
bottle: bottle, pin: pin, path: $path
)
}
}
.padding()
Expand All @@ -72,12 +68,6 @@ struct BottleView: View {
}
}
.formStyle(.grouped)
.onAppear {
updateStartMenu()
}
.onChange(of: loadStartMenu) {
updateStartMenu()
}
}
.bottomBar {
HStack {
Expand Down Expand Up @@ -130,19 +120,27 @@ struct BottleView: View {
}
.padding()
}
.onAppear {
updateStartMenu()
}
.disabled(!bottle.isActive)
.navigationTitle(bottle.settings.name)
.sheet(isPresented: $showWinetricksSheet) {
WinetricksView(bottle: bottle)
}
.onChange(of: bottle.settings, { oldValue, newValue in
guard oldValue != newValue else { return }
// Trigger a reload
BottleVM.shared.bottles = BottleVM.shared.bottles
})
.navigationDestination(for: BottleStage.self) { stage in
switch stage {
case .config:
ConfigView(bottle: $bottle)
ConfigView(bottle: bottle)
case .programs:
ProgramsView(bottle: bottle,
reloadStartMenu: $loadStartMenu,
path: $path)
ProgramsView(
bottle: bottle, path: $path
)
}
}
.navigationDestination(for: Program.self) { program in
Expand All @@ -151,7 +149,7 @@ struct BottleView: View {
}
}

func updateStartMenu() {
private func updateStartMenu() {
bottle.programs = bottle.updateInstalledPrograms()
let startMenuPrograms = bottle.getStartMenuPrograms()
for startMenuProgram in startMenuPrograms {
Expand All @@ -166,8 +164,6 @@ struct BottleView: View {
}
}
}

pins = bottle.settings.pins
}
}

Expand Down
Loading

0 comments on commit 8f3ad21

Please sign in to comment.