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 few bugs in custom action configuration view #547

Merged
Show file tree
Hide file tree
Changes from 5 commits
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
31 changes: 23 additions & 8 deletions Loop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
A83E1C352ABFCA3200853FE9 /* WindowRecords.swift in Sources */ = {isa = PBXBuildFile; fileRef = A83E1C342ABFCA3200853FE9 /* WindowRecords.swift */; };
A8427E662C02594E00F20759 /* ExcludedAppsConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8427E652C02594E00F20759 /* ExcludedAppsConfiguration.swift */; };
A848D8A72A8C2F3F00060834 /* LoopManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A848D8A62A8C2F3F00060834 /* LoopManager.swift */; };
A849C60B2C817FD100608009 /* Luminare in Frameworks */ = {isa = PBXBuildFile; productRef = A849C60A2C817FD100608009 /* Luminare */; };
MrKai77 marked this conversation as resolved.
Show resolved Hide resolved
A849C60E2C817FDF00608009 /* Luminare in Frameworks */ = {isa = PBXBuildFile; productRef = A849C60D2C817FDF00608009 /* Luminare */; };
A858914B2BDC5D3F00C10FB1 /* AdvancedConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = A858914A2BDC5D3F00C10FB1 /* AdvancedConfiguration.swift */; };
A859799B2B55FE94009FB067 /* UNNotification+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A859799A2B55FE94009FB067 /* UNNotification+Extensions.swift */; };
A85B560E2AAAD62C00386ACE /* EventMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = A85B560D2AAAD62C00386ACE /* EventMonitor.swift */; };
Expand All @@ -58,7 +60,6 @@
A87F78942BAE28050087B1DE /* CustomWindowActionSizeMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = A87F78932BAE28050087B1DE /* CustomWindowActionSizeMode.swift */; };
A87F78962BAE333C0087B1DE /* CustomWindowActionPositionMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = A87F78952BAE333C0087B1DE /* CustomWindowActionPositionMode.swift */; };
A883642F298B7288005D6C19 /* ServiceManagement.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A883642E298B7288005D6C19 /* ServiceManagement.framework */; };
A88699DE2C815E3B007EBF47 /* Luminare in Frameworks */ = {isa = PBXBuildFile; productRef = A88699DD2C815E3B007EBF47 /* Luminare */; };
A8878A252AA3B2C800850A66 /* WindowTransformAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8878A242AA3B2C800850A66 /* WindowTransformAnimation.swift */; };
A88E27AD2BDDE5300042CF04 /* CustomActionConfigurationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A88E27AC2BDDE5300042CF04 /* CustomActionConfigurationView.swift */; };
A88E83C52B37B354009D332F /* CGEvent+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A88E83C42B37B354009D332F /* CGEvent+Extensions.swift */; };
Expand Down Expand Up @@ -199,8 +200,9 @@
buildActionMask = 2147483647;
files = (
A8DCC97B2980D5F500D41065 /* Defaults in Frameworks */,
A88699DE2C815E3B007EBF47 /* Luminare in Frameworks */,
A849C60B2C817FD100608009 /* Luminare in Frameworks */,
A800418A2C7C110F005AD0D3 /* Luminare in Frameworks */,
A849C60E2C817FDF00608009 /* Luminare in Frameworks */,
A883642F298B7288005D6C19 /* ServiceManagement.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -487,7 +489,8 @@
packageProductDependencies = (
A8DCC97A2980D5F500D41065 /* Defaults */,
A80041892C7C110F005AD0D3 /* Luminare */,
A88699DD2C815E3B007EBF47 /* Luminare */,
A849C60A2C817FD100608009 /* Luminare */,
A849C60D2C817FDF00608009 /* Luminare */,
);
productName = WindowManager;
productReference = A8E59C35297F5E9A0064D4BA /* Loop.app */;
Expand Down Expand Up @@ -530,7 +533,8 @@
mainGroup = A8E59C2C297F5E9A0064D4BA;
packageReferences = (
A8DCC9792980D5F500D41065 /* XCRemoteSwiftPackageReference "Defaults" */,
A88699DC2C815E3B007EBF47 /* XCRemoteSwiftPackageReference "Luminare" */,
A849C6092C817FD100608009 /* XCRemoteSwiftPackageReference "DynamicNotchKit" */,
MrKai77 marked this conversation as resolved.
Show resolved Hide resolved
A849C60C2C817FDF00608009 /* XCLocalSwiftPackageReference "../Luminare" */,
);
productRefGroup = A8E59C36297F5E9A0064D4BA /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -896,10 +900,17 @@
};
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
A849C60C2C817FDF00608009 /* XCLocalSwiftPackageReference "../Luminare" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = ../Luminare;
};
/* End XCLocalSwiftPackageReference section */

/* Begin XCRemoteSwiftPackageReference section */
A88699DC2C815E3B007EBF47 /* XCRemoteSwiftPackageReference "Luminare" */ = {
A849C6092C817FD100608009 /* XCRemoteSwiftPackageReference "DynamicNotchKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/MrKai77/Luminare";
repositoryURL = "https://github.com/MrKai77/DynamicNotchKit";
requirement = {
branch = main;
kind = branch;
Expand All @@ -920,9 +931,13 @@
isa = XCSwiftPackageProductDependency;
productName = Luminare;
};
A88699DD2C815E3B007EBF47 /* Luminare */ = {
A849C60A2C817FD100608009 /* Luminare */ = {
isa = XCSwiftPackageProductDependency;
package = A849C6092C817FD100608009 /* XCRemoteSwiftPackageReference "DynamicNotchKit" */;
productName = Luminare;
};
A849C60D2C817FDF00608009 /* Luminare */ = {
isa = XCSwiftPackageProductDependency;
package = A88699DC2C815E3B007EBF47 /* XCRemoteSwiftPackageReference "Luminare" */;
productName = Luminare;
};
A8DCC97A2980D5F500D41065 /* Defaults */ = {
Expand Down
111 changes: 23 additions & 88 deletions Loop/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "%@ нуждается в разрешении универсального доступа"
"value" : "%@ нужны разрешения универсального доступа"
}
},
"zh-Hans" : {
Expand Down Expand Up @@ -999,7 +999,7 @@
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Продвинутые"
"value" : "Дополнительные настройки"
}
},
"zh-Hans" : {
Expand Down Expand Up @@ -3316,7 +3316,7 @@
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Двойное нажатие чтобы активировать"
"value" : "Двойное нажатие для активации"
}
},
"zh-Hans" : {
Expand Down Expand Up @@ -7141,7 +7141,7 @@
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Зайти в Discord"
"value" : "Перейти в Discord"
}
},
"zh-Hans" : {
Expand Down Expand Up @@ -7492,7 +7492,7 @@
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Влево %@"
"value" : "Левый %@"
}
},
"zh-Hans" : {
Expand Down Expand Up @@ -9999,26 +9999,26 @@
"plural" : {
"few" : {
"stringUnit" : {
"state" : "new",
"value" : "%lld Loops left"
"state" : "translated",
"value" : "Осталось %lld Loop’ов"
}
},
"many" : {
"stringUnit" : {
"state" : "new",
"value" : "%lld Loops left"
"state" : "translated",
"value" : "Осталось %lld Loop’ов"
}
},
"one" : {
"stringUnit" : {
"state" : "new",
"value" : "%lld Loop left"
"state" : "translated",
"value" : "Остался %lld Loop"
}
},
"other" : {
"stringUnit" : {
"state" : "new",
"value" : "%lld Loops left"
"state" : "translated",
"value" : "Осталось %lld Loop’ов"
}
}
}
Expand Down Expand Up @@ -10477,7 +10477,7 @@
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Двигать курсор за окном"
"value" : "Перемещать курсор за окном"
}
},
"zh-Hans" : {
Expand Down Expand Up @@ -10547,7 +10547,7 @@
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Нет игнорированных приложений"
"value" : "Нет игнорируемых приложений"
}
},
"zh-Hans" : {
Expand Down Expand Up @@ -16330,7 +16330,7 @@
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Вправо %@"
"value" : "Правый %@"
}
},
"zh-Hans" : {
Expand Down Expand Up @@ -16621,7 +16621,7 @@
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Отправить"
"value" : "Обратная связь"
}
},
"zh-Hans" : {
Expand Down Expand Up @@ -20768,6 +20768,12 @@
"value" : "Centro do macOS"
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "macOS Центр"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
Expand Down Expand Up @@ -22700,77 +22706,6 @@
}
}
},
"Window Manipulation" : {
"extractionState" : "stale",
"localizations" : {
"ar" : {
"stringUnit" : {
"state" : "translated",
"value" : "تلاعب النافذة"
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Fenstermanipulation"
}
},
"en-GB" : {
"stringUnit" : {
"state" : "translated",
"value" : "Window Manipulation"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Manipulación de ventanas"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "Manipolazione finestra"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
"value" : "윈도우 조작"
}
},
"nl-BE" : {
"stringUnit" : {
"state" : "translated",
"value" : "Venster Manipulatie"
}
},
"pt-BR" : {
"stringUnit" : {
"state" : "translated",
"value" : "Manipulação de Janelas"
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Управление окнами"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "窗口操作"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "視窗操作"
}
}
}
},
"Window snapping" : {
"localizations" : {
"ar" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct CustomActionConfigurationView: View {
ScreenView {
GeometryReader { geo in
let frame = action.getFrame(window: nil, bounds: CGRect(origin: .zero, size: geo.size), disablePadding: true)
let _ = print(frame)
ZStack {
if action.sizeMode == .custom {
blurredWindow()
Expand Down Expand Up @@ -73,10 +74,38 @@ struct CustomActionConfigurationView: View {
unitToggle()
}

if currentTab == .position {
positionConfiguration()
} else {
sizeConfiguration()
Group {
if currentTab == .position {
positionConfiguration()
} else {
sizeConfiguration()
}
}
.animation(LuminareSettingsWindow.animation, value: action.unit)
.onAppear {
if action.unit == nil {
action.unit = .percentage
}

if action.sizeMode == nil {
action.sizeMode = .custom
}

if action.width == nil {
action.width = 80
}

if action.height == nil {
action.height = 80
}

if action.positionMode == nil {
action.positionMode = .generic
}

if action.anchor == nil {
action.anchor = .center
}
}
}

Expand All @@ -96,21 +125,27 @@ struct CustomActionConfigurationView: View {

@ViewBuilder private func actionButtons() -> some View {
HStack(spacing: 8) {
Button("Preview") {
previewAction()
}
.disabled(action.sizeMode != .custom)
Button("Preview") {}
.onLongPressGesture( // Allows for a press-and-hold gesture to show the preview
minimumDuration: 100.0,
maximumDistance: .infinity,
pressing: { pressing in
if pressing {
guard let screen = NSScreen.main else { return }
previewController.open(screen: screen, startingAction: action)
} else {
previewController.close()
}
},
perform: {}
)
.disabled(action.sizeMode != .custom)

Button("Close") { isPresented = false }
}
.buttonStyle(LuminareCompactButtonStyle())
}

private func previewAction() {
guard let screen = NSScreen.main else { return }
previewController.open(screen: screen, startingAction: action)
}

@ViewBuilder private func positionConfiguration() -> some View {
LuminareSection {
LuminareToggle(
Expand Down Expand Up @@ -176,7 +211,7 @@ struct CustomActionConfigurationView: View {
action.xPoint = $0
}
),
sliderRange: action.unit == .percentage ?
sliderRange: action.unit != .percentage ?
0...100 :
0...Double(screenSize.width),
suffix: .init(action.unit?.suffix ?? CustomWindowActionUnit.percentage.suffix),
Expand All @@ -193,7 +228,7 @@ struct CustomActionConfigurationView: View {
action.yPoint = $0
}
),
sliderRange: action.unit == .percentage ?
sliderRange: action.unit != .percentage ?
0...100 :
0...Double(screenSize.height),
suffix: .init(action.unit?.suffix ?? CustomWindowActionUnit.percentage.suffix),
Expand Down
Loading