Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
enzevalos_iphone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
enzevalos
enzevalos_iphone
Commits
eab857f8
Commit
eab857f8
authored
5 years ago
by
freij89
Browse files
Options
Downloads
Patches
Plain Diff
resolve MR comments
parent
4724a94b
Branches
Branches containing commit
Tags
Tags containing commit
4 merge requests
!58
Onboarding screens swift ui merge dev
,
!55
WIP: Resolve "UI for gamifcation & stats"
,
!47
Provisional fix for OpenSSL 1.1+, needs testing
,
!34
Resolve "Extract Authentication from current Onboarding"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
enzevalos_iphone/AuthenticationScreen.swift
+64
-62
64 additions, 62 deletions
enzevalos_iphone/AuthenticationScreen.swift
enzevalos_iphone/AuthenticationViewModel.swift
+5
-11
5 additions, 11 deletions
enzevalos_iphone/AuthenticationViewModel.swift
with
69 additions
and
73 deletions
enzevalos_iphone/AuthenticationScreen.swift
+
64
−
62
View file @
eab857f8
...
@@ -18,81 +18,83 @@ struct AuthenticationScreen: View {
...
@@ -18,81 +18,83 @@ struct AuthenticationScreen: View {
@State
private
var
smtpPort
:
String
=
""
@State
private
var
smtpPort
:
String
=
""
@State
private
var
imapEncryption
=
0
@State
private
var
imapEncryption
=
0
@State
private
var
smtpEncryption
=
0
@State
private
var
smtpEncryption
=
0
@ObservedObject
private
var
viewModel
=
AuthenticationViewModel
()
@ObservedObject
private
var
viewModel
=
AuthenticationViewModel
()
var
encryptionOptions
=
[
"Plaintext"
,
"StartTLS"
,
"TLS/SSL"
]
var
encryptionOptions
=
[
"Plaintext"
,
"StartTLS"
,
"TLS/SSL"
]
var
body
:
some
View
{
var
body
:
some
View
{
ZStack
{
ScrollView
{
Color
.
white
.
edgesIgnoringSafeArea
(
.
all
)
ZStack
{
Color
.
white
.
edgesIgnoringSafeArea
(
.
all
)
VStack
{
Text
(
"Please enter Your credentials"
)
.
padding
()
.
foregroundColor
(
Color
.
yellow
)
Text
(
"Login"
)
TextField
(
"Please enter your login"
,
text
:
$login
)
.
textFieldStyle
(
RoundedBorderTextFieldStyle
())
Text
(
"Password"
)
SecureField
(
"Please enter your password"
,
text
:
$password
)
.
textFieldStyle
(
RoundedBorderTextFieldStyle
())
HStack
{
VStack
{
Toggle
(
isOn
:
self
.
$viewModel
.
isDetailedAuthentication
)
{
Text
(
"Please enter Your credentials"
)
.
padding
()
.
foregroundColor
(
Color
.
yellow
)
Text
(
"Advanced options"
)
Text
(
"Login"
)
}
TextField
(
"Please enter your login"
,
text
:
$login
)
.
textFieldStyle
(
RoundedBorderTextFieldStyle
())
Spacer
()
Text
(
"Password"
)
Button
(
action
:
{
self
.
viewModel
.
isDetailedAuthentication
?
SecureField
(
"Please enter your password"
,
text
:
$password
)
.
textFieldStyle
(
RoundedBorderTextFieldStyle
())
self
.
viewModel
.
validate
(
self
.
login
,
self
.
password
,
self
.
username
,
self
.
imapServer
,
self
.
imapPort
,
self
.
imapEncryption
,
self
.
smtpServer
,
self
.
smtpPort
,
self
.
smtpEncryption
)
:
self
.
viewModel
.
validate
(
self
.
login
,
self
.
password
)
})
{
Text
(
"Button"
)
}
}
if
self
.
viewModel
.
isDetailedAuthentication
{
Text
(
"Username"
)
TextField
(
"Please enter your nickname"
,
text
:
$username
)
.
textFieldStyle
(
RoundedBorderTextFieldStyle
())
HStack
{
Text
(
"Imap server"
)
TextField
(
"e.g. imap.web.de"
,
text
:
$imapServer
)
}
HStack
{
HStack
{
Text
(
"Imap port"
)
Toggle
(
isOn
:
self
.
$viewModel
.
isDetailedAuthentication
)
{
TextField
(
"e.g. 993"
,
text
:
$imapPort
)
.
keyboardType
(
.
numberPad
)
Text
(
"Advanced options"
)
}
}
Picker
(
selection
:
$imapEncryption
,
label
:
Text
(
"IMAP-Transportencryption"
))
{
Spacer
()
ForEach
(
0
..<
encryptionOptions
.
count
)
{
Button
(
action
:
{
self
.
viewModel
.
isDetailedAuthentication
?
Text
(
self
.
encryptionOptions
[
$0
])
self
.
viewModel
.
validate
(
self
.
login
,
self
.
password
,
self
.
username
,
self
.
imapServer
,
self
.
imapPort
,
self
.
imapEncryption
,
self
.
smtpServer
,
self
.
smtpPort
,
self
.
smtpEncryption
)
:
self
.
viewModel
.
validate
(
self
.
login
,
self
.
password
)
})
{
Text
(
"Login"
)
}
}
}
}
HStack
{
Text
(
"Smtp server"
)
if
self
.
viewModel
.
isDetailedAuthentication
{
TextField
(
"e.g. smtp.web.de"
,
text
:
$smtpServer
)
Text
(
"Username"
)
TextField
(
"Please enter your username"
,
text
:
$username
)
.
textFieldStyle
(
RoundedBorderTextFieldStyle
())
HStack
{
Text
(
"Imap server"
)
TextField
(
"e.g. imap.web.de"
,
text
:
$imapServer
)
}
HStack
{
Text
(
"Imap port"
)
TextField
(
"e.g. 993"
,
text
:
$imapPort
)
.
keyboardType
(
.
numberPad
)
}
Picker
(
selection
:
$imapEncryption
,
label
:
Text
(
"IMAP-Transportencryption"
))
{
ForEach
(
0
..<
encryptionOptions
.
count
)
{
Text
(
self
.
encryptionOptions
[
$0
])
}
}
HStack
{
Text
(
"Smtp server"
)
TextField
(
"e.g. smtp.web.de"
,
text
:
$smtpServer
)
}
HStack
{
Text
(
"Smtp port"
)
TextField
(
"e.g. 587"
,
text
:
$smtpPort
)
.
keyboardType
(
.
numberPad
)
}
Picker
(
selection
:
$smtpEncryption
,
label
:
Text
(
"SMTP-Transportencryption"
))
{
ForEach
(
0
..<
encryptionOptions
.
count
)
{
Text
(
self
.
encryptionOptions
[
$0
])
}
}
}
}
HStack
{
Text
(
"Smtp port"
)
Button
(
action
:
{
self
.
viewModel
.
oauth
()
})
{
Text
Field
(
"e.g. 587"
,
text
:
$smtpPort
)
.
keyboardType
(
.
numberPad
)
Text
(
"Google login"
)
}
}
}
.
padding
()
Picker
(
selection
:
$smtpEncryption
,
label
:
Text
(
"SMTP-Transportencryption"
))
{
//TODO: once SWIFTUI supports optionals improve this if statement
ForEach
(
0
..<
encryptionOptions
.
count
)
{
if
self
.
viewModel
.
errorMessage
!=
nil
&&
!
self
.
viewModel
.
errorMessage
!.
isEmpty
{
Text
(
self
.
encryptionOptions
[
$0
])
VStack
{
}
Text
(
self
.
viewModel
.
errorMessage
!
)
.
foregroundColor
(
Color
.
white
)
.
background
(
Color
.
red
)
Spacer
()
}
}
}
}
Button
(
action
:
{
self
.
viewModel
.
oauth
()
})
{
Text
(
"Google button"
)
}
}
.
padding
()
//TODO: once SWIFTUI supports optionals improve this if statement
if
self
.
viewModel
.
errorMessage
!=
nil
&&
!
self
.
viewModel
.
errorMessage
!.
isEmpty
{
VStack
{
Text
(
self
.
viewModel
.
errorMessage
!
)
.
foregroundColor
(
Color
.
white
)
.
background
(
Color
.
red
)
Spacer
()
}
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
enzevalos_iphone/AuthenticationViewModel.swift
+
5
−
11
View file @
eab857f8
...
@@ -18,11 +18,11 @@ class AuthenticationViewModel : ObservableObject {
...
@@ -18,11 +18,11 @@ class AuthenticationViewModel : ObservableObject {
var
login
:
String
=
""
var
login
:
String
=
""
@Published
var
imapServer
:
String
=
"imap.
web.de
"
@Published
var
imapServer
:
String
=
"imap.
example.com
"
@Published
var
imapPort
:
String
=
String
(
DEFAULT_IMAP_PORT
)
@Published
var
imapPort
:
String
=
String
(
DEFAULT_IMAP_PORT
)
@Published
var
imapTransportEncryption
=
2
@Published
var
imapTransportEncryption
=
2
@Published
var
smtpServer
:
String
=
"smtp.
web.de
"
@Published
var
smtpServer
:
String
=
"smtp.
example.com
"
@Published
var
smtpPort
:
String
=
String
(
DEFAULT_SMTP_PORT
)
@Published
var
smtpPort
:
String
=
String
(
DEFAULT_SMTP_PORT
)
@Published
var
smtpTransportEncryption
=
1
@Published
var
smtpTransportEncryption
=
1
...
@@ -30,7 +30,7 @@ class AuthenticationViewModel : ObservableObject {
...
@@ -30,7 +30,7 @@ class AuthenticationViewModel : ObservableObject {
var
imapConfigurationSuccessful
=
false
var
imapConfigurationSuccessful
=
false
var
smtpConfigurationSuccessful
=
false
var
smtpConfigurationSuccessful
=
false
var
startTimeIMAPCheck
:
Date
?
//TODO What about SMTP?
var
startTimeIMAPCheck
:
Date
?
var
startTimeView
=
Date
()
var
startTimeView
=
Date
()
var
transportRows
:
[
Int
:
String
]
=
[
MCOConnectionType
.
clear
.
rawValue
:
NSLocalizedString
(
"Plaintext"
,
comment
:
""
),
MCOConnectionType
.
startTLS
.
rawValue
:
"StartTLS"
,
MCOConnectionType
.
TLS
.
rawValue
:
"TLS/SSL"
]
var
transportRows
:
[
Int
:
String
]
=
[
MCOConnectionType
.
clear
.
rawValue
:
NSLocalizedString
(
"Plaintext"
,
comment
:
""
),
MCOConnectionType
.
startTLS
.
rawValue
:
"StartTLS"
,
MCOConnectionType
.
TLS
.
rawValue
:
"TLS/SSL"
]
...
@@ -52,7 +52,7 @@ class AuthenticationViewModel : ObservableObject {
...
@@ -52,7 +52,7 @@ class AuthenticationViewModel : ObservableObject {
self
.
smtpServer
=
smtpServer
self
.
smtpServer
=
smtpServer
self
.
smtpPort
=
smtpPort
self
.
smtpPort
=
smtpPort
self
.
smtpTransportEncryption
=
smtpEncryption
self
.
smtpTransportEncryption
=
smtpEncryption
checkDetailConfig
(
imap
:
true
,
login
,
password
,
username
:
"rtes"
,
imapServer
,
Int
(
imapPort
)
!
,
imapEncryption
,
smtpServer
,
Int
(
smtpPort
)
!
,
smtpEncryption
)
checkDetailConfig
(
imap
:
true
,
login
,
password
,
username
:
username
,
imapServer
,
Int
(
imapPort
)
!
,
imapEncryption
,
smtpServer
,
Int
(
smtpPort
)
!
,
smtpEncryption
)
}
}
func
checkIMAPConfig
(
_
login
:
String
,
_
password
:
String
)
{
func
checkIMAPConfig
(
_
login
:
String
,
_
password
:
String
)
{
...
@@ -111,7 +111,6 @@ class AuthenticationViewModel : ObservableObject {
...
@@ -111,7 +111,6 @@ class AuthenticationViewModel : ObservableObject {
print
(
"No view controller!"
)
print
(
"No view controller!"
)
return
return
}
}
// TODO guard: Internet connection?
Logger
.
log
(
onboardingState
:
.
GoogleLogIn
,
duration
:
0
)
Logger
.
log
(
onboardingState
:
.
GoogleLogIn
,
duration
:
0
)
EmailHelper
.
singleton
()
.
doEmailLoginIfRequired
(
onVC
:
vc
,
completionBlock
:
{
EmailHelper
.
singleton
()
.
doEmailLoginIfRequired
(
onVC
:
vc
,
completionBlock
:
{
...
@@ -171,12 +170,7 @@ class AuthenticationViewModel : ObservableObject {
...
@@ -171,12 +170,7 @@ class AuthenticationViewModel : ObservableObject {
let
imapSession
=
setupIMAPSession
(
login
,
password
)
let
imapSession
=
setupIMAPSession
(
login
,
password
)
let
smtpSession
=
setupSMTPSession
(
login
,
password
)
let
smtpSession
=
setupSMTPSession
(
login
,
password
)
var
name
=
login
if
let
n
=
username
{
name
=
n
}
let
imapConnValue
=
1
<<
imapEncryption
let
imapConnValue
=
1
<<
imapEncryption
let
smtpConnValue
=
1
<<
smtpEncryption
let
smtpConnValue
=
1
<<
smtpEncryption
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment