From e67ee64730e608b1d8b936f18363ef8457b35c9f Mon Sep 17 00:00:00 2001 From: Oliver Wiese <oliver.wiese@fu-berlin.de> Date: Wed, 15 Apr 2020 12:49:18 +0200 Subject: [PATCH] clean code --- enzevalos_iphone.xcodeproj/project.pbxproj | 4 --- .../SwiftUI/Read/ReadViewCoordinator.swift | 2 -- .../SwiftUI/Read/ReadViewModel.swift | 34 ------------------- .../AttachmentChildren/CardWithTitle.swift | 2 +- .../Read/Tabbed Views/MessageViewMain.swift | 13 +++---- .../Tabbed Views/SecurityBriefingView.swift | 9 ++--- .../SenderViewChildren/PhishingView.swift | 12 ++----- .../SenderViewChildren/SenderDetails.swift | 4 --- enzevalos_iphone/en.lproj/Localizable.strings | 1 + 9 files changed, 11 insertions(+), 70 deletions(-) delete mode 100644 enzevalos_iphone/SwiftUI/Read/ReadViewModel.swift diff --git a/enzevalos_iphone.xcodeproj/project.pbxproj b/enzevalos_iphone.xcodeproj/project.pbxproj index 3595b099..0fdf3205 100644 --- a/enzevalos_iphone.xcodeproj/project.pbxproj +++ b/enzevalos_iphone.xcodeproj/project.pbxproj @@ -161,7 +161,6 @@ 47C822682438A85C005BCE73 /* SenderDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C822662438A85C005BCE73 /* SenderDetails.swift */; }; 47C822692438A85C005BCE73 /* PhishingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C822672438A85C005BCE73 /* PhishingView.swift */; }; 47C8226B2438A86B005BCE73 /* SenderViewMain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C8226A2438A86A005BCE73 /* SenderViewMain.swift */; }; - 47C8226D2438C2CF005BCE73 /* ReadViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C8226C2438C2CF005BCE73 /* ReadViewModel.swift */; }; 47CD5AAA2012368D00E771A1 /* logging_pk.asc in Resources */ = {isa = PBXBuildFile; fileRef = 47CD5AA82012368D00E771A1 /* logging_pk.asc */; }; 47CD5AAD2012369400E771A1 /* support_pk2.asc in Resources */ = {isa = PBXBuildFile; fileRef = 47CD5AAC2012369300E771A1 /* support_pk2.asc */; }; 47CEAC98222541B40075B7DC /* MailSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47CEAC97222541B40075B7DC /* MailSession.swift */; }; @@ -613,7 +612,6 @@ 47C822662438A85C005BCE73 /* SenderDetails.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SenderDetails.swift; sourceTree = "<group>"; }; 47C822672438A85C005BCE73 /* PhishingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhishingView.swift; sourceTree = "<group>"; }; 47C8226A2438A86A005BCE73 /* SenderViewMain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SenderViewMain.swift; sourceTree = "<group>"; }; - 47C8226C2438C2CF005BCE73 /* ReadViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReadViewModel.swift; sourceTree = "<group>"; }; 47CD5AA82012368D00E771A1 /* logging_pk.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = logging_pk.asc; path = keys/logging_pk.asc; sourceTree = "<group>"; }; 47CD5AAC2012369300E771A1 /* support_pk2.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = support_pk2.asc; path = keys/support_pk2.asc; sourceTree = "<group>"; }; 47CEAC97222541B40075B7DC /* MailSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MailSession.swift; sourceTree = "<group>"; }; @@ -1281,7 +1279,6 @@ 47C8224224379EAE005BCE73 /* Tabbed Views */, 47C8225124379EAE005BCE73 /* ReadViewCoordinator.swift */, 47C8225224379EAE005BCE73 /* ReadMainView.swift */, - 47C8226C2438C2CF005BCE73 /* ReadViewModel.swift */, ); path = Read; sourceTree = "<group>"; @@ -2259,7 +2256,6 @@ 4751C7002344D37C006B2A4D /* SecretKey+CoreDataClass.swift in Sources */, A1AEBA5921E808CB00C84E59 /* IntroYesNoViewController.swift in Sources */, A1EB05941D956931008659C1 /* InboxCellDelegator.swift in Sources */, - 47C8226D2438C2CF005BCE73 /* ReadViewModel.swift in Sources */, 47C822602437A143005BCE73 /* CornerRounder.swift in Sources */, 8428A85D1F436A05007649A5 /* Badges.swift in Sources */, 4775D7AC243F18BC0052F2CC /* SecurityBriefingView.swift in Sources */, diff --git a/enzevalos_iphone/SwiftUI/Read/ReadViewCoordinator.swift b/enzevalos_iphone/SwiftUI/Read/ReadViewCoordinator.swift index 5a79de55..ca25281f 100644 --- a/enzevalos_iphone/SwiftUI/Read/ReadViewCoordinator.swift +++ b/enzevalos_iphone/SwiftUI/Read/ReadViewCoordinator.swift @@ -73,14 +73,12 @@ class ReadViewCoordinator { } func delete(mail: PersistentMail){ - //TODO: make this work Logger.log(delete: mail, toTrash: true) AppDelegate.getAppDelegate().mailHandler.move(mails: [mail], from: mail.folder.path, to: UserManager.backendTrashFolderPath) AppDelegate.getAppDelegate().presentInboxViewController() } func archive(mail: PersistentMail){ - //TODO: make this work Logger.log(archive: mail) AppDelegate.getAppDelegate().mailHandler.move(mails: [mail], from: mail.folder.path, to: UserManager.backendArchiveFolderPath) } diff --git a/enzevalos_iphone/SwiftUI/Read/ReadViewModel.swift b/enzevalos_iphone/SwiftUI/Read/ReadViewModel.swift deleted file mode 100644 index 2641bc40..00000000 --- a/enzevalos_iphone/SwiftUI/Read/ReadViewModel.swift +++ /dev/null @@ -1,34 +0,0 @@ -// -// ReadViewModel.swift -// enzevalos_iphone -// -// Created by Oliver Wiese on 04.04.20. -// Copyright © 2020 fu-berlin. All rights reserved. -// - -import Foundation -import SwiftUI - -class ReadViewModel: ObservableObject { - - // Meta data - let senderName: String - let senderImg: Image - - let landmarks: [Landmark] - - let ccsNames: [String] - let bccsNames: [String] - - - init(senderName: String, senderImg: Image, landmarks: [Landmark], ccs: [String], bccs: [String]) { - self.senderName = senderName - self.senderImg = senderImg - self.landmarks = landmarks - self.ccsNames = ccs - self.bccsNames = bccs - } - - -} - diff --git a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/AttachmentChildren/CardWithTitle.swift b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/AttachmentChildren/CardWithTitle.swift index 1c84b83c..a06b540f 100644 --- a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/AttachmentChildren/CardWithTitle.swift +++ b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/AttachmentChildren/CardWithTitle.swift @@ -28,7 +28,7 @@ struct CardV<Content:View>: View{ var content: () -> Content @State private var isAdvancedVisable:Bool = false - @/*Gesture*/State private var isTapDownB:Bool = false + @State private var isTapDownB:Bool = false private let colo=Color(red:0.85,green:0.85,blue:0.88) diff --git a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/MessageViewMain.swift b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/MessageViewMain.swift index 52248f2b..d1b50a52 100644 --- a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/MessageViewMain.swift +++ b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/MessageViewMain.swift @@ -14,15 +14,11 @@ struct MessageViewMain <M: DisplayMail>: View { @Environment(\.presentationMode) var presentationMode: Binding<PresentationMode> - let innerPadding:CGFloat = 20 // button radius - let outerPadding:CGFloat = 5 + let innerPadding: CGFloat = 20 // button radius + let outerPadding: CGFloat = 5 let extraButtonFactor: CGFloat = 0.8 - @State var showExtraButtons:Bool = false - - func action() { - print("Click!") - } + @State var showExtraButtons: Bool = false var body: some View { ZStack{ @@ -66,7 +62,6 @@ struct MessageViewMain <M: DisplayMail>: View { HStack{ Spacer() ZStack{ - if mail.folderType == FolderType.Archive { forwardButton.offset(y: showExtraButtons ? -innerPadding*9 : 0) replyAllButton.offset(y: showExtraButtons ? -innerPadding*4.5 : 0) @@ -160,7 +155,7 @@ struct MessageViewMain <M: DisplayMail>: View { radius: innerPadding*extraButtonFactor, onShortPress: { self.moveMail(target: .Trash) - self.presentationMode.wrappedValue.dismiss()}/*TODO: fill in stuff*/ + self.presentationMode.wrappedValue.dismiss()} ){ VStack{ Image(systemName: "trash") diff --git a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SecurityBriefingView.swift b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SecurityBriefingView.swift index 0e136d1f..806501e6 100644 --- a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SecurityBriefingView.swift +++ b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SecurityBriefingView.swift @@ -123,7 +123,7 @@ struct WarningView: View { init(warning: Dialog) { title = warning.title description = warning.body - icon = Image(systemName: "xmark.octagon.fill") //warning.img + icon = Image(systemName: "xmark.octagon.fill") color = warning.dialogColor if let ctaTitle = warning.ctaButtonTitle, let ctaAction = warning.ctaButtonAction { ctaButton = ButtonStruct(titleKey: ctaTitle, action: ctaAction, type: .CTA) @@ -189,9 +189,6 @@ struct InfoView: View { Text(titleString) .font(.headline) .padding(padding) - // Text(descriptionString) - // .fontWeight(.light) - // .padding(padding) HStack { icon Text(stateString) @@ -205,13 +202,13 @@ struct InfoView: View { var color: Color switch rating { case .Positiv: - image = Image(systemName: "hand.thumbsup")//"checkmark") + image = Image(systemName: "hand.thumbsup") color = Color(ThemeManager.encryptedMessageColor()) case .Neutral: image = Image(systemName: "hand.thumbsdown") color = Color(ThemeManager.unencryptedMessageColor()) case .Negativ: - image = Image(systemName: "xmark.ocatgon.fill")//"hand.raised") + image = Image(systemName: "xmark.ocatgon.fill") color = Color(ThemeManager.troubleMessageColor()) } image = image.resizable() diff --git a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/PhishingView.swift b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/PhishingView.swift index 6094a341..ba5ff223 100644 --- a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/PhishingView.swift +++ b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/PhishingView.swift @@ -34,7 +34,6 @@ struct AllPhishingContent: Identifiable { let message: String } -//not struct PhishingView : View { /// This content stores the phishing information in a list var PhishingList = [ @@ -45,21 +44,14 @@ struct PhishingView : View { ] var body: some View { - - List(PhishingList) { AllPhishingContent in - + List(PhishingList) { AllPhishingContent in VStack { - Text("Identification").bold() Text(AllPhishingContent.name) Text(AllPhishingContent.message).italic() - } - - } - + } } - } diff --git a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/SenderDetails.swift b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/SenderDetails.swift index 78d5a92a..a1d28713 100644 --- a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/SenderDetails.swift +++ b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/SenderDetails.swift @@ -36,20 +36,16 @@ struct SenderDetails: View { @State private var moreDetails = false var body: some View { VStack (alignment: .leading, spacing: 20) { - Text("Sender:") .font(.subheadline) .padding(.bottom, 5) - HStack(alignment: .top) { Text("More Details") .foregroundColor(.blue) .font(.system(size: 10)) - Button (action: { self.moreDetails.toggle() }) { - Image(systemName: moreDetails ? "chevron.up" : "chevron.down") .resizable() .frame(width: 12.0, height: 7.0) diff --git a/enzevalos_iphone/en.lproj/Localizable.strings b/enzevalos_iphone/en.lproj/Localizable.strings index 5b889ab0..70b50be2 100644 --- a/enzevalos_iphone/en.lproj/Localizable.strings +++ b/enzevalos_iphone/en.lproj/Localizable.strings @@ -101,6 +101,7 @@ "Next" = "Next"; "Button.Next" = "Next"; "next" = "next"; +"Button.Prev" = "Prev"; "None" = "None"; "NormalPassword" = "Normal, password"; "Now" = "just now"; -- GitLab