mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-01-11 16:45:27 +00:00
Add swipe actions on timeline
This commit is contained in:
parent
9b2e48abab
commit
d5b81dab5c
2 changed files with 46 additions and 1 deletions
|
@ -2,9 +2,11 @@ import DesignSystem
|
|||
import Models
|
||||
import Shimmer
|
||||
import SwiftUI
|
||||
import Env
|
||||
|
||||
public struct StatusesListView<Fetcher>: View where Fetcher: StatusesFetcher {
|
||||
@EnvironmentObject private var theme: Theme
|
||||
@EnvironmentObject private var routerPath: RouterPath
|
||||
|
||||
@ObservedObject private var fetcher: Fetcher
|
||||
private let isRemote: Bool
|
||||
|
@ -69,7 +71,6 @@ public struct StatusesListView<Fetcher>: View where Fetcher: StatusesFetcher {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch nextPageState {
|
||||
case .hasNextPage:
|
||||
loadingRow
|
||||
|
|
|
@ -83,6 +83,12 @@ public struct StatusRowView: View {
|
|||
.contextMenu {
|
||||
contextMenu
|
||||
}
|
||||
.swipeActions(edge: .trailing) {
|
||||
trailinSwipeActions
|
||||
}
|
||||
.swipeActions(edge: .leading) {
|
||||
leadingSwipeActions
|
||||
}
|
||||
.accessibilityElement(children: viewModel.isFocused ? .contain : .combine)
|
||||
.accessibilityActions {
|
||||
// Add the individual mentions as accessibility actions
|
||||
|
@ -410,4 +416,42 @@ public struct StatusRowView: View {
|
|||
.background(Color.black.opacity(0.40))
|
||||
.transition(.opacity)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var trailinSwipeActions: some View {
|
||||
Button {
|
||||
Task {
|
||||
if viewModel.isFavorited {
|
||||
await viewModel.unFavorite()
|
||||
} else {
|
||||
await viewModel.favorite()
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "star")
|
||||
}
|
||||
.tint(.yellow)
|
||||
Button {
|
||||
Task {
|
||||
if viewModel.isReblogged {
|
||||
await viewModel.unReblog()
|
||||
} else {
|
||||
await viewModel.reblog()
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "arrow.left.arrow.right.circle")
|
||||
}
|
||||
.tint(theme.tintColor)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var leadingSwipeActions: some View {
|
||||
Button {
|
||||
routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
|
||||
} label: {
|
||||
Image(systemName: "arrowshape.turn.up.left")
|
||||
}
|
||||
.tint(theme.tintColor)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue