Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix view sizes #916

Merged
merged 4 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Whisky.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
6365C4C12B1AA69D00AAE1FD /* Animation+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6365C4C02B1AA69D00AAE1FD /* Animation+Extensions.swift */; };
6365C4C32B1AA8CD00AAE1FD /* BottleListEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6365C4C22B1AA8CD00AAE1FD /* BottleListEntry.swift */; };
63FFDE862ADF0C7700178665 /* BottomBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63FFDE852ADF0C7700178665 /* BottomBar.swift */; };
6763D8F62BC6314100651D27 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6763D8F52BC6314100651D27 /* Constants.swift */; };
6763D8F82BC632A800651D27 /* View+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6763D8F72BC632A800651D27 /* View+Extension.swift */; };
67D278512BC5907E006F9A1E /* ActionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67D278502BC5907E006F9A1E /* ActionView.swift */; };
6E064B1229DD32A200D9A2D2 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 6E064B1129DD32A200D9A2D2 /* Sparkle */; };
6E064B1429DD331F00D9A2D2 /* SparkleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E064B1329DD331F00D9A2D2 /* SparkleView.swift */; };
Expand Down Expand Up @@ -113,6 +115,8 @@
6365C4C02B1AA69D00AAE1FD /* Animation+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Animation+Extensions.swift"; sourceTree = "<group>"; };
6365C4C22B1AA8CD00AAE1FD /* BottleListEntry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottleListEntry.swift; sourceTree = "<group>"; };
63FFDE852ADF0C7700178665 /* BottomBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BottomBar.swift; sourceTree = "<group>"; };
6763D8F52BC6314100651D27 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
6763D8F72BC632A800651D27 /* View+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Extension.swift"; sourceTree = "<group>"; };
67D278502BC5907E006F9A1E /* ActionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionView.swift; sourceTree = "<group>"; };
6E064B1329DD331F00D9A2D2 /* SparkleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SparkleView.swift; sourceTree = "<group>"; };
6E17B6452AF3FDC100831173 /* PinView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PinView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -202,6 +206,7 @@
children = (
6E40498229CCA91B006E3F1B /* Bottle+Extensions.swift */,
6365C4C02B1AA69D00AAE1FD /* Animation+Extensions.swift */,
6763D8F72BC632A800651D27 /* View+Extension.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -347,6 +352,7 @@
6E621CEE2A5F631200C9AAB3 /* Winetricks.swift */,
6E70A4A02A9A280C007799E9 /* WhiskyCmd.swift */,
6E7C07BD2AAE7B0100F6E66B /* ProgramShortcut.swift */,
6763D8F52BC6314100651D27 /* Constants.swift */,
);
path = Utils;
sourceTree = "<group>";
Expand Down Expand Up @@ -583,6 +589,7 @@
buildActionMask = 2147483647;
files = (
EEA5A2462A31DD65008274AE /* AppDelegate.swift in Sources */,
6763D8F62BC6314100651D27 /* Constants.swift in Sources */,
6E70A4A12A9A280C007799E9 /* WhiskyCmd.swift in Sources */,
6E40495829CCA19C006E3F1B /* ContentView.swift in Sources */,
67D278512BC5907E006F9A1E /* ActionView.swift in Sources */,
Expand All @@ -593,6 +600,7 @@
6E355E5829D78249002D83BE /* ConfigView.swift in Sources */,
63FFDE862ADF0C7700178665 /* BottomBar.swift in Sources */,
6E6C0CF62A419A8300356232 /* WhiskyWineDownloadView.swift in Sources */,
6763D8F82BC632A800651D27 /* View+Extension.swift in Sources */,
6365C4C32B1AA8CD00AAE1FD /* BottleListEntry.swift in Sources */,
6E50D98529CDF25B008C39F6 /* BottleCreationView.swift in Sources */,
6E182FCA2B0BF64E00AADE81 /* WinetricksView.swift in Sources */,
Expand Down
29 changes: 29 additions & 0 deletions Whisky/Extensions/View+Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// View+Extension.swift
// Whisky
//
// This file is part of Whisky.
//
// Whisky is free software: you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Whisky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with Whisky.
// If not, see https://www.gnu.org/licenses/.
//

import SwiftUI

extension View {
func fixedHorizontalSize() -> some View {
IsaacMarovitz marked this conversation as resolved.
Show resolved Hide resolved
self.fixedSize(horizontal: true, vertical: false)
}

func fixedVerticalSize() -> some View {
zorikon marked this conversation as resolved.
Show resolved Hide resolved
self.fixedSize(horizontal: false, vertical: true)
}
}
28 changes: 28 additions & 0 deletions Whisky/Utils/Constants.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// Constants.swift
// Whisky
//
// This file is part of Whisky.
//
// Whisky is free software: you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Whisky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with Whisky.
// If not, see https://www.gnu.org/licenses/.
//

import Foundation

enum Constant {
zorikon marked this conversation as resolved.
Show resolved Hide resolved
// swiftlint:disable:next type_name
enum width {
static let small: Double = 400
static let medium: Double = 500
static let large: Double = 600
}
}
3 changes: 2 additions & 1 deletion Whisky/Views/Bottle/BottleCreationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ struct BottleCreationView: View {
submit()
}
}
.frame(minWidth: 400, minHeight: 210)
.fixedVerticalSize()
.frame(width: Constant.width.small)
}

func submit() {
Expand Down
2 changes: 1 addition & 1 deletion Whisky/Views/Bottle/ConfigView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ struct DPIConfigSheetView: View {
}
}
.padding()
.frame(width: 500, height: 240)
.frame(width: Constant.width.medium, height: 240)
}
}

Expand Down
4 changes: 2 additions & 2 deletions Whisky/Views/Bottle/Pins/PinCreationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ struct PinCreationView: View {
submit()
}
}
.fixedSize(horizontal: false, vertical: true)
.frame(minWidth: 400)
.fixedVerticalSize()
.frame(minWidth: Constant.width.small)
}

func submit() {
Expand Down
2 changes: 1 addition & 1 deletion Whisky/Views/Bottle/WinetricksView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ struct WinetricksView: View {
winetricks = await Winetricks.parseVerbs()
}
}
.frame(minWidth: 600, minHeight: 400)
.frame(minWidth: Constant.width.large, minHeight: 400)
}
}
3 changes: 2 additions & 1 deletion Whisky/Views/Common/RenameView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ struct RenameView: View {
submit()
}
}
.frame(minWidth: 350, minHeight: 115)
.fixedVerticalSize()
.frame(minWidth: Constant.width.small)
}

var isNameValid: Bool {
Expand Down
3 changes: 2 additions & 1 deletion Whisky/Views/FileOpenView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ struct FileOpenView: View {
}
}
}
.frame(minWidth: 400, minHeight: 115)
.fixedVerticalSize()
.frame(width: Constant.width.small)
.onAppear {
// Makes sure there are more than 0 bottles.
// Otherwise, it will crash on the nil cascade
Expand Down
3 changes: 2 additions & 1 deletion Whisky/Views/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ struct SettingsView: View {
}
}
.formStyle(.grouped)
.frame(width: 500, height: 250)
.fixedVerticalSize()
.frame(width: Constant.width.medium)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Whisky/Views/WhiskyApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct WhiskyApp: App {
var body: some Scene {
WindowGroup {
ContentView(showSetup: $showSetup)
.frame(minWidth: 550, minHeight: 250)
.frame(minWidth: Constant.width.large, minHeight: 316)
.environmentObject(BottleVM.shared)
.onAppear {
NSWindow.allowsAutomaticWindowTabbing = false
Expand Down
Loading