From fd7c232ecc2d9a6d1a28bac116110b0b34e29bcf Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Thu, 21 Apr 2022 16:22:45 +0200 Subject: [PATCH] Unroll ProfileView toolbar items Also leave them visible when disabled. --- Passepartout.xcodeproj/project.pbxproj | 8 ++-- ...enuBar.swift => ProfileView+Toolbar.swift} | 41 ++++++++++++------- Passepartout/App/Views/ProfileView.swift | 15 +++---- 3 files changed, 38 insertions(+), 26 deletions(-) rename Passepartout/App/Views/{ProfileView+MenuBar.swift => ProfileView+Toolbar.swift} (87%) diff --git a/Passepartout.xcodeproj/project.pbxproj b/Passepartout.xcodeproj/project.pbxproj index 35bc3ade..bfe9707f 100644 --- a/Passepartout.xcodeproj/project.pbxproj +++ b/Passepartout.xcodeproj/project.pbxproj @@ -32,7 +32,7 @@ 0E3B7FD627E5173A00C66F13 /* ProfileView+VPN.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3B7FD527E5173A00C66F13 /* ProfileView+VPN.swift */; }; 0E3B7FDA27E51A0200C66F13 /* ProfileView+Provider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3B7FD927E51A0200C66F13 /* ProfileView+Provider.swift */; }; 0E3CD47F280DA14B007075C0 /* OrganizerView+AddMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3CD47E280DA14B007075C0 /* OrganizerView+AddMenu.swift */; }; - 0E3CD483280DAE92007075C0 /* ProfileView+MenuBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3CD482280DAE92007075C0 /* ProfileView+MenuBar.swift */; }; + 0E3CD483280DAE92007075C0 /* ProfileView+Toolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3CD482280DAE92007075C0 /* ProfileView+Toolbar.swift */; }; 0E44689627B051C300A14CE4 /* ProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E44689527B051C300A14CE4 /* ProfileView.swift */; }; 0E44689C27B11B5300A14CE4 /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E44689B27B11B5300A14CE4 /* AboutView.swift */; }; 0E49F6BB27D7638300385834 /* EndpointAdvancedView+OpenVPN.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E49F6BA27D7638300385834 /* EndpointAdvancedView+OpenVPN.swift */; }; @@ -212,7 +212,7 @@ 0E3B7FD527E5173A00C66F13 /* ProfileView+VPN.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProfileView+VPN.swift"; sourceTree = ""; }; 0E3B7FD927E51A0200C66F13 /* ProfileView+Provider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProfileView+Provider.swift"; sourceTree = ""; }; 0E3CD47E280DA14B007075C0 /* OrganizerView+AddMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrganizerView+AddMenu.swift"; sourceTree = ""; }; - 0E3CD482280DAE92007075C0 /* ProfileView+MenuBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProfileView+MenuBar.swift"; sourceTree = ""; }; + 0E3CD482280DAE92007075C0 /* ProfileView+Toolbar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProfileView+Toolbar.swift"; sourceTree = ""; }; 0E44689527B051C300A14CE4 /* ProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = ""; }; 0E44689B27B11B5300A14CE4 /* AboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = ""; }; 0E49F6BA27D7638300385834 /* EndpointAdvancedView+OpenVPN.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EndpointAdvancedView+OpenVPN.swift"; sourceTree = ""; }; @@ -446,9 +446,9 @@ 0E92D7C527F103300033CB7B /* ProfileView+Configuration.swift */, 0E92D7F327F104B80033CB7B /* ProfileView+Diagnostics.swift */, 0E92D7C827F1042A0033CB7B /* ProfileView+Extra.swift */, - 0E3CD482280DAE92007075C0 /* ProfileView+MenuBar.swift */, 0E3B7FD927E51A0200C66F13 /* ProfileView+Provider.swift */, 0EBC074B27EB673C00208AD9 /* ProfileView+Rename.swift */, + 0E3CD482280DAE92007075C0 /* ProfileView+Toolbar.swift */, 0E3B7FD527E5173A00C66F13 /* ProfileView+VPN.swift */, 0E0AD48F27BD53CB00FBB520 /* ProfileView+Welcome.swift */, 0E71ACF027C1073800F85C4B /* ProviderLocationView.swift */, @@ -960,7 +960,7 @@ 0E71ACF927C12E4800F85C4B /* CreditsView.swift in Sources */, 0ED89C1527DE0A0C008B36D6 /* Shortcut.swift in Sources */, 0E34A2B927CAA96A00C73B67 /* OpenVPN+L10n.swift in Sources */, - 0E3CD483280DAE92007075C0 /* ProfileView+MenuBar.swift in Sources */, + 0E3CD483280DAE92007075C0 /* ProfileView+Toolbar.swift in Sources */, 0EB17EAE27D226CF00D473B5 /* LocalProduct.swift in Sources */, 0E71ACEB27C1060D00F85C4B /* EndpointView.swift in Sources */, 0E53249927D26B51002565C3 /* ProductManager.swift in Sources */, diff --git a/Passepartout/App/Views/ProfileView+MenuBar.swift b/Passepartout/App/Views/ProfileView+Toolbar.swift similarity index 87% rename from Passepartout/App/Views/ProfileView+MenuBar.swift rename to Passepartout/App/Views/ProfileView+Toolbar.swift index f4c67999..28c4a13c 100644 --- a/Passepartout/App/Views/ProfileView+MenuBar.swift +++ b/Passepartout/App/Views/ProfileView+Toolbar.swift @@ -1,5 +1,5 @@ // -// ProfileView+MenuBar.swift +// ProfileView+Toolbar.swift // Passepartout // // Created by Davide De Rosa on 2/6/22. @@ -27,34 +27,26 @@ import SwiftUI import PassepartoutCore extension ProfileView { - struct MenuBar: View { + struct ShortcutsItem: View { @ObservedObject private var productManager: ProductManager - @ObservedObject private var currentProfile: ObservableProfile - @Binding private var modalType: ModalType? + init(modalType: Binding) { + productManager = .shared + _modalType = modalType + } + private var isEligibleForSiri: Bool { productManager.isEligible(forFeature: .siriShortcuts) } - init(currentProfile: ObservableProfile, modalType: Binding) { - productManager = .shared - self.currentProfile = currentProfile - _modalType = modalType - } - var body: some View { Button { presentShortcutsOrPaywall() } label: { themeShortcutsImage.asSystemImage } - Button { - modalType = .rename - } label: { - themeRenameProfileImage.asSystemImage - } } private func presentShortcutsOrPaywall() { @@ -67,4 +59,23 @@ extension ProfileView { } } } + + struct RenameItem: View { + @ObservedObject private var currentProfile: ObservableProfile + + @Binding private var modalType: ModalType? + + init(currentProfile: ObservableProfile, modalType: Binding) { + self.currentProfile = currentProfile + _modalType = modalType + } + + var body: some View { + Button { + modalType = .rename + } label: { + themeRenameProfileImage.asSystemImage + } + } + } } diff --git a/Passepartout/App/Views/ProfileView.swift b/Passepartout/App/Views/ProfileView.swift index 7dba88f0..0286da73 100644 --- a/Passepartout/App/Views/ProfileView.swift +++ b/Passepartout/App/Views/ProfileView.swift @@ -79,14 +79,15 @@ struct ProfileView: View { welcomeView } }.toolbar { - // FIXME: toolbars, unroll single items ToolbarItemGroup(placement: .navigationBarTrailing) { - if !isDeleted { - MenuBar( - currentProfile: profileManager.currentProfile, - modalType: $modalType - ) - } + ShortcutsItem( + modalType: $modalType + ).disabled(isDeleted) + + RenameItem( + currentProfile: profileManager.currentProfile, + modalType: $modalType + ).disabled(isDeleted) } }.sheet(item: $modalType, content: presentedModal) .onAppear(perform: loadProfileIfNeeded)