add action sheet

pull/874/head
ryanzhao 1 year ago
parent 114868ef16
commit e07887c4aa

@ -10,6 +10,7 @@ extension ContextMenuVC {
let isEmojiAction: Bool let isEmojiAction: Bool
let isEmojiPlus: Bool let isEmojiPlus: Bool
let isDismissAction: Bool let isDismissAction: Bool
let isDestructive: Bool
let accessibilityLabel: String? let accessibilityLabel: String?
let work: () -> Void let work: () -> Void
@ -21,6 +22,7 @@ extension ContextMenuVC {
isEmojiAction: Bool = false, isEmojiAction: Bool = false,
isEmojiPlus: Bool = false, isEmojiPlus: Bool = false,
isDismissAction: Bool = false, isDismissAction: Bool = false,
isDestructive: Bool = false,
accessibilityLabel: String? = nil, accessibilityLabel: String? = nil,
work: @escaping () -> Void work: @escaping () -> Void
) { ) {
@ -29,6 +31,7 @@ extension ContextMenuVC {
self.isEmojiAction = isEmojiAction self.isEmojiAction = isEmojiAction
self.isEmojiPlus = isEmojiPlus self.isEmojiPlus = isEmojiPlus
self.isDismissAction = isDismissAction self.isDismissAction = isDismissAction
self.isDestructive = isDestructive
self.accessibilityLabel = accessibilityLabel self.accessibilityLabel = accessibilityLabel
self.work = work self.work = work
} }
@ -83,6 +86,7 @@ extension ContextMenuVC {
return Action( return Action(
icon: UIImage(named: "ic_trash"), icon: UIImage(named: "ic_trash"),
title: "TXT_DELETE_TITLE".localized(), title: "TXT_DELETE_TITLE".localized(),
isDestructive: true,
accessibilityLabel: "Delete message" accessibilityLabel: "Delete message"
) { delegate?.delete(cellViewModel) } ) { delegate?.delete(cellViewModel) }
} }

@ -88,20 +88,23 @@ struct MessageInfoView: View {
} }
// TODO: Attachment carousel view // TODO: Attachment carousel view
SessionCarouselView_SwiftUI(contentInfos: [.orange, .gray, .blue, .yellow]) if let attachments = messageViewModel.attachments, !attachments.isEmpty {
.frame( SessionCarouselView_SwiftUI(contentInfos: [.orange, .gray, .blue, .yellow])
maxWidth: .infinity, .frame(
maxHeight: .infinity, maxWidth: .infinity,
alignment: .topLeading maxHeight: .infinity,
) alignment: .topLeading
.padding(
EdgeInsets(
top: 4,
leading: 0,
bottom: 4,
trailing: 0
) )
) .padding(
EdgeInsets(
top: 4,
leading: 0,
bottom: 4,
trailing: 0
)
)
}
// Attachment Info // Attachment Info
if (messageViewModel.attachments?.isEmpty != false) { if (messageViewModel.attachments?.isEmpty != false) {
@ -120,8 +123,7 @@ struct MessageInfoView: View {
} }
HStack( HStack(
alignment: .center, alignment: .center
spacing: 48
) { ) {
InfoBlock(title: "ATTACHMENT_INFO_FILE_TYPE".localized() + ":") { InfoBlock(title: "ATTACHMENT_INFO_FILE_TYPE".localized() + ":") {
Text(".PNG") Text(".PNG")
@ -141,8 +143,7 @@ struct MessageInfoView: View {
} }
HStack( HStack(
alignment: .center, alignment: .center
spacing: 48
) { ) {
InfoBlock(title: "ATTACHMENT_INFO_RESOLUTION".localized() + ":") { InfoBlock(title: "ATTACHMENT_INFO_RESOLUTION".localized() + ":") {
Text("550×550") Text("550×550")
@ -168,10 +169,10 @@ struct MessageInfoView: View {
) )
.padding( .padding(
EdgeInsets( EdgeInsets(
top: 16, top: 24,
leading: 16, leading: 24,
bottom: 16, bottom: 24,
trailing: 16 trailing: 24
) )
) )
} }
@ -253,10 +254,10 @@ struct MessageInfoView: View {
) )
.padding( .padding(
EdgeInsets( EdgeInsets(
top: 16, top: 24,
leading: 16, leading: 24,
bottom: 16, bottom: 24,
trailing: 16 trailing: 24
) )
) )
} }
@ -274,19 +275,61 @@ struct MessageInfoView: View {
// Actions // Actions
if !actions.isEmpty { if !actions.isEmpty {
ZStack { ZStack {
RoundedRectangle(cornerRadius: 8) RoundedRectangle(cornerRadius: 17)
VStack { .fill(Color(red: 27.0/255, green: 27.0/255, blue: 27.0/255))
VStack(
alignment: .leading,
spacing: 0
) {
ForEach( ForEach(
0...(actions.count - 1), 0...(actions.count - 1),
id: \.self id: \.self
) { index in ) { index in
HStack { let tintColor: Color = actions[index].isDestructive ? .red : .white
Image(uiImage: actions[index].icon!) HStack(spacing: 24) {
Image(uiImage: actions[index].icon!.withRenderingMode(.alwaysTemplate))
.resizable()
.scaledToFit()
.foregroundColor(tintColor)
.frame(width: 26, height: 26)
Text(actions[index].title) Text(actions[index].title)
.bold()
.font(.system(size: 18))
.foregroundColor(tintColor)
}
.frame(width: .infinity, height: 60)
if index < (actions.count - 1) {
Divider()
.foregroundColor(.gray)
} }
} }
} }
.frame(
maxWidth: .infinity,
maxHeight: .infinity,
alignment: .topLeading
)
.padding(
EdgeInsets(
top: 0,
leading: 24,
bottom: 0,
trailing: 24
)
)
} }
.frame(maxHeight: .infinity)
.fixedSize(horizontal: false, vertical: true)
.padding(
EdgeInsets(
top: 4,
leading: 30,
bottom: 4,
trailing: 30
)
)
} }
} }
} }
@ -309,6 +352,10 @@ struct InfoBlock<Content>: View where Content: View {
.foregroundColor(.white) .foregroundColor(.white)
self.content() self.content()
} }
.frame(
minWidth: 100,
alignment: .leading
)
} }
} }
@ -342,7 +389,13 @@ struct MessageInfoView_Previews: PreviewProvider {
return result return result
} }
static var actions: [ContextMenuVC.Action] = [] static var actions: [ContextMenuVC.Action] {
return [
.reply(messageViewModel, nil),
.retry(messageViewModel, nil),
.delete(messageViewModel, nil)
]
}
static var previews: some View { static var previews: some View {
MessageInfoView( MessageInfoView(

Loading…
Cancel
Save