mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-11-07 21:20:07 +01:00
👌 Cleanup
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
//
|
||||
// PMHeaderView.swift
|
||||
// PHP Monitor
|
||||
//
|
||||
// Created by Nico Verbruggen on 15/04/2021.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
@available(OSX 11.0, *)
|
||||
struct PMHeaderView: View {
|
||||
@State var content: String = "Your Title Here"
|
||||
|
||||
var body: some View {
|
||||
PMHeader(labelText: $content).frame(minWidth: 0, maxWidth: 450, minHeight: 0, maxHeight: 50)
|
||||
}
|
||||
}
|
||||
|
||||
@available(OSX 11.0, *)
|
||||
struct PMHeader: NSViewRepresentable {
|
||||
@Binding var labelText: String
|
||||
|
||||
func makeNSView(context: Context) -> some NSView {
|
||||
return HeaderView.asMenuItem(text: labelText).view!
|
||||
}
|
||||
|
||||
func updateNSView(_ nsView: NSViewType, context: Context) {}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// PMHeaderView.swift
|
||||
// PHP Monitor
|
||||
//
|
||||
// Created by Nico Verbruggen on 15/04/2021.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
@available(OSX 11.0, *)
|
||||
struct PMServicesView: View {
|
||||
var body: some View {
|
||||
PMServices().frame(minWidth: 0, maxWidth: 450, minHeight: 0, maxHeight: 50)
|
||||
}
|
||||
}
|
||||
|
||||
@available(OSX 11.0, *)
|
||||
struct PMServices: NSViewRepresentable {
|
||||
func makeNSView(context: Context) -> some NSView {
|
||||
return ServicesView.asMenuItem().view!
|
||||
}
|
||||
|
||||
func updateNSView(_ nsView: NSViewType, context: Context) {}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
//
|
||||
// PMStatsView.swift
|
||||
// PHP Monitor
|
||||
//
|
||||
// Created by Nico Verbruggen on 15/04/2021.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
@available(OSX 11.0, *)
|
||||
struct PMStats: NSViewRepresentable {
|
||||
@Binding var labelText: String
|
||||
|
||||
func makeNSView(context: Context) -> some NSView {
|
||||
return StatsView.asMenuItem(memory: labelText, post: labelText, upload: labelText).view!
|
||||
}
|
||||
|
||||
func updateNSView(_ nsView: NSViewType, context: Context) {}
|
||||
}
|
||||
|
||||
@available(OSX 11.0, *)
|
||||
struct PMStatsView: View {
|
||||
@State var content: String = "5 MB"
|
||||
|
||||
var body: some View {
|
||||
PMStats(labelText: $content).frame(minWidth: 0, maxWidth: 450, minHeight: 0, maxHeight: 80)
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
//
|
||||
// Preview.swift
|
||||
// PHP Monitor
|
||||
//
|
||||
// Created by Nico Verbruggen on 15/04/2021.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Cocoa
|
||||
|
||||
@available(OSX 11.0, *)
|
||||
struct Preview_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
PMHeaderView(content: "You are running PHP 8.1")
|
||||
PMStatsView(content: "15 MB")
|
||||
PMStatsView(content: "2 GB")
|
||||
PMServicesView() // uses live services data!
|
||||
}
|
||||
}
|
||||
@@ -55,15 +55,11 @@ struct VersionPopoverView: View {
|
||||
if !validPhpVersions.isEmpty {
|
||||
// Suggestions for alternative PHP versions
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
HStack(alignment: .center, spacing: 5) {
|
||||
Image(systemName: "info.circle.fill")
|
||||
.renderingMode(.template)
|
||||
.foregroundColor(Color("AppColor"))
|
||||
Text("alert.php_suggestions".localized)
|
||||
.font(.subheadline)
|
||||
.foregroundColor(Color("AppColor"))
|
||||
|
||||
}.padding(EdgeInsets(top: 5, leading: 0, bottom: 0, trailing: 0))
|
||||
DisclaimerView(
|
||||
iconName: "info.circle",
|
||||
message: "alert.php_suggestions".localized,
|
||||
color: Color("AppColor")
|
||||
)
|
||||
HStack {
|
||||
ForEach(validPhpVersions, id: \.self) { version in
|
||||
Button("site_link.switch_to_php".localized(version.homebrewVersion), action: {
|
||||
@@ -75,23 +71,16 @@ struct VersionPopoverView: View {
|
||||
}
|
||||
} else {
|
||||
if site.composerPhpSource != .unknown {
|
||||
HStack(alignment: .center, spacing: 5) {
|
||||
Image(systemName: "checkmark.seal.fill")
|
||||
.renderingMode(.template)
|
||||
.foregroundColor(Color("IconColorGreen"))
|
||||
Text("alert.php_version_ideal".localized)
|
||||
.font(.subheadline)
|
||||
.foregroundColor(Color("IconColorGreen"))
|
||||
}.padding(EdgeInsets(top: 5, leading: 0, bottom: 0, trailing: 0))
|
||||
DisclaimerView(
|
||||
iconName: "checkmark.seal.fill",
|
||||
message: "alert.php_version_ideal".localized,
|
||||
color: Color("IconColorGreen")
|
||||
)
|
||||
} else {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 5) {
|
||||
Image(systemName: "questionmark.circle.fill")
|
||||
.renderingMode(.template)
|
||||
.foregroundColor(Color.secondary)
|
||||
Text("alert.unable_to_determine_is_fine".localized)
|
||||
.font(.subheadline)
|
||||
.foregroundColor(Color.secondary)
|
||||
}.padding(EdgeInsets(top: 5, leading: 0, bottom: 0, trailing: 0))
|
||||
DisclaimerView(
|
||||
iconName: "questionmark.circle",
|
||||
message: "alert.unable_to_determine_is_fine".localized
|
||||
)
|
||||
}
|
||||
}
|
||||
}.frame(width: 400, height: nil, alignment: .center)
|
||||
@@ -102,6 +91,23 @@ struct VersionPopoverView: View {
|
||||
}
|
||||
}
|
||||
|
||||
struct DisclaimerView: View {
|
||||
@State var iconName: String
|
||||
@State var message: String
|
||||
@State var color: Color = Color.secondary
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 5) {
|
||||
Image(systemName: iconName)
|
||||
.renderingMode(.template)
|
||||
.foregroundColor(color)
|
||||
Text(message)
|
||||
.font(.subheadline)
|
||||
.foregroundColor(color)
|
||||
}.padding(EdgeInsets(top: 5, leading: 0, bottom: 0, trailing: 0))
|
||||
}
|
||||
}
|
||||
|
||||
struct VersionPopoverView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VersionPopoverView(
|
||||
|
||||
Reference in New Issue
Block a user