Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7c8c1c0a0 | ||
|
|
73bf1ee6fc | ||
|
|
c5906f42b7 | ||
|
|
27a6ce7ce3 | ||
|
|
82168755e2 | ||
|
|
6c7716ec16 | ||
|
|
d8b683d570 | ||
|
|
1fdc8dbf45 | ||
|
|
58e3488a9d | ||
|
|
d7067db1d6 | ||
|
|
927ac45ec8 | ||
|
|
f172e33123 | ||
|
|
05a0d85c09 |
@ -91,7 +91,7 @@ struct TopBarView: View {
|
||||
.padding()
|
||||
.frame(height: 50) // Стандартная высота для нав. бара
|
||||
|
||||
// Divider()
|
||||
Divider()
|
||||
}
|
||||
.background(Color(UIColor.systemBackground))
|
||||
}
|
||||
|
||||
@ -132,16 +132,9 @@ class PostService {
|
||||
}
|
||||
}
|
||||
|
||||
func fetchAllPosts(page: Int, limit: Int, completion: @escaping ([Post]) -> Void) {
|
||||
func fetchAllPosts(completion: @escaping ([Post]) -> Void) {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
let start = page * limit
|
||||
let end = min(start + limit, self.posts.count)
|
||||
|
||||
if start < end {
|
||||
completion(Array(self.posts[start..<end]))
|
||||
} else {
|
||||
completion([])
|
||||
}
|
||||
completion(self.posts)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
53
Shared/Services/ThemeManager.swift
Normal file
53
Shared/Services/ThemeManager.swift
Normal file
@ -0,0 +1,53 @@
|
||||
import SwiftUI
|
||||
|
||||
// Enum to represent the three theme options
|
||||
enum Theme: String, CaseIterable {
|
||||
case system = "System"
|
||||
case light = "Light"
|
||||
case dark = "Dark"
|
||||
|
||||
var colorScheme: ColorScheme? {
|
||||
switch self {
|
||||
case .system:
|
||||
return nil
|
||||
case .light:
|
||||
return .light
|
||||
case .dark:
|
||||
return .dark
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Observable class to manage the theme state
|
||||
class ThemeManager: ObservableObject {
|
||||
@AppStorage("selectedTheme") private var selectedThemeValue: String = Theme.system.rawValue
|
||||
|
||||
@Published var theme: Theme
|
||||
|
||||
init() {
|
||||
// Read directly from UserDefaults to avoid using self before initialization is complete.
|
||||
let storedThemeValue = UserDefaults.standard.string(forKey: "selectedTheme") ?? ""
|
||||
self.theme = Theme(rawValue: storedThemeValue) ?? .system
|
||||
}
|
||||
|
||||
func setTheme(_ theme: Theme) {
|
||||
self.theme = theme
|
||||
selectedThemeValue = theme.rawValue
|
||||
}
|
||||
|
||||
// This will be called from the button
|
||||
func toggleTheme(from currentSystemScheme: ColorScheme) {
|
||||
let newTheme: Theme
|
||||
|
||||
switch theme {
|
||||
case .system:
|
||||
// If system is active, toggle to the opposite of the current system theme
|
||||
newTheme = currentSystemScheme == .dark ? .light : .dark
|
||||
case .light:
|
||||
newTheme = .dark
|
||||
case .dark:
|
||||
newTheme = .light
|
||||
}
|
||||
setTheme(newTheme)
|
||||
}
|
||||
}
|
||||
@ -5,70 +5,26 @@ class NewHomeTabViewModel: ObservableObject {
|
||||
@Published var posts: [Post] = []
|
||||
@Published var isLoading = true
|
||||
@Published var isRefreshing = false
|
||||
@Published var isLoadingPage = false
|
||||
|
||||
@Published var canLoadMorePages = true
|
||||
|
||||
private var currentPage = 0
|
||||
private let postsPerPage = 10
|
||||
|
||||
private var hasLoadedData = false
|
||||
|
||||
func fetchDataIfNeeded() {
|
||||
guard posts.isEmpty else { return }
|
||||
fetchPosts()
|
||||
guard !hasLoadedData else { return }
|
||||
refreshData()
|
||||
}
|
||||
|
||||
func refreshData() {
|
||||
guard !isRefreshing else { return }
|
||||
|
||||
isRefreshing = true
|
||||
currentPage = 0
|
||||
canLoadMorePages = true
|
||||
|
||||
fetchPosts(isRefresh: true)
|
||||
}
|
||||
|
||||
func loadMoreContentIfNeeded(currentItem item: Post?) {
|
||||
guard let item = item else {
|
||||
fetchPosts()
|
||||
return
|
||||
DispatchQueue.main.async {
|
||||
self.isRefreshing = true
|
||||
}
|
||||
|
||||
let thresholdIndex = posts.index(posts.endIndex, offsetBy: -5)
|
||||
if posts.firstIndex(where: { $0.id == item.id }) == thresholdIndex {
|
||||
fetchPosts()
|
||||
}
|
||||
}
|
||||
|
||||
private func fetchPosts(isRefresh: Bool = false) {
|
||||
guard !isLoadingPage, canLoadMorePages else {
|
||||
if isRefresh {
|
||||
DispatchQueue.main.async {
|
||||
self.isRefreshing = false
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
isLoadingPage = true
|
||||
if isRefresh {
|
||||
currentPage = 0
|
||||
} else {
|
||||
currentPage += 1
|
||||
}
|
||||
|
||||
PostService.shared.fetchAllPosts(page: currentPage, limit: postsPerPage) { [weak self] fetchedPosts in
|
||||
PostService.shared.fetchAllPosts { [weak self] fetchedPosts in
|
||||
guard let self = self else { return }
|
||||
|
||||
DispatchQueue.main.async {
|
||||
if isRefresh {
|
||||
self.posts = fetchedPosts
|
||||
} else {
|
||||
self.posts.append(contentsOf: fetchedPosts)
|
||||
}
|
||||
|
||||
self.canLoadMorePages = !fetchedPosts.isEmpty
|
||||
self.posts = fetchedPosts
|
||||
self.isLoading = false
|
||||
self.isLoadingPage = false
|
||||
self.hasLoadedData = true
|
||||
self.isRefreshing = false
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,8 +33,8 @@ struct CustomTabBar: View {
|
||||
}
|
||||
.padding(.horizontal)
|
||||
.padding(.top, 1)
|
||||
.padding(.bottom, 18) // Добавляем отступ снизу
|
||||
.background(Color(.systemGray6))
|
||||
.padding(.bottom, 30) // Добавляем отступ снизу
|
||||
// .background(Color(.systemGray6))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -32,25 +32,6 @@ struct HomeTab: View {
|
||||
}
|
||||
}
|
||||
|
||||
// private func fetchData(isInitialLoad: Bool = false) {
|
||||
// if isInitialLoad {
|
||||
// isLoading = true
|
||||
// } else {
|
||||
// isRefreshing = true
|
||||
// }
|
||||
//
|
||||
// PostService.shared.fetchAllPosts { fetchedPosts in
|
||||
// self.posts = fetchedPosts
|
||||
//
|
||||
// if isInitialLoad {
|
||||
// print("content updated")
|
||||
// self.isLoading = false
|
||||
// }
|
||||
// self.isRefreshing = false
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
private func fetchData(isInitialLoad: Bool = false) {
|
||||
if isInitialLoad {
|
||||
isLoading = true
|
||||
@ -58,13 +39,14 @@ struct HomeTab: View {
|
||||
isRefreshing = true
|
||||
}
|
||||
|
||||
// Временный код вместо PostService
|
||||
self.posts = [] // или сюда можно подставить мок-данные
|
||||
|
||||
// Сбрасываем индикаторы загрузки
|
||||
if isInitialLoad {
|
||||
self.isLoading = false
|
||||
PostService.shared.fetchAllPosts { fetchedPosts in
|
||||
self.posts = fetchedPosts
|
||||
|
||||
if isInitialLoad {
|
||||
print("content updated")
|
||||
self.isLoading = false
|
||||
}
|
||||
self.isRefreshing = false
|
||||
}
|
||||
self.isRefreshing = false
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,8 +10,9 @@ struct MainView: View {
|
||||
@State private var accounts = ["@user1", "@user2", "@user3"]
|
||||
@State private var sheetType: ProfileTab.SheetType? = nil
|
||||
|
||||
// Состояние для бокового меню
|
||||
// Состояния для бокового меню
|
||||
@State private var isSideMenuPresented = false
|
||||
@State private var menuOffset: CGFloat = 0
|
||||
|
||||
private var tabTitle: String {
|
||||
switch selectedTab {
|
||||
@ -22,10 +23,14 @@ struct MainView: View {
|
||||
default: return "Home"
|
||||
}
|
||||
}
|
||||
|
||||
private var menuWidth: CGFloat {
|
||||
UIScreen.main.bounds.width * 0.8
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
ZStack {
|
||||
ZStack(alignment: .leading) { // Выравниваем ZStack по левому краю
|
||||
// Основной контент
|
||||
VStack(spacing: 0) {
|
||||
TopBarView(
|
||||
@ -56,35 +61,70 @@ struct MainView: View {
|
||||
print("Create button tapped")
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity) // Убедимся, что основной контент занимает все пространство
|
||||
.ignoresSafeArea(edges: .bottom)
|
||||
.navigationBarHidden(true)
|
||||
.sheet(item: $sheetType) { type in
|
||||
// ... sheet presentation logic
|
||||
}
|
||||
// Затемнение фона при открытом меню
|
||||
.background(isSideMenuPresented ? Color.black.opacity(0.4) : Color.clear)
|
||||
.onTapGesture {
|
||||
if isSideMenuPresented {
|
||||
withAnimation {
|
||||
|
||||
// Затемнение и закрытие по тапу
|
||||
Color.black
|
||||
.opacity(Double(menuOffset / menuWidth) * 0.4)
|
||||
.ignoresSafeArea()
|
||||
.onTapGesture {
|
||||
withAnimation(.easeInOut) {
|
||||
isSideMenuPresented = false
|
||||
}
|
||||
}
|
||||
}
|
||||
.allowsHitTesting(menuOffset > 0)
|
||||
|
||||
// Боковое меню
|
||||
if isSideMenuPresented {
|
||||
HStack {
|
||||
SideMenuView(isPresented: $isSideMenuPresented)
|
||||
.frame(width: UIScreen.main.bounds.width * 0.8)
|
||||
Spacer()
|
||||
}
|
||||
.ignoresSafeArea(edges: .vertical) // Игнорируем safe area
|
||||
.transition(.move(edge: .leading))
|
||||
.zIndex(1) // Убедимся, что меню поверх всего
|
||||
}
|
||||
SideMenuView(isPresented: $isSideMenuPresented)
|
||||
.frame(width: menuWidth)
|
||||
.offset(x: -menuWidth + menuOffset) // Новая логика смещения
|
||||
.ignoresSafeArea(edges: .vertical)
|
||||
}
|
||||
.gesture(
|
||||
DragGesture()
|
||||
.onChanged { gesture in
|
||||
if !isSideMenuPresented && gesture.startLocation.x > 60 { return }
|
||||
|
||||
let translation = gesture.translation.width
|
||||
|
||||
// Определяем базовое смещение в зависимости от того, открыто меню или нет
|
||||
let baseOffset = isSideMenuPresented ? menuWidth : 0
|
||||
|
||||
// Новое смещение — это база плюс текущий свайп
|
||||
let newOffset = baseOffset + translation
|
||||
|
||||
// Жестко ограничиваем итоговое смещение между 0 и шириной меню
|
||||
self.menuOffset = max(0, min(menuWidth, newOffset))
|
||||
}
|
||||
.onEnded { gesture in
|
||||
if !isSideMenuPresented && gesture.startLocation.x > 60 { return }
|
||||
|
||||
let threshold = menuWidth * 0.4
|
||||
|
||||
withAnimation(.easeInOut) {
|
||||
if self.menuOffset > threshold {
|
||||
isSideMenuPresented = true
|
||||
} else {
|
||||
isSideMenuPresented = false
|
||||
}
|
||||
// Устанавливаем финальное смещение после анимации
|
||||
self.menuOffset = isSideMenuPresented ? menuWidth : 0
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
.navigationViewStyle(StackNavigationViewStyle())
|
||||
.onChange(of: isSideMenuPresented) { presented in
|
||||
// Плавная анимация при нажатии на кнопку, а не только при жесте
|
||||
withAnimation(.easeInOut) {
|
||||
menuOffset = presented ? menuWidth : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,5 +132,6 @@ struct MainView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let mockViewModel = LoginViewModel()
|
||||
MainView(viewModel: mockViewModel)
|
||||
.environmentObject(ThemeManager())
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,37 +19,19 @@ struct NewHomeTab: View {
|
||||
RefreshableScrollView(isRefreshing: $viewModel.isRefreshing, onRefresh: {
|
||||
viewModel.refreshData()
|
||||
}) {
|
||||
VStack {
|
||||
HStack(alignment: .top, spacing: 6) {
|
||||
LazyVStack(spacing: 6) {
|
||||
ForEach(column1Posts) { post in
|
||||
PostGridItem(post: post)
|
||||
.onAppear {
|
||||
viewModel.loadMoreContentIfNeeded(currentItem: post)
|
||||
}
|
||||
}
|
||||
}
|
||||
LazyVStack(spacing: 6) {
|
||||
ForEach(column2Posts) { post in
|
||||
PostGridItem(post: post)
|
||||
.onAppear {
|
||||
viewModel.loadMoreContentIfNeeded(currentItem: post)
|
||||
}
|
||||
}
|
||||
HStack(alignment: .top, spacing: 6) {
|
||||
LazyVStack(spacing: 6) {
|
||||
ForEach(column1Posts) { post in
|
||||
PostGridItem(post: post)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 4)
|
||||
|
||||
if viewModel.isLoadingPage {
|
||||
ProgressView()
|
||||
} else if !viewModel.canLoadMorePages {
|
||||
Text(":(")
|
||||
.foregroundColor(.secondary)
|
||||
.padding()
|
||||
LazyVStack(spacing: 6) {
|
||||
ForEach(column2Posts) { post in
|
||||
PostGridItem(post: post)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.padding(.horizontal, 4)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +67,6 @@ struct ProfileTab: View {
|
||||
self.selectedPostData = (post, posts)
|
||||
}
|
||||
)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -80,23 +79,6 @@ struct ProfileTab: View {
|
||||
}
|
||||
}
|
||||
|
||||
// private func fetchData(isInitialLoad: Bool = false) {
|
||||
// if isInitialLoad {
|
||||
// isLoading = true
|
||||
// } else {
|
||||
// isRefreshing = true
|
||||
// }
|
||||
//
|
||||
// PostService.shared.fetchAllPosts { fetchedPosts in
|
||||
// self.allPosts = fetchedPosts
|
||||
//
|
||||
// if isInitialLoad {
|
||||
// self.isLoading = false
|
||||
// }
|
||||
// self.isRefreshing = false
|
||||
// }
|
||||
// }
|
||||
|
||||
private func fetchData(isInitialLoad: Bool = false) {
|
||||
if isInitialLoad {
|
||||
isLoading = true
|
||||
@ -104,16 +86,16 @@ struct ProfileTab: View {
|
||||
isRefreshing = true
|
||||
}
|
||||
|
||||
// Временный код вместо PostService
|
||||
self.allPosts = [] // или сюда можно подставить мок-данные
|
||||
|
||||
// Сбрасываем индикаторы загрузки
|
||||
if isInitialLoad {
|
||||
self.isLoading = false
|
||||
PostService.shared.fetchAllPosts { fetchedPosts in
|
||||
self.allPosts = fetchedPosts
|
||||
|
||||
if isInitialLoad {
|
||||
self.isLoading = false
|
||||
}
|
||||
self.isRefreshing = false
|
||||
}
|
||||
self.isRefreshing = false
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Шапка профиля
|
||||
private var header: some View {
|
||||
VStack(spacing: 12) {
|
||||
|
||||
@ -1,78 +1,21 @@
|
||||
import SwiftUI
|
||||
|
||||
struct SideMenuView: View {
|
||||
@Binding var isPresented: Bool
|
||||
// --- HELPER STRUCTS & EXTENSIONS ---
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
// Header
|
||||
VStack(alignment: .leading) {
|
||||
Image(systemName: "person.circle.fill")
|
||||
.resizable()
|
||||
.frame(width: 60, height: 60)
|
||||
.foregroundColor(.gray)
|
||||
Text("Your Name")
|
||||
.font(.title2).bold()
|
||||
Text("@yourusername")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.padding(20)
|
||||
// Dummy data for the account list
|
||||
struct Account: Identifiable {
|
||||
let id = UUID()
|
||||
let name: String
|
||||
let username: String
|
||||
let isCurrent: Bool
|
||||
}
|
||||
|
||||
// Menu Items
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 20) {
|
||||
// Section 1
|
||||
VStack(alignment: .leading, spacing: 15) {
|
||||
SideMenuButton(icon: "person.2.fill", title: "People You May Like", action: {})
|
||||
SideMenuButton(icon: "star.fill", title: "Fun Fest", action: {})
|
||||
SideMenuButton(icon: "lightbulb.fill", title: "Creator Center", action: {})
|
||||
}
|
||||
|
||||
Divider()
|
||||
|
||||
// Section 2
|
||||
VStack(alignment: .leading, spacing: 15) {
|
||||
Text("CATEGORY").font(.caption).foregroundColor(.secondary)
|
||||
SideMenuButton(icon: "doc.text", title: "Drafts", action: {})
|
||||
SideMenuButton(icon: "bubble.left", title: "My Comments", action: {})
|
||||
SideMenuButton(icon: "clock", title: "History", action: {})
|
||||
SideMenuButton(icon: "arrow.down.circle", title: "My Downloads", action: {})
|
||||
}
|
||||
|
||||
Divider()
|
||||
|
||||
// Section 3
|
||||
VStack(alignment: .leading, spacing: 15) {
|
||||
Text("SERVICES").font(.caption).foregroundColor(.secondary)
|
||||
SideMenuButton(icon: "shippingbox", title: "Orders", action: {})
|
||||
SideMenuButton(icon: "cart", title: "Cart", action: {})
|
||||
SideMenuButton(icon: "wallet.pass", title: "Wallet", action: {})
|
||||
}
|
||||
|
||||
Divider()
|
||||
|
||||
// Section 4
|
||||
VStack(alignment: .leading, spacing: 15) {
|
||||
SideMenuButton(icon: "square.grid.2x2", title: "Applets", action: {})
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
// Footer
|
||||
HStack(spacing: 20) {
|
||||
Spacer()
|
||||
SideMenuFooterButton(icon: "qrcode.viewfinder", title: "Scan", action: {})
|
||||
SideMenuFooterButton(icon: "questionmark.circle", title: "Help Center", action: {})
|
||||
SideMenuFooterButton(icon: "gear", title: "Settings", action: {})
|
||||
Spacer()
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
.background(Color(UIColor.systemBackground))
|
||||
// Custom Transition for older Xcode versions
|
||||
extension AnyTransition {
|
||||
static var slideAndFade: AnyTransition {
|
||||
let insertion = AnyTransition.move(edge: .top).combined(with: .opacity)
|
||||
let removal = AnyTransition.move(edge: .top).combined(with: .opacity)
|
||||
return .asymmetric(insertion: insertion, removal: removal)
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +32,7 @@ struct SideMenuButton: View {
|
||||
.font(.title3)
|
||||
.frame(width: 30)
|
||||
Text(title)
|
||||
.font(.headline)
|
||||
.font(.subheadline)
|
||||
}
|
||||
.foregroundColor(.primary)
|
||||
.padding(.vertical, 8)
|
||||
@ -108,9 +51,209 @@ struct SideMenuFooterButton: View {
|
||||
Image(systemName: icon)
|
||||
.font(.title2)
|
||||
Text(title)
|
||||
.font(.caption)
|
||||
.font(.caption2)
|
||||
}
|
||||
.foregroundColor(.primary)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- MAIN VIEW ---
|
||||
|
||||
struct SideMenuView: View {
|
||||
@EnvironmentObject var themeManager: ThemeManager
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
@Binding var isPresented: Bool
|
||||
@State private var isAccountListExpanded = false
|
||||
|
||||
// Adjustable paddings
|
||||
private let topPadding: CGFloat = 66
|
||||
private let bottomPadding: CGFloat = 34
|
||||
|
||||
// Dummy account data
|
||||
private let accounts: [Account] = [
|
||||
Account(name: "Your Name", username: "@yourusername", isCurrent: true),
|
||||
Account(name: "Second Account", username: "@second", isCurrent: false),
|
||||
Account(name: "Another One", username: "@another", isCurrent: false),
|
||||
Account(name: "Test User", username: "@test", isCurrent: false),
|
||||
Account(name: "Creative Profile", username: "@creative", isCurrent: false)
|
||||
]
|
||||
|
||||
private var themeToggleButton: some View {
|
||||
Button(action: {
|
||||
themeManager.toggleTheme(from: colorScheme)
|
||||
}) {
|
||||
Image(systemName: iconName)
|
||||
.font(.title2)
|
||||
.foregroundColor(.primary)
|
||||
}
|
||||
}
|
||||
|
||||
private var iconName: String {
|
||||
let effectiveScheme: ColorScheme
|
||||
switch themeManager.theme {
|
||||
case .system:
|
||||
effectiveScheme = colorScheme
|
||||
case .light:
|
||||
effectiveScheme = .light
|
||||
case .dark:
|
||||
effectiveScheme = .dark
|
||||
}
|
||||
|
||||
return effectiveScheme == .dark ? "sun.max.fill" : "moon.fill"
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 0) { // Parent VStack
|
||||
|
||||
// --- Header ---
|
||||
HStack(alignment: .top) {
|
||||
Button(action: { }) {
|
||||
Image(systemName: "person.circle.fill")
|
||||
.resizable()
|
||||
.frame(width: 60, height: 60)
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
Spacer()
|
||||
themeToggleButton
|
||||
}
|
||||
.padding(.horizontal, 20)
|
||||
.padding(.top, topPadding)
|
||||
.padding(.bottom, 10)
|
||||
|
||||
// --- Header Button ---
|
||||
Button(action: {
|
||||
withAnimation(.spring()) {
|
||||
isAccountListExpanded.toggle()
|
||||
}
|
||||
}) {
|
||||
HStack {
|
||||
VStack(alignment: .leading) {
|
||||
Text("Your Name")
|
||||
.font(.title3).bold()
|
||||
Text("@yourusername")
|
||||
.font(.footnote)
|
||||
}
|
||||
.foregroundColor(.primary)
|
||||
|
||||
Spacer()
|
||||
|
||||
Image(systemName: isAccountListExpanded ? "chevron.up" : "chevron.down")
|
||||
.font(.headline)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 20)
|
||||
.padding(.bottom, 10)
|
||||
|
||||
// --- Collapsible Account List in a clipped container ---
|
||||
VStack {
|
||||
if isAccountListExpanded {
|
||||
VStack(alignment: .leading, spacing: 15) {
|
||||
ForEach(accounts) { account in
|
||||
HStack {
|
||||
Button(action: { }) {
|
||||
ZStack {
|
||||
Image(systemName: "person.circle.fill")
|
||||
.resizable()
|
||||
.frame(width: 32, height: 32) // Smaller icon
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
if account.isCurrent {
|
||||
Image(systemName: "checkmark.circle.fill")
|
||||
.foregroundColor(.blue)
|
||||
.background(Circle().fill(Color(UIColor.systemBackground)))
|
||||
.font(.body) // Smaller checkmark
|
||||
.offset(x: 11, y: 11) // Adjusted offset
|
||||
}
|
||||
}
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Text(account.name).font(.footnote).bold() // Smaller text
|
||||
Text(account.username).font(.caption2) // Smaller text
|
||||
}
|
||||
.foregroundColor(.primary)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 20)
|
||||
.padding(.vertical, 10)
|
||||
.transition(.slideAndFade)
|
||||
}
|
||||
}
|
||||
.clipped()
|
||||
|
||||
// Menu Items
|
||||
VStack(alignment: .leading, spacing: 20) {
|
||||
// Section 1
|
||||
VStack(alignment: .leading, spacing: 7) {
|
||||
SideMenuButton(icon: "person.2.fill", title: "People You May Like", action: {})
|
||||
SideMenuButton(icon: "star.fill", title: "Fun Fest", action: {})
|
||||
SideMenuButton(icon: "lightbulb.fill", title: "Creator Center", action: {})
|
||||
}
|
||||
|
||||
Divider()
|
||||
|
||||
// Section 2
|
||||
VStack(alignment: .leading, spacing: 7) {
|
||||
Text("CATEGORY").font(.caption2).foregroundColor(.secondary)
|
||||
SideMenuButton(icon: "doc.text", title: "Drafts", action: {})
|
||||
SideMenuButton(icon: "bubble.left", title: "My Comments", action: {})
|
||||
SideMenuButton(icon: "clock", title: "History", action: {})
|
||||
SideMenuButton(icon: "arrow.down.circle", title: "My Downloads", action: {})
|
||||
}
|
||||
|
||||
Divider()
|
||||
|
||||
// Section 3
|
||||
VStack(alignment: .leading, spacing: 7) {
|
||||
Text("SERVICES").font(.caption2).foregroundColor(.secondary)
|
||||
SideMenuButton(icon: "shippingbox", title: "Orders", action: {})
|
||||
SideMenuButton(icon: "cart", title: "Cart", action: {})
|
||||
SideMenuButton(icon: "wallet.pass", title: "Wallet", action: {})
|
||||
}
|
||||
|
||||
Divider()
|
||||
|
||||
// Section 4
|
||||
VStack(alignment: .leading, spacing: 15) {
|
||||
SideMenuButton(icon: "square.grid.2x2", title: "Applets", action: {})
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading) // Align to the left
|
||||
}
|
||||
.clipped()
|
||||
|
||||
Spacer()
|
||||
|
||||
// Footer
|
||||
HStack(spacing: 20) {
|
||||
Spacer()
|
||||
SideMenuFooterButton(icon: "qrcode.viewfinder", title: "Scan", action: {})
|
||||
SideMenuFooterButton(icon: "questionmark.circle", title: "Help Center", action: {})
|
||||
SideMenuFooterButton(icon: "gear", title: "Settings", action: {})
|
||||
Spacer()
|
||||
}
|
||||
.padding()
|
||||
.padding(.bottom, bottomPadding)
|
||||
}
|
||||
.background(Color(UIColor.systemBackground))
|
||||
}
|
||||
}
|
||||
|
||||
// --- PREVIEW ---
|
||||
|
||||
struct SideMenuView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
SideMenuView(isPresented: .constant(true))
|
||||
.environmentObject(ThemeManager())
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,31 +7,24 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
//@AppStorage("isLoggedIn") var isLoggedIn: Bool = false
|
||||
//@AppStorage("isDarkMode") private var isDarkMode: Bool = false
|
||||
//@AppStorage("currentUser") var currentUser: String = ""
|
||||
|
||||
@main
|
||||
struct volnahubApp: App {
|
||||
@AppStorage("isDarkMode") private var isDarkMode: Bool = true
|
||||
@StateObject private var themeManager = ThemeManager()
|
||||
@StateObject private var viewModel = LoginViewModel()
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ZStack {
|
||||
Color(isDarkMode ? .black : .white) // ✅ Фон в зависимости от темы
|
||||
|
||||
if viewModel.isLoading{
|
||||
Group {
|
||||
if viewModel.isLoading {
|
||||
SplashScreenView()
|
||||
}else{
|
||||
if viewModel.isLoggedIn {
|
||||
MainView(viewModel: viewModel)
|
||||
} else {
|
||||
LoginView(viewModel: viewModel)
|
||||
}
|
||||
} else if viewModel.isLoggedIn {
|
||||
MainView(viewModel: viewModel)
|
||||
} else {
|
||||
LoginView(viewModel: viewModel)
|
||||
}
|
||||
}
|
||||
.preferredColorScheme(isDarkMode ? .dark : .light)
|
||||
.environmentObject(themeManager)
|
||||
.preferredColorScheme(themeManager.theme.colorScheme)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
1A9B01662E4BFA3600887E0B /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1A9B01652E4BFA3600887E0B /* Media.xcassets */; };
|
||||
1A9B016E2E4BFB9000887E0B /* NewHomeTabViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A9B016D2E4BFB9000887E0B /* NewHomeTabViewModel.swift */; };
|
||||
1A9B017C2E4C087F00887E0B /* SideMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A9B017B2E4C087F00887E0B /* SideMenuView.swift */; };
|
||||
1A9E4FB32E4D6A67002249D6 /* ThemeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A9E4FB22E4D6A67002249D6 /* ThemeManager.swift */; };
|
||||
1AB4F8CD2E22E341002B6E40 /* AccountShareSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AB4F8CC2E22E341002B6E40 /* AccountShareSheet.swift */; };
|
||||
1AB4F8F32E22EC9F002B6E40 /* FollowersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AB4F8F22E22EC9F002B6E40 /* FollowersView.swift */; };
|
||||
1AB4F8F72E22ECAC002B6E40 /* FollowingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AB4F8F62E22ECAC002B6E40 /* FollowingView.swift */; };
|
||||
@ -90,6 +91,7 @@
|
||||
1A9B01652E4BFA3600887E0B /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = "<group>"; };
|
||||
1A9B016D2E4BFB9000887E0B /* NewHomeTabViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NewHomeTabViewModel.swift; sourceTree = "<group>"; };
|
||||
1A9B017B2E4C087F00887E0B /* SideMenuView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideMenuView.swift; sourceTree = "<group>"; };
|
||||
1A9E4FB22E4D6A67002249D6 /* ThemeManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThemeManager.swift; sourceTree = "<group>"; };
|
||||
1AB4F8CC2E22E341002B6E40 /* AccountShareSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountShareSheet.swift; sourceTree = "<group>"; };
|
||||
1AB4F8F22E22EC9F002B6E40 /* FollowersView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowersView.swift; sourceTree = "<group>"; };
|
||||
1AB4F8F62E22ECAC002B6E40 /* FollowingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowingView.swift; sourceTree = "<group>"; };
|
||||
@ -227,6 +229,7 @@
|
||||
1A7940E52DF7B341002569DA /* Services */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1A9E4FB22E4D6A67002249D6 /* ThemeManager.swift */,
|
||||
1A7940E12DF7B1C5002569DA /* KeychainService.swift */,
|
||||
);
|
||||
path = Services;
|
||||
@ -450,6 +453,7 @@
|
||||
1A7940E22DF7B1C5002569DA /* KeychainService.swift in Sources */,
|
||||
1A7940A62DF77DF5002569DA /* User.swift in Sources */,
|
||||
1A7940A22DF77DE9002569DA /* AuthService.swift in Sources */,
|
||||
1A9E4FB32E4D6A67002249D6 /* ThemeManager.swift in Sources */,
|
||||
1AEE5EB32E21A85800A3DCA3 /* SearchTab.swift in Sources */,
|
||||
1ACE61152E22FE2000B37AC5 /* PostDetailView.swift in Sources */,
|
||||
1ACE61192E22FF1400B37AC5 /* Post.swift in Sources */,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user