mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 02:01:02 +00:00
Various fixes
This commit is contained in:
parent
5db6d2d991
commit
94d4db6214
5 changed files with 58 additions and 33 deletions
|
@ -15,6 +15,7 @@ struct AccountDetailHeaderView: View {
|
|||
let isCurrentUser: Bool
|
||||
let account: Account
|
||||
let relationship: Relationshionship?
|
||||
let scrollViewProxy: ScrollViewProxy?
|
||||
|
||||
@Binding var scrollOffset: CGFloat
|
||||
|
||||
|
@ -83,7 +84,13 @@ struct AccountDetailHeaderView: View {
|
|||
}
|
||||
Spacer()
|
||||
Group {
|
||||
makeCustomInfoLabel(title: "Posts", count: account.statusesCount)
|
||||
Button {
|
||||
withAnimation {
|
||||
scrollViewProxy?.scrollTo("status", anchor: .top)
|
||||
}
|
||||
} label: {
|
||||
makeCustomInfoLabel(title: "Posts", count: account.statusesCount)
|
||||
}
|
||||
NavigationLink(value: RouteurDestinations.following(id: account.id)) {
|
||||
makeCustomInfoLabel(title: "Following", count: account.followingCount)
|
||||
}
|
||||
|
@ -139,6 +146,7 @@ struct AccountDetailHeaderView_Previews: PreviewProvider {
|
|||
AccountDetailHeaderView(isCurrentUser: false,
|
||||
account: .placeholder(),
|
||||
relationship: .placeholder(),
|
||||
scrollViewProxy: nil,
|
||||
scrollOffset: .constant(0))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,34 +34,39 @@ public struct AccountDetailView: View {
|
|||
}
|
||||
|
||||
public var body: some View {
|
||||
ScrollViewOffsetReader { offset in
|
||||
self.scrollOffset = offset
|
||||
} content: {
|
||||
LazyVStack(alignment: .leading) {
|
||||
headerView
|
||||
familliarFollowers
|
||||
.offset(y: -36)
|
||||
featuredTagsView
|
||||
.offset(y: -36)
|
||||
if isCurrentUser {
|
||||
Picker("", selection: $viewModel.selectedTab) {
|
||||
ForEach(AccountDetailViewModel.Tab.allCases, id: \.self) { tab in
|
||||
Text(tab.title).tag(tab)
|
||||
ScrollViewReader { proxy in
|
||||
ScrollViewOffsetReader { offset in
|
||||
self.scrollOffset = offset
|
||||
} content: {
|
||||
LazyVStack(alignment: .leading) {
|
||||
makeHeaderView(proxy: proxy)
|
||||
familliarFollowers
|
||||
.offset(y: -36)
|
||||
featuredTagsView
|
||||
.offset(y: -36)
|
||||
Group {
|
||||
if isCurrentUser {
|
||||
Picker("", selection: $viewModel.selectedTab) {
|
||||
ForEach(AccountDetailViewModel.Tab.allCases, id: \.self) { tab in
|
||||
Text(tab.title).tag(tab)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
||||
.offset(y: -20)
|
||||
} else {
|
||||
Divider()
|
||||
.offset(y: -20)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
||||
.offset(y: -20)
|
||||
} else {
|
||||
Divider()
|
||||
.offset(y: -20)
|
||||
}
|
||||
.id("status")
|
||||
|
||||
switch viewModel.tabState {
|
||||
case .statuses:
|
||||
StatusesListView(fetcher: viewModel)
|
||||
case let .followedTags(tags):
|
||||
makeTagsListView(tags: tags)
|
||||
switch viewModel.tabState {
|
||||
case .statuses:
|
||||
StatusesListView(fetcher: viewModel)
|
||||
case let .followedTags(tags):
|
||||
makeTagsListView(tags: tags)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,18 +95,20 @@ public struct AccountDetailView: View {
|
|||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var headerView: some View {
|
||||
private func makeHeaderView(proxy: ScrollViewProxy?) -> some View {
|
||||
switch viewModel.accountState {
|
||||
case .loading:
|
||||
AccountDetailHeaderView(isCurrentUser: isCurrentUser,
|
||||
account: .placeholder(),
|
||||
relationship: .placeholder(),
|
||||
scrollViewProxy: proxy,
|
||||
scrollOffset: $scrollOffset)
|
||||
.redacted(reason: .placeholder)
|
||||
case let .data(account):
|
||||
AccountDetailHeaderView(isCurrentUser: isCurrentUser,
|
||||
account: account,
|
||||
relationship: viewModel.relationship,
|
||||
scrollViewProxy: proxy,
|
||||
scrollOffset: $scrollOffset)
|
||||
case let .error(error):
|
||||
Text("Error: \(error.localizedDescription)")
|
||||
|
|
|
@ -6,11 +6,16 @@ import Models
|
|||
|
||||
@MainActor
|
||||
extension Account {
|
||||
private struct Part: Identifiable {
|
||||
let id = UUID().uuidString
|
||||
let value: Substring
|
||||
}
|
||||
|
||||
public var displayNameWithEmojis: some View {
|
||||
let splittedDisplayName = displayName.split(separator: ":")
|
||||
let splittedDisplayName = displayName.split(separator: ":").map{ Part(value: $0) }
|
||||
return HStack(spacing: 0) {
|
||||
ForEach(splittedDisplayName, id: \.self) { part in
|
||||
if let emoji = emojis.first(where: { $0.shortcode == part }) {
|
||||
ForEach(splittedDisplayName, id: \.id) { part in
|
||||
if let emoji = emojis.first(where: { $0.shortcode == part.value }) {
|
||||
LazyImage(url: emoji.url) { state in
|
||||
if let image = state.image {
|
||||
image
|
||||
|
@ -24,7 +29,7 @@ extension Account {
|
|||
.processors([ImageProcessors.Resize(size: .init(width: 20, height: 20))])
|
||||
.frame(width: 20, height: 20)
|
||||
} else {
|
||||
Text(part)
|
||||
Text(part.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,9 @@ public struct StatusRowView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.contextMenu {
|
||||
contextMenu
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
|
|
@ -75,7 +75,9 @@ public struct TimelineView: View {
|
|||
if !viewModel.pendingStatuses.isEmpty {
|
||||
Button {
|
||||
proxy.scrollTo(Constants.scrollToTop)
|
||||
viewModel.displayPendingStatuses()
|
||||
withAnimation {
|
||||
viewModel.displayPendingStatuses()
|
||||
}
|
||||
} label: {
|
||||
Text(viewModel.pendingStatusesButtonTitle)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue