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