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 import SwiftUI
struct ContentView: View { 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 @State private var selection: Tab = .chats
enum Tab { case home, chats, settings } enum Tab { case contacts, chats, settings }
init() { init() {
let appearance = UITabBarAppearance() let appearance = UITabBarAppearance()
@ -14,12 +46,15 @@ struct ContentView: View {
let normal = UIColor(ClaudeTheme.Palette.textTertiary) let normal = UIColor(ClaudeTheme.Palette.textTertiary)
let active = UIColor(ClaudeTheme.Palette.gold) let active = UIColor(ClaudeTheme.Palette.gold)
appearance.stackedLayoutAppearance.normal.iconColor = normal appearance.stackedLayoutAppearance.normal.iconColor = normal
appearance.stackedLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: normal, appearance.stackedLayoutAppearance.normal.titleTextAttributes = [
.font: UIFont.systemFont(ofSize: 10, weight: .medium)] .foregroundColor: normal,
.font: UIFont.systemFont(ofSize: 10, weight: .medium)
]
appearance.stackedLayoutAppearance.selected.iconColor = active appearance.stackedLayoutAppearance.selected.iconColor = active
appearance.stackedLayoutAppearance.selected.titleTextAttributes = [.foregroundColor: active, appearance.stackedLayoutAppearance.selected.titleTextAttributes = [
.font: UIFont.systemFont(ofSize: 10, weight: .semibold)] .foregroundColor: active,
.font: UIFont.systemFont(ofSize: 10, weight: .semibold)
]
UITabBar.appearance().standardAppearance = appearance UITabBar.appearance().standardAppearance = appearance
UITabBar.appearance().scrollEdgeAppearance = appearance UITabBar.appearance().scrollEdgeAppearance = appearance
@ -31,11 +66,6 @@ struct ContentView: View {
.foregroundColor: UIColor(ClaudeTheme.Palette.textPrimary), .foregroundColor: UIColor(ClaudeTheme.Palette.textPrimary),
.font: UIFont.systemFont(ofSize: 17, weight: .semibold) .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().standardAppearance = nav
UINavigationBar.appearance().scrollEdgeAppearance = nav UINavigationBar.appearance().scrollEdgeAppearance = nav
UINavigationBar.appearance().compactAppearance = nav UINavigationBar.appearance().compactAppearance = nav
@ -44,12 +74,12 @@ struct ContentView: View {
var body: some View { var body: some View {
TabView(selection: $selection) { TabView(selection: $selection) {
HomeFeedView() ContactsView()
.tabItem { .tabItem {
Image(systemName: selection == .home ? "house.fill" : "house") Image(systemName: selection == .contacts ? "person.2.fill" : "person.2")
Text("Главная") Text("Контакты")
} }
.tag(Tab.home) .tag(Tab.contacts)
ChatsView() ChatsView()
.tabItem { .tabItem {