123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- //
- // ContentView.swift
- // Shared
- //
- // Created by Sergey Tarasov on 24.07.2022.
- //
- import SwiftUI
- struct ContentView: View {
- @State var selectedTab: Tab = .rooms
-
- var body: some View {
- NavigationView {
- TabView(selection: $selectedTab) {
- ChatListView()
- .navigationViewStyle(StackNavigationViewStyle())
- .tabItem {
- Label(Tab.contacts.string, systemImage: "person.crop.circle")
- }
- .tag(Tab.contacts)
- RoomsListView()
- .navigationViewStyle(StackNavigationViewStyle())
- .tabItem {
- Label(Tab.rooms.string, systemImage: "bubble.left.and.bubble.right")
- }
- .tag(Tab.rooms)
- Text("")
- .navigationBarTitleDisplayMode(.inline)
- .navigationViewStyle(StackNavigationViewStyle())
- .tabItem {
- Label(Tab.settings.string, systemImage: "gear")
- }
- .tag(Tab.settings)
- }
- .navigationBarTitle(returnNaviBarTitle(self.selectedTab))
- }
- }
- func returnNaviBarTitle(_ tabSelection: Tab) -> String {
- switch tabSelection {
- case .contacts: return "Контакты"
- case .rooms: return "Чаты"
- case .settings: return "Настройки"
- }
- }
- enum Tab {
- case contacts
- case rooms
- case settings
- var string: String {
- switch self {
- case .contacts: return "Контакты"
- case .rooms: return "Чаты"
- case .settings: return "Настройки"
- }
- }
- }
- }
- struct ContentView_Previews: PreviewProvider {
- static var previews: some View {
- ContentView()
- }
- }
|