From 39f4c5bb7cef50ce0a3d4ab48b0b694dffa35ec1 Mon Sep 17 00:00:00 2001 From: cheykrym Date: Sat, 12 Jul 2025 19:50:02 +0300 Subject: [PATCH] profile post update --- Shared/ViewModels/LoginViewModel.swift | 3 +- Shared/Views/tab/profile/ProfileTab.swift | 149 ++++++++++++++++++---- Shared/yobbleApp.swift | 12 +- 3 files changed, 135 insertions(+), 29 deletions(-) diff --git a/Shared/ViewModels/LoginViewModel.swift b/Shared/ViewModels/LoginViewModel.swift index ad32f91..4ec02b9 100644 --- a/Shared/ViewModels/LoginViewModel.swift +++ b/Shared/ViewModels/LoginViewModel.swift @@ -31,7 +31,7 @@ class LoginViewModel: ObservableObject { func autoLogin() { authService.autoLogin { [weak self] success, error in DispatchQueue.main.async { - self?.isLoading = false +// self?.isLoading = false if success { self?.isLoggedIn = true } else { @@ -39,6 +39,7 @@ class LoginViewModel: ObservableObject { self?.errorMessage = error ?? "Произошла ошибка." self?.showError = false } + self?.isLoading = false } } } diff --git a/Shared/Views/tab/profile/ProfileTab.swift b/Shared/Views/tab/profile/ProfileTab.swift index ad985c1..cec2dd3 100644 --- a/Shared/Views/tab/profile/ProfileTab.swift +++ b/Shared/Views/tab/profile/ProfileTab.swift @@ -5,6 +5,11 @@ struct ProfileTab: View { @State private var showingAccountSwitch = false @State private var selectedTabIndex = 0 @State private var selectedSort = "По дате" + @State private var selectedCategory = "#все" + @State private var searchQuery = "" + @State private var searchQueryArchive = "" + @State private var searchQuerySaved = "" + @State private var searchQueryLiked = "" var body: some View { NavigationView { @@ -31,21 +36,6 @@ struct ProfileTab: View { statView("156", "Подписки") } - // Кнопка редактирования - Button(action: { - // редактировать профиль - }) { - Text("Редактировать профиль") - .font(.subheadline) - .padding(.horizontal, 24) - .padding(.vertical, 8) - .overlay( - RoundedRectangle(cornerRadius: 8) - .stroke(Color.gray, lineWidth: 1) - ) - } - .padding(.top, 8) - // Вкладки профиля HStack(spacing: 32) { menuTab(index: 0) @@ -57,6 +47,77 @@ struct ProfileTab: View { } .padding(.horizontal) .frame(width: geometry.size.width) + + if selectedTabIndex == 0 { + HStack { + Menu { + // Здесь список категорий + Button("#все") { selectedCategory = "#все" } + Button("#влог") { selectedCategory = "#влог" } + Button("#игры") { selectedCategory = "#игры" } + Button("#путешествия") { selectedCategory = "#путешествия" } + } label: { + Label(selectedCategory, systemImage: "tag") + .font(.subheadline) + .padding(8) + .background(Color.gray.opacity(0.2)) + .cornerRadius(8) + } + + // Поиск + TextField("Поиск", text: $searchQuery) + .padding(.horizontal, 10) + .padding(.vertical, 6) + .background(Color.gray.opacity(0.15)) + .cornerRadius(8) + .font(.subheadline) + + Button(action: { + // Создание поста + }) { + Label("Создать", systemImage: "plus") + .font(.subheadline) + .padding(8) + .background(Color.blue.opacity(0.2)) + .cornerRadius(8) + } + } + .padding(.horizontal) + } else if selectedTabIndex == 1 { + HStack { + // Поиск + TextField("Поиск", text: $searchQueryArchive) + .padding(.horizontal, 10) + .padding(.vertical, 6) + .background(Color.gray.opacity(0.15)) + .cornerRadius(8) + .font(.subheadline) + } + .padding(.horizontal) + } else if selectedTabIndex == 2 { + HStack { + // Поиск + TextField("Поиск", text: $searchQuerySaved) + .padding(.horizontal, 10) + .padding(.vertical, 6) + .background(Color.gray.opacity(0.15)) + .cornerRadius(8) + .font(.subheadline) + } + .padding(.horizontal) + } else if selectedTabIndex == 3 { + HStack { + // Поиск + TextField("Поиск", text: $searchQueryLiked) + .padding(.horizontal, 10) + .padding(.vertical, 6) + .background(Color.gray.opacity(0.15)) + .cornerRadius(8) + .font(.subheadline) + } + .padding(.horizontal) + } + // Контентная часть TabView(selection: $selectedTabIndex) { @@ -67,17 +128,47 @@ struct ProfileTab: View { .fill(contentColor(for: index)) .aspectRatio(1, contentMode: .fit) .overlay( - index == 0 ? - Text(selectedSort) - .font(.caption2) - .foregroundColor(.gray) - .padding(4) : nil, - alignment: .bottomTrailing + ZStack { + // Верхний левый угол — дата + VStack { + HStack { + Text("3 года назад") + .font(.caption2) + .foregroundColor(.white) + .padding(4) + .background(Color.black.opacity(0.6)) + .cornerRadius(4) + Spacer() + } + Spacer() + } + .padding(4) + + // Нижний левый угол — просмотры + VStack { + Spacer() + HStack { + HStack(spacing: 4) { + Image(systemName: "play.fill") + .font(.caption2) + Text("1.2k") + .font(.caption2) + } + .foregroundColor(.white) + .padding(4) + .background(Color.black.opacity(0.6)) + .cornerRadius(4) + + Spacer() + } + .padding(4) + } + } ) + } } - .padding(.horizontal) - .tag(index) + } } .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never)) @@ -100,11 +191,21 @@ struct ProfileTab: View { } } + // Левый верх — ручка (редактирование) + ToolbarItem(placement: .navigationBarLeading) { + Button(action: { + // действие редактирования профиля + }) { + Image(systemName: "paintbrush") + .imageScale(.large) + } + } + ToolbarItem(placement: .navigationBarTrailing) { Button(action: { // перейти к настройкам }) { - Image(systemName: "gearshape") + Image(systemName: "wrench") .imageScale(.large) } } diff --git a/Shared/yobbleApp.swift b/Shared/yobbleApp.swift index fa5ad06..4e27251 100644 --- a/Shared/yobbleApp.swift +++ b/Shared/yobbleApp.swift @@ -21,10 +21,14 @@ struct volnahubApp: App { ZStack { Color(isDarkMode ? .black : .white) // ✅ Фон в зависимости от темы - if viewModel.isLoggedIn { - MainView(viewModel: viewModel) - } else { - LoginView(viewModel: viewModel) + if viewModel.isLoading{ + SplashScreenView() + }else{ + if viewModel.isLoggedIn { + MainView(viewModel: viewModel) + } else { + LoginView(viewModel: viewModel) + } } } .preferredColorScheme(isDarkMode ? .dark : .light)