DM: Various UX fixes

This commit is contained in:
Thomas Ricouard 2023-01-26 18:27:53 +01:00
parent 377374d34f
commit 72fbcff1dd
3 changed files with 20 additions and 16 deletions

View file

@ -119,12 +119,17 @@ public struct ConversationDetailView: View {
} label: {
Image(systemName: "plus")
}
.padding(.bottom, 6)
.padding(.bottom, 7)
TextField("conversations.new.message.placeholder", text: $viewModel.newMessageText, axis: .vertical)
.textFieldStyle(.roundedBorder)
.focused($isMessageFieldFocused)
.keyboardType(.default)
.backgroundStyle(.thickMaterial)
.padding(6)
.overlay(
RoundedRectangle(cornerRadius: 14)
.stroke(.gray, lineWidth: 1)
)
.font(.scaledBody)
if !viewModel.newMessageText.isEmpty {
Button {
@ -139,7 +144,7 @@ public struct ConversationDetailView: View {
}
}
.keyboardShortcut(.return, modifiers: .command)
.padding(.bottom, 5)
.padding(.bottom, 6)
}
}
.padding(8)

View file

@ -66,9 +66,13 @@ struct ConversationMessageView: View {
if isOwnMessage {
Spacer()
}
Text(message.createdAt.asDate, style: .time)
.font(.scaledFootnote)
.foregroundColor(.gray)
Group {
Text(message.createdAt.shortDateFormatted) +
Text(" ")
Text(message.createdAt.asDate, style: .time)
}
.font(.scaledFootnote)
.foregroundColor(.gray)
if !isOwnMessage {
Spacer()
}

View file

@ -19,7 +19,8 @@ extension ServerDate {
private static var createdAtShortDateFormatted: DateFormatter = {
let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .medium
dateFormatter.dateStyle = .short
dateFormatter.timeStyle = .none
return dateFormatter
}()
@ -32,14 +33,8 @@ extension ServerDate {
public var relativeFormatted: String {
return Self.createdAtRelativeFormatter.localizedString(for: asDate, relativeTo: Date())
}
}
extension Calendar {
func numberOfDaysBetween(_ from: Date, and to: Date) -> Int {
let fromDate = startOfDay(for: from)
let toDate = startOfDay(for: to)
let numberOfDays = dateComponents([.day], from: fromDate, to: toDate)
return numberOfDays.day!
public var shortDateFormatted: String {
return Self.createdAtShortDateFormatted.string(from: asDate)
}
}