Unroll ProfileView toolbar items

Also leave them visible when disabled.
This commit is contained in:
Davide De Rosa 2022-04-21 16:22:45 +02:00
parent 992178bcd6
commit fd7c232ecc
3 changed files with 38 additions and 26 deletions

View File

@ -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 = "<group>"; };
0E3B7FD927E51A0200C66F13 /* ProfileView+Provider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProfileView+Provider.swift"; sourceTree = "<group>"; };
0E3CD47E280DA14B007075C0 /* OrganizerView+AddMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrganizerView+AddMenu.swift"; sourceTree = "<group>"; };
0E3CD482280DAE92007075C0 /* ProfileView+MenuBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProfileView+MenuBar.swift"; sourceTree = "<group>"; };
0E3CD482280DAE92007075C0 /* ProfileView+Toolbar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProfileView+Toolbar.swift"; sourceTree = "<group>"; };
0E44689527B051C300A14CE4 /* ProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = "<group>"; };
0E44689B27B11B5300A14CE4 /* AboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = "<group>"; };
0E49F6BA27D7638300385834 /* EndpointAdvancedView+OpenVPN.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EndpointAdvancedView+OpenVPN.swift"; sourceTree = "<group>"; };
@ -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 */,

View File

@ -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<ModalType?>) {
productManager = .shared
_modalType = modalType
}
private var isEligibleForSiri: Bool {
productManager.isEligible(forFeature: .siriShortcuts)
}
init(currentProfile: ObservableProfile, modalType: Binding<ModalType?>) {
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<ModalType?>) {
self.currentProfile = currentProfile
_modalType = modalType
}
var body: some View {
Button {
modalType = .rename
} label: {
themeRenameProfileImage.asSystemImage
}
}
}
}

View File

@ -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)