From f24e2de4b2cd918cb882c7949c71960728ccfdaa Mon Sep 17 00:00:00 2001 From: efir369999 Date: Tue, 5 May 2026 17:16:34 +0300 Subject: [PATCH] iOS update: ContentView.swift --- .../Montana Messenger/ContentView.swift | 60 ++++++++++++++----- 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/Montana-iOS/Montana Messenger/Montana Messenger/ContentView.swift b/Montana-iOS/Montana Messenger/Montana Messenger/ContentView.swift index 6842373..b93e506 100644 --- a/Montana-iOS/Montana Messenger/Montana Messenger/ContentView.swift +++ b/Montana-iOS/Montana Messenger/Montana Messenger/ContentView.swift @@ -1,9 +1,41 @@ import SwiftUI struct ContentView: View { + @StateObject private var identity = IdentityManager.shared + @StateObject private var chats = ChatsStore.shared + + var body: some View { + Group { + if identity.identity == nil { + OnboardingView() + .environmentObject(identity) + } else { + MainTabs() + .environmentObject(identity) + } + } + .onChange(of: identity.identity?.accountID) { _, newID in + if newID != nil, let id = identity.identity { + chats.startPolling(identity: id) + chats.attachWebSocket(identity: id) + } else { + chats.stopPolling() + WebSocketLink.shared.disconnect() + } + } + .task { + if let id = identity.identity { + chats.startPolling(identity: id) + chats.attachWebSocket(identity: id) + } + } + } +} + +private struct MainTabs: View { @State private var selection: Tab = .chats - enum Tab { case home, chats, settings } + enum Tab { case contacts, chats, settings } init() { let appearance = UITabBarAppearance() @@ -14,12 +46,15 @@ struct ContentView: View { let normal = UIColor(ClaudeTheme.Palette.textTertiary) let active = UIColor(ClaudeTheme.Palette.gold) appearance.stackedLayoutAppearance.normal.iconColor = normal - appearance.stackedLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: normal, - .font: UIFont.systemFont(ofSize: 10, weight: .medium)] + appearance.stackedLayoutAppearance.normal.titleTextAttributes = [ + .foregroundColor: normal, + .font: UIFont.systemFont(ofSize: 10, weight: .medium) + ] appearance.stackedLayoutAppearance.selected.iconColor = active - appearance.stackedLayoutAppearance.selected.titleTextAttributes = [.foregroundColor: active, - .font: UIFont.systemFont(ofSize: 10, weight: .semibold)] - + appearance.stackedLayoutAppearance.selected.titleTextAttributes = [ + .foregroundColor: active, + .font: UIFont.systemFont(ofSize: 10, weight: .semibold) + ] UITabBar.appearance().standardAppearance = appearance UITabBar.appearance().scrollEdgeAppearance = appearance @@ -31,11 +66,6 @@ struct ContentView: View { .foregroundColor: UIColor(ClaudeTheme.Palette.textPrimary), .font: UIFont.systemFont(ofSize: 17, weight: .semibold) ] - nav.largeTitleTextAttributes = [ - .foregroundColor: UIColor(ClaudeTheme.Palette.textPrimary), - .font: UIFont(descriptor: UIFontDescriptor.preferredFontDescriptor(withTextStyle: .largeTitle) - .withDesign(.serif)!.withSymbolicTraits(.traitBold)!, size: 32) - ] UINavigationBar.appearance().standardAppearance = nav UINavigationBar.appearance().scrollEdgeAppearance = nav UINavigationBar.appearance().compactAppearance = nav @@ -44,12 +74,12 @@ struct ContentView: View { var body: some View { TabView(selection: $selection) { - HomeFeedView() + ContactsView() .tabItem { - Image(systemName: selection == .home ? "house.fill" : "house") - Text("Главная") + Image(systemName: selection == .contacts ? "person.2.fill" : "person.2") + Text("Контакты") } - .tag(Tab.home) + .tag(Tab.contacts) ChatsView() .tabItem {