add messenger mod
This commit is contained in:
		
							parent
							
								
									3ae7576c24
								
							
						
					
					
						commit
						d692c7c984
					
				@ -3,6 +3,7 @@ import SwiftUI
 | 
			
		||||
struct TopBarView: View {
 | 
			
		||||
    var title: String
 | 
			
		||||
    
 | 
			
		||||
    let isMessengerModeEnabled: Bool
 | 
			
		||||
    // Состояния для ProfileTab
 | 
			
		||||
    @Binding var selectedAccount: String
 | 
			
		||||
//    @Binding var sheetType: ProfileTab.SheetType?
 | 
			
		||||
@ -41,17 +42,19 @@ struct TopBarView: View {
 | 
			
		||||
    var body: some View {
 | 
			
		||||
        VStack(spacing: 0) {
 | 
			
		||||
            HStack {
 | 
			
		||||
                // Кнопка "Гамбургер" для открытия меню
 | 
			
		||||
                Button(action: {
 | 
			
		||||
                    withAnimation {
 | 
			
		||||
                        isSideMenuPresented.toggle()
 | 
			
		||||
                    }
 | 
			
		||||
                }) {
 | 
			
		||||
                    Image(systemName: "line.horizontal.3")
 | 
			
		||||
                        .imageScale(.large)
 | 
			
		||||
                        .foregroundColor(.primary)
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
                if !isMessengerModeEnabled{
 | 
			
		||||
                    // Кнопка "Гамбургер" для открытия меню
 | 
			
		||||
                    Button(action: {
 | 
			
		||||
                        withAnimation {
 | 
			
		||||
                            isSideMenuPresented.toggle()
 | 
			
		||||
                        }
 | 
			
		||||
                    }) {
 | 
			
		||||
                        Image(systemName: "line.horizontal.3")
 | 
			
		||||
                            .imageScale(.large)
 | 
			
		||||
                            .foregroundColor(.primary)
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
//                Spacer()
 | 
			
		||||
                
 | 
			
		||||
                if let statusMessage {
 | 
			
		||||
@ -221,13 +224,14 @@ struct TopBarView_Previews: PreviewProvider {
 | 
			
		||||
        var body: some View {
 | 
			
		||||
            TopBarView(
 | 
			
		||||
                title: "Chats",
 | 
			
		||||
                isMessengerModeEnabled: false,
 | 
			
		||||
                selectedAccount: $selectedAccount,
 | 
			
		||||
                accounts: [selectedAccount],
 | 
			
		||||
                viewModel: viewModel,
 | 
			
		||||
                isSettingsPresented: $isSettingsPresented,
 | 
			
		||||
                isSideMenuPresented: $isSideMenuPresented,
 | 
			
		||||
                chatSearchRevealProgress: $revealProgress,
 | 
			
		||||
                chatSearchText: $searchText
 | 
			
		||||
                chatSearchText: $searchText,
 | 
			
		||||
            )
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										24
									
								
								yobble/Views/Tab/ContactsTab.swift
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								yobble/Views/Tab/ContactsTab.swift
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,24 @@
 | 
			
		||||
//
 | 
			
		||||
//  ContactsTab.swift
 | 
			
		||||
//  yobble
 | 
			
		||||
//
 | 
			
		||||
//  Created by cheykrym on 23.10.2025.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
import SwiftUI
 | 
			
		||||
 | 
			
		||||
struct ContactsTab: View {
 | 
			
		||||
    
 | 
			
		||||
    var body: some View {
 | 
			
		||||
        VStack {
 | 
			
		||||
            VStack {
 | 
			
		||||
                Text("Здесь не будут чаты")
 | 
			
		||||
                    .font(.title)
 | 
			
		||||
                    .foregroundColor(.gray)
 | 
			
		||||
                
 | 
			
		||||
                Spacer()
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
//        .background(Color(.secondarySystemBackground)) // Фон для всей вкладки
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -2,33 +2,44 @@ import SwiftUI
 | 
			
		||||
 | 
			
		||||
struct CustomTabBar: View {
 | 
			
		||||
    @Binding var selectedTab: Int
 | 
			
		||||
    let isMessengerModeEnabled: Bool
 | 
			
		||||
    var onCreate: () -> Void
 | 
			
		||||
 | 
			
		||||
    var body: some View {
 | 
			
		||||
        HStack {
 | 
			
		||||
            // Tab 1: Feed
 | 
			
		||||
            TabBarButton(systemName: "list.bullet.rectangle", text: NSLocalizedString("Лента", comment: ""), isSelected: selectedTab == 0) {
 | 
			
		||||
                selectedTab = 0
 | 
			
		||||
            }
 | 
			
		||||
            if isMessengerModeEnabled {
 | 
			
		||||
 | 
			
		||||
            // Tab 2: Search
 | 
			
		||||
            TabBarButton(systemName: "gamecontroller.fill", text: NSLocalizedString("Концепт", comment: "Tab bar: concept clicker"), isSelected: selectedTab == 1) {
 | 
			
		||||
                selectedTab = 1
 | 
			
		||||
            }
 | 
			
		||||
                TabBarButton(systemName: "person.2.fill", text: NSLocalizedString("Контакты", comment: ""), isSelected: selectedTab == 4) {
 | 
			
		||||
                    selectedTab = 4
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
                TabBarButton(systemName: "bubble.left.and.bubble.right.fill", text: NSLocalizedString("Чаты", comment: ""), isSelected: selectedTab == 2) {
 | 
			
		||||
                    selectedTab = 2
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            // Create Button
 | 
			
		||||
            CreateButton {
 | 
			
		||||
                onCreate()
 | 
			
		||||
            }
 | 
			
		||||
                TabBarButton(systemName: "gearshape.fill", text: NSLocalizedString("Настройки", comment: ""), isSelected: selectedTab == 5) {
 | 
			
		||||
                    selectedTab = 5
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                TabBarButton(systemName: "list.bullet.rectangle", text: NSLocalizedString("Лента", comment: ""), isSelected: selectedTab == 0) {
 | 
			
		||||
                    selectedTab = 0
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            // Tab 3: Chats
 | 
			
		||||
            TabBarButton(systemName: "bubble.left.and.bubble.right.fill", text: NSLocalizedString("Чаты", comment: ""), isSelected: selectedTab == 2) {
 | 
			
		||||
                selectedTab = 2
 | 
			
		||||
            }
 | 
			
		||||
                TabBarButton(systemName: "gamecontroller.fill", text: NSLocalizedString("Концепт", comment: "Tab bar: concept clicker"), isSelected: selectedTab == 1) {
 | 
			
		||||
                    selectedTab = 1
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            // Tab 4: Profile
 | 
			
		||||
            TabBarButton(systemName: "person.crop.square", text: NSLocalizedString("Лицо", comment: ""), isSelected: selectedTab == 3) {
 | 
			
		||||
                selectedTab = 3
 | 
			
		||||
                CreateButton {
 | 
			
		||||
                    onCreate()
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                TabBarButton(systemName: "bubble.left.and.bubble.right.fill", text: NSLocalizedString("Чаты", comment: ""), isSelected: selectedTab == 2) {
 | 
			
		||||
                    selectedTab = 2
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                TabBarButton(systemName: "person.crop.square", text: NSLocalizedString("Лицо", comment: ""), isSelected: selectedTab == 3) {
 | 
			
		||||
                    selectedTab = 3
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        .padding(.horizontal)
 | 
			
		||||
 | 
			
		||||
@ -4,6 +4,7 @@ struct MainView: View {
 | 
			
		||||
    @ObservedObject var viewModel: LoginViewModel
 | 
			
		||||
    @EnvironmentObject private var messageCenter: IncomingMessageCenter
 | 
			
		||||
    @State private var selectedTab: Int = 0
 | 
			
		||||
    @AppStorage("messengerModeEnabled") private var isMessengerModeEnabled: Bool = false
 | 
			
		||||
//    @StateObject private var newHomeTabViewModel = NewHomeTabViewModel()
 | 
			
		||||
    
 | 
			
		||||
    // Состояния для TopBarView
 | 
			
		||||
@ -26,6 +27,8 @@ struct MainView: View {
 | 
			
		||||
        case 1: return "Concept"
 | 
			
		||||
        case 2: return "Chats"
 | 
			
		||||
        case 3: return "Profile"
 | 
			
		||||
        case 4: return "Contacts"
 | 
			
		||||
        case 5: return "Settings"
 | 
			
		||||
        default: return "Home"
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@ -42,6 +45,7 @@ struct MainView: View {
 | 
			
		||||
                    VStack(spacing: 0) {
 | 
			
		||||
                        TopBarView(
 | 
			
		||||
                            title: tabTitle,
 | 
			
		||||
                            isMessengerModeEnabled: isMessengerModeEnabled,
 | 
			
		||||
                            selectedAccount: $selectedAccount,
 | 
			
		||||
                            accounts: accounts,
 | 
			
		||||
                            viewModel: viewModel,
 | 
			
		||||
@ -52,26 +56,42 @@ struct MainView: View {
 | 
			
		||||
                        )
 | 
			
		||||
                        
 | 
			
		||||
                        ZStack {
 | 
			
		||||
                            NewHomeTab()
 | 
			
		||||
                                .opacity(selectedTab == 0 ? 1 : 0)
 | 
			
		||||
 | 
			
		||||
                            ConceptTab()
 | 
			
		||||
                                .opacity(selectedTab == 1 ? 1 : 0)
 | 
			
		||||
 | 
			
		||||
                            ChatsTab(
 | 
			
		||||
                                loginViewModel: viewModel,
 | 
			
		||||
                                searchRevealProgress: $chatSearchRevealProgress,
 | 
			
		||||
                                searchText: $chatSearchText
 | 
			
		||||
                            )
 | 
			
		||||
                            if isMessengerModeEnabled {
 | 
			
		||||
                                ChatsTab(
 | 
			
		||||
                                    loginViewModel: viewModel,
 | 
			
		||||
                                    searchRevealProgress: $chatSearchRevealProgress,
 | 
			
		||||
                                    searchText: $chatSearchText
 | 
			
		||||
                                )
 | 
			
		||||
                                .opacity(selectedTab == 2 ? 1 : 0)
 | 
			
		||||
                                .allowsHitTesting(selectedTab == 2)
 | 
			
		||||
                            
 | 
			
		||||
                            ProfileTab()
 | 
			
		||||
                                .opacity(selectedTab == 3 ? 1 : 0)
 | 
			
		||||
 | 
			
		||||
                                ContactsTab()
 | 
			
		||||
                                    .opacity(selectedTab == 4 ? 1 : 0)
 | 
			
		||||
 | 
			
		||||
                                SettingsView(viewModel: viewModel)
 | 
			
		||||
                                    .opacity(selectedTab == 5 ? 1 : 0)
 | 
			
		||||
                            } else {
 | 
			
		||||
                                NewHomeTab()
 | 
			
		||||
                                    .opacity(selectedTab == 0 ? 1 : 0)
 | 
			
		||||
 | 
			
		||||
                                ConceptTab()
 | 
			
		||||
                                    .opacity(selectedTab == 1 ? 1 : 0)
 | 
			
		||||
 | 
			
		||||
                                ChatsTab(
 | 
			
		||||
                                    loginViewModel: viewModel,
 | 
			
		||||
                                    searchRevealProgress: $chatSearchRevealProgress,
 | 
			
		||||
                                    searchText: $chatSearchText
 | 
			
		||||
                                )
 | 
			
		||||
                                .opacity(selectedTab == 2 ? 1 : 0)
 | 
			
		||||
                                .allowsHitTesting(selectedTab == 2)
 | 
			
		||||
 | 
			
		||||
                                ProfileTab()
 | 
			
		||||
                                    .opacity(selectedTab == 3 ? 1 : 0)
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        .frame(maxWidth: .infinity, maxHeight: .infinity)
 | 
			
		||||
                        
 | 
			
		||||
                        CustomTabBar(selectedTab: $selectedTab) {
 | 
			
		||||
                        CustomTabBar(selectedTab: $selectedTab, isMessengerModeEnabled: isMessengerModeEnabled) {
 | 
			
		||||
                            print("Create button tapped")
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
@ -94,10 +114,12 @@ struct MainView: View {
 | 
			
		||||
                        .allowsHitTesting(menuOffset > 0)
 | 
			
		||||
 | 
			
		||||
                    // Боковое меню
 | 
			
		||||
                    SideMenuView(viewModel: viewModel, isPresented: $isSideMenuPresented)
 | 
			
		||||
                        .frame(width: menuWidth)
 | 
			
		||||
                        .offset(x: -menuWidth + menuOffset) // Новая логика смещения
 | 
			
		||||
                        .ignoresSafeArea(edges: .vertical)
 | 
			
		||||
                    if !isMessengerModeEnabled {
 | 
			
		||||
                        SideMenuView(viewModel: viewModel, isPresented: $isSideMenuPresented)
 | 
			
		||||
                            .frame(width: menuWidth)
 | 
			
		||||
                            .offset(x: -menuWidth + menuOffset) // Новая логика смещения
 | 
			
		||||
                            .ignoresSafeArea(edges: .vertical)
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                deepLinkNavigationLink
 | 
			
		||||
@ -142,6 +164,12 @@ struct MainView: View {
 | 
			
		||||
                menuOffset = presented ? menuWidth : 0
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        .onAppear {
 | 
			
		||||
            enforceTabSelectionForMessengerMode()
 | 
			
		||||
        }
 | 
			
		||||
        .onChange(of: isMessengerModeEnabled) { _ in
 | 
			
		||||
            enforceTabSelectionForMessengerMode()
 | 
			
		||||
        }
 | 
			
		||||
        .onChange(of: messageCenter.pendingNavigation?.id) { _ in
 | 
			
		||||
            guard !AppConfig.PRESENT_CHAT_AS_SHEET,
 | 
			
		||||
                  let target = messageCenter.pendingNavigation else { return }
 | 
			
		||||
@ -173,6 +201,16 @@ struct MainView: View {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
private extension MainView {
 | 
			
		||||
    func enforceTabSelectionForMessengerMode() {
 | 
			
		||||
        if isMessengerModeEnabled {
 | 
			
		||||
            if selectedTab < 2 {
 | 
			
		||||
                selectedTab = 2
 | 
			
		||||
            }
 | 
			
		||||
        } else if selectedTab > 3 {
 | 
			
		||||
            selectedTab = 0
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    var deepLinkNavigationLink: some View {
 | 
			
		||||
        NavigationLink(
 | 
			
		||||
            destination: deepLinkChatDestination,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user