mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-27 01:20:41 +00:00
Add a new custom Post tab for the tabbar
This commit is contained in:
parent
c0a78ef007
commit
6bb6a02912
5 changed files with 18 additions and 5 deletions
|
@ -22,7 +22,7 @@ struct AppView: View {
|
|||
|
||||
|
||||
@Binding var selectedTab: Tab
|
||||
@Binding var sidebarRouterPath: RouterPath
|
||||
@Binding var appRouterPath: RouterPath
|
||||
|
||||
@State var popToRootTab: Tab = .other
|
||||
@State var iosTabs = iOSTabs.shared
|
||||
|
@ -46,6 +46,10 @@ struct AppView: View {
|
|||
TabView(selection: .init(get: {
|
||||
selectedTab
|
||||
}, set: { newTab in
|
||||
if newTab == .post {
|
||||
appRouterPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
|
||||
return
|
||||
}
|
||||
if newTab == selectedTab {
|
||||
/// Stupid hack to trigger onChange binding in tab views.
|
||||
popToRootTab = .other
|
||||
|
@ -74,6 +78,7 @@ struct AppView: View {
|
|||
}
|
||||
}
|
||||
.id(appAccountsManager.currentClient.id)
|
||||
.withSheetDestinations(sheetDestinations: $appRouterPath.presentedSheet)
|
||||
}
|
||||
|
||||
private func badgeFor(tab: Tab) -> Int {
|
||||
|
@ -115,7 +120,7 @@ struct AppView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.environment(sidebarRouterPath)
|
||||
.environment(appRouterPath)
|
||||
}
|
||||
|
||||
var notificationsSecondaryColumn: some View {
|
||||
|
|
|
@ -13,7 +13,7 @@ extension IceCubesApp {
|
|||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: userPreferences.postVisibility))
|
||||
#else
|
||||
sidebarRouterPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
|
||||
appRouterPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
|
||||
#endif
|
||||
}
|
||||
.keyboardShortcut("n", modifiers: .command)
|
||||
|
|
|
@ -6,7 +6,7 @@ import SwiftUI
|
|||
extension IceCubesApp {
|
||||
var appScene: some Scene {
|
||||
WindowGroup(id: "MainWindow") {
|
||||
AppView(selectedTab: $selectedTab, sidebarRouterPath: $sidebarRouterPath)
|
||||
AppView(selectedTab: $selectedTab, appRouterPath: $appRouterPath)
|
||||
.applyTheme(theme)
|
||||
.onAppear {
|
||||
setNewClientsInEnv(client: appAccountsManager.currentClient)
|
||||
|
|
|
@ -28,7 +28,7 @@ struct IceCubesApp: App {
|
|||
@State var theme = Theme.shared
|
||||
|
||||
@State var selectedTab: Tab = .timeline
|
||||
@State var sidebarRouterPath = RouterPath()
|
||||
@State var appRouterPath = RouterPath()
|
||||
|
||||
@State var isSupporter: Bool = false
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ enum Tab: Int, Identifiable, Hashable, CaseIterable {
|
|||
case profile
|
||||
case bookmarks
|
||||
case favorites
|
||||
case post
|
||||
|
||||
nonisolated var id: Int {
|
||||
rawValue
|
||||
|
@ -63,6 +64,8 @@ enum Tab: Int, Identifiable, Hashable, CaseIterable {
|
|||
NavigationTab {
|
||||
AccountStatusesListView(mode: .favorites)
|
||||
}
|
||||
case .post:
|
||||
VStack { }
|
||||
case .other:
|
||||
EmptyView()
|
||||
}
|
||||
|
@ -95,8 +98,11 @@ enum Tab: Int, Identifiable, Hashable, CaseIterable {
|
|||
Label("accessibility.tabs.profile.picker.bookmarks", systemImage: iconName)
|
||||
case .favorites:
|
||||
Label("accessibility.tabs.profile.picker.favorites", systemImage: iconName)
|
||||
case .post:
|
||||
Label("menu.new-post", systemImage: iconName)
|
||||
case .other:
|
||||
EmptyView()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,6 +132,8 @@ enum Tab: Int, Identifiable, Hashable, CaseIterable {
|
|||
"bookmark"
|
||||
case .favorites:
|
||||
"star"
|
||||
case .post:
|
||||
"square.and.pencil"
|
||||
case .other:
|
||||
""
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue