Browse Source

Ton of changes to layout and resolving issues fixing the color scheme

profile-edit
Sam DuBois 2 years ago
parent
commit
614e6a7ee8
  1. 16
      damus/ContentView.swift
  2. 6
      damus/Views/EventActionBar.swift
  3. 3
      damus/Views/EventView.swift
  4. 25
      damus/Views/FollowButtonView.swift
  5. 2
      damus/Views/NoteContentView.swift
  6. 78
      damus/Views/ProfileName.swift
  7. 12
      damus/Views/ProfileView.swift

16
damus/ContentView.swift

@ -151,19 +151,21 @@ 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())
}
}
}
}
.navigationViewStyle(.stack)
}

6
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)

3
damus/Views/EventView.swift

@ -119,8 +119,9 @@ 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)
}

25
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 {

2
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)

78
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)
}
}
}

12
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()

Loading…
Cancel
Save