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. 18
      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

18
damus/ContentView.swift

@ -151,16 +151,18 @@ struct ContentView: View {
} }
ToolbarItem(placement: .navigationBarTrailing) { ToolbarItem(placement: .navigationBarTrailing) {
NavigationLink(destination: ConfigView(state: viewModel.state!)) { HStack(alignment: .center) {
if #available(iOS 16.0, *) { if viewModel.home.signal.signal != viewModel.home.signal.max_signal {
Image(systemName: "chart.bar.fill", variableValue: Double(viewModel.home.signal.signal) / Double(viewModel.home.signal.max_signal)) Text("\(viewModel.home.signal.signal)/\(viewModel.home.signal.max_signal)")
.font(.body.weight(.ultraLight)) .font(.callout)
.symbolRenderingMode(.hierarchical) .foregroundColor(.gray)
} else { }
// Fallback on earlier versions
} NavigationLink(destination: ConfigView(state: viewModel.state!)) {
Image(systemName: "gear")
} }
.buttonStyle(PlainButtonStyle()) .buttonStyle(PlainButtonStyle())
}
} }
} }
} }

6
damus/Views/EventActionBar.swift

@ -42,7 +42,7 @@ struct EventActionBar: View {
HStack(alignment: .bottom) { HStack(alignment: .bottom) {
Text("\(bar.boosts > 0 ? "\(bar.boosts)" : "")") Text("\(bar.boosts > 0 ? "\(bar.boosts)" : "")")
.font(.footnote) .font(.footnote.weight(.medium))
.foregroundColor(bar.boosted ? Color.green : Color.gray) .foregroundColor(bar.boosted ? Color.green : Color.gray)
EventActionButton(img: "arrow.2.squarepath", col: bar.boosted ? Color.green : nil) { EventActionButton(img: "arrow.2.squarepath", col: bar.boosted ? Color.green : nil) {
@ -56,7 +56,7 @@ struct EventActionBar: View {
HStack(alignment: .bottom) { HStack(alignment: .bottom) {
Text("\(bar.likes > 0 ? "\(bar.likes)" : "")") Text("\(bar.likes > 0 ? "\(bar.likes)" : "")")
.font(.footnote) .font(.footnote.weight(.medium))
.foregroundColor(bar.liked ? Color.red : Color.gray) .foregroundColor(bar.liked ? Color.red : Color.gray)
EventActionButton(img: bar.liked ? "heart.fill" : "heart", col: bar.liked ? Color.red : nil) { 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 { func EventActionButton(img: String, col: Color?, action: @escaping () -> ()) -> some View {
Button(action: action) { Button(action: action) {
Label("", systemImage: img) Label("", systemImage: img)
.font(.footnote) .font(.footnote.weight(.medium))
.foregroundColor(col == nil ? Color.gray : col!) .foregroundColor(col == nil ? Color.gray : col!)
} }
.padding(.trailing, 40) .padding(.trailing, 40)

3
damus/Views/EventView.swift

@ -119,8 +119,9 @@ struct EventView: View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
HStack(alignment: .center) { 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))") Text("\(format_relative_time(event.created_at))")
.font(.subheadline)
.foregroundColor(.gray) .foregroundColor(.gray)
} }

25
damus/Views/FollowButtonView.swift

@ -8,6 +8,9 @@
import SwiftUI import SwiftUI
struct FollowButtonView: View { struct FollowButtonView: View {
@Environment(\.colorScheme) var colorScheme
let target: FollowTarget let target: FollowTarget
@State var follow_state: FollowState @State var follow_state: FollowState
@ -16,15 +19,15 @@ struct FollowButtonView: View {
follow_state = perform_follow_btn_action(follow_state, target: target) follow_state = perform_follow_btn_action(follow_state, target: target)
} label: { } label: {
Text(follow_btn_txt(follow_state)) Text(follow_btn_txt(follow_state))
.padding(.horizontal, 20) .padding(.horizontal, 25)
.padding(.vertical, 7) .padding(.vertical, 10)
.font(.caption.weight(.bold)) .font(.caption.weight(.bold))
.foregroundColor(follow_state == .unfollows ? .white : .black) .foregroundColor(follow_state == .unfollows ? emptyColor() : fillColor())
.background(follow_state == .unfollows ? .black : .white) .background(follow_state == .unfollows ? fillColor() : emptyColor())
.cornerRadius(20) .cornerRadius(20)
.overlay { .overlay {
RoundedRectangle(cornerRadius: 16) 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 .onReceive(handle_notify(.followed)) { notif in
@ -44,6 +47,18 @@ struct FollowButtonView: View {
self.follow_state = .unfollows 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 { struct FollowButtonPreviews: View {

2
damus/Views/NoteContentView.swift

@ -64,8 +64,10 @@ struct NoteContentView: View {
return VStack(alignment: .leading) { return VStack(alignment: .leading) {
if let txt = try? AttributedString(markdown: artifacts.content, options: md_opts) { if let txt = try? AttributedString(markdown: artifacts.content, options: md_opts) {
Text(txt) Text(txt)
.font(.subheadline)
} else { } else {
Text(artifacts.content) Text(artifacts.content)
.font(.subheadline)
} }
if show_images && artifacts.images.count > 0 { if show_images && artifacts.images.count > 0 {
ImageCarousel(urls: artifacts.images) ImageCarousel(urls: artifacts.images)

78
damus/Views/ProfileName.swift

@ -23,7 +23,7 @@ struct ProfileFullName: View {
.font(.footnote) .font(.footnote)
.foregroundColor(.gray) .foregroundColor(.gray)
} else { } 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 { var body: some View {
HStack { HStack {
Text(prefix + String(display_name ?? Profile.displayName(profile: profile, pubkey: pubkey))) Text(prefix + String(display_name ?? Profile.displayName(profile: profile, pubkey: pubkey)))
//.foregroundColor(hex_to_rgb(pubkey)) .font(.subheadline)
.fontWeight(prefix == "@" ? .none : .bold) .fontWeight(prefix == "@" ? .none : .bold)
if let frend = friend_icon { if let frend = friend_icon {
Label("", systemImage: frend) 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 { struct ProfileView: View {
@Environment(\.colorScheme) var colorScheme
let damus_state: DamusState let damus_state: DamusState
@State private var selected_tab: ProfileTab = .posts @State private var selected_tab: ProfileTab = .posts
@ -94,8 +97,8 @@ struct ProfileView: View {
}) { }) {
Image(systemName: "bolt.circle") Image(systemName: "bolt.circle")
.symbolRenderingMode(.palette) .symbolRenderingMode(.palette)
.foregroundStyle(.black, .gray) .font(.system(size: 34).weight(.thin))
.font(.system(size: 27).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) { return NavigationLink(destination: dmview) {
Image(systemName: "bubble.left.circle") Image(systemName: "bubble.left.circle")
.symbolRenderingMode(.palette) .symbolRenderingMode(.palette)
.font(.system(size: 29).weight(.thin)) .font(.system(size: 34).weight(.thin))
.foregroundStyle(.black, .gray) .foregroundStyle(colorScheme == .light ? .black : .white, colorScheme == .light ? .black.opacity(0.1) : .white.opacity(0.1))
} }
} }
@ -133,6 +136,7 @@ struct ProfileView: View {
.padding(.bottom) .padding(.bottom)
Text(data?.about ?? "") Text(data?.about ?? "")
.font(.subheadline)
Divider() Divider()

Loading…
Cancel
Save