95 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			95 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
import SwiftUI
 | 
						||
 | 
						||
struct TopBarView: View {
 | 
						||
    var title: String
 | 
						||
    
 | 
						||
    // Состояния для ProfileTab
 | 
						||
    @Binding var selectedAccount: String
 | 
						||
    @Binding var sheetType: ProfileTab.SheetType?
 | 
						||
    var accounts: [String]
 | 
						||
    var viewModel: LoginViewModel
 | 
						||
    
 | 
						||
    // Привязка для управления боковым меню
 | 
						||
    @Binding var isSideMenuPresented: Bool
 | 
						||
    
 | 
						||
    var isHomeTab: Bool {
 | 
						||
        return title == "Home"
 | 
						||
    }
 | 
						||
    
 | 
						||
    var isProfileTab: Bool {
 | 
						||
        return title == "Profile"
 | 
						||
    }
 | 
						||
 | 
						||
    var body: some View {
 | 
						||
        VStack(spacing: 0) {
 | 
						||
            HStack {
 | 
						||
                // Кнопка "Гамбургер" для открытия меню
 | 
						||
                Button(action: {
 | 
						||
                    withAnimation {
 | 
						||
                        isSideMenuPresented.toggle()
 | 
						||
                    }
 | 
						||
                }) {
 | 
						||
                    Image(systemName: "line.horizontal.3")
 | 
						||
                        .imageScale(.large)
 | 
						||
                        .foregroundColor(.primary)
 | 
						||
                }
 | 
						||
                
 | 
						||
//                Spacer()
 | 
						||
                
 | 
						||
                if isHomeTab{
 | 
						||
                    Text("Yobble")
 | 
						||
                        .font(.largeTitle)
 | 
						||
                        .fontWeight(.bold)
 | 
						||
                    Spacer()
 | 
						||
                } else if isProfileTab {
 | 
						||
                    Spacer()
 | 
						||
                    Button(action: { sheetType = .accountShare }) {
 | 
						||
                        HStack(spacing: 4) {
 | 
						||
                            Text(selectedAccount)
 | 
						||
                                .font(.headline)
 | 
						||
                                .foregroundColor(.primary)
 | 
						||
                            Image(systemName: "chevron.down")
 | 
						||
                                .font(.subheadline)
 | 
						||
                                .foregroundColor(.gray)
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    Spacer()
 | 
						||
                } else {
 | 
						||
                    Text(title)
 | 
						||
                        .font(.largeTitle)
 | 
						||
                        .fontWeight(.bold)
 | 
						||
                    Spacer()
 | 
						||
                }
 | 
						||
                
 | 
						||
                if isHomeTab{
 | 
						||
                    // Заглушка кнопки
 | 
						||
                    Button(action: {
 | 
						||
                        // пока ничего не делаем
 | 
						||
                    }) {
 | 
						||
                        Image(systemName: "magnifyingglass")
 | 
						||
                            .imageScale(.large)
 | 
						||
                            .foregroundColor(.primary)
 | 
						||
                    }
 | 
						||
                } else if isProfileTab {
 | 
						||
                    NavigationLink(destination: SettingsView(viewModel: viewModel)) {
 | 
						||
                        Image(systemName: "wrench")
 | 
						||
                            .imageScale(.large)
 | 
						||
                            .foregroundColor(.primary)
 | 
						||
                    }
 | 
						||
                }
 | 
						||
            }
 | 
						||
            .padding()
 | 
						||
            .frame(height: 50) // Стандартная высота для нав. бара
 | 
						||
            
 | 
						||
//            Divider()
 | 
						||
        }
 | 
						||
        .background(Color(UIColor.systemBackground))
 | 
						||
    }
 | 
						||
}
 | 
						||
 | 
						||
struct TopBarView_Previews: PreviewProvider {
 | 
						||
    static var previews: some View {
 | 
						||
        /*@START_MENU_TOKEN@*/Text("Hello, World!")/*@END_MENU_TOKEN@*/
 | 
						||
    }
 | 
						||
}
 |