profile post update

This commit is contained in:
cheykrym 2025-07-12 19:50:02 +03:00
parent 1c0c41ecac
commit 39f4c5bb7c
3 changed files with 135 additions and 29 deletions

View File

@ -31,7 +31,7 @@ class LoginViewModel: ObservableObject {
func autoLogin() { func autoLogin() {
authService.autoLogin { [weak self] success, error in authService.autoLogin { [weak self] success, error in
DispatchQueue.main.async { DispatchQueue.main.async {
self?.isLoading = false // self?.isLoading = false
if success { if success {
self?.isLoggedIn = true self?.isLoggedIn = true
} else { } else {
@ -39,6 +39,7 @@ class LoginViewModel: ObservableObject {
self?.errorMessage = error ?? "Произошла ошибка." self?.errorMessage = error ?? "Произошла ошибка."
self?.showError = false self?.showError = false
} }
self?.isLoading = false
} }
} }
} }

View File

@ -5,6 +5,11 @@ struct ProfileTab: View {
@State private var showingAccountSwitch = false @State private var showingAccountSwitch = false
@State private var selectedTabIndex = 0 @State private var selectedTabIndex = 0
@State private var selectedSort = "По дате" @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 { var body: some View {
NavigationView { NavigationView {
@ -31,21 +36,6 @@ struct ProfileTab: View {
statView("156", "Подписки") 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) { HStack(spacing: 32) {
menuTab(index: 0) menuTab(index: 0)
@ -58,6 +48,77 @@ struct ProfileTab: View {
.padding(.horizontal) .padding(.horizontal)
.frame(width: geometry.size.width) .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) { TabView(selection: $selectedTabIndex) {
ForEach(0..<4) { index in ForEach(0..<4) { index in
@ -67,17 +128,47 @@ struct ProfileTab: View {
.fill(contentColor(for: index)) .fill(contentColor(for: index))
.aspectRatio(1, contentMode: .fit) .aspectRatio(1, contentMode: .fit)
.overlay( .overlay(
index == 0 ? ZStack {
Text(selectedSort) // Верхний левый угол дата
.font(.caption2) VStack {
.foregroundColor(.gray) HStack {
.padding(4) : nil, Text("3 года назад")
alignment: .bottomTrailing .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)) .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
@ -100,11 +191,21 @@ struct ProfileTab: View {
} }
} }
// Левый верх ручка (редактирование)
ToolbarItem(placement: .navigationBarLeading) {
Button(action: {
// действие редактирования профиля
}) {
Image(systemName: "paintbrush")
.imageScale(.large)
}
}
ToolbarItem(placement: .navigationBarTrailing) { ToolbarItem(placement: .navigationBarTrailing) {
Button(action: { Button(action: {
// перейти к настройкам // перейти к настройкам
}) { }) {
Image(systemName: "gearshape") Image(systemName: "wrench")
.imageScale(.large) .imageScale(.large)
} }
} }

View File

@ -21,10 +21,14 @@ struct volnahubApp: App {
ZStack { ZStack {
Color(isDarkMode ? .black : .white) // Фон в зависимости от темы Color(isDarkMode ? .black : .white) // Фон в зависимости от темы
if viewModel.isLoggedIn { if viewModel.isLoading{
MainView(viewModel: viewModel) SplashScreenView()
} else { }else{
LoginView(viewModel: viewModel) if viewModel.isLoggedIn {
MainView(viewModel: viewModel)
} else {
LoginView(viewModel: viewModel)
}
} }
} }
.preferredColorScheme(isDarkMode ? .dark : .light) .preferredColorScheme(isDarkMode ? .dark : .light)