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() {
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
}
}
}

View File

@ -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)
@ -58,6 +48,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) {
ForEach(0..<4) { index in
@ -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)
}
}

View File

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