WIP: binding real infos

pull/874/head
ryanzhao 2 years ago
parent 09bece5c10
commit 8e1e74b9c0

@ -5,6 +5,7 @@ import SessionUIKit
import SessionSnodeKit import SessionSnodeKit
struct MessageInfoView: View { struct MessageInfoView: View {
@State var index = 1
var actions: [ContextMenuVC.Action] var actions: [ContextMenuVC.Action]
var messageViewModel: MessageViewModel var messageViewModel: MessageViewModel
var isMessageFailed: Bool { var isMessageFailed: Bool {
@ -95,9 +96,10 @@ struct MessageInfoView: View {
) )
} }
if let attachments = messageViewModel.attachments, !attachments.isEmpty { if let attachments = messageViewModel.attachments {
if attachments.count > 1 {
// Attachment carousel view // Attachment carousel view
SessionCarouselView_SwiftUI(contentInfos: [.orange, .gray, .blue, .yellow]) SessionCarouselView_SwiftUI(index: $index, contentInfos: [.orange, .gray, .blue, .yellow])
.frame( .frame(
maxWidth: .infinity, maxWidth: .infinity,
maxHeight: .infinity, maxHeight: .infinity,
@ -111,6 +113,9 @@ struct MessageInfoView: View {
trailing: 0 trailing: 0
) )
) )
} else {
// TODO: one attachment
}
// Attachment Info // Attachment Info
ZStack { ZStack {
@ -202,13 +207,13 @@ struct MessageInfoView: View {
alignment: .leading, alignment: .leading,
spacing: 16 spacing: 16
) { ) {
InfoBlock(title: "Sent:") { InfoBlock(title: "MESSAGE_INFO_SENT".localized() + ":") {
Text(messageViewModel.dateForUI.fromattedForMessageInfo) Text(messageViewModel.dateForUI.fromattedForMessageInfo)
.font(.system(size: 16)) .font(.system(size: 16))
.foregroundColor(themeColor: .textPrimary) .foregroundColor(themeColor: .textPrimary)
} }
InfoBlock(title: "Received:") { InfoBlock(title: "MESSAGE_INFO_RECEIVED".localized() + ":") {
Text(messageViewModel.receivedDateForUI.fromattedForMessageInfo) Text(messageViewModel.receivedDateForUI.fromattedForMessageInfo)
.font(.system(size: 16)) .font(.system(size: 16))
.foregroundColor(themeColor: .textPrimary) .foregroundColor(themeColor: .textPrimary)
@ -216,14 +221,14 @@ struct MessageInfoView: View {
if isMessageFailed { if isMessageFailed {
let failureText: String = messageViewModel.mostRecentFailureText ?? "Message failed to send" let failureText: String = messageViewModel.mostRecentFailureText ?? "Message failed to send"
InfoBlock(title: "Error:") { InfoBlock(title: "ALERT_ERROR_TITLE".localized() + ":") {
Text(failureText) Text(failureText)
.font(.system(size: 16)) .font(.system(size: 16))
.foregroundColor(themeColor: .danger) .foregroundColor(themeColor: .danger)
} }
} }
InfoBlock(title: "From:") { InfoBlock(title: "MESSAGE_INFO_FROM".localized() + ":") {
HStack( HStack(
spacing: 10 spacing: 10
) { ) {

@ -3,12 +3,12 @@
import SwiftUI import SwiftUI
public struct SessionCarouselView_SwiftUI: View { public struct SessionCarouselView_SwiftUI: View {
@State var index = 1 @Binding var index: Int
var contentInfos: [Color] var contentInfos: [Color]
let numberOfPages: Int let numberOfPages: Int
public init(contentInfos: [Color]) { public init(index: Binding<Int>, contentInfos: [Color]) {
self._index = index
self.contentInfos = contentInfos self.contentInfos = contentInfos
self.numberOfPages = contentInfos.count self.numberOfPages = contentInfos.count
@ -191,6 +191,7 @@ struct PageControl: View {
} }
struct SessionCarouselView_SwiftUI_Previews: PreviewProvider { struct SessionCarouselView_SwiftUI_Previews: PreviewProvider {
@State static var index = 1
static var previews: some View { static var previews: some View {
ZStack { ZStack {
if #available(iOS 14.0, *) { if #available(iOS 14.0, *) {
@ -199,7 +200,7 @@ struct SessionCarouselView_SwiftUI_Previews: PreviewProvider {
Color.black Color.black
} }
SessionCarouselView_SwiftUI(contentInfos: [.red, .orange, .blue]) SessionCarouselView_SwiftUI(index: $index, contentInfos: [.red, .orange, .blue])
} }
} }
} }

Loading…
Cancel
Save