From 9f013ccdf29646367ce69247d2aa736f2f5b83db Mon Sep 17 00:00:00 2001 From: Matt Kiazyk Date: Sat, 4 Jun 2022 21:30:39 -0500 Subject: [PATCH] Adds a bottom status bar to the window --- Xcodes.xcodeproj/project.pbxproj | 4 ++ Xcodes/Backend/AppState.swift | 11 +++++ Xcodes/Frontend/MainWindow.swift | 2 + .../Frontend/XcodeList/BottomStatusBar.swift | 49 +++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 Xcodes/Frontend/XcodeList/BottomStatusBar.swift diff --git a/Xcodes.xcodeproj/project.pbxproj b/Xcodes.xcodeproj/project.pbxproj index ea9bff8..0f8c35a 100644 --- a/Xcodes.xcodeproj/project.pbxproj +++ b/Xcodes.xcodeproj/project.pbxproj @@ -107,6 +107,7 @@ E8977EA325C11E1500835F80 /* PreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8977EA225C11E1500835F80 /* PreferencesView.swift */; }; E8CBDB8927ADE32300B22292 /* unxip in Copy aria2c */ = {isa = PBXBuildFile; fileRef = E8CBDB8627ADD92000B22292 /* unxip */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; E8CBDB8B27AE02FF00B22292 /* ExperiementsPreferencePane.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8CBDB8A27AE02FF00B22292 /* ExperiementsPreferencePane.swift */; }; + E8D0296F284B029800647641 /* BottomStatusBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D0296E284B029800647641 /* BottomStatusBar.swift */; }; E8DA461125FAF7FB002E85EF /* NotificationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8DA461025FAF7FB002E85EF /* NotificationsView.swift */; }; E8E98A9025D8631800EC89A0 /* InstallationStepRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAFBC3FF259AC17F00E2A3D8 /* InstallationStepRowView.swift */; }; E8E98A9625D863D700EC89A0 /* InstallationStepDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8E98A9525D863D700EC89A0 /* InstallationStepDetailView.swift */; }; @@ -289,6 +290,7 @@ E8977EA225C11E1500835F80 /* PreferencesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesView.swift; sourceTree = ""; }; E8CBDB8627ADD92000B22292 /* unxip */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = unxip; sourceTree = ""; }; E8CBDB8A27AE02FF00B22292 /* ExperiementsPreferencePane.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExperiementsPreferencePane.swift; sourceTree = ""; }; + E8D0296E284B029800647641 /* BottomStatusBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomStatusBar.swift; sourceTree = ""; }; E8DA461025FAF7FB002E85EF /* NotificationsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsView.swift; sourceTree = ""; }; E8E98A9525D863D700EC89A0 /* InstallationStepDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallationStepDetailView.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -426,6 +428,7 @@ CAE42486259A68A300B8B246 /* XcodeListCategory.swift */, CAD2E7A32449574E00113D76 /* XcodeListView.swift */, CAFFFED7259CDA5000903F81 /* XcodeListViewRow.swift */, + E8D0296E284B029800647641 /* BottomStatusBar.swift */, ); path = XcodeList; sourceTree = ""; @@ -860,6 +863,7 @@ CA9FF87B2595293E00E47BAF /* DataSource.swift in Sources */, CABFA9C92592EEEA00380FEE /* URLRequest+Apple.swift in Sources */, CABFAA432593104F00380FEE /* AboutView.swift in Sources */, + E8D0296F284B029800647641 /* BottomStatusBar.swift in Sources */, E8E98A9025D8631800EC89A0 /* InstallationStepRowView.swift in Sources */, CABFA9CC2592EEEA00380FEE /* Path+.swift in Sources */, CAD2E7A22449574E00113D76 /* XcodesApp.swift in Sources */, diff --git a/Xcodes/Backend/AppState.swift b/Xcodes/Backend/AppState.swift index 146e153..8cc87c5 100644 --- a/Xcodes/Backend/AppState.swift +++ b/Xcodes/Backend/AppState.swift @@ -96,6 +96,17 @@ class AppState: ObservableObject { savedUsername != nil } + var bottomStatusBarMessage: String { + let formatter = DateFormatter() + formatter.dateFormat = "dd/MM/yyyy" + let finishDate = formatter.date(from: "11/06/2022") + + if Date().compare(finishDate!) == .orderedAscending { + return "👨🏻‍💻👩🏼‍💻 Happy WWDC 2022! 👨🏽‍💻🧑🏻‍💻" + } + return "" + } + // MARK: - Init init() { diff --git a/Xcodes/Frontend/MainWindow.swift b/Xcodes/Frontend/MainWindow.swift index 87c0276..42de1da 100644 --- a/Xcodes/Frontend/MainWindow.swift +++ b/Xcodes/Frontend/MainWindow.swift @@ -37,6 +37,8 @@ struct MainWindow: View { isShowingInfoPane: $isShowingInfoPane, searchText: $searchText ) + .bottomStatusBar() + .padding([.top], 0) .navigationSubtitle(subtitleText) .frame(minWidth: 600, maxWidth: .infinity, minHeight: 300, maxHeight: .infinity) .emittingError($appState.error, recoveryHandler: { _ in }) diff --git a/Xcodes/Frontend/XcodeList/BottomStatusBar.swift b/Xcodes/Frontend/XcodeList/BottomStatusBar.swift new file mode 100644 index 0000000..ed74fe6 --- /dev/null +++ b/Xcodes/Frontend/XcodeList/BottomStatusBar.swift @@ -0,0 +1,49 @@ +// +// BottomStatusBar.swift +// Xcodes +// +// Created by Matt Kiazyk on 2022-06-03. +// Copyright © 2022 Robots and Pencils. All rights reserved. +// + +import Foundation +import SwiftUI + + +struct BottomStatusModifier: ViewModifier { + @EnvironmentObject var appState: AppState + + func body(content: Content) -> some View { + content + VStack(spacing: 0) { + Divider() + HStack { + Text(appState.bottomStatusBarMessage) + .font(.subheadline) + Spacer() + Text(Bundle.main.shortVersion!) + .font(.subheadline) + } + .frame(maxWidth: .infinity, maxHeight: 30, alignment: .leading) + .padding([.leading, .trailing], 10) + } + .frame(maxWidth: .infinity, maxHeight: 30, alignment: .leading) + } + +} + +extension View { + func bottomStatusBar() -> some View { + self.modifier( + BottomStatusModifier() + ) + } +} + +struct Previews_BottomStatusBar_Previews: PreviewProvider { + static var previews: some View { + HStack { + + }.bottomStatusBar() + } +}