minor refactor and clean up

pull/874/head
Ryan Zhao 2 years ago
parent 8419d06a7e
commit 9efba621f7

@ -49,14 +49,8 @@ struct MessageInfoView: View {
Text(body) Text(body)
.foregroundColor(themeColor: bubbleTextColor) .foregroundColor(themeColor: bubbleTextColor)
.padding( .padding(.vertical, Values.smallSpacing)
EdgeInsets( .padding(.horizontal, Values.mediumSpacing)
top: 8,
leading: 16,
bottom: 8,
trailing: 16
)
)
} }
.frame( .frame(
maxWidth: .infinity, maxWidth: .infinity,
@ -64,14 +58,9 @@ struct MessageInfoView: View {
alignment: .topLeading alignment: .topLeading
) )
.fixedSize(horizontal: true, vertical: true) .fixedSize(horizontal: true, vertical: true)
.padding( .padding(.top, Values.smallSpacing)
EdgeInsets( .padding(.bottom, Values.verySmallSpacing)
top: 8, .padding(.horizontal, 30)
leading: 30,
bottom: 4,
trailing: 30
)
)
} }
if isMessageFailed { if isMessageFailed {
@ -91,18 +80,13 @@ struct MessageInfoView: View {
if let statusText: String = statusText { if let statusText: String = statusText {
Text(statusText) Text(statusText)
.font(.system(size: 11)) .font(.system(size: Values.verySmallFontSize))
.foregroundColor(themeColor: tintColor) .foregroundColor(themeColor: tintColor)
} }
} }
.padding( .padding(.top, -Values.smallSpacing)
EdgeInsets( .padding(.bottom, Values.verySmallSpacing)
top: -8, .padding(.horizontal, 30)
leading: 30,
bottom: 4,
trailing: 30
)
)
} }
if let attachments = messageViewModel.attachments { if let attachments = messageViewModel.attachments {
@ -134,14 +118,7 @@ struct MessageInfoView: View {
) )
.aspectRatio(1, contentMode: .fit) .aspectRatio(1, contentMode: .fit)
.clipShape(RoundedRectangle(cornerRadius: 15)) .clipShape(RoundedRectangle(cornerRadius: 15))
.padding( .padding(.horizontal, 30)
EdgeInsets(
top: 0,
leading: 30,
bottom: 0,
trailing: 30
)
)
} }
Button { Button {
@ -164,23 +141,10 @@ struct MessageInfoView: View {
} }
.frame(width: 26, height: 26) .frame(width: 26, height: 26)
} }
.padding( .padding(.bottom, Values.smallSpacing)
EdgeInsets( .padding(.trailing, 38)
top: 0,
leading: 0,
bottom: 8,
trailing: 38
)
)
} }
.padding( .padding(.vertical, Values.verySmallSpacing)
EdgeInsets(
top: 4,
leading: 0,
bottom: 4,
trailing: 0
)
)
// Attachment Info // Attachment Info
ZStack { ZStack {
@ -189,11 +153,11 @@ struct MessageInfoView: View {
VStack( VStack(
alignment: .leading, alignment: .leading,
spacing: 16 spacing: Values.mediumSpacing
) { ) {
InfoBlock(title: "ATTACHMENT_INFO_FILE_ID".localized() + ":") { InfoBlock(title: "ATTACHMENT_INFO_FILE_ID".localized() + ":") {
Text(attachment.serverId ?? "") Text(attachment.serverId ?? "")
.font(.system(size: 16)) .font(.system(size: Values.mediumFontSize))
.foregroundColor(themeColor: .textPrimary) .foregroundColor(themeColor: .textPrimary)
} }
@ -202,7 +166,7 @@ struct MessageInfoView: View {
) { ) {
InfoBlock(title: "ATTACHMENT_INFO_FILE_TYPE".localized() + ":") { InfoBlock(title: "ATTACHMENT_INFO_FILE_TYPE".localized() + ":") {
Text(attachment.contentType) Text(attachment.contentType)
.font(.system(size: 16)) .font(.system(size: Values.mediumFontSize))
.foregroundColor(themeColor: .textPrimary) .foregroundColor(themeColor: .textPrimary)
} }
@ -210,7 +174,7 @@ struct MessageInfoView: View {
InfoBlock(title: "ATTACHMENT_INFO_FILE_SIZE".localized() + ":") { InfoBlock(title: "ATTACHMENT_INFO_FILE_SIZE".localized() + ":") {
Text(Format.fileSize(attachment.byteCount)) Text(Format.fileSize(attachment.byteCount))
.font(.system(size: 16)) .font(.system(size: Values.mediumFontSize))
.foregroundColor(themeColor: .textPrimary) .foregroundColor(themeColor: .textPrimary)
} }
@ -225,7 +189,7 @@ struct MessageInfoView: View {
}() }()
InfoBlock(title: "ATTACHMENT_INFO_RESOLUTION".localized() + ":") { InfoBlock(title: "ATTACHMENT_INFO_RESOLUTION".localized() + ":") {
Text(resolution) Text(resolution)
.font(.system(size: 16)) .font(.system(size: Values.mediumFontSize))
.foregroundColor(themeColor: .textPrimary) .foregroundColor(themeColor: .textPrimary)
} }
@ -237,7 +201,7 @@ struct MessageInfoView: View {
}() }()
InfoBlock(title: "ATTACHMENT_INFO_DURATION".localized() + ":") { InfoBlock(title: "ATTACHMENT_INFO_DURATION".localized() + ":") {
Text(duration) Text(duration)
.font(.system(size: 16)) .font(.system(size: Values.mediumFontSize))
.foregroundColor(themeColor: .textPrimary) .foregroundColor(themeColor: .textPrimary)
} }
@ -249,25 +213,12 @@ struct MessageInfoView: View {
maxHeight: .infinity, maxHeight: .infinity,
alignment: .topLeading alignment: .topLeading
) )
.padding( .padding(.all, Values.largeSpacing)
EdgeInsets(
top: 24,
leading: 24,
bottom: 24,
trailing: 24
)
)
} }
.frame(maxHeight: .infinity) .frame(maxHeight: .infinity)
.fixedSize(horizontal: false, vertical: true) .fixedSize(horizontal: false, vertical: true)
.padding( .padding(.vertical, Values.verySmallSpacing)
EdgeInsets( .padding(.horizontal, 30)
top: 4,
leading: 30,
bottom: 4,
trailing: 30
)
)
} }
// Message Info // Message Info
@ -277,17 +228,17 @@ struct MessageInfoView: View {
VStack( VStack(
alignment: .leading, alignment: .leading,
spacing: 16 spacing: Values.mediumSpacing
) { ) {
InfoBlock(title: "MESSAGE_INFO_SENT".localized() + ":") { InfoBlock(title: "MESSAGE_INFO_SENT".localized() + ":") {
Text(messageViewModel.dateForUI.fromattedForMessageInfo) Text(messageViewModel.dateForUI.fromattedForMessageInfo)
.font(.system(size: 16)) .font(.system(size: Values.mediumFontSize))
.foregroundColor(themeColor: .textPrimary) .foregroundColor(themeColor: .textPrimary)
} }
InfoBlock(title: "MESSAGE_INFO_RECEIVED".localized() + ":") { InfoBlock(title: "MESSAGE_INFO_RECEIVED".localized() + ":") {
Text(messageViewModel.receivedDateForUI.fromattedForMessageInfo) Text(messageViewModel.receivedDateForUI.fromattedForMessageInfo)
.font(.system(size: 16)) .font(.system(size: Values.mediumFontSize))
.foregroundColor(themeColor: .textPrimary) .foregroundColor(themeColor: .textPrimary)
} }
@ -295,7 +246,7 @@ struct MessageInfoView: View {
let failureText: String = messageViewModel.mostRecentFailureText ?? "Message failed to send" let failureText: String = messageViewModel.mostRecentFailureText ?? "Message failed to send"
InfoBlock(title: "ALERT_ERROR_TITLE".localized() + ":") { InfoBlock(title: "ALERT_ERROR_TITLE".localized() + ":") {
Text(failureText) Text(failureText)
.font(.system(size: 16)) .font(.system(size: Values.mediumFontSize))
.foregroundColor(themeColor: .danger) .foregroundColor(themeColor: .danger)
} }
} }
@ -335,11 +286,11 @@ struct MessageInfoView: View {
if !messageViewModel.authorName.isEmpty { if !messageViewModel.authorName.isEmpty {
Text(messageViewModel.authorName) Text(messageViewModel.authorName)
.bold() .bold()
.font(.system(size: 18)) .font(.system(size: Values.mediumLargeFontSize))
.foregroundColor(themeColor: .textPrimary) .foregroundColor(themeColor: .textPrimary)
} }
Text(messageViewModel.authorId) Text(messageViewModel.authorId)
.font(.spaceMono(size: 16)) .font(.spaceMono(size: Values.mediumFontSize))
.foregroundColor(themeColor: .textPrimary) .foregroundColor(themeColor: .textPrimary)
} }
} }
@ -350,25 +301,12 @@ struct MessageInfoView: View {
maxHeight: .infinity, maxHeight: .infinity,
alignment: .topLeading alignment: .topLeading
) )
.padding( .padding(.all, Values.largeSpacing)
EdgeInsets(
top: 24,
leading: 24,
bottom: 24,
trailing: 24
)
)
} }
.frame(maxHeight: .infinity) .frame(maxHeight: .infinity)
.fixedSize(horizontal: false, vertical: true) .fixedSize(horizontal: false, vertical: true)
.padding( .padding(.vertical, Values.verySmallSpacing)
EdgeInsets( .padding(.horizontal, 30)
top: 4,
leading: 30,
bottom: 4,
trailing: 30
)
)
// Actions // Actions
if !actions.isEmpty { if !actions.isEmpty {
@ -391,7 +329,7 @@ struct MessageInfoView: View {
dismiss?() dismiss?()
}, },
label: { label: {
HStack(spacing: 24) { HStack(spacing: Values.largeSpacing) {
Image(uiImage: actions[index].icon!.withRenderingMode(.alwaysTemplate)) Image(uiImage: actions[index].icon!.withRenderingMode(.alwaysTemplate))
.resizable() .resizable()
.scaledToFit() .scaledToFit()
@ -399,7 +337,7 @@ struct MessageInfoView: View {
.frame(width: 26, height: 26) .frame(width: 26, height: 26)
Text(actions[index].title) Text(actions[index].title)
.bold() .bold()
.font(.system(size: 18)) .font(.system(size: Values.mediumLargeFontSize))
.foregroundColor(themeColor: tintColor) .foregroundColor(themeColor: tintColor)
} }
.frame(maxWidth: .infinity, alignment: .topLeading) .frame(maxWidth: .infinity, alignment: .topLeading)
@ -418,25 +356,12 @@ struct MessageInfoView: View {
maxHeight: .infinity, maxHeight: .infinity,
alignment: .topLeading alignment: .topLeading
) )
.padding( .padding(.horizontal, Values.largeSpacing)
EdgeInsets(
top: 0,
leading: 24,
bottom: 0,
trailing: 24
)
)
} }
.frame(maxHeight: .infinity) .frame(maxHeight: .infinity)
.fixedSize(horizontal: false, vertical: true) .fixedSize(horizontal: false, vertical: true)
.padding( .padding(.vertical, Values.verySmallSpacing)
EdgeInsets( .padding(.horizontal, 30)
top: 4,
leading: 30,
bottom: 4,
trailing: 30
)
)
} }
} }
} }
@ -452,11 +377,11 @@ struct InfoBlock<Content>: View where Content: View {
var body: some View { var body: some View {
VStack( VStack(
alignment: .leading, alignment: .leading,
spacing: 4 spacing: Values.verySmallSpacing
) { ) {
Text(self.title) Text(self.title)
.bold() .bold()
.font(.system(size: 18)) .font(.system(size: Values.mediumLargeFontSize))
.foregroundColor(themeColor: .textPrimary) .foregroundColor(themeColor: .textPrimary)
self.content() self.content()
} }

@ -13,8 +13,10 @@ public final class Values : NSObject {
@objc public static let verySmallFontSize = isIPhone5OrSmaller ? CGFloat(10) : CGFloat(12) @objc public static let verySmallFontSize = isIPhone5OrSmaller ? CGFloat(10) : CGFloat(12)
@objc public static let smallFontSize = isIPhone5OrSmaller ? CGFloat(13) : CGFloat(15) @objc public static let smallFontSize = isIPhone5OrSmaller ? CGFloat(13) : CGFloat(15)
@objc public static let mediumFontSize = isIPhone5OrSmaller ? CGFloat(15) : CGFloat(17) @objc public static let mediumFontSize = isIPhone5OrSmaller ? CGFloat(15) : CGFloat(17)
@objc public static let mediumLargeFontSize = isIPhone5OrSmaller ? CGFloat(17) : CGFloat(19)
@objc public static let largeFontSize = isIPhone5OrSmaller ? CGFloat(20) : CGFloat(22) @objc public static let largeFontSize = isIPhone5OrSmaller ? CGFloat(20) : CGFloat(22)
@objc public static let veryLargeFontSize = isIPhone5OrSmaller ? CGFloat(24) : CGFloat(26) @objc public static let veryLargeFontSize = isIPhone5OrSmaller ? CGFloat(24) : CGFloat(26)
@objc public static let superLargeFontSize = isIPhone5OrSmaller ? CGFloat(31) : CGFloat(33)
@objc public static let massiveFontSize = CGFloat(50) @objc public static let massiveFontSize = CGFloat(50)
// MARK: - Element Sizes // MARK: - Element Sizes

Loading…
Cancel
Save