mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-28 15:44:32 +00:00
Feature: Media Panel Disable in standard mode
This commit is contained in:
parent
465d6e089a
commit
f425b38a81
8 changed files with 240 additions and 6 deletions
|
|
@ -36,12 +36,18 @@ struct TabSelectionView: View {
|
|||
@Default(.enableThirdPartyExtensions) private var enableThirdPartyExtensions
|
||||
@Default(.enableExtensionNotchExperiences) private var enableExtensionNotchExperiences
|
||||
@Default(.enableExtensionNotchTabs) private var enableExtensionNotchTabs
|
||||
@Default(.showCalendar) private var showCalendar
|
||||
@Default(.showMirror) private var showMirror
|
||||
@Default(.showStandardMediaControls) private var showStandardMediaControls
|
||||
@Default(.enableMinimalisticUI) private var enableMinimalisticUI
|
||||
@Namespace var animation
|
||||
|
||||
private var tabs: [TabModel] {
|
||||
var tabsArray: [TabModel] = []
|
||||
|
||||
tabsArray.append(TabModel(label: "Home", icon: "house.fill", view: .home))
|
||||
|
||||
if homeTabVisible {
|
||||
tabsArray.append(TabModel(label: "Home", icon: "house.fill", view: .home))
|
||||
}
|
||||
|
||||
if Defaults[.dynamicShelf] {
|
||||
tabsArray.append(TabModel(label: "Shelf", icon: "tray.fill", view: .shelf))
|
||||
|
|
@ -77,7 +83,9 @@ struct TabSelectionView: View {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
ensureValidSelection(with: tabsArray)
|
||||
}
|
||||
return tabsArray
|
||||
}
|
||||
var body: some View {
|
||||
|
|
@ -121,6 +129,13 @@ struct TabSelectionView: View {
|
|||
extensionNotchExperienceManager.activeExperiences.filter { $0.descriptor.tab != nil }
|
||||
}
|
||||
|
||||
private var homeTabVisible: Bool {
|
||||
if enableMinimalisticUI {
|
||||
return true
|
||||
}
|
||||
return showStandardMediaControls || showCalendar || showMirror
|
||||
}
|
||||
|
||||
private func isSelected(_ tab: TabModel) -> Bool {
|
||||
if tab.view == .extensionExperience {
|
||||
return coordinator.currentView == .extensionExperience
|
||||
|
|
@ -128,6 +143,20 @@ struct TabSelectionView: View {
|
|||
}
|
||||
return coordinator.currentView == tab.view
|
||||
}
|
||||
|
||||
private func ensureValidSelection(with tabs: [TabModel]) {
|
||||
guard !tabs.isEmpty else { return }
|
||||
if tabs.contains(where: { isSelected($0) }) {
|
||||
return
|
||||
}
|
||||
guard let first = tabs.first else { return }
|
||||
if first.view == .extensionExperience {
|
||||
coordinator.selectedExtensionExperienceID = first.experienceID
|
||||
} else {
|
||||
coordinator.selectedExtensionExperienceID = nil
|
||||
}
|
||||
coordinator.currentView = first.view
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue