iOS update: ContentView.swift

This commit is contained in:
efir369999 2026-05-05 17:16:34 +03:00
parent 4d28739503
commit f24e2de4b2

View File

@ -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 {