mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2026-04-03 09:50:10 +02:00
👌 Cleanup
This commit is contained in:
@@ -28,6 +28,10 @@ class Preferences {
|
|||||||
environmentVariables: [:]
|
environmentVariables: [:]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if isRunningSwiftUIPreview {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
Task { await loadCustomPreferences() }
|
Task { await loadCustomPreferences() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import SwiftUI
|
|||||||
struct PhpExtensionManagerView: View {
|
struct PhpExtensionManagerView: View {
|
||||||
@ObservedObject var manager: BrewExtensionsObservable
|
@ObservedObject var manager: BrewExtensionsObservable
|
||||||
@ObservedObject var status: BusyStatus
|
@ObservedObject var status: BusyStatus
|
||||||
|
|
||||||
@State var searchText: String
|
@State var searchText: String
|
||||||
@State private var highlightedExtension: String?
|
@State private var highlightedExtension: String?
|
||||||
|
|
||||||
@@ -23,6 +24,14 @@ struct PhpExtensionManagerView: View {
|
|||||||
self.status.busy = false
|
self.status.busy = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var availablePhpVersions: [String] {
|
||||||
|
if isRunningSwiftUIPreview {
|
||||||
|
return [manager.phpVersion]
|
||||||
|
}
|
||||||
|
|
||||||
|
return PhpEnvironments.shared.availablePhpVersions
|
||||||
|
}
|
||||||
|
|
||||||
var filteredExtensions: [BrewPhpExtension] {
|
var filteredExtensions: [BrewPhpExtension] {
|
||||||
guard !searchText.isEmpty else {
|
guard !searchText.isEmpty else {
|
||||||
return manager.extensions.sorted { $0.isInstalled && !$1.isInstalled }
|
return manager.extensions.sorted { $0.isInstalled && !$1.isInstalled }
|
||||||
@@ -85,9 +94,8 @@ struct PhpExtensionManagerView: View {
|
|||||||
// MARK: View Variables
|
// MARK: View Variables
|
||||||
|
|
||||||
private var phpVersionPicker: some View {
|
private var phpVersionPicker: some View {
|
||||||
Picker("",
|
Picker("", selection: $manager.phpVersion) {
|
||||||
selection: $manager.phpVersion) {
|
ForEach(self.availablePhpVersions, id: \.self) {
|
||||||
ForEach(PhpEnvironments.shared.availablePhpVersions, id: \.self) {
|
|
||||||
Text("PHP \($0)")
|
Text("PHP \($0)")
|
||||||
.tag($0)
|
.tag($0)
|
||||||
.font(.system(size: 12))
|
.font(.system(size: 12))
|
||||||
@@ -156,30 +164,16 @@ struct PhpExtensionManagerView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func scrollAndAnimate(_ ext: BrewPhpExtension, _ proxy: ScrollViewProxy) {
|
|
||||||
withAnimation {
|
|
||||||
highlightedExtension = ext.name
|
|
||||||
proxy.scrollTo(ext.name, anchor: .top)
|
|
||||||
}
|
|
||||||
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
|
|
||||||
withAnimation {
|
|
||||||
highlightedExtension = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private func listContent(for ext: BrewPhpExtension, proxy: ScrollViewProxy) -> some View {
|
private func listContent(for ext: BrewPhpExtension, proxy: ScrollViewProxy) -> some View {
|
||||||
HStack(alignment: .center, spacing: 7.0) {
|
HStack(alignment: .center, spacing: 7.0) {
|
||||||
VStack(alignment: .center, spacing: 0) {
|
VStack(alignment: .center, spacing: 0) {
|
||||||
HStack {
|
HStack {
|
||||||
HStack {
|
HStack {
|
||||||
Image(systemName: ext.isInstalled || ext.hasAlternativeInstall
|
Image(systemName: ext.isInstalled || ext.hasAlternativeInstall
|
||||||
? "puzzlepiece.extension.fill"
|
? "puzzlepiece.extension.fill" : "puzzlepiece.extension")
|
||||||
: "puzzlepiece.extension")
|
.resizable()
|
||||||
.resizable()
|
.frame(width: 24, height: 20)
|
||||||
.frame(width: 24, height: 20)
|
.foregroundColor(ext.hasAlternativeInstall ? Color.gray : Color.blue)
|
||||||
.foregroundColor(ext.hasAlternativeInstall ? Color.gray : Color.blue)
|
|
||||||
}.frame(width: 36, height: 24)
|
}.frame(width: 36, height: 24)
|
||||||
|
|
||||||
VStack(alignment: .leading, spacing: 5) {
|
VStack(alignment: .leading, spacing: 5) {
|
||||||
@@ -226,9 +220,21 @@ struct PhpExtensionManagerView: View {
|
|||||||
.cornerRadius(8)
|
.cornerRadius(8)
|
||||||
.animation(.easeInOut(duration: 0.5), value: highlightedExtension)
|
.animation(.easeInOut(duration: 0.5), value: highlightedExtension)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func scrollAndAnimate(_ ext: BrewPhpExtension, _ proxy: ScrollViewProxy) {
|
||||||
|
withAnimation {
|
||||||
|
highlightedExtension = ext.name
|
||||||
|
proxy.scrollTo(ext.name, anchor: .top)
|
||||||
|
}
|
||||||
|
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
|
||||||
|
withAnimation {
|
||||||
|
highlightedExtension = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
PhpExtensionManagerView()
|
PhpExtensionManagerView().frame(width: 600, height: 600)
|
||||||
.frame(width: 600, height: 600)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user