'Instagram like profile page with SwiftUI
I want to recreate an instagram like profile page. But want i'm trying to do now just doesnt cut it. I want the page to be refreshable and the tabs on the bottom swipeable and also the items in the list inside the tabs to have swipeactions. What i come up with up until now is
var body: some View {
ScrollView(.vertical) {
// This part is where my profile details are
TopProfileSection()
// here you can select which tab you want to see
TabsView(selectedTab: $selectedTab)
// These are the tabs
VStack {
if selectedTab == .posts {
ForEach(userModel.posts) { post in
StreamPost(post: post)
}
} else {
ForEach(userModel.upvotes) { post in
StreamPost(post: post)
}
}
}
}
}
Which semi works but doesnt have the refreshable, swipeactions and swipe between tabs functionality.
Below is something i want but obviously doesnt work since an List doesnt allow me to have a section on top which is completely different from the list and i can add TabView inside. Also the swipeActions wont work.
var body: some View {
List {
// This part is where my profile details are
TopProfileSection()
// here you can select which tab you want to see
TabsView(selectedTab: $selectedTab)
// These are the tabs
TabView(selection: $selectedTab) {
VStack {
ForEach(userModel.posts) { post in
StreamPost(post: post)
.swipeActions {
// Delete post
}
}
}
.tag("posts")
VStack {
ForEach(userModel.upvotes) { post in
StreamPost(post: post)
.swipeActions {
// Delete post
}
}
}
.tag("upvotes")
}
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
}
.refreshable {
// code to refresh the profile page
}
}
Does anyone have some tips into the right direction. UIKit i also fine.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
