diff --git a/enzevalos_iphone.xcodeproj/project.pbxproj b/enzevalos_iphone.xcodeproj/project.pbxproj index 56fa23b32fe483cf806c0a6cd6844c298a9ffeb3..36ad295519c92b9e5e1b69c9595893817f960f69 100644 --- a/enzevalos_iphone.xcodeproj/project.pbxproj +++ b/enzevalos_iphone.xcodeproj/project.pbxproj @@ -144,9 +144,6 @@ 47C22281218AFD6300BD2C2B /* AutocryptTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C22280218AFD6300BD2C2B /* AutocryptTest.swift */; }; 47C22283218B02C700BD2C2B /* autocryptSimpleExample1.eml in Resources */ = {isa = PBXBuildFile; fileRef = 47C22282218B02C700BD2C2B /* autocryptSimpleExample1.eml */; }; 47C8225324379EAE005BCE73 /* AttachmentsViewMain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C8224324379EAE005BCE73 /* AttachmentsViewMain.swift */; }; - 47C8225424379EAE005BCE73 /* SenderViewMain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C8224424379EAE005BCE73 /* SenderViewMain.swift */; }; - 47C8225524379EAE005BCE73 /* ProfileEmoji.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C8224624379EAE005BCE73 /* ProfileEmoji.swift */; }; - 47C8225624379EAE005BCE73 /* MapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C8224724379EAE005BCE73 /* MapView.swift */; }; 47C8225724379EAE005BCE73 /* Warning_MessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C8224924379EAE005BCE73 /* Warning_MessageView.swift */; }; 47C8225824379EAE005BCE73 /* FloatingActionButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C8224A24379EAE005BCE73 /* FloatingActionButton.swift */; }; 47C8225924379EAE005BCE73 /* AttPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C8224C24379EAE005BCE73 /* AttPreview.swift */; }; @@ -155,6 +152,10 @@ 47C8225D24379EAE005BCE73 /* ReadViewCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C8225124379EAE005BCE73 /* ReadViewCoordinator.swift */; }; 47C8225E24379EAE005BCE73 /* ReadMainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C8225224379EAE005BCE73 /* ReadMainView.swift */; }; 47C822602437A143005BCE73 /* CornerRounder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C8225F2437A143005BCE73 /* CornerRounder.swift */; }; + 47C822622438A81C005BCE73 /* MapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C822612438A81C005BCE73 /* MapView.swift */; }; + 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 */; }; 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 */; }; @@ -588,9 +589,6 @@ 47C22280218AFD6300BD2C2B /* AutocryptTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutocryptTest.swift; sourceTree = "<group>"; }; 47C22282218B02C700BD2C2B /* autocryptSimpleExample1.eml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = autocryptSimpleExample1.eml; sourceTree = "<group>"; }; 47C8224324379EAE005BCE73 /* AttachmentsViewMain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttachmentsViewMain.swift; sourceTree = "<group>"; }; - 47C8224424379EAE005BCE73 /* SenderViewMain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SenderViewMain.swift; sourceTree = "<group>"; }; - 47C8224624379EAE005BCE73 /* ProfileEmoji.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileEmoji.swift; sourceTree = "<group>"; }; - 47C8224724379EAE005BCE73 /* MapView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapView.swift; sourceTree = "<group>"; }; 47C8224924379EAE005BCE73 /* Warning_MessageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Warning_MessageView.swift; sourceTree = "<group>"; }; 47C8224A24379EAE005BCE73 /* FloatingActionButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FloatingActionButton.swift; sourceTree = "<group>"; }; 47C8224C24379EAE005BCE73 /* AttPreview.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttPreview.swift; sourceTree = "<group>"; }; @@ -599,6 +597,10 @@ 47C8225124379EAE005BCE73 /* ReadViewCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReadViewCoordinator.swift; sourceTree = "<group>"; }; 47C8225224379EAE005BCE73 /* ReadMainView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReadMainView.swift; sourceTree = "<group>"; }; 47C8225F2437A143005BCE73 /* CornerRounder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CornerRounder.swift; sourceTree = "<group>"; }; + 47C822612438A81C005BCE73 /* MapView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapView.swift; sourceTree = "<group>"; }; + 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>"; }; 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>"; }; @@ -1116,6 +1118,7 @@ 4764068C2416B54D00C7D426 /* SupportingViews */ = { isa = PBXGroup; children = ( + 47C822612438A81C005BCE73 /* MapView.swift */, 47EABF2A2423C20C00774A93 /* LoadingBlocker.swift */, 47EABF282423C1FB00774A93 /* KeyboardChecker.swift */, 4764068D2416B54D00C7D426 /* CiricleImage.swift */, @@ -1252,6 +1255,8 @@ children = ( 47C8224224379EAE005BCE73 /* Tabbed Views */, 47C8225124379EAE005BCE73 /* ReadViewCoordinator.swift */, + 47C8226A2438A86A005BCE73 /* SenderViewMain.swift */, + 47C8224324379EAE005BCE73 /* AttachmentsViewMain.swift */, 47C8225224379EAE005BCE73 /* ReadMainView.swift */, ); path = Read; @@ -1260,9 +1265,7 @@ 47C8224224379EAE005BCE73 /* Tabbed Views */ = { isa = PBXGroup; children = ( - 47C8224324379EAE005BCE73 /* AttachmentsViewMain.swift */, - 47C8224424379EAE005BCE73 /* SenderViewMain.swift */, - 47C8224524379EAE005BCE73 /* SenderViewChildren */, + 47C822632438A84C005BCE73 /* SenderViewChildren */, 47C8224824379EAE005BCE73 /* MessageViewChildren */, 47C8224B24379EAE005BCE73 /* AttachmentChildren */, 47C8224E24379EAE005BCE73 /* MessageViewMain.swift */, @@ -1270,15 +1273,6 @@ path = "Tabbed Views"; sourceTree = "<group>"; }; - 47C8224524379EAE005BCE73 /* SenderViewChildren */ = { - isa = PBXGroup; - children = ( - 47C8224624379EAE005BCE73 /* ProfileEmoji.swift */, - 47C8224724379EAE005BCE73 /* MapView.swift */, - ); - path = SenderViewChildren; - sourceTree = "<group>"; - }; 47C8224824379EAE005BCE73 /* MessageViewChildren */ = { isa = PBXGroup; children = ( @@ -1297,6 +1291,15 @@ path = AttachmentChildren; sourceTree = "<group>"; }; + 47C822632438A84C005BCE73 /* SenderViewChildren */ = { + isa = PBXGroup; + children = ( + 47C822672438A85C005BCE73 /* PhishingView.swift */, + 47C822662438A85C005BCE73 /* SenderDetails.swift */, + ); + path = SenderViewChildren; + sourceTree = "<group>"; + }; 47EABF04241A9C6400774A93 /* Recovered References */ = { isa = PBXGroup; children = ( @@ -2236,8 +2239,8 @@ 472F39811E1E5347009260FB /* Mail_Address+CoreDataClass.swift in Sources */, A1EB05821D95685B008659C1 /* CollectionDataDelegate.swift in Sources */, 47A5D6E22294BF3B0084F81D /* TempKey.swift in Sources */, + 47C8226B2438A86B005BCE73 /* SenderViewMain.swift in Sources */, 4751C7012344D37C006B2A4D /* SecretKey+CoreDataProperties.swift in Sources */, - 47C8225624379EAE005BCE73 /* MapView.swift in Sources */, 476406992416B54D00C7D426 /* SearchView.swift in Sources */, 47D1302B1F7CEE6D007B14DF /* DebugSettings.swift in Sources */, A1EB05801D956851008659C1 /* SendViewController.swift in Sources */, @@ -2248,10 +2251,10 @@ 8428A8671F436A11007649A5 /* SubBadgeHeaderTableViewCell.swift in Sources */, A1EB05981D956947008659C1 /* InboxViewController.swift in Sources */, F1984D721E1D327200804E1E /* IconsStyleKit.swift in Sources */, + 47C822692438A85C005BCE73 /* PhishingView.swift in Sources */, F1737ACB2031D7D70000312B /* StudySettings.swift in Sources */, 0ECA5798240D496800B0F231 /* SMIME.swift in Sources */, 47C8225A24379EAE005BCE73 /* CardWithTitle.swift in Sources */, - 47C8225524379EAE005BCE73 /* ProfileEmoji.swift in Sources */, 6789425F2430C3B300C746D1 /* MailComparison.swift in Sources */, 8428A8691F436A11007649A5 /* UserNameGamificationTableViewCell.swift in Sources */, A114E4321FACB23000E40243 /* StringExtension.swift in Sources */, @@ -2261,6 +2264,7 @@ 0EF148082422572500B3C198 /* general-helpers.c in Sources */, F113C3851F30D06800E7F1D6 /* QRScannerView.swift in Sources */, 97BDE0432429188500B0BF03 /* BadgeProgressView.swift in Sources */, + 47C822682438A85C005BCE73 /* SenderDetails.swift in Sources */, 477670C6228454F700043604 /* ButtonCell.swift in Sources */, 47C8225824379EAE005BCE73 /* FloatingActionButton.swift in Sources */, F18B44601E704C550080C041 /* ReplaceSegue.swift in Sources */, @@ -2350,7 +2354,6 @@ 47C8225924379EAE005BCE73 /* AttPreview.swift in Sources */, 475B00341F7B9565006CDD41 /* Cryptography.swift in Sources */, A1EB057C1D956838008659C1 /* MailHandler.swift in Sources */, - 47C8225424379EAE005BCE73 /* SenderViewMain.swift in Sources */, A182182E21E50D8D00918A29 /* IntroButtonViewController.swift in Sources */, 0EFEF0952417C0B400BB2FF7 /* CHelpers.swift in Sources */, 4764069D2416B54D00C7D426 /* Stroke.swift in Sources */, @@ -2366,6 +2369,7 @@ 47EABF2D2423C65F00774A93 /* AuthenticationView.swift in Sources */, 479011492289975D0057AB04 /* NoSecIconStyleKit.swift in Sources */, F12060821DA552FC00F6EF37 /* MailHandlerDelegator.swift in Sources */, + 47C822622438A81C005BCE73 /* MapView.swift in Sources */, 474994022261E4E6000F8DA5 /* SimpleSendIcon.swift in Sources */, 0ECEA0E8240E7081007DC71E /* SearchHelper.swift in Sources */, A12F91D821F3A99800AB0589 /* NSLayoutConstraintExtension.swift in Sources */, diff --git a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/AttachmentsViewMain.swift b/enzevalos_iphone/SwiftUI/Read/AttachmentsViewMain.swift similarity index 100% rename from enzevalos_iphone/SwiftUI/Read/Tabbed Views/AttachmentsViewMain.swift rename to enzevalos_iphone/SwiftUI/Read/AttachmentsViewMain.swift diff --git a/enzevalos_iphone/SwiftUI/Read/SenderViewMain.swift b/enzevalos_iphone/SwiftUI/Read/SenderViewMain.swift new file mode 100644 index 0000000000000000000000000000000000000000..e6a43805fa38a64b6fe6160e490313a01c8e6a29 --- /dev/null +++ b/enzevalos_iphone/SwiftUI/Read/SenderViewMain.swift @@ -0,0 +1,333 @@ +// +// SenderViewMain.swift +// enzevalos_iphone +// +// Created by fatimaaa96 on 12.03.20. +// Copyright © 2020 fu-berlin. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <https://www.gnu.org/licenses/>. +// + +import SwiftUI +import CoreLocation + +/** + The Landmark struct is defined by three parameters. + + id, name, domain and location. + + */ + +struct Landmark: Equatable { + static func ==(lhs: Landmark, rhs: Landmark) -> Bool { + lhs.id == rhs.id + } + + let id = UUID().uuidString + let name: String + let domain: String + let location: CLLocationCoordinate2D +} + + +struct SenderViewMain: View { + + let mail:PersistentMail + + @State var push=false + + @State var landmarks: [Landmark] = [ + Landmark(name: "Berlin", domain: "exampledomain.de", location: .init(latitude: 52.520008, longitude: 13.404954)), + Landmark(name: "New York", domain: "secondexampledomain.de", location: .init(latitude: 40.730610, longitude: -73.935242)), + Landmark(name: "Sydney", domain: "thirdexampledomain.de", location: .init(latitude: -33.865143, longitude: 151.209900)) + ] + + @State var selectedLandmark: Landmark? = nil + + @State var showingLandmarkDetails = false + + @State var scale: CGFloat = 1.0 + + func getCCs()->[String]{ + /// this method displays CC emails in a received email + var ccs:[String]=[] + for cc in mail.cc ?? []{ + let cc2 = cc as! MailAddress + ccs.append(cc2.mailAddress) + } + return ccs + } + + func getBCCs()->[String]{ + /// this method displays BCC emails in a received mail + var bccs:[String]=[] + for bcc in mail.bcc ?? []{ + bccs.append(bcc as! String) + } + return bccs + } + + var body: some View { + VStack { + ZStack { + + ZStack { + MapView(landmarks: $landmarks, + selectedLandmark: $selectedLandmark, showingLandmarkDetails: $showingLandmarkDetails) + .frame(height: 220) + HStack { + + Button(action: { + /// this button displays the previous selected landmark + self.selectPrevLandmark() + }) { + Text("prev") + .foregroundColor(.black) + .padding() + .background(Color.white) + .cornerRadius(6) + .shadow(radius: 3) + .padding(.top, 150) + } + + Spacer() + //.frame(width: 320) + + Button(action: { + /// this button displays the next selected landmark + self.selectNextLandmark() + }) { + Text("Next") + .foregroundColor(.black) + .padding() + .background(Color.white) + .cornerRadius(6) + .shadow(radius: 3) + .padding(.top, 150) + } + + } + + } .alert(isPresented: $showingLandmarkDetails) { + /// alert displays the landmark details and gets trigered when the user taps the information button of a landmark + Alert(title: Text("Domain for this location"), message: Text(selectedLandmark?.domain ?? "Missing place information"), dismissButton: .default(Text("OK")) ) + } + HStack (spacing: -5) { + + /* ProfileEmoji() + // .offset(y: 50) + .padding(.bottom, -270) + .onTapGesture { + self.push = true + }*/ + + //TODO: make toucarea clip to circle .clipShape(Circle()) + NavigationLink(destination: WasAuchImmerOlliHierHabenWill(), isActive: $push) + /// when the user clickes on the profile image a new view (ContactViews) is pushed + { + EmptyView() + }.hidden() + + + + + + /* Button (action: { + self.showMemojiGallery.toggle() + }) { + + Text("Edit") + .padding(7) + .background(Color.blue) + .foregroundColor(.white) + .font(.system(size: 14)) + .cornerRadius(10) + + }.padding(.top, 190) */ + + }.offset(y: 60) + + + } + + Spacer() + + ZStack { + + VStack(alignment: .leading) { + + Spacer() + .frame(height: 70) + + SenderDetails() + Divider() + VStack (alignment: .leading){ + + HStack{ + + Text("CC:") + //// the CC emails are displayed only when they exist + .font(.subheadline) + .padding(.bottom, 20) + + if getCCs().count==0 { + Text("-") + }else{ + ScrollView(.vertical){ + + ForEach(0..<getCCs().count) { i in + Text(self.getCCs()[i]) + } + + }.frame(height: 30) + + .padding(.bottom, 10) + + } + + }.font(.system(size: 12)) + + } + + if getBCCs().count>0 { + /// the whole BCC section is displayed only when BCC emails exist + Divider() + VStack (alignment: .leading){ + + HStack (spacing: 20){ + + Text("BCC:") + .font(.subheadline) + .padding(.bottom, 8) + + ScrollView (.vertical){ + + ForEach(0..<getBCCs().count) { i in + Text(self.getBCCs()[i]) + } + + }.frame(height: 30) + .padding(.bottom, 10) + + }.font(.system(size: 12)) + + } + } + Divider() + DropDown() + Spacer() + + }.padding() + + /* if $showMemojiGallery.wrappedValue { + /* ZStack { + Color.black.opacity(0.4) + .edgesIgnoringSafeArea(.vertical) */ + VStack(spacing: 20) { + Text("Memoji Gallery") + .bold().padding() + .frame(maxWidth: .infinity) + .background(Color.blue) + .foregroundColor(Color.white) + Text("Choose a memoji from the gallery") + .padding() + .font(.subheadline) + MemojiDisplay() + Button(action: { + self.showMemojiGallery = false + }) { + Text("Apply") + }.padding() + } + .frame(width: 350, height: 250) + .background(Color.white) + .cornerRadius(20).shadow(radius: 20) + .offset(y: -110) + // } + + } */ + + Spacer() + + } + + + } + } + + private func selectNextLandmark() { + /// This method identifies and moves to the next selected landmark + if let selectedLandmark = selectedLandmark, let currentIndex = landmarks.firstIndex(where: { $0 == selectedLandmark }), currentIndex + 1 < landmarks.endIndex { + self.selectedLandmark = landmarks[currentIndex + 1] + } else { + selectedLandmark = landmarks.first + } + } + private func selectPrevLandmark() { + /// This method identifies and moves to the prevoius selected landmark + if let selectedLandmark = selectedLandmark, let currentIndex = landmarks.firstIndex(where: { $0 == selectedLandmark }), currentIndex + -1 >= 0 { + self.selectedLandmark = landmarks[currentIndex - 1] + } else { + selectedLandmark = landmarks.last + } + } +} + + + +// important TODO: add phishing elements +struct DropDown: View { + /// Displays the phishing details in a drop down window + @State private var clicked = false + var body: some View { + VStack (alignment: .leading, spacing: 20) { + + HStack(alignment: .top) { + Text("Phishing:") + .font(.subheadline) + + Button (action: { + self.clicked.toggle() + }) { + + Image(systemName: clicked ? "chevron.up" : "chevron.down") + } + } + + if clicked { + + HStack { + + Spacer() + .frame(width: 70) + + PhishingView() + .font(.system(size: 12)) + } + + + } + }.padding([.top, .bottom], 5) + } +} + + +struct WasAuchImmerOlliHierHabenWill: View{ + + /// new view where the Content View will be + + var body: some View{ + Text("coole neue seite") + } +} diff --git a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/MapView.swift b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/MapView.swift deleted file mode 100644 index bf632f12ab02cd0ac1ed373bd8c8e5c5d3f02e7b..0000000000000000000000000000000000000000 --- a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/MapView.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// MapView.swift -// enzevalos_iphone -// -// Created by Sabina on 16.03.20. -// Copyright © 2020 fu-berlin. All rights reserved. -// - -import SwiftUI -import MapKit - -struct MapView: UIViewRepresentable { - func makeUIView(context: Context) -> MKMapView { - MKMapView(frame: .zero) - } - - func updateUIView(_ uiView: MKMapView, context: Context) { - let coordinate = CLLocationCoordinate2D( - latitude: 52.5065116, longitude: 13.1438676) - let span = MKCoordinateSpan(latitudeDelta: 2.0, longitudeDelta: 2.0) - let region = MKCoordinateRegion(center: coordinate, span: span) - uiView.setRegion(region, animated: true) - } -} - -struct MapView_Previews: PreviewProvider { - static var previews: some View { - MapView() - } -} diff --git a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/PhishingView.swift b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/PhishingView.swift new file mode 100644 index 0000000000000000000000000000000000000000..6094a341256aed4852c73623f8f83db9d9158b5f --- /dev/null +++ b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/PhishingView.swift @@ -0,0 +1,72 @@ +// +// ContentView.swift +// enzevalos_iphone +// +// Created by Fatima on 19/03/2020. +// Copyright © 2020 fu-berlin. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <https://www.gnu.org/licenses/>. +// + +import SwiftUI + +/** + + The view displays Phishing information in a VStack and uses a list to present details. + + + */ + +struct AllPhishingContent: Identifiable { + let id: Int + let name: String + let message: String +} + +//not +struct PhishingView : View { + /// This content stores the phishing information in a list + var PhishingList = [ + AllPhishingContent(id: 0, name: "no declaration", message: "content empty"), + AllPhishingContent(id: 1, name: "no declaration", message: "content empty"), + AllPhishingContent(id: 2, name: "no declaration", message: "content empty"), + AllPhishingContent(id: 3, name: "no declaration", message: "content empty"), + ] + + var body: some View { + + List(PhishingList) { AllPhishingContent in + + VStack { + + Text("Identification").bold() + Text(AllPhishingContent.name) + Text(AllPhishingContent.message).italic() + + } + + } + + } + +} + + + +struct PhishingList_Previews: PreviewProvider { + static var previews: some View { + PhishingView() + } +} + diff --git a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/ProfileEmoji.swift b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/ProfileEmoji.swift deleted file mode 100644 index 3192fa32e5e53cc574502d245b2c89741eeb8957..0000000000000000000000000000000000000000 --- a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/ProfileEmoji.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// SwiftUIView.swift -// enzevalos_iphone -// -// Created by Fatima on 16/03/2020. -// Copyright © 2020 fu-berlin. All rights reserved. -// - -import SwiftUI -/* -struct ProfileEmoji: View { - var body: some View { - Image("profileEmoji") - .resizable() - .frame(width: 130.0, height: 110.0) - .clipShape(Circle()) - .overlay( - Circle().stroke(Color.white, lineWidth: 2)) - .shadow(radius: 8) - } -} - -struct ProfileEmoji_Previews: PreviewProvider { - static var previews: some View { - ProfileEmoji() - } -} - */ - diff --git a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/SenderDetails.swift b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/SenderDetails.swift new file mode 100644 index 0000000000000000000000000000000000000000..78d5a92ab5cadff9c06d1026d4ae831383b72d1d --- /dev/null +++ b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewChildren/SenderDetails.swift @@ -0,0 +1,84 @@ +// +// SenderDetails.swift +// enzevalos_iphone +// +// Created by Sabina on 22.03.20. +// Copyright © 2020 fu-berlin. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <https://www.gnu.org/licenses/>./ + +import SwiftUI + +/** + + SenderDetails contains information about the sender. + + They are wrapped in a VStack that has also HStack for showing textes below + + Those more details are message information. They can be displayed in a drop down window. + + Click on the arrow to see all details. + + */ + +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) + } + } + + if moreDetails { + + HStack { + + Spacer() + .frame(width: 40) + + VStack(alignment: .leading){ + Text("Last message received on:") + Text("Last message sent on:") + Text("Total number of messages sent:") + + } .font(.system(size: 10)) + + } + + } + } + } +} + +struct SenderDetails_Previews: PreviewProvider { + static var previews: some View { + SenderDetails() + } +} diff --git a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewMain.swift b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewMain.swift deleted file mode 100644 index 015dd2246855c9fa3ad057a9810f995ea6ced912..0000000000000000000000000000000000000000 --- a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewMain.swift +++ /dev/null @@ -1,192 +0,0 @@ -// -// SenderViewMain.swift -// enzevalos_iphone -// -// Created by fatimaaa96 on 12.03.20. -// Copyright © 2020 fu-berlin. All rights reserved. -// - - - -import SwiftUI - -//map, Memoji picture, sender information and phishing detail -struct SenderViewMain: View { - - - let mail:PersistentMail - - - var body: some View { - VStack { - ZStack { - MapView() - .frame(height: 250) - HStack (spacing: -5) { - Spacer() - .frame(width: 60) - // ProfileEmoji() - //.offset(y: 105) - .padding(.bottom, -270) - Button (action: { - print ("Edit activated") - }) { - - Text("Edit") - .font(.system(size: 9)) - - }.padding(.top, 190) - - }.offset(y: 60) - - - } - - Spacer() - - VStack(alignment: .leading) { - - Spacer() - .frame(height: 70) - - // TODO: add reference about sender information (additionally to be done: link update to data base ?!) - Text("Sender:") - .font(.subheadline) - .padding(.bottom, 5) - - MoreDetailsSender() - - Divider() - - VStack (alignment: .leading){ - - Text("CC:") - .font(.subheadline) - .padding(.bottom, 8) - - HStack (spacing: 20){ - - Text("Email 1") - Text("Email 2") - Text("Email 3") - - }.font(.system(size: 12)) - - }.padding([.top, .bottom], 5) - - Divider() - - VStack (alignment: .leading){ - - Text("BCC:") - .font(.subheadline) - .padding(.bottom, 8) - - HStack (spacing: 20){ - - Text("Email 1") - Text("Email 2") - Text("Email 3") - - }.font(.system(size: 12)) - - }.padding([.top, .bottom], 5) - - Divider() - - DropDown() - - Spacer() - - }.padding() - - Spacer() - - } - } -} - -/* -struct SenderViewMain_Previews: PreviewProvider { - static var previews: some View { - SenderViewMain() - } -} - */ - -struct MoreDetailsSender: View { - @State private var moreDetails = false - var body: some View { - VStack (alignment: .leading, spacing: 20) { - - HStack(alignment: .top) { - Text("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) - } - } - - if moreDetails { - - HStack { - - Spacer() - .frame(width: 40) - - VStack(alignment: .leading){ - Text("Last message received on:") - Text("Last message sent on:") - Text("Total number of messages sent:") - - } .font(.system(size: 10)) - - } - - } - } - } -} - -// important TODO: add phishing elements -struct DropDown: View { - @State private var clicked = false - var body: some View { - VStack (alignment: .leading, spacing: 20) { - - HStack(alignment: .top) { - Text("Phishing:") - .font(.subheadline) - - Button (action: { - self.clicked.toggle() - }) { - - Image(systemName: clicked ? "chevron.up" : "chevron.down") - } - } - - if clicked { - - HStack { - - Spacer() - .frame(width: 70) - - Text ("Here comes the text with phishing details.") //TODO: Add content for phishing details - .font(.system(size: 12)) - } - - - } - }.padding([.top, .bottom], 5) - } -} - diff --git a/enzevalos_iphone/SwiftUI/SupportingViews/MapView.swift b/enzevalos_iphone/SwiftUI/SupportingViews/MapView.swift new file mode 100644 index 0000000000000000000000000000000000000000..9ba4691389c1beeb60d4c0465e9dc3fe70f7cc8c --- /dev/null +++ b/enzevalos_iphone/SwiftUI/SupportingViews/MapView.swift @@ -0,0 +1,166 @@ +// +// MapView.swift +// enzevalos_iphone +// +// Created by Sabina on 16.03.20. +// Copyright © 2020 fu-berlin. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <https://www.gnu.org/licenses/>. +// + +import SwiftUI +import MapKit + +/** + + This file handles the configuration of the MapView from the SenderViewMain. + + */ + +final class LandmarkAnnotation: NSObject, MKAnnotation { + let id: String + let title: String? + let domainName: String? + let coordinate: CLLocationCoordinate2D + + init(landmark: Landmark) { + self.id = landmark.id + self.title = landmark.name + self.domainName = landmark.domain + self.coordinate = landmark.location + } +} + +struct MapView: UIViewRepresentable { + + @Binding var landmarks: [Landmark] /// all displayed landmaeeks are stored in an array of type Landmark + @Binding var selectedLandmark: Landmark? /// this variable stored the next landmark from the array which is selected/displayed + @Binding var showingLandmarkDetails: Bool /// this Boolean shows more details about the selected landmark + + + func makeUIView(context: Context) -> MKMapView { + /// configuration of the UIView + let map = MKMapView() + map.delegate = context.coordinator + return map + } + + func updateUIView(_ uiView: MKMapView, context: Context) { + /** + This function gets calles whenever the values being sent into the UIViewReprensentable have changed. + + When a new landmark is selected the updateAnnotation and the addPolyline functions are called again in order to update the annotations in the MapView and add a polyline between them. + */ + updateAnnotations(from: uiView) + addPolyline(from: uiView) + } + + func makeCoordinator() -> Coordinator { + Coordinator(self) + } + + final class Coordinator: NSObject, MKMapViewDelegate { + + var parent: MapView + + init(_ parent: MapView) { + self.parent = parent + } + + + func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) { + /// this method configures the zoom level when the next landmark/annotation is selcted + guard let coordinates = view.annotation?.coordinate else { return } + let span = mapView.region.span + let region = MKCoordinateRegion(center: coordinates, span: span) + mapView.setRegion(region, animated: true) + } + + func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { + /** + This method uses a custom view to representan annotation, reuses views for performance and has a button that can be tapped for more information. + */ + guard let annotation = annotation as? LandmarkAnnotation else { return nil } + let identifier = "Annotation" + var annotationView: MKMarkerAnnotationView? = mapView.dequeueReusableAnnotationView(withIdentifier: identifier) as? MKMarkerAnnotationView + if annotationView == nil { + annotationView = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: identifier) + annotationView?.canShowCallout = true + annotationView?.rightCalloutAccessoryView = UIButton(type: .detailDisclosure) + } else { + annotationView?.annotation = annotation + } + return annotationView + } + + func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) { + + /** + + This method gets called when the button for more details is tapped. + + It checks if there is a selected landmark and if so, it uses it to set the selected landmark porperty to the parent MapView with the help of the getLandMarkByCoordinates method. + + Also the showingLandmarkDetails is set to true, which will trigger the alert in the SenderViewMain. + + */ + + print(view.annotation) + guard let placemark = view.annotation as? LandmarkAnnotation?/*MKPointAnnotation?*/ else { print("failed conversion") ;return } + parent.selectedLandmark = getLandMarkByCoordinates(placemark!.coordinate) + parent.showingLandmarkDetails = true + } + + func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer { + /// This function creates and configures a polyline + let renderer = MKPolylineRenderer(overlay: overlay) + renderer.strokeColor = UIColor.orange + renderer.lineWidth = 3 + return renderer + } + + func getLandMarkByCoordinates(_ coords:CLLocationCoordinate2D)->Landmark{ + + func equals(_ lm1:CLLocationCoordinate2D,_ lm2:CLLocationCoordinate2D)->Bool{ + return lm1.latitude==lm2.latitude&&lm1.longitude==lm2.longitude + } + + let marks:[Landmark]=parent.landmarks + var i:Int=0 + while !equals(marks[i].location,coords) { + i+=1 + } + return marks[i] + } + + } + + private func updateAnnotations(from mapView: MKMapView) { + /// this method updates the displayed annotations in the MapView according to the selected landmark + mapView.removeAnnotations(mapView.annotations) + let newAnnotations = landmarks.map { LandmarkAnnotation(landmark: $0) } + mapView.addAnnotations(newAnnotations) + if let selectedAnnotation = newAnnotations.filter({ $0.id == selectedLandmark?.id }).first { + mapView.selectAnnotation(selectedAnnotation, animated: true) + } + } + + private func addPolyline(from mapView: MKMapView){ + /// this method adds a polyline between the landmarks in the MapView + var locations = landmarks.map { $0.location } + let polyline = MKPolyline (coordinates: &locations, count: locations.count) + mapView.addOverlay(polyline) + } + +}