Skip to content

Commit

Permalink
relays: allow users to hide the recommended relay view
Browse files Browse the repository at this point in the history
  • Loading branch information
ericholguin committed Oct 7, 2023
1 parent 1fabd4c commit feac597
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions damus/Views/Relays/RelayConfigView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct RelayConfigView: View {
@State var relays: [RelayDescriptor]
@State private var showActionButtons = false
@State var show_add_relay: Bool = false
@SceneStorage("RelayConfigView.show_recommended") var show_recommended : Bool = true

@Environment(\.dismiss) var dismiss

Expand Down Expand Up @@ -43,16 +44,48 @@ struct RelayConfigView: View {
VStack {
Divider()

if recommended.count > 0 {
if showActionButtons && !show_recommended {
VStack {
Button(action: {
withAnimation(.easeOut(duration: 0.2)) {
show_recommended.toggle()
}
}) {
Text("Show recommended relays", comment: "Button to show recommended relays.")
.foregroundStyle(DamusLightGradient.gradient)
.padding(10)
.background {
RoundedRectangle(cornerRadius: 15)
.stroke(DamusLightGradient.gradient)
}
}
.padding(.top, 10)
}
}

if recommended.count > 0 && show_recommended {
VStack {
HStack(alignment: .top) {
Spacer()
Button(action: {
withAnimation(.easeOut(duration: 0.2)) {
show_recommended.toggle()
}
}) {
Image(systemName: "xmark.circle")
.font(.system(size: 18))
.foregroundStyle(DamusLightGradient.gradient)
}
.padding([.top, .trailing], 8)
}

Text("Recommended relays", comment: "Title for view of recommended relays.")
.foregroundStyle(DamusLightGradient.gradient)
.padding(10)
.background {
RoundedRectangle(cornerRadius: 15)
.stroke(DamusLightGradient.gradient)
}
.padding(.vertical)

HStack(spacing: 20) {
ForEach(recommended, id: \.url) { r in
Expand Down

0 comments on commit feac597

Please sign in to comment.