Remove tab bar in settings

This commit is contained in:
Lumaa 2024-08-10 17:28:15 +02:00
parent ac6219450a
commit f52716f748
3 changed files with 21 additions and 1 deletions

View File

@ -275,3 +275,9 @@ public final class Client: Equatable, Identifiable, Hashable {
}
extension Client: Sendable {}
extension CGFloat {
static func getFontSize(from font: UIFont.TextStyle) -> CGFloat {
return UIFont.preferredFont(forTextStyle: font).pointSize
}
}

View File

@ -20,6 +20,10 @@ public class Navigator: ObservableObject {
}
private var currentTab: TabDestination = .timeline
public var inSettings: Bool {
self.path.contains(RouterDestination.allSettings)
}
public private(set) var memorizedNav: [TabDestination : [RouterDestination]] = [:]
public var showTabbar: Bool {
get {

View File

@ -44,10 +44,15 @@ struct ContentView: View {
TabsView(postButton: {
uniNavigator.presentedSheet = .post(content: "", replyId: nil, editId: nil)
}, retapAction: {
Navigator.shared.path = []
navigator.path = []
// Navigator.shared.showTabbar.toggle()
})
.safeAreaPadding(.vertical, 10)
.zIndex(10)
.offset(
y: navigator.showTabbar ? 0 : CGFloat
.getFontSize(from: .extraLargeTitle) * 7.5
)
}
.withSheets(sheetDestination: $uniNavigator.presentedSheet)
.withCovers(sheetDestination: $uniNavigator.presentedCover)
@ -57,6 +62,11 @@ struct ContentView: View {
.environment(huggingFace)
.environmentObject(preferences)
.navigationBarTitleDisplayMode(.inline)
.onChange(of: navigator.path) { _, newValue in
guard !newValue.isEmpty else { navigator.showTabbar = true; return }
navigator.showTabbar = newValue
.filter({ $0 == RouterDestination.settings }).first == nil
}
.onAppear {
showNew()