Convert more NavigationLinks to router
This commit is contained in:
committed by
William Casarin
parent
f0b0eade37
commit
242455410e
@@ -25,7 +25,7 @@ struct EventDetailBar: View {
|
||||
var body: some View {
|
||||
HStack {
|
||||
if bar.boosts > 0 {
|
||||
NavigationLink(destination: RepostsView(damus_state: state, model: RepostsModel(state: state, target: target))) {
|
||||
NavigationLink(value: Route.Reposts(reposts: RepostsModel(state: state, target: target))) {
|
||||
let noun = Text(verbatim: repostsCountString(bar.boosts)).foregroundColor(.gray)
|
||||
Text("\(Text(verbatim: bar.boosts.formatted()).font(.body.bold())) \(noun)", comment: "Sentence composed of 2 variables to describe how many reposts. In source English, the first variable is the number of reposts, and the second variable is 'Repost' or 'Reposts'.")
|
||||
}
|
||||
@@ -33,7 +33,7 @@ struct EventDetailBar: View {
|
||||
}
|
||||
|
||||
if bar.likes > 0 && !state.settings.onlyzaps_mode {
|
||||
NavigationLink(destination: ReactionsView(damus_state: state, model: ReactionsModel(state: state, target: target))) {
|
||||
NavigationLink(value: Route.Reactions(reactions: ReactionsModel(state: state, target: target))) {
|
||||
let noun = Text(verbatim: reactionsCountString(bar.likes)).foregroundColor(.gray)
|
||||
Text("\(Text(verbatim: bar.likes.formatted()).font(.body.bold())) \(noun)", comment: "Sentence composed of 2 variables to describe how many reactions there are on a post. In source English, the first variable is the number of reactions, and the second variable is 'Reaction' or 'Reactions'.")
|
||||
}
|
||||
@@ -41,8 +41,7 @@ struct EventDetailBar: View {
|
||||
}
|
||||
|
||||
if bar.zaps > 0 {
|
||||
let dst = ZapsView(state: state, target: .note(id: target, author: target_pk))
|
||||
NavigationLink(destination: dst) {
|
||||
NavigationLink(value: Route.Zaps(target: .note(id: target, author: target_pk))) {
|
||||
let noun = Text(verbatim: zapsCountString(bar.zaps)).foregroundColor(.gray)
|
||||
Text("\(Text(verbatim: bar.zaps.formatted()).font(.body.bold())) \(noun)", comment: "Sentence composed of 2 variables to describe how many zap payments there are on a post. In source English, the first variable is the number of zap payments, and the second variable is 'Zap' or 'Zaps'.")
|
||||
}
|
||||
|
||||
@@ -18,16 +18,16 @@ struct ConfigView: View {
|
||||
@State var delete_account_warning: Bool = false
|
||||
@State var confirm_delete_account: Bool = false
|
||||
@State var delete_text: String = ""
|
||||
|
||||
|
||||
@ObservedObject var settings: UserSettingsStore
|
||||
|
||||
private let DELETE_KEYWORD = "DELETE"
|
||||
|
||||
|
||||
init(state: DamusState) {
|
||||
self.state = state
|
||||
_settings = ObservedObject(initialValue: state.settings)
|
||||
}
|
||||
|
||||
|
||||
func textColor() -> Color {
|
||||
colorScheme == .light ? DamusColors.black : DamusColors.white
|
||||
}
|
||||
@@ -36,31 +36,30 @@ struct ConfigView: View {
|
||||
ZStack(alignment: .leading) {
|
||||
Form {
|
||||
Section {
|
||||
NavigationLink(destination: KeySettingsView(keypair: state.keypair)) {
|
||||
NavigationLink(value: Route.KeySettings(keypair: state.keypair)) {
|
||||
IconLabel(NSLocalizedString("Keys", comment: "Settings section for managing keys"), img_name: "key", color: .purple)
|
||||
}
|
||||
|
||||
NavigationLink(destination: AppearanceSettingsView(settings: settings)) {
|
||||
|
||||
NavigationLink(value: Route.AppearanceSettings(settings: settings)) {
|
||||
IconLabel(NSLocalizedString("Appearance", comment: "Section header for text and appearance settings"), img_name: "eye", color: .red)
|
||||
}
|
||||
|
||||
|
||||
NavigationLink(destination: SearchSettingsView(settings: settings)) {
|
||||
IconLabel(NSLocalizedString("Search/Universe", comment: "Section header for search/universe settings"), img_name: "magnifyingglass", color: .red)
|
||||
}
|
||||
|
||||
NavigationLink(destination: NotificationSettingsView(settings: settings)) {
|
||||
|
||||
NavigationLink(value: Route.NotificationSettings(settings: settings)) {
|
||||
IconLabel(NSLocalizedString("Notifications", comment: "Section header for Damus notifications"), img_name: "notification-bell-on", color: .blue)
|
||||
}
|
||||
|
||||
NavigationLink(destination: ZapSettingsView(settings: settings)) {
|
||||
|
||||
NavigationLink(value: Route.ZapSettings(settings: settings)) {
|
||||
IconLabel(NSLocalizedString("Zaps", comment: "Section header for zap settings"), img_name: "zap.fill", color: .orange)
|
||||
}
|
||||
|
||||
NavigationLink(destination: TranslationSettingsView(settings: settings)) {
|
||||
|
||||
NavigationLink(value: Route.TranslationSettings(settings: settings)) {
|
||||
IconLabel(NSLocalizedString("Translation", comment: "Section header for text and appearance settings"), img_name: "globe", color: .green)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Section(NSLocalizedString("Sign Out", comment: "Section title for signing out")) {
|
||||
Button(action: {
|
||||
@@ -116,11 +115,11 @@ struct ConfigView: View {
|
||||
guard let full_kp = state.keypair.to_full() else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
guard delete_text == DELETE_KEYWORD else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
let ev = created_deleted_account_profile(keypair: full_kp)
|
||||
state.postbox.send(ev)
|
||||
notify(.logout, ())
|
||||
@@ -164,7 +163,7 @@ func handle_string_amount(new_value: String) -> Int? {
|
||||
guard let amt = NumberFormatter().number(from: filtered) as? Int else {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
return amt
|
||||
}
|
||||
|
||||
|
||||
@@ -61,8 +61,7 @@ struct DMChatView: View, KeyboardReadable {
|
||||
|
||||
var Header: some View {
|
||||
let profile = damus_state.profiles.lookup(id: pubkey)
|
||||
let profile_page = ProfileView(damus_state: damus_state, pubkey: pubkey)
|
||||
return NavigationLink(destination: profile_page) {
|
||||
return NavigationLink(value: Route.ProfileByKey(pubkey: pubkey)) {
|
||||
HStack {
|
||||
ProfilePicView(pubkey: pubkey, size: 24, highlight: .none, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
||||
|
||||
|
||||
@@ -72,8 +72,7 @@ struct BuilderEventView: View {
|
||||
if let event {
|
||||
let ev = event.get_inner_event(cache: damus.events) ?? event
|
||||
let thread = ThreadModel(event: ev, damus_state: damus)
|
||||
let dest = ThreadView(state: damus, thread: thread)
|
||||
NavigationLink(destination: dest) {
|
||||
NavigationLink(value: Route.Thread(thread: thread)) {
|
||||
EventView(damus: damus, event: event, options: .embedded)
|
||||
.padding([.top, .bottom], 8)
|
||||
}.buttonStyle(.plain)
|
||||
|
||||
@@ -37,7 +37,7 @@ struct EventProfile: View {
|
||||
var body: some View {
|
||||
HStack(alignment: .center) {
|
||||
VStack {
|
||||
NavigationLink(destination: ProfileView(damus_state: damus_state, pubkey: pubkey)) {
|
||||
NavigationLink(value: Route.ProfileByKey(pubkey: pubkey)) {
|
||||
ProfilePicView(pubkey: pubkey, size: pfp_size, highlight: .none, profiles: damus_state.profiles, disable_animation: disable_animation)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,8 +240,7 @@ struct EventGroupView: View {
|
||||
|
||||
if let event {
|
||||
let thread = ThreadModel(event: event, damus_state: state)
|
||||
let dest = ThreadView(state: state, thread: thread)
|
||||
NavigationLink(destination: dest) {
|
||||
NavigationLink(value: Route.Thread(thread: thread)) {
|
||||
VStack(alignment: .leading) {
|
||||
GroupDescription(unique_pubkeys)
|
||||
EventBody(damus_state: state, event: event, size: .normal, options: [.truncate_content])
|
||||
|
||||
@@ -59,7 +59,7 @@ struct NotificationItemView: View {
|
||||
EventGroupView(state: state, event: ev, group: .reaction(evgrp))
|
||||
|
||||
case .reply(let ev):
|
||||
NavigationLink(destination: ThreadView(state: state, thread: ThreadModel(event: ev, damus_state: state))) {
|
||||
NavigationLink(value: Route.Thread(thread: ThreadModel(event: ev, damus_state: state))) {
|
||||
EventView(damus: state, event: ev, options: options)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
|
||||
@@ -28,7 +28,7 @@ struct MaybeAnonPfpView: View {
|
||||
.font(.largeTitle)
|
||||
.frame(width: size, height: size)
|
||||
} else {
|
||||
NavigationLink(destination: ProfileView(damus_state: state, pubkey: pubkey)) {
|
||||
NavigationLink(value: Route.ProfileByKey(pubkey: pubkey)) {
|
||||
ProfilePicView(pubkey: pubkey, size: size, highlight: .none, profiles: state.profiles, disable_animation: state.settings.disable_animation)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,11 +73,11 @@ func followedByString(_ friend_intersection: [String], profiles: Profiles, local
|
||||
|
||||
struct EditButton: View {
|
||||
let damus_state: DamusState
|
||||
|
||||
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
|
||||
|
||||
var body: some View {
|
||||
NavigationLink(value: Route.EditMetadata(damusState: damus_state)) {
|
||||
NavigationLink(value: Route.EditMetadata) {
|
||||
Text("Edit", comment: "Button to edit user's profile.")
|
||||
.frame(height: 30)
|
||||
.padding(.horizontal,25)
|
||||
@@ -92,11 +92,11 @@ struct EditButton: View {
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func fillColor() -> Color {
|
||||
colorScheme == .light ? DamusColors.black : DamusColors.white
|
||||
}
|
||||
|
||||
|
||||
func borderColor() -> Color {
|
||||
colorScheme == .light ? DamusColors.black : DamusColors.white
|
||||
}
|
||||
@@ -104,11 +104,11 @@ struct EditButton: View {
|
||||
|
||||
struct VisualEffectView: UIViewRepresentable {
|
||||
var effect: UIVisualEffect?
|
||||
|
||||
|
||||
func makeUIView(context: UIViewRepresentableContext<Self>) -> UIVisualEffectView {
|
||||
UIVisualEffectView()
|
||||
}
|
||||
|
||||
|
||||
func updateUIView(_ uiView: UIVisualEffectView, context: UIViewRepresentableContext<Self>) {
|
||||
uiView.effect = effect
|
||||
}
|
||||
@@ -120,52 +120,52 @@ struct ProfileView: View {
|
||||
let bannerHeight: CGFloat = 150.0
|
||||
|
||||
static let markdown = Markdown()
|
||||
|
||||
|
||||
@State var is_zoomed: Bool = false
|
||||
@State var show_share_sheet: Bool = false
|
||||
@State var show_qr_code: Bool = false
|
||||
@State var action_sheet_presented: Bool = false
|
||||
@State var filter_state : FilterState = .posts
|
||||
@State var yOffset: CGFloat = 0
|
||||
|
||||
|
||||
@StateObject var profile: ProfileModel
|
||||
@StateObject var followers: FollowersModel
|
||||
@StateObject var zap_button_model: ZapButtonModel = ZapButtonModel()
|
||||
|
||||
|
||||
init(damus_state: DamusState, profile: ProfileModel, followers: FollowersModel) {
|
||||
self.damus_state = damus_state
|
||||
self._profile = StateObject(wrappedValue: profile)
|
||||
self._followers = StateObject(wrappedValue: followers)
|
||||
}
|
||||
|
||||
|
||||
init(damus_state: DamusState, pubkey: String) {
|
||||
self.damus_state = damus_state
|
||||
self._profile = StateObject(wrappedValue: ProfileModel(pubkey: pubkey, damus: damus_state))
|
||||
self._followers = StateObject(wrappedValue: FollowersModel(damus_state: damus_state, target: pubkey))
|
||||
}
|
||||
|
||||
|
||||
@Environment(\.dismiss) var dismiss
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
@Environment(\.presentationMode) var presentationMode
|
||||
|
||||
|
||||
func imageBorderColor() -> Color {
|
||||
colorScheme == .light ? DamusColors.white : DamusColors.black
|
||||
}
|
||||
|
||||
|
||||
func bannerBlurViewOpacity() -> Double {
|
||||
let progress = -(yOffset + navbarHeight) / 100
|
||||
return Double(-yOffset > navbarHeight ? progress : 0)
|
||||
}
|
||||
|
||||
|
||||
var bannerSection: some View {
|
||||
GeometryReader { proxy -> AnyView in
|
||||
|
||||
|
||||
let minY = proxy.frame(in: .global).minY
|
||||
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.yOffset = minY
|
||||
}
|
||||
|
||||
|
||||
return AnyView(
|
||||
VStack(spacing: 0) {
|
||||
ZStack {
|
||||
@@ -173,10 +173,10 @@ struct ProfileView: View {
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: proxy.size.width, height: minY > 0 ? bannerHeight + minY : bannerHeight)
|
||||
.clipped()
|
||||
|
||||
|
||||
VisualEffectView(effect: UIBlurEffect(style: .systemUltraThinMaterial)).opacity(bannerBlurViewOpacity())
|
||||
}
|
||||
|
||||
|
||||
Divider().opacity(bannerBlurViewOpacity())
|
||||
}
|
||||
.frame(height: minY > 0 ? bannerHeight + minY : nil)
|
||||
@@ -187,11 +187,11 @@ struct ProfileView: View {
|
||||
.frame(height: bannerHeight)
|
||||
.allowsHitTesting(false)
|
||||
}
|
||||
|
||||
|
||||
var navbarHeight: CGFloat {
|
||||
return 100.0 - (Theme.safeAreaInsets?.top ?? 0)
|
||||
}
|
||||
|
||||
|
||||
@ViewBuilder
|
||||
func navImage(img: String) -> some View {
|
||||
Image(img)
|
||||
@@ -199,7 +199,7 @@ struct ProfileView: View {
|
||||
.background(Color.black.opacity(0.6))
|
||||
.clipShape(Circle())
|
||||
}
|
||||
|
||||
|
||||
var navBackButton: some View {
|
||||
Button {
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
@@ -207,7 +207,7 @@ struct ProfileView: View {
|
||||
navImage(img: "chevron-left")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var navActionSheetButton: some View {
|
||||
Button(action: {
|
||||
action_sheet_presented = true
|
||||
@@ -218,7 +218,7 @@ struct ProfileView: View {
|
||||
Button(NSLocalizedString("Share", comment: "Button to share the link to a profile.")) {
|
||||
show_share_sheet = true
|
||||
}
|
||||
|
||||
|
||||
Button(NSLocalizedString("QR Code", comment: "Button to view profile's qr code.")) {
|
||||
show_qr_code = true
|
||||
}
|
||||
@@ -238,7 +238,7 @@ struct ProfileView: View {
|
||||
else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
guard let new_ev = remove_from_mutelist(keypair: keypair, prev: mutelist, to_remove: profile.pubkey) else {
|
||||
return
|
||||
}
|
||||
@@ -254,7 +254,7 @@ struct ProfileView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var customNavbar: some View {
|
||||
HStack {
|
||||
navBackButton
|
||||
@@ -265,7 +265,7 @@ struct ProfileView: View {
|
||||
.padding(.horizontal)
|
||||
.accentColor(DamusColors.white)
|
||||
}
|
||||
|
||||
|
||||
func lnButton(lnurl: String, profile: Profile) -> some View {
|
||||
let button_img = profile.reactions == false ? "zap.fill" : "zap"
|
||||
return Button(action: {
|
||||
@@ -278,7 +278,7 @@ struct ProfileView: View {
|
||||
if profile.reactions == false {
|
||||
Text("OnlyZaps Enabled", comment: "Non-tappable text in context menu that shows up when the zap button on profile is long pressed to indicate that the user has enabled OnlyZaps, meaning that they would like to be only zapped and not accept reactions to their notes.")
|
||||
}
|
||||
|
||||
|
||||
if let addr = profile.lud16 {
|
||||
Button {
|
||||
UIPasteboard.general.string = addr
|
||||
@@ -293,30 +293,30 @@ struct ProfileView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
.cornerRadius(24)
|
||||
}
|
||||
|
||||
var dmButton: some View {
|
||||
let dm_model = damus_state.dms.lookup_or_create(profile.pubkey)
|
||||
return NavigationLink(value: Route.DMChat(damusState: damus_state, dms: dm_model)) {
|
||||
return NavigationLink(value: Route.DMChat(dms: dm_model)) {
|
||||
Image("messages")
|
||||
.profile_button_style(scheme: colorScheme)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func actionSection(profile_data: Profile?) -> some View {
|
||||
return Group {
|
||||
|
||||
|
||||
if let profile = profile_data {
|
||||
if let lnurl = profile.lnurl, lnurl != "" {
|
||||
lnButton(lnurl: lnurl, profile: profile)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dmButton
|
||||
|
||||
|
||||
if profile.pubkey != damus_state.pubkey {
|
||||
FollowButtonView(
|
||||
target: profile.get_follow_target(),
|
||||
@@ -324,26 +324,26 @@ struct ProfileView: View {
|
||||
follow_state: damus_state.contacts.follow_state(profile.pubkey)
|
||||
)
|
||||
} else if damus_state.keypair.privkey != nil {
|
||||
NavigationLink(value: Route.EditMetadata(damusState: damus_state)) {
|
||||
NavigationLink(value: Route.EditMetadata) {
|
||||
EditButton(damus_state: damus_state)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func pfpOffset() -> CGFloat {
|
||||
let progress = -yOffset / navbarHeight
|
||||
let offset = (pfp_size / 4.0) * (progress < 1.0 ? progress : 1)
|
||||
return offset > 0 ? offset : 0
|
||||
}
|
||||
|
||||
|
||||
func pfpScale() -> CGFloat {
|
||||
let progress = -yOffset / navbarHeight
|
||||
let scale = 1.0 - (0.5 * (progress < 1.0 ? progress : 1))
|
||||
return scale < 1 ? scale : 1
|
||||
}
|
||||
|
||||
|
||||
func nameSection(profile_data: Profile?) -> some View {
|
||||
return Group {
|
||||
HStack(alignment: .center) {
|
||||
@@ -357,17 +357,17 @@ struct ProfileView: View {
|
||||
.fullScreenCover(isPresented: $is_zoomed) {
|
||||
ProfilePicImageView(pubkey: profile.pubkey, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
||||
}
|
||||
|
||||
|
||||
Spacer()
|
||||
|
||||
|
||||
actionSection(profile_data: profile_data)
|
||||
}
|
||||
|
||||
|
||||
let follows_you = profile.pubkey != damus_state.pubkey && profile.follows(pubkey: damus_state.pubkey)
|
||||
ProfileNameView(pubkey: profile.pubkey, profile: profile_data, follows_you: follows_you, damus: damus_state)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var followersCount: some View {
|
||||
HStack {
|
||||
if followers.count == nil {
|
||||
@@ -384,26 +384,26 @@ struct ProfileView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var aboutSection: some View {
|
||||
VStack(alignment: .leading, spacing: 8.0) {
|
||||
let profile_data = damus_state.profiles.lookup(id: profile.pubkey)
|
||||
|
||||
|
||||
nameSection(profile_data: profile_data)
|
||||
|
||||
if let about = profile_data?.about {
|
||||
AboutView(state: damus_state, about: about)
|
||||
}
|
||||
|
||||
|
||||
if let url = profile_data?.website_url {
|
||||
WebsiteLink(url: url)
|
||||
}
|
||||
|
||||
|
||||
HStack {
|
||||
if let contact = profile.contacts {
|
||||
let contacts = contact.referenced_pubkeys.map { $0.ref_id }
|
||||
let following_model = FollowingModel(damus_state: damus_state, contacts: contacts)
|
||||
NavigationLink(value: Route.Following(damusState: damus_state, following: following_model)) {
|
||||
NavigationLink(value: Route.Following(following: following_model)) {
|
||||
HStack {
|
||||
let noun_text = Text(verbatim: "\(followingCountString(profile.following))").font(.subheadline).foregroundColor(.gray)
|
||||
Text("\(Text(verbatim: profile.following.formatted()).font(.subheadline.weight(.medium))) \(noun_text)", comment: "Sentence composed of 2 variables to describe how many profiles a user is following. In source English, the first variable is the number of profiles being followed, and the second variable is 'Following'.")
|
||||
@@ -413,7 +413,7 @@ struct ProfileView: View {
|
||||
}
|
||||
|
||||
if followers.contacts != nil {
|
||||
NavigationLink(value: Route.Followers(damusState: damus_state, environmentObject: followers)) {
|
||||
NavigationLink(value: Route.Followers(environmentObject: followers)) {
|
||||
followersCount
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
@@ -425,18 +425,18 @@ struct ProfileView: View {
|
||||
followers.subscribe()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if let relays = profile.relays {
|
||||
// Only open relay config view if the user is logged in with private key and they are looking at their own profile.
|
||||
let noun_text = Text(verbatim: relaysCountString(relays.keys.count)).font(.subheadline).foregroundColor(.gray)
|
||||
let relay_text = Text("\(Text(verbatim: relays.keys.count.formatted()).font(.subheadline.weight(.medium))) \(noun_text)", comment: "Sentence composed of 2 variables to describe how many relay servers a user is connected. In source English, the first variable is the number of relay servers, and the second variable is 'Relay' or 'Relays'.")
|
||||
if profile.pubkey == damus_state.pubkey && damus_state.is_privkey_user {
|
||||
NavigationLink(value: Route.RelayConfig(damusState: damus_state)) {
|
||||
NavigationLink(value: Route.RelayConfig) {
|
||||
relay_text
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
} else {
|
||||
NavigationLink(value: Route.UserRelays(damusState: damus_state, relays: Array(relays.keys).sorted())) {
|
||||
NavigationLink(value: Route.UserRelays(relays: Array(relays.keys).sorted())) {
|
||||
relay_text
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
@@ -462,7 +462,7 @@ struct ProfileView: View {
|
||||
}
|
||||
.padding(.horizontal)
|
||||
}
|
||||
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
ScrollView(.vertical) {
|
||||
@@ -540,7 +540,7 @@ struct ProfileView_Previews: PreviewProvider {
|
||||
func test_damus_state() -> DamusState {
|
||||
let pubkey = "3efdaebb1d8923ebd99c9e7ace3b4194ab45512e2be79c1b7d68d9243e0d2681"
|
||||
let damus = DamusState.empty
|
||||
|
||||
|
||||
let prof = Profile(name: "damus", display_name: "damus", about: "iOS app!", picture: "https://damus.io/img/logo.png", banner: "", website: "https://damus.io", lud06: nil, lud16: "jb55@sendsats.lol", nip05: "damus.io", damus_donation: nil)
|
||||
let tsprof = TimestampedProfile(profile: prof, timestamp: 0, event: test_event)
|
||||
damus.profiles.add(id: pubkey, profile: tsprof)
|
||||
@@ -549,15 +549,15 @@ func test_damus_state() -> DamusState {
|
||||
|
||||
struct KeyView: View {
|
||||
let pubkey: String
|
||||
|
||||
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
|
||||
|
||||
@State private var isCopied = false
|
||||
|
||||
|
||||
func keyColor() -> Color {
|
||||
colorScheme == .light ? DamusColors.black : DamusColors.white
|
||||
}
|
||||
|
||||
|
||||
private func copyPubkey(_ pubkey: String) {
|
||||
UIPasteboard.general.string = pubkey
|
||||
UIImpactFeedbackGenerator(style: .medium).impactOccurred()
|
||||
@@ -570,10 +570,10 @@ struct KeyView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var body: some View {
|
||||
let bech32 = bech32_pubkey(pubkey) ?? pubkey
|
||||
|
||||
|
||||
HStack {
|
||||
Text(verbatim: "\(abbrev_pubkey(bech32, amount: 16))")
|
||||
.font(.footnote)
|
||||
@@ -581,7 +581,7 @@ struct KeyView: View {
|
||||
.padding(5)
|
||||
.padding([.leading, .trailing], 5)
|
||||
.background(RoundedRectangle(cornerRadius: 11).foregroundColor(DamusColors.adaptableGrey))
|
||||
|
||||
|
||||
if isCopied != true {
|
||||
Button {
|
||||
copyPubkey(bech32)
|
||||
|
||||
@@ -72,7 +72,9 @@ struct RelayDetailView: View {
|
||||
|
||||
if let pubkey = nip11.pubkey {
|
||||
Section(NSLocalizedString("Admin", comment: "Label to display relay contact user.")) {
|
||||
UserViewRow(damus_state: state, pubkey: pubkey)
|
||||
NavigationLink(value: Route.ProfileByKey(pubkey: pubkey), label: {
|
||||
UserViewRow(damus_state: state, pubkey: pubkey)
|
||||
})
|
||||
}
|
||||
}
|
||||
if let relay_connection {
|
||||
|
||||
@@ -30,8 +30,9 @@ struct RelayView: View {
|
||||
if let meta = state.relay_metadata.lookup(relay_id: relay) {
|
||||
Text(relay)
|
||||
.background(
|
||||
NavigationLink("", destination: RelayDetailView(state: state, relay: relay, nip11: meta)).opacity(0.0)
|
||||
.disabled(showActionButtons)
|
||||
NavigationLink(value: Route.RelayDetail(relay: relay, metadata: meta), label: {
|
||||
EmptyView()
|
||||
}).opacity(0.0).disabled(showActionButtons)
|
||||
)
|
||||
|
||||
Spacer()
|
||||
|
||||
@@ -14,7 +14,7 @@ struct SignalView: View {
|
||||
var body: some View {
|
||||
Group {
|
||||
if signal.signal != signal.max_signal {
|
||||
NavigationLink(destination: RelayConfigView(state: state)) {
|
||||
NavigationLink(value: Route.RelayConfig) {
|
||||
Text("\(signal.signal)/\(signal.max_signal)", comment: "Fraction of how many of the user's relay servers that are operational.")
|
||||
.font(.callout)
|
||||
.foregroundColor(.gray)
|
||||
|
||||
@@ -16,9 +16,8 @@ struct RepostedEvent: View {
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
let prof = damus.profiles.lookup(id: event.pubkey)
|
||||
let booster_profile = ProfileView(damus_state: damus, pubkey: event.pubkey)
|
||||
|
||||
NavigationLink(destination: booster_profile) {
|
||||
NavigationLink(value: Route.ProfileByKey(pubkey: event.pubkey)) {
|
||||
Reposted(damus: damus, pubkey: event.pubkey, profile: prof)
|
||||
.padding(.horizontal)
|
||||
}
|
||||
|
||||
@@ -100,14 +100,12 @@ struct SearchingEventView: View {
|
||||
.progressViewStyle(.circular)
|
||||
}
|
||||
case .found(let ev):
|
||||
NavigationLink(destination: ThreadView(state: state, thread: ThreadModel(event: ev, damus_state: state))) {
|
||||
|
||||
NavigationLink(value: Route.Thread(thread: ThreadModel(event: ev, damus_state: state))) {
|
||||
EventView(damus: state, event: ev)
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
case .found_profile(let pk):
|
||||
NavigationLink(destination: ProfileView(damus_state: state, pubkey: pk)) {
|
||||
|
||||
NavigationLink(value: Route.ProfileByKey(pubkey: pk)) {
|
||||
FollowUserView(target: .pubkey(pk), damus_state: state)
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
|
||||
@@ -44,8 +44,7 @@ struct InnerSearchResults: View {
|
||||
|
||||
func HashtagSearch(_ ht: String) -> some View {
|
||||
let search_model = SearchModel(state: damus_state, search: .filter_hashtag([ht]))
|
||||
let dst = SearchView(appstate: damus_state, search: search_model)
|
||||
return NavigationLink(destination: dst) {
|
||||
return NavigationLink(value: Route.Search(search: search_model)) {
|
||||
Text("Search hashtag: #\(ht)", comment: "Navigation link to search hashtag.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,23 +11,23 @@ struct SideMenuView: View {
|
||||
let damus_state: DamusState
|
||||
@Binding var isSidebarVisible: Bool
|
||||
@State var confirm_logout: Bool = false
|
||||
|
||||
|
||||
@State private var showQRCode = false
|
||||
|
||||
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
|
||||
|
||||
var sideBarWidth = min(UIScreen.main.bounds.size.width * 0.65, 400.0)
|
||||
let verticalSpacing: CGFloat = 20
|
||||
let padding: CGFloat = 30
|
||||
|
||||
|
||||
func fillColor() -> Color {
|
||||
colorScheme == .light ? DamusColors.white : DamusColors.black
|
||||
}
|
||||
|
||||
|
||||
func textColor() -> Color {
|
||||
colorScheme == .light ? DamusColors.black : DamusColors.white
|
||||
}
|
||||
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
GeometryReader { _ in
|
||||
@@ -42,20 +42,20 @@ struct SideMenuView: View {
|
||||
content
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func SidemenuItems(profile_model: ProfileModel, followers: FollowersModel) -> some View {
|
||||
return VStack(spacing: verticalSpacing) {
|
||||
NavigationLink(value: Route.Profile(damusSate: damus_state, profile: profile_model, followers: followers)) {
|
||||
NavigationLink(value: Route.Profile(profile: profile_model, followers: followers)) {
|
||||
navLabel(title: NSLocalizedString("Profile", comment: "Sidebar menu label for Profile view."), img: "user")
|
||||
}
|
||||
|
||||
|
||||
NavigationLink(destination: WalletView(damus_state: damus_state, model: damus_state.wallet)) {
|
||||
navLabel(title: NSLocalizedString("Wallet", comment: "Sidebar menu label for Wallet view."), img: "wallet")
|
||||
/*
|
||||
HStack {
|
||||
Image("wallet")
|
||||
.tint(DamusColors.adaptableBlack)
|
||||
|
||||
|
||||
Text(NSLocalizedString("wallet", comment: "Sidebar menu label for Wallet view."))
|
||||
.font(.title2)
|
||||
.foregroundColor(textColor())
|
||||
@@ -63,36 +63,35 @@ struct SideMenuView: View {
|
||||
.dynamicTypeSize(.xSmall)
|
||||
}*/
|
||||
}
|
||||
|
||||
NavigationLink(value: Route.MuteList(damusState: damus_state, users: get_mutelist_users(damus_state.contacts.mutelist))) {
|
||||
|
||||
NavigationLink(value: Route.MuteList(users: get_mutelist_users(damus_state.contacts.mutelist))) {
|
||||
navLabel(title: NSLocalizedString("Muted", comment: "Sidebar menu label for muted users view."), img: "mute")
|
||||
}
|
||||
|
||||
NavigationLink(value: Route.RelayConfig(damusState: damus_state)) {
|
||||
|
||||
NavigationLink(value: Route.RelayConfig) {
|
||||
navLabel(title: NSLocalizedString("Relays", comment: "Sidebar menu label for Relays view."), img: "world-relays")
|
||||
}
|
||||
|
||||
NavigationLink(value: Route.Bookmarks(damusState: damus_state)) {
|
||||
|
||||
NavigationLink(value: Route.Bookmarks) {
|
||||
navLabel(title: NSLocalizedString("Bookmarks", comment: "Sidebar menu label for Bookmarks view."), img: "bookmark")
|
||||
}
|
||||
|
||||
NavigationLink(value: Route.Config(damusState: damus_state)) {
|
||||
|
||||
NavigationLink(value: Route.Config) {
|
||||
navLabel(title: NSLocalizedString("Settings", comment: "Sidebar menu label for accessing the app settings"), img: "settings")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var MainSidemenu: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
let profile = damus_state.profiles.lookup(id: damus_state.pubkey)
|
||||
let followers = FollowersModel(damus_state: damus_state, target: damus_state.pubkey)
|
||||
let profile_model = ProfileModel(pubkey: damus_state.pubkey, damus: damus_state)
|
||||
|
||||
NavigationLink(destination: ProfileView(damus_state: damus_state, profile: profile_model, followers: followers)) {
|
||||
|
||||
|
||||
NavigationLink(value: Route.Profile(profile: profile_model, followers: followers), label: {
|
||||
HStack {
|
||||
ProfilePicView(pubkey: damus_state.pubkey, size: 60, highlight: .none, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
||||
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
if let display_name = profile?.display_name {
|
||||
Text(display_name)
|
||||
@@ -109,10 +108,10 @@ struct SideMenuView: View {
|
||||
}
|
||||
}
|
||||
.padding(.bottom, verticalSpacing)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
Divider()
|
||||
|
||||
|
||||
ScrollView {
|
||||
SidemenuItems(profile_model: profile_model, followers: followers)
|
||||
.labelStyle(SideMenuLabelStyle())
|
||||
@@ -120,7 +119,7 @@ struct SideMenuView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var content: some View {
|
||||
HStack(alignment: .top) {
|
||||
ZStack(alignment: .top) {
|
||||
@@ -186,20 +185,20 @@ struct SideMenuView: View {
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ViewBuilder
|
||||
func navLabel(title: String, img: String) -> some View {
|
||||
Image(img)
|
||||
.tint(DamusColors.adaptableBlack)
|
||||
|
||||
|
||||
Text(title)
|
||||
.font(.title2)
|
||||
.foregroundColor(textColor())
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.dynamicTypeSize(.xSmall)
|
||||
}
|
||||
|
||||
|
||||
struct SideMenuLabelStyle: LabelStyle {
|
||||
func makeBody(configuration: Configuration) -> some View {
|
||||
HStack(alignment: .center, spacing: 8) {
|
||||
|
||||
Reference in New Issue
Block a user