following view

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2022-05-16 16:23:34 -07:00
parent 713effdc35
commit 874d15df45
8 changed files with 168 additions and 37 deletions

View File

@@ -0,0 +1,44 @@
//
// FollowButtonView.swift
// damus
//
// Created by William Casarin on 2022-05-16.
//
import SwiftUI
struct FollowButtonView: View {
let pubkey: String
@State var follow_state: FollowState
var body: some View {
Button("\(follow_btn_txt(follow_state))") {
follow_state = perform_follow_btn_action(follow_state, target: pubkey)
}
.buttonStyle(.bordered)
.onReceive(handle_notify(.followed)) { notif in
let pk = notif.object as! String
if pk != pubkey {
return
}
self.follow_state = .follows
}
.onReceive(handle_notify(.unfollowed)) { notif in
let pk = notif.object as! String
if pk != pubkey {
return
}
self.follow_state = .unfollows
}
}
}
/*
struct FollowButtonView_Previews: PreviewProvider {
static var previews: some View {
FollowButtonView()
}
}
*/