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 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
disableMainThreadChecker = "YES"
codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
......@@ -92,6 +93,20 @@
BlueprintName = "enzevalos_iphoneUITests"
ReferencedContainer = "container:enzevalos_iphone.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "SwiftUIOnboardingUITests/testDetailLogin2()">
</Test>
<Test
Identifier = "SwiftUIOnboardingUITests/testDetailLogin5()">
</Test>
<Test
Identifier = "SwiftUIOnboardingUITests/testHappyPath2()">
</Test>
<Test
Identifier = "SwiftUIOnboardingUITests/testHappyPath5()">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
</TestAction>
......
......@@ -25,24 +25,21 @@ import SystemConfiguration
import QAKit
import GTMAppAuth
import UserNotifications
import SwiftUI
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var newOnboarding = true
var newOnboarding=true
var inboxCoordinator: InboxCoordinator? = nil
var window: UIWindow?
var contactStore = CNContactStore()
var mailHandler = MailHandler()
//var dataHandler = DataHandler.handler
var orientationLock = UIInterfaceOrientationMask.allButUpsideDown
var counterBackgroundFetch = 0
var start: Date = Date()
let showAlertNoConnection = false
var inboxCoordinator: InboxCoordinator? = nil
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
......@@ -64,7 +61,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
self.window = UIWindow(frame: UIScreen.main.bounds)
if (newOnboarding)
{self.window?.rootViewController = UIHostingController(rootView: AuthenticationScreen())}
{
let avm=AuthenticationViewModel(authenticationModel: AuthenticationModel())
self.window?.rootViewController = UIHostingController(rootView: NewOnboardingView().environmentObject(avm))}
else
{self.window?.rootViewController = Onboarding.onboarding()}
self.window?.makeKeyAndVisible()
......@@ -255,10 +254,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
class func getAppDelegate() -> AppDelegate {
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
fatalError("No AppDelegate!")
}
return appDelegate
return UIApplication.shared.delegate as! AppDelegate
}
......@@ -319,13 +315,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
self.requestForAccess(self.contactCheck)
}
func sceneDidEnterBackground(_ scene: UIScene) {
DataHandler.handler.saveContext()
}
func presentInboxViewController() {
//presentSwiftUITest()
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 @@
// AuthenticationModel.swift
// 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.
//
......@@ -68,6 +68,7 @@ class AuthenticationModel: NSObject {
func checkIMAPConfig(mailAccount: MailAccount, _ callback: AuthenticationCallback) {
imapConfigurationSuccessful = false
let mailSession: MailSession = setupIMAPSession(mailAccount: mailAccount, callback: callback)
print(mailSession.server.port)
currentIMAP = mailSession
if extendedValidation && mailSession.startTestingServerConfig(){
imapConfigurationSuccessful = true
......@@ -194,3 +195,4 @@ class AuthenticationCallback {
}
}
}
......@@ -106,43 +106,3 @@ struct AuthenticationScreen: View {
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 @@
// AuthenticationViewModel.swift
// 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.
//
import Foundation
import Combine
/**
ViewModel of the Authentication according to MVVP pattern. Uses AuthenticationModel to get the result of the authentication.
*/
class AuthenticationViewModel : ObservableObject {
@Published var errorMessage: String?
......@@ -105,3 +102,4 @@ class AuthenticationViewModel : ObservableObject {
errorMessage = NSLocalizedString(MailServerConnectionError.TimeoutError.localizedUIBodyString, comment: "")
}
}
This diff is collapsed.
......@@ -535,6 +535,7 @@ extension ContactViewController: UITableViewDataSource {
return cell
case 5 where isUser:
let badgeCell = tableView.dequeueReusableCell(withIdentifier: "BadgeCaseCell", for: indexPath)
badgeCell.textLabel?.text = NSLocalizedString("YourBadges", comment: "")
badgeCell.detailTextLabel?.text = NSLocalizedString("YourBadges", comment: "")
if StudySettings.hideBadges {
badgeCell.isHidden = false
......
......@@ -1025,6 +1025,14 @@ class DataHandler {
}
record.addToPersistentMails(mail)
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
if record.newestDate == nil, isInbox {
......
......@@ -164,4 +164,3 @@ extension Folder: Comparable {
return lhs.name == rhs.name && lhs.path == rhs.path
}
}
......@@ -85,13 +85,14 @@ class FolderViewController: UITableViewController {
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
navigationController?.isToolbarHidden = false
tableView.reloadData()
}
override func viewWillDisappear(_ animated: Bool){
navigationController?.isToolbarHidden = true
}
override func numberOfSections(in tableView: UITableView) -> Int {
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)
}
}
}
}
......@@ -34,6 +34,9 @@ extension KeyRecord {
@NSManaged public var persistentMails: NSSet?
@NSManaged public var newestDate: Date?
@NSManaged public var nick: String?
@NSManaged public var firstMail: PersistentMail?
@NSManaged public var secondMail: PersistentMail?
var activeKey: PersistentKey? {
......@@ -57,7 +60,6 @@ extension KeyRecord {
@objc(addPersistentMailsObject:)
@NSManaged public func addToPersistentMails(_ value: PersistentMail)
@objc(removePersistentMailsObject:)
@NSManaged public func removeFromPersistentMails(_ value: PersistentMail)
......@@ -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 {
override func viewWillAppear(_ animated: Bool) {
tableView.reloadData()
navigationController?.isToolbarHidden = false
}
override func viewWillDisappear(_ animated: Bool){
navigationController?.isToolbarHidden = true
}
override func viewDidLoad() {
......@@ -110,8 +105,6 @@ class ListViewController: UITableViewController {
tableView.reloadData()
}
deinit {
print("===============|| ListViewController deinitialized ||===============")
}
......
......@@ -12,7 +12,6 @@ class MailAccount {
let emailAddress: String
let password: String
// Username used for imap/smtp protocol. This can be different than emailAddress. Currently we do not support different usernames for imap and smtp
let username: String?
let imapServer: String
let imapPort: Int
......
......@@ -502,9 +502,6 @@ class MailSession {
static let AUTHTYPE = [MCOAuthType.saslPlain, MCOAuthType.saslLogin, MCOAuthType.SASLNTLM, MCOAuthType.saslKerberosV4, MCOAuthType.SASLCRAMMD5, MCOAuthType.SASLDIGESTMD5, MCOAuthType.SASLGSSAPI, MCOAuthType.SASLSRP, MCOAuthType.init(rawValue: 0)]
static let CONNTECTIONTYPE = [MCOConnectionType.TLS, MCOConnectionType.startTLS] // We do not test for plain connections!
static let dispatchQueue: DispatchQueue = DispatchQueue(label: "MailSessionQueue")
var defaultIMAPSession: MCOIMAPSession? {
get {
if let server = try? MailServer(userValues: sessionType, callback: callback) {
......@@ -646,7 +643,7 @@ class MailSession {
let (_, server) = MailSession.splitAddr(userAddr: self.mailAddr)
if let domain = server {
if self.sessionType == SessionType.IMAP {
createServers(domain: domain, prefixes: MailSession.IMAPPREFIX, ports: MailSession.IMAPPORT)
createServers(domain: domain, prefixes: MailSession.IMAPPREFIX, ports: [UInt32(111)])
}
else {
createServers(domain: domain, prefixes: MailSession.SMTPPREFIX, ports: MailSession.SMTPPORT)
......@@ -725,7 +722,6 @@ class MailSession {
}
private func readJson() -> [MCONetService] {
MailSession.dispatchQueue.sync {
var servers: [MCONetService] = []
let manager = MCOMailProvidersManager.shared()
if let path = Bundle.main.path(forResource: "providers", ofType: "json") {
......@@ -741,7 +737,6 @@ class MailSession {
}
return servers
}
}
var hasJsonFile: Bool {
get {
......
......@@ -2,9 +2,18 @@
// NewOnboardingView.swift
// enzevalos_iphone
//
// Created by melicoa97 on 02.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
......@@ -12,7 +21,10 @@ struct NewOnboardingView: View {
@ObservedObject var press=loginManager()
var body: some View {
if press.loggedIn{
return AnyView(VCSwiftUIView(vcID: "RootViewController"))
return AnyView(
VCSwiftUIView(storyboard: "Main", vcID: "RootViewController")
//AuthenticationScreen()
)
}else{
return AnyView(
OnboardingIntro(onClick: press.login)
......
......@@ -27,7 +27,7 @@ class Onboarding: NSObject {
super.init()
}
static var textDelegate = TextFieldDelegate.init()
static let defaultColor = UIColor.red
static let defaultColor = UIColor.darkGray
static let textColor = UIColor.white
static var mailaddress = UITextField.init()
static var username = UITextField.init()
......@@ -77,13 +77,7 @@ class Onboarding: NSObject {
private static var currentIMAP: MailSession?
private static var currentSMTP: MailSession?
static func onboarding(_ errorCode: MailServerConnectionError? = nil) -> UIViewController {
password.isSecureTextEntry = true
doWhenDone = checkIMAPConfig
startTimeView = Date()
......
......@@ -2,42 +2,155 @@
// OnboardingIntro.swift
// enzevalos_iphone
//
// Created by melicoa97 on 03.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/>.
var buttonheight:CGFloat=60
import SwiftUI
//Main Onboarding
struct OnboardingIntro: View {
var onClick: ()->Void
@State var setupView: Bool = false
@ViewBuilder
var body: some View {
VStack(alignment: .center){