Commit eb9f2fed authored by wieseoli's avatar wieseoli

Merge branch 'onboardingScreens_swiftUI_merge_Dev' into 'dev'

Onboarding screens swift ui merge dev

See merge request !59
parents b631329b 7b34ea1b
This diff is collapsed.
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES" shouldUseLaunchSchemeArgsEnv = "YES"
disableMainThreadChecker = "YES"
codeCoverageEnabled = "YES"> codeCoverageEnabled = "YES">
<MacroExpansion> <MacroExpansion>
<BuildableReference <BuildableReference
...@@ -92,6 +93,20 @@ ...@@ -92,6 +93,20 @@
BlueprintName = "enzevalos_iphoneUITests" BlueprintName = "enzevalos_iphoneUITests"
ReferencedContainer = "container:enzevalos_iphone.xcodeproj"> ReferencedContainer = "container:enzevalos_iphone.xcodeproj">
</BuildableReference> </BuildableReference>
<SkippedTests>
<Test
Identifier = "SwiftUIOnboardingUITests/testDetailLogin2()">
</Test>
<Test
Identifier = "SwiftUIOnboardingUITests/testDetailLogin5()">
</Test>
<Test
Identifier = "SwiftUIOnboardingUITests/testHappyPath2()">
</Test>
<Test
Identifier = "SwiftUIOnboardingUITests/testHappyPath5()">
</Test>
</SkippedTests>
</TestableReference> </TestableReference>
</Testables> </Testables>
</TestAction> </TestAction>
......
...@@ -25,24 +25,21 @@ import SystemConfiguration ...@@ -25,24 +25,21 @@ import SystemConfiguration
import QAKit import QAKit
import GTMAppAuth import GTMAppAuth
import UserNotifications import UserNotifications
import SwiftUI
@UIApplicationMain @UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate { class AppDelegate: UIResponder, UIApplicationDelegate {
var newOnboarding = true var newOnboarding=true
var inboxCoordinator: InboxCoordinator? = nil
var window: UIWindow? var window: UIWindow?
var contactStore = CNContactStore() var contactStore = CNContactStore()
var mailHandler = MailHandler() var mailHandler = MailHandler()
//var dataHandler = DataHandler.handler
var orientationLock = UIInterfaceOrientationMask.allButUpsideDown var orientationLock = UIInterfaceOrientationMask.allButUpsideDown
var counterBackgroundFetch = 0 var counterBackgroundFetch = 0
var start: Date = Date() var start: Date = Date()
let showAlertNoConnection = false let showAlertNoConnection = false
var inboxCoordinator: InboxCoordinator? = nil
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
...@@ -64,7 +61,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -64,7 +61,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
self.window = UIWindow(frame: UIScreen.main.bounds) self.window = UIWindow(frame: UIScreen.main.bounds)
if (newOnboarding) if (newOnboarding)
{self.window?.rootViewController = UIHostingController(rootView: AuthenticationScreen())} {
let avm=AuthenticationViewModel(authenticationModel: AuthenticationModel())
self.window?.rootViewController = UIHostingController(rootView: NewOnboardingView().environmentObject(avm))}
else else
{self.window?.rootViewController = Onboarding.onboarding()} {self.window?.rootViewController = Onboarding.onboarding()}
self.window?.makeKeyAndVisible() self.window?.makeKeyAndVisible()
...@@ -255,10 +254,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -255,10 +254,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
class func getAppDelegate() -> AppDelegate { class func getAppDelegate() -> AppDelegate {
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return UIApplication.shared.delegate as! AppDelegate
fatalError("No AppDelegate!")
}
return appDelegate
} }
...@@ -318,14 +314,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -318,14 +314,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func requestForAccess() { func requestForAccess() {
self.requestForAccess(self.contactCheck) self.requestForAccess(self.contactCheck)
} }
func sceneDidEnterBackground(_ scene: UIScene) {
DataHandler.handler.saveContext()
}
func presentInboxViewController() { func presentInboxViewController() {
//presentSwiftUITest() //presentSwiftUITest()
guard let vc = self.window?.rootViewController as? UINavigationController else { guard let vc = self.window?.rootViewController as? UINavigationController else {
......
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "usericon.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "gluecklich.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "1024px-Google_\"G\"_Logo.svg.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "stornieren.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "schild.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "image.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// AuthenticationModel.swift // AuthenticationModel.swift
// enzevalos_iphone // enzevalos_iphone
// //
// Created by SWP Usable Security für Smartphones on 10.03.20. // Created by hanneh00 on 18.03.20.
// Copyright © 2020 fu-berlin. All rights reserved. // Copyright © 2020 fu-berlin. All rights reserved.
// //
...@@ -68,6 +68,7 @@ class AuthenticationModel: NSObject { ...@@ -68,6 +68,7 @@ class AuthenticationModel: NSObject {
func checkIMAPConfig(mailAccount: MailAccount, _ callback: AuthenticationCallback) { func checkIMAPConfig(mailAccount: MailAccount, _ callback: AuthenticationCallback) {
imapConfigurationSuccessful = false imapConfigurationSuccessful = false
let mailSession: MailSession = setupIMAPSession(mailAccount: mailAccount, callback: callback) let mailSession: MailSession = setupIMAPSession(mailAccount: mailAccount, callback: callback)
print(mailSession.server.port)
currentIMAP = mailSession currentIMAP = mailSession
if extendedValidation && mailSession.startTestingServerConfig(){ if extendedValidation && mailSession.startTestingServerConfig(){
imapConfigurationSuccessful = true imapConfigurationSuccessful = true
...@@ -194,3 +195,4 @@ class AuthenticationCallback { ...@@ -194,3 +195,4 @@ class AuthenticationCallback {
} }
} }
} }
...@@ -106,43 +106,3 @@ struct AuthenticationScreen: View { ...@@ -106,43 +106,3 @@ struct AuthenticationScreen: View {
return (self.viewModel.errorMessage != nil) && (!self.viewModel.errorMessage!.isEmpty) return (self.viewModel.errorMessage != nil) && (!self.viewModel.errorMessage!.isEmpty)
} }
} }
struct ActivityIndicator: UIViewRepresentable {
@Binding var isAnimating: Bool
let style: UIActivityIndicatorView.Style
func makeUIView(context: UIViewRepresentableContext<ActivityIndicator>) -> UIActivityIndicatorView {
return UIActivityIndicatorView(style: style)
}
func updateUIView(_ uiView: UIActivityIndicatorView, context: UIViewRepresentableContext<ActivityIndicator>) {
isAnimating ? uiView.startAnimating() : uiView.stopAnimating()
}
}
struct LoadingView<Content>: View where Content: View {
@Binding var isShowing: Bool
var content: () -> Content
var body: some View {
ZStack(alignment: .center) {
self.content()
.disabled(self.isShowing)
.blur(radius: self.isShowing ? 3 : 0)
VStack {
Text("Loading...")
ActivityIndicator(isAnimating: .constant(true), style: .large)
}
.frame(width: UIScreen.main.bounds.size.width / 2,
height: UIScreen.main.bounds.size.height / 5)
.background(Color.secondary.colorInvert())
.foregroundColor(Color.primary)
.cornerRadius(20)
.opacity(self.isShowing ? 1 : 0)
}
}
}
This diff is collapsed.
...@@ -2,16 +2,13 @@ ...@@ -2,16 +2,13 @@
// AuthenticationViewModel.swift // AuthenticationViewModel.swift
// enzevalos_iphone // enzevalos_iphone
// //
// Created by SWP Usable Security für Smartphones on 02.03.20. // Created by Cezary Pilaszewicz on 02.03.20.
// Copyright © 2020 fu-berlin. All rights reserved. // Copyright © 2020 fu-berlin. All rights reserved.
// //
import Foundation import Foundation
import Combine import Combine
/**
ViewModel of the Authentication according to MVVP pattern. Uses AuthenticationModel to get the result of the authentication.
*/
class AuthenticationViewModel : ObservableObject { class AuthenticationViewModel : ObservableObject {
@Published var errorMessage: String? @Published var errorMessage: String?
...@@ -105,3 +102,4 @@ class AuthenticationViewModel : ObservableObject { ...@@ -105,3 +102,4 @@ class AuthenticationViewModel : ObservableObject {
errorMessage = NSLocalizedString(MailServerConnectionError.TimeoutError.localizedUIBodyString, comment: "") errorMessage = NSLocalizedString(MailServerConnectionError.TimeoutError.localizedUIBodyString, comment: "")
} }
} }
This diff is collapsed.
...@@ -535,6 +535,7 @@ extension ContactViewController: UITableViewDataSource { ...@@ -535,6 +535,7 @@ extension ContactViewController: UITableViewDataSource {
return cell return cell
case 5 where isUser: case 5 where isUser:
let badgeCell = tableView.dequeueReusableCell(withIdentifier: "BadgeCaseCell", for: indexPath) let badgeCell = tableView.dequeueReusableCell(withIdentifier: "BadgeCaseCell", for: indexPath)
badgeCell.textLabel?.text = NSLocalizedString("YourBadges", comment: "")
badgeCell.detailTextLabel?.text = NSLocalizedString("YourBadges", comment: "") badgeCell.detailTextLabel?.text = NSLocalizedString("YourBadges", comment: "")
if StudySettings.hideBadges { if StudySettings.hideBadges {
badgeCell.isHidden = false badgeCell.isHidden = false
......
...@@ -1025,6 +1025,14 @@ class DataHandler { ...@@ -1025,6 +1025,14 @@ class DataHandler {
} }
record.addToPersistentMails(mail) record.addToPersistentMails(mail)
mail.folder.addToKeyRecords(record) mail.folder.addToKeyRecords(record)
if record.firstMail == nil {
record.firstMail = mail
} else if let first = record.firstMail, mail < first {
record.firstMail = mail
record.secondMail = first
} else if let second = record.secondMail, mail < second {
record.secondMail = mail
}
let isInbox = mail.folder.path == Folder.inbox.path let isInbox = mail.folder.path == Folder.inbox.path
if record.newestDate == nil, isInbox { if record.newestDate == nil, isInbox {
......
...@@ -164,4 +164,3 @@ extension Folder: Comparable { ...@@ -164,4 +164,3 @@ extension Folder: Comparable {
return lhs.name == rhs.name && lhs.path == rhs.path return lhs.name == rhs.name && lhs.path == rhs.path
} }
} }
...@@ -85,13 +85,14 @@ class FolderViewController: UITableViewController { ...@@ -85,13 +85,14 @@ class FolderViewController: UITableViewController {
} }
override func viewDidAppear(_ animated: Bool) { override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated) super.viewDidAppear(animated)
navigationController?.isToolbarHidden = false
tableView.reloadData() tableView.reloadData()
} }
override func viewWillDisappear(_ animated: Bool){ override func viewWillDisappear(_ animated: Bool){
navigationController?.isToolbarHidden = true navigationController?.isToolbarHidden = true
} }
override func numberOfSections(in tableView: UITableView) -> Int { override func numberOfSections(in tableView: UITableView) -> Int {
var count = 0 var count = 0
......
//
// GeometryGetter.swift
// enzevalos_iphone
//
// Created by melicoa97 on 05.03.20.
// Copyright © 2020 fu-berlin. All rights reserved.
//
import SwiftUI
struct GeometryGetter: View {
@Binding var rect: CGRect
var body: some View {
GeometryReader { geometry in
Group { () -> AnyView in
DispatchQueue.main.async {
self.rect = geometry.frame(in: .global)
}
return AnyView(Color.clear)
}
}
}
}
...@@ -30,7 +30,7 @@ import SwiftUI ...@@ -30,7 +30,7 @@ import SwiftUI
One person can have multiple key records, e.g. one with key, one without a key or multiple keys. One person can have multiple key records, e.g. one with key, one without a key or multiple keys.
*/ */
@objc(KeyRecord) @objc(KeyRecord)
public class KeyRecord: NSManagedObject, Record, Identifiable { public class KeyRecord: NSManagedObject, Record, Identifiable {
public var isUser: Bool { public var isUser: Bool {
get{ get{
/** /**
...@@ -134,7 +134,7 @@ public class KeyRecord: NSManagedObject, Record, Identifiable { ...@@ -134,7 +134,7 @@ public class KeyRecord: NSManagedObject, Record, Identifiable {
} }
} }
} }
return false return false
} }
public var cryptoscheme: CryptoScheme { public var cryptoscheme: CryptoScheme {
......
...@@ -34,6 +34,9 @@ extension KeyRecord { ...@@ -34,6 +34,9 @@ extension KeyRecord {
@NSManaged public var persistentMails: NSSet? @NSManaged public var persistentMails: NSSet?
@NSManaged public var newestDate: Date? @NSManaged public var newestDate: Date?
@NSManaged public var nick: String? @NSManaged public var nick: String?
@NSManaged public var firstMail: PersistentMail?
@NSManaged public var secondMail: PersistentMail?
var activeKey: PersistentKey? { var activeKey: PersistentKey? {
...@@ -49,7 +52,7 @@ extension KeyRecord { ...@@ -49,7 +52,7 @@ extension KeyRecord {
} }
} }
} }
} }
// MARK: Generated accessors for persitentMails // MARK: Generated accessors for persitentMails
...@@ -57,7 +60,6 @@ extension KeyRecord { ...@@ -57,7 +60,6 @@ extension KeyRecord {
@objc(addPersistentMailsObject:) @objc(addPersistentMailsObject:)
@NSManaged public func addToPersistentMails(_ value: PersistentMail) @NSManaged public func addToPersistentMails(_ value: PersistentMail)
@objc(removePersistentMailsObject:) @objc(removePersistentMailsObject:)
@NSManaged public func removeFromPersistentMails(_ value: PersistentMail) @NSManaged public func removeFromPersistentMails(_ value: PersistentMail)
...@@ -91,4 +93,20 @@ extension KeyRecord { ...@@ -91,4 +93,20 @@ extension KeyRecord {
} }
} }
extension KeyRecord{
static func findFirstMails(){
let allRecord = DataHandler.handler.getAllKeyRecords()
for rec in allRecord {
if rec.firstMail == nil {
rec.firstMail = rec.mails.first
}
if rec.secondMail == nil && rec.mails.count > 1 {
rec.secondMail = rec.mails[1]
}
if rec.firstMail == nil {
print("Empty record: \(rec.name)")
}
}
DataHandler.handler.save(during: "Fix first mails")
}
}
...@@ -74,11 +74,6 @@ class ListViewController: UITableViewController { ...@@ -74,11 +74,6 @@ class ListViewController: UITableViewController {
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
tableView.reloadData() tableView.reloadData()
navigationController?