diff --git a/damus/ContentView.swift b/damus/ContentView.swift index 912bdbc..04698c6 100644 --- a/damus/ContentView.swift +++ b/damus/ContentView.swift @@ -151,16 +151,18 @@ struct ContentView: View { } ToolbarItem(placement: .navigationBarTrailing) { - NavigationLink(destination: ConfigView(state: viewModel.state!)) { - if #available(iOS 16.0, *) { - Image(systemName: "chart.bar.fill", variableValue: Double(viewModel.home.signal.signal) / Double(viewModel.home.signal.max_signal)) - .font(.body.weight(.ultraLight)) - .symbolRenderingMode(.hierarchical) - } else { - // Fallback on earlier versions - } + HStack(alignment: .center) { + if viewModel.home.signal.signal != viewModel.home.signal.max_signal { + Text("\(viewModel.home.signal.signal)/\(viewModel.home.signal.max_signal)") + .font(.callout) + .foregroundColor(.gray) + } + + NavigationLink(destination: ConfigView(state: viewModel.state!)) { + Image(systemName: "gear") } .buttonStyle(PlainButtonStyle()) + } } } } diff --git a/damus/Views/EventActionBar.swift b/damus/Views/EventActionBar.swift index 7a4ccf3..dc00b6b 100644 --- a/damus/Views/EventActionBar.swift +++ b/damus/Views/EventActionBar.swift @@ -42,7 +42,7 @@ struct EventActionBar: View { HStack(alignment: .bottom) { Text("\(bar.boosts > 0 ? "\(bar.boosts)" : "")") - .font(.footnote) + .font(.footnote.weight(.medium)) .foregroundColor(bar.boosted ? Color.green : Color.gray) EventActionButton(img: "arrow.2.squarepath", col: bar.boosted ? Color.green : nil) { @@ -56,7 +56,7 @@ struct EventActionBar: View { HStack(alignment: .bottom) { Text("\(bar.likes > 0 ? "\(bar.likes)" : "")") - .font(.footnote) + .font(.footnote.weight(.medium)) .foregroundColor(bar.liked ? Color.red : Color.gray) EventActionButton(img: bar.liked ? "heart.fill" : "heart", col: bar.liked ? Color.red : nil) { @@ -136,7 +136,7 @@ struct EventActionBar: View { func EventActionButton(img: String, col: Color?, action: @escaping () -> ()) -> some View { Button(action: action) { Label("", systemImage: img) - .font(.footnote) + .font(.footnote.weight(.medium)) .foregroundColor(col == nil ? Color.gray : col!) } .padding(.trailing, 40) diff --git a/damus/Views/EventView.swift b/damus/Views/EventView.swift index 23392eb..ea9dd2c 100644 --- a/damus/Views/EventView.swift +++ b/damus/Views/EventView.swift @@ -119,11 +119,12 @@ struct EventView: View { VStack(alignment: .leading) { HStack(alignment: .center) { - ProfileName(pubkey: pubkey, profile: profile, contacts: damus.contacts, show_friend_confirmed: show_friend_icon) + EventProfileName(pubkey: pubkey, profile: profile, contacts: damus.contacts, show_friend_confirmed: show_friend_icon) Text("\(format_relative_time(event.created_at))") + .font(.subheadline) .foregroundColor(.gray) } - + if event.is_reply(damus.keypair.privkey) { Text("\(reply_desc(profiles: damus.profiles, event: event))") .font(.footnote) diff --git a/damus/Views/FollowButtonView.swift b/damus/Views/FollowButtonView.swift index ea8280e..294d31a 100644 --- a/damus/Views/FollowButtonView.swift +++ b/damus/Views/FollowButtonView.swift @@ -8,6 +8,9 @@ import SwiftUI struct FollowButtonView: View { + + @Environment(\.colorScheme) var colorScheme + let target: FollowTarget @State var follow_state: FollowState @@ -16,15 +19,15 @@ struct FollowButtonView: View { follow_state = perform_follow_btn_action(follow_state, target: target) } label: { Text(follow_btn_txt(follow_state)) - .padding(.horizontal, 20) - .padding(.vertical, 7) + .padding(.horizontal, 25) + .padding(.vertical, 10) .font(.caption.weight(.bold)) - .foregroundColor(follow_state == .unfollows ? .white : .black) - .background(follow_state == .unfollows ? .black : .white) + .foregroundColor(follow_state == .unfollows ? emptyColor() : fillColor()) + .background(follow_state == .unfollows ? fillColor() : emptyColor()) .cornerRadius(20) .overlay { RoundedRectangle(cornerRadius: 16) - .stroke(follow_state == .unfollows ? .white : .gray, lineWidth: 1) + .stroke(follow_state == .unfollows ? borderColor() : fillColor(), lineWidth: 1) } } .onReceive(handle_notify(.followed)) { notif in @@ -44,6 +47,18 @@ struct FollowButtonView: View { self.follow_state = .unfollows } } + + func fillColor() -> Color { + colorScheme == .light ? .black : .white + } + + func emptyColor() -> Color { + colorScheme == .light ? .white : .black + } + + func borderColor() -> Color { + colorScheme == .light ? .black.opacity(0.1) : .white.opacity(0.1) + } } struct FollowButtonPreviews: View { diff --git a/damus/Views/NoteContentView.swift b/damus/Views/NoteContentView.swift index 5fcdef2..6d6fc21 100644 --- a/damus/Views/NoteContentView.swift +++ b/damus/Views/NoteContentView.swift @@ -64,8 +64,10 @@ struct NoteContentView: View { return VStack(alignment: .leading) { if let txt = try? AttributedString(markdown: artifacts.content, options: md_opts) { Text(txt) + .font(.subheadline) } else { Text(artifacts.content) + .font(.subheadline) } if show_images && artifacts.images.count > 0 { ImageCarousel(urls: artifacts.images) diff --git a/damus/Views/ProfileName.swift b/damus/Views/ProfileName.swift index c1cf17f..93715a3 100644 --- a/damus/Views/ProfileName.swift +++ b/damus/Views/ProfileName.swift @@ -23,7 +23,7 @@ struct ProfileFullName: View { .font(.footnote) .foregroundColor(.gray) } else { - ProfileName(pubkey: pubkey, profile: profile, contacts: contacts, show_friend_confirmed: true) +// ProfileName(pubkey: pubkey, profile: profile, contacts: contacts, show_friend_confirmed: true) } } } @@ -73,8 +73,9 @@ struct ProfileName: View { var body: some View { HStack { + Text(prefix + String(display_name ?? Profile.displayName(profile: profile, pubkey: pubkey))) - //.foregroundColor(hex_to_rgb(pubkey)) + .font(.subheadline) .fontWeight(prefix == "@" ? .none : .bold) if let frend = friend_icon { Label("", systemImage: frend) @@ -92,4 +93,77 @@ struct ProfileName: View { } } - +/// Profile Name used when displaying an event in the timeline +struct EventProfileName: View { + let pubkey: String + let profile: Profile? + let contacts: Contacts + let prefix: String + + let show_friend_confirmed: Bool + + @State var display_name: String? + + init(pubkey: String, profile: Profile?, contacts: Contacts, show_friend_confirmed: Bool) { + self.pubkey = pubkey + self.profile = profile + self.prefix = "" + self.contacts = contacts + self.show_friend_confirmed = show_friend_confirmed + } + + init(pubkey: String, profile: Profile?, prefix: String, contacts: Contacts, show_friend_confirmed: Bool) { + self.pubkey = pubkey + self.profile = profile + self.prefix = prefix + self.contacts = contacts + self.show_friend_confirmed = show_friend_confirmed + } + + var friend_icon: String? { + if !show_friend_confirmed { + return nil + } + + if self.contacts.is_friend(self.pubkey) { + return "person.fill.checkmark" + } + + if self.contacts.is_friend_of_friend(self.pubkey) { + return "person.fill.and.arrow.left.and.arrow.right" + } + + return nil + } + + var body: some View { + HStack { + if let real_name = profile?.display_name { + Text(real_name) + .font(.subheadline.weight(.bold)) + + Text("@" + String(display_name ?? Profile.displayName(profile: profile, pubkey: pubkey))) + .foregroundColor(.gray) + .font(.subheadline) + } else { + Text(String(display_name ?? Profile.displayName(profile: profile, pubkey: pubkey))) + .foregroundColor(.black) + .font(.subheadline) + .fontWeight(.bold) + } + + if let frend = friend_icon { + Label("", systemImage: frend) + .foregroundColor(.gray) + .font(.footnote) + } + } + .onReceive(handle_notify(.profile_updated)) { notif in + let update = notif.object as! ProfileUpdate + if update.pubkey != pubkey { + return + } + display_name = Profile.displayName(profile: update.profile, pubkey: pubkey) + } + } +} diff --git a/damus/Views/ProfileView.swift b/damus/Views/ProfileView.swift index ca6ebd1..db39b54 100644 --- a/damus/Views/ProfileView.swift +++ b/damus/Views/ProfileView.swift @@ -78,6 +78,9 @@ struct ProfileNameView: View { } struct ProfileView: View { + + @Environment(\.colorScheme) var colorScheme + let damus_state: DamusState @State private var selected_tab: ProfileTab = .posts @@ -94,8 +97,8 @@ struct ProfileView: View { }) { Image(systemName: "bolt.circle") .symbolRenderingMode(.palette) - .foregroundStyle(.black, .gray) - .font(.system(size: 27).weight(.thin)) + .font(.system(size: 34).weight(.thin)) + .foregroundStyle(colorScheme == .light ? .black : .white, colorScheme == .light ? .black.opacity(0.1) : .white.opacity(0.1)) } } @@ -106,8 +109,8 @@ struct ProfileView: View { return NavigationLink(destination: dmview) { Image(systemName: "bubble.left.circle") .symbolRenderingMode(.palette) - .font(.system(size: 29).weight(.thin)) - .foregroundStyle(.black, .gray) + .font(.system(size: 34).weight(.thin)) + .foregroundStyle(colorScheme == .light ? .black : .white, colorScheme == .light ? .black.opacity(0.1) : .white.opacity(0.1)) } } @@ -133,6 +136,7 @@ struct ProfileView: View { .padding(.bottom) Text(data?.about ?? "") + .font(.subheadline) Divider()