topbar update

This commit is contained in:
cheykrym 2025-08-13 01:11:14 +03:00
parent 2052492912
commit db12fca1c3
4 changed files with 32 additions and 25 deletions

View File

@ -56,7 +56,7 @@ struct TopBarView: View {
.padding()
.frame(height: 50) // Стандартная высота для нав. бара
Divider()
// Divider()
}
.background(Color(UIColor.systemBackground))
}

View File

@ -38,15 +38,16 @@ struct MainView: View {
var body: some View {
NavigationView {
VStack(spacing: 0) {
TopBarView(
title: tabTitle,
selectedAccount: $selectedAccount,
sheetType: $sheetType,
accounts: accounts,
viewModel: viewModel
)
.offset(y: topBarVisible ? 0 : -100)
.animation(.spring(response: 0.4, dampingFraction: 0.8), value: topBarVisible)
if topBarVisible {
TopBarView(
title: tabTitle,
selectedAccount: $selectedAccount,
sheetType: $sheetType,
accounts: accounts,
viewModel: viewModel
)
.transition(AnyTransition.move(edge: .top).combined(with: .opacity))
}
ZStack {
switch selectedTab {
@ -70,9 +71,11 @@ struct MainView: View {
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
if topBarVisible {
CustomTabBar(selectedTab: $selectedTab) {
print("Create button tapped")
}
}
}
.ignoresSafeArea(edges: .bottom)
.navigationBarHidden(true)
@ -97,17 +100,21 @@ struct MainView: View {
let currentY = offset.y
// Показываем бар, если скроллим вверх или дошли до верха
if currentY < lastScrollY || currentY <= 0 {
if !topBarVisible {
topBarVisible = true
}
}
// Скрываем, если скроллим вниз и отступили от верха
else if currentY > lastScrollY && currentY > 50 {
if topBarVisible {
topBarVisible = false
}
}
// if currentY < lastScrollY || currentY <= 0 {
// if !topBarVisible {
// withAnimation(.default) {
// topBarVisible = true
// }
// }
// }
// // Скрываем, если скроллим вниз и отступили от верха
// else if currentY > lastScrollY && currentY > 50 {
// if topBarVisible {
// withAnimation(.default) {
// topBarVisible = false
// }
// }
// }
lastScrollY = currentY
}

View File

@ -66,7 +66,7 @@
1A7940A52DF77DF5002569DA /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
1A7940A92DF77E05002569DA /* LoginViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginViewModel.swift; sourceTree = "<group>"; };
1A7940AF2DF77E26002569DA /* LoginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginView.swift; sourceTree = "<group>"; };
1A7940B52DF77F21002569DA /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
1A7940B52DF77F21002569DA /* MainView.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; tabWidth = 4; };
1A7940C52DF7A98E002569DA /* ContactsTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactsTab.swift; sourceTree = "<group>"; };
1A7940C92DF7A99B002569DA /* ChatsTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatsTab.swift; sourceTree = "<group>"; };
1A7940CD2DF7A9AA002569DA /* ProfileTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileTab.swift; sourceTree = "<group>"; };

View File

@ -17,12 +17,12 @@
<key>yobble (iOS).xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
<key>yobble (macOS).xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>