Compare commits
3 Commits
32dd59e635
...
9ad744f3f1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ad744f3f1 | ||
|
|
0cd38f3922 | ||
|
|
8630910c94 |
@ -14,6 +14,7 @@ struct RefreshableScrollView<Content: View>: UIViewRepresentable {
|
|||||||
|
|
||||||
func makeUIView(context: Context) -> UIScrollView {
|
func makeUIView(context: Context) -> UIScrollView {
|
||||||
let scrollView = UIScrollView()
|
let scrollView = UIScrollView()
|
||||||
|
scrollView.delaysContentTouches = false
|
||||||
|
|
||||||
let refreshControl = UIRefreshControl()
|
let refreshControl = UIRefreshControl()
|
||||||
refreshControl.addTarget(context.coordinator, action: #selector(Coordinator.handleRefresh), for: .valueChanged)
|
refreshControl.addTarget(context.coordinator, action: #selector(Coordinator.handleRefresh), for: .valueChanged)
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
//
|
//
|
||||||
// Created by cheykrym on 09/06/2025.
|
// Created by cheykrym on 09/06/2025.
|
||||||
//
|
//
|
||||||
|
// НЕ ИСПОЛЬЗУЕТСЯ
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,10 @@ struct HomeTab: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.navigationTitle("Лента")
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
|
.toolbar {
|
||||||
|
ToolbarItem(placement: .principal) {}
|
||||||
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
if posts.isEmpty {
|
if posts.isEmpty {
|
||||||
fetchData(isInitialLoad: true)
|
fetchData(isInitialLoad: true)
|
||||||
@ -35,6 +38,8 @@ struct HomeTab: View {
|
|||||||
private func fetchData(isInitialLoad: Bool = false) {
|
private func fetchData(isInitialLoad: Bool = false) {
|
||||||
if isInitialLoad {
|
if isInitialLoad {
|
||||||
isLoading = true
|
isLoading = true
|
||||||
|
} else {
|
||||||
|
isRefreshing = true
|
||||||
}
|
}
|
||||||
|
|
||||||
PostService.shared.fetchAllPosts { fetchedPosts in
|
PostService.shared.fetchAllPosts { fetchedPosts in
|
||||||
|
|||||||
@ -43,15 +43,7 @@ struct ProfileContentTabbedGrid: View {
|
|||||||
.cornerRadius(8)
|
.cornerRadius(8)
|
||||||
.font(.subheadline)
|
.font(.subheadline)
|
||||||
|
|
||||||
Button {
|
|
||||||
// Создать пост
|
|
||||||
} label: {
|
|
||||||
Label("Создать", systemImage: "plus")
|
|
||||||
.font(.subheadline)
|
|
||||||
.padding(8)
|
|
||||||
.background(Color.blue.opacity(0.2))
|
|
||||||
.cornerRadius(8)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
TextField("Поиск", text: $searchQuery)
|
TextField("Поиск", text: $searchQuery)
|
||||||
.padding(.horizontal, 10)
|
.padding(.horizontal, 10)
|
||||||
|
|||||||
@ -22,50 +22,72 @@ struct ProfileTab: View {
|
|||||||
|
|
||||||
@State private var selectedPostData: (Post, [Post])?
|
@State private var selectedPostData: (Post, [Post])?
|
||||||
|
|
||||||
|
@State private var isShowingFollowers = false
|
||||||
|
@State private var isShowingFollowing = false
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
if !isContentLoaded {
|
if !isContentLoaded {
|
||||||
SplashScreenView()
|
SplashScreenView()
|
||||||
} else {
|
} else {
|
||||||
VStack(spacing: 0) {
|
ZStack(alignment: .bottomTrailing) {
|
||||||
// Скрытый NavigationLink для программного перехода
|
VStack(spacing: 0) {
|
||||||
if let (post, posts) = selectedPostData {
|
// Скрытые NavigationLink для программного перехода
|
||||||
NavigationLink(
|
NavigationLink(destination: FollowersView(followers: followers), isActive: $isShowingFollowers) { EmptyView() }
|
||||||
destination: PostFeedView(posts: posts, selectedPostID: post.id),
|
NavigationLink(destination: FollowingView(following: following), isActive: $isShowingFollowing) { EmptyView() }
|
||||||
isActive: Binding(
|
|
||||||
get: { selectedPostData != nil },
|
if let (post, posts) = selectedPostData {
|
||||||
set: { if !$0 { selectedPostData = nil } }
|
NavigationLink(
|
||||||
),
|
destination: PostFeedView(posts: posts, selectedPostID: post.id),
|
||||||
label: { EmptyView() }
|
isActive: Binding(
|
||||||
)
|
get: { selectedPostData != nil },
|
||||||
}
|
set: { if !$0 { selectedPostData = nil } }
|
||||||
|
),
|
||||||
RefreshableScrollView(isRefreshing: $isRefreshing, onRefresh: {
|
label: { EmptyView() }
|
||||||
fetchData()
|
|
||||||
}) {
|
|
||||||
VStack(spacing: 0) {
|
|
||||||
header
|
|
||||||
.frame(minHeight: 300)
|
|
||||||
.frame(maxWidth: .infinity)
|
|
||||||
.background(Color(.systemBackground))
|
|
||||||
|
|
||||||
ProfileContentTabbedGrid(
|
|
||||||
isContentLoaded: isContentLoaded,
|
|
||||||
allPosts: $allPosts,
|
|
||||||
isLoading: $isLoading,
|
|
||||||
onPostTapped: { post, posts in
|
|
||||||
self.selectedPostData = (post, posts)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RefreshableScrollView(isRefreshing: $isRefreshing, onRefresh: {
|
||||||
|
fetchData()
|
||||||
|
}) {
|
||||||
|
VStack(spacing: 12) {
|
||||||
|
header
|
||||||
|
// .frame(minHeight: 300)
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.background(Color(.systemBackground))
|
||||||
|
|
||||||
|
ProfileContentTabbedGrid(
|
||||||
|
isContentLoaded: isContentLoaded,
|
||||||
|
allPosts: $allPosts,
|
||||||
|
isLoading: $isLoading,
|
||||||
|
onPostTapped: { post, posts in
|
||||||
|
self.selectedPostData = (post, posts)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FAB
|
||||||
|
Button(action: {
|
||||||
|
// TODO: Действие для создания поста
|
||||||
|
}) {
|
||||||
|
Image(systemName: "plus")
|
||||||
|
.font(.system(size: 24, weight: .bold))
|
||||||
|
.foregroundColor(.white)
|
||||||
|
.padding()
|
||||||
|
.background(Color.blue)
|
||||||
|
.clipShape(Circle())
|
||||||
|
.shadow(radius: 5)
|
||||||
|
}
|
||||||
|
.padding()
|
||||||
}
|
}
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem(placement: .principal) {
|
ToolbarItem(placement: .principal) {
|
||||||
Button(action: { sheetType = .accountShare }) {
|
Button(action: { sheetType = .accountShare }) {
|
||||||
HStack(spacing: 4) {
|
HStack(spacing: 4) {
|
||||||
Text("custom_user_name")
|
Text(selectedAccount)
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.foregroundColor(.primary)
|
.foregroundColor(.primary)
|
||||||
Image(systemName: "chevron.down")
|
Image(systemName: "chevron.down")
|
||||||
@ -131,7 +153,7 @@ struct ProfileTab: View {
|
|||||||
.frame(width: 72, height: 72)
|
.frame(width: 72, height: 72)
|
||||||
.foregroundColor(.gray)
|
.foregroundColor(.gray)
|
||||||
|
|
||||||
Text(selectedAccount)
|
Text("custom_user_name")
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
}
|
}
|
||||||
.padding(.top, 16)
|
.padding(.top, 16)
|
||||||
@ -145,10 +167,10 @@ struct ProfileTab: View {
|
|||||||
// Статистика
|
// Статистика
|
||||||
HStack(spacing: 32) {
|
HStack(spacing: 32) {
|
||||||
statView("24", "Посты")
|
statView("24", "Посты")
|
||||||
NavigationLink(destination: FollowersView(followers: followers)) {
|
Button(action: { isShowingFollowers = true }) {
|
||||||
statView("1.2k", "Подписчики")
|
statView("1.2k", "Подписчики")
|
||||||
}
|
}
|
||||||
NavigationLink(destination: FollowingView(following: following)) {
|
Button(action: { isShowingFollowing = true }) {
|
||||||
statView("156", "Подписки")
|
statView("156", "Подписки")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,5 +186,6 @@ struct ProfileTab: View {
|
|||||||
Text(label)
|
Text(label)
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
}
|
}
|
||||||
|
.foregroundColor(.primary)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,3 +1,5 @@
|
|||||||
|
// НЕ ИСПОЛЬЗУЕТСЯ
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct PublicsTab: View {
|
struct PublicsTab: View {
|
||||||
|
|||||||
@ -250,13 +250,14 @@
|
|||||||
1AEE5EA92E21A4FC00A3DCA3 /* Tab */ = {
|
1AEE5EA92E21A4FC00A3DCA3 /* Tab */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
1AEE5ECC2E21C9D100A3DCA3 /* Profile */,
|
|
||||||
1A7940C52DF7A98E002569DA /* ContactsTab.swift */,
|
|
||||||
1A7940C92DF7A99B002569DA /* ChatsTab.swift */,
|
|
||||||
1A7940B52DF77F21002569DA /* MainView.swift */,
|
1A7940B52DF77F21002569DA /* MainView.swift */,
|
||||||
1AEE5EAA2E21A83200A3DCA3 /* HomeTab.swift */,
|
1AEE5EAA2E21A83200A3DCA3 /* HomeTab.swift */,
|
||||||
1AEE5EAE2E21A84500A3DCA3 /* PublicsTab.swift */,
|
|
||||||
1AEE5EB22E21A85800A3DCA3 /* SearchTab.swift */,
|
1AEE5EB22E21A85800A3DCA3 /* SearchTab.swift */,
|
||||||
|
1A7940C92DF7A99B002569DA /* ChatsTab.swift */,
|
||||||
|
1A7940CD2DF7A9AA002569DA /* ProfileTab.swift */,
|
||||||
|
1AEE5ECC2E21C9D100A3DCA3 /* Profile */,
|
||||||
|
1A7940C52DF7A98E002569DA /* ContactsTab.swift */,
|
||||||
|
1AEE5EAE2E21A84500A3DCA3 /* PublicsTab.swift */,
|
||||||
);
|
);
|
||||||
path = Tab;
|
path = Tab;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -266,7 +267,6 @@
|
|||||||
children = (
|
children = (
|
||||||
1AD757CC2E27608C0069C1FD /* PostFeedView.swift */,
|
1AD757CC2E27608C0069C1FD /* PostFeedView.swift */,
|
||||||
1ACE60FF2E22F54700B37AC5 /* Settings */,
|
1ACE60FF2E22F54700B37AC5 /* Settings */,
|
||||||
1A7940CD2DF7A9AA002569DA /* ProfileTab.swift */,
|
|
||||||
1AB4F8CC2E22E341002B6E40 /* AccountShareSheet.swift */,
|
1AB4F8CC2E22E341002B6E40 /* AccountShareSheet.swift */,
|
||||||
1AE587242E23337000254F06 /* ProfileContentGrid.swift */,
|
1AE587242E23337000254F06 /* ProfileContentGrid.swift */,
|
||||||
1ACE61202E22FFD000B37AC5 /* ProfileContentTabbedGrid.swift */,
|
1ACE61202E22FFD000B37AC5 /* ProfileContentTabbedGrid.swift */,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user