IceCubesApp/Packages/DesignSystem/Sources/DesignSystem/Views/FollowRequestButtons.swift
Jérôme Danthinne 9b3b3692ee
Support for follow requests (#376) close #321
* Support for follow requests (#321)

* Run SwiftFormat

Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
2023-01-25 13:02:28 +01:00

42 lines
992 B
Swift

import Env
import Models
import SwiftUI
public struct FollowRequestButtons: View {
@EnvironmentObject private var currentAccount: CurrentAccount
let account: Account
let requestUpdated: (() -> Void)?
public init(account: Account, requestUpdated: (() -> Void)? = nil) {
self.account = account
self.requestUpdated = requestUpdated
}
public var body: some View {
HStack {
Button {
Task {
await currentAccount.acceptFollowerRequest(id: account.id)
requestUpdated?()
}
} label: {
Text("account.follow-request.accept")
.frame(maxWidth: .infinity)
}
Button {
Task {
await currentAccount.rejectFollowerRequest(id: account.id)
requestUpdated?()
}
} label: {
Text("account.follow-request.reject")
.frame(maxWidth: .infinity)
}
}
.buttonStyle(.bordered)
.disabled(currentAccount.isUpdating)
.padding(.top, 4)
}
}