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
e8599065
Commit
e8599065
authored
5 years ago
by
Oliver Wiese
Browse files
Options
Downloads
Patches
Plain Diff
new SenderView in ReadView
parent
af53453b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
enzevalos_iphone/SwiftUI/Read/ReadViewModel.swift
+111
-0
111 additions, 0 deletions
enzevalos_iphone/SwiftUI/Read/ReadViewModel.swift
enzevalos_iphone/SwiftUI/Read/SenderViewMain.swift
+14
-117
14 additions, 117 deletions
enzevalos_iphone/SwiftUI/Read/SenderViewMain.swift
with
125 additions
and
117 deletions
enzevalos_iphone/SwiftUI/Read/ReadViewModel.swift
+
111
−
0
View file @
e8599065
...
@@ -9,6 +9,16 @@
...
@@ -9,6 +9,16 @@
import
Foundation
import
Foundation
import
SwiftUI
import
SwiftUI
let
alice
=
PseudoContact
(
name
:
"Alice"
,
addr
:
"alice@example.com"
,
myImage
:
PseudoContact
.
makeImg
(
"Alice"
,
color
:
.
blue
))
let
bob
=
PseudoContact
(
name
:
"Bob"
,
addr
:
"Bob.lord.of.kingsbridge.and.king.of.england@huge.subdomain.with. a.long.long.long.domain.example.com"
,
myImage
:
PseudoContact
.
makeImg
(
"Bob"
,
color
:
.
red
))
let
charlie
=
PseudoContact
(
name
:
"Charlie"
,
addr
:
"charlie@example.com"
,
myImage
:
PseudoContact
.
makeImg
(
"Charlie"
,
color
:
.
green
))
let
landmarks
=
[
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
))
]
let
mail
=
PseuoMail
(
sender
:
alice
,
tos
:
[
bob
,
charlie
],
ccs
:
[
bob
,
charlie
,
bob
,
charlie
,
bob
],
bccs
:
[],
routingStops
:
landmarks
,
signedState
:
.
ValidSignature
,
encState
:
.
ValidedEncryptedWithCurrentKey
)
protocol
DisplayContact
{
protocol
DisplayContact
{
// General
// General
var
name
:
String
{
get
}
var
name
:
String
{
get
}
...
@@ -69,3 +79,104 @@ class ReadViewModel: ObservableObject {
...
@@ -69,3 +79,104 @@ class ReadViewModel: ObservableObject {
}
}
struct
PseudoContact
:
DisplayContact
{
var
previousMails
:
Int
=
10
var
previousResponses
:
Int
=
2
var
name
:
String
var
addr
:
String
var
myImage
:
Image
var
isInContactBook
:
Bool
=
false
var
otherAddresses
:
[
String
]
=
[]
var
keys
:
[
String
]
=
[]
var
hasPreviousMails
:
Bool
=
false
var
hasSimilarContacts
:
Bool
=
false
var
similarContacts
:
[
String
]
=
[]
public
static
func
makeImg
(
_
name
:
String
,
color
:
UIColor
)
->
Image
{
var
text
:
NSAttributedString
var
tag
=
String
()
if
name
.
count
>
0
{
let
seperated
=
name
.
components
(
separatedBy
:
" "
)
tag
=
seperated
.
map
({
if
let
a
=
$0
.
first
{
return
"
\(
a
)
"
};
return
""
})
.
joined
()
}
text
=
NSAttributedString
(
string
:
tag
.
uppercased
(),
attributes
:
[
NSAttributedString
.
Key
.
foregroundColor
:
UIColor
.
white
,
NSAttributedString
.
Key
.
font
:
UIFont
.
systemFont
(
ofSize
:
32.2
)])
var
myBounds
=
CGRect
()
myBounds
.
size
.
width
=
70
myBounds
.
size
.
height
=
70
UIGraphicsBeginImageContextWithOptions
(
myBounds
.
size
,
false
,
2
)
//try 200 here
let
context
=
UIGraphicsGetCurrentContext
()
//
// Clip context to a circle
//
let
path
=
CGPath
(
ellipseIn
:
myBounds
,
transform
:
nil
);
context
!.
addPath
(
path
);
context
!.
clip
();
//
// Fill background of context
//
context
!.
setFillColor
(
color
.
cgColor
)
context
!.
fill
(
CGRect
(
x
:
0
,
y
:
0
,
width
:
myBounds
.
size
.
width
,
height
:
myBounds
.
size
.
height
));
//
// Draw text in the context
//
let
textSize
=
text
.
size
()
text
.
draw
(
in
:
CGRect
(
x
:
myBounds
.
size
.
width
/
2
-
textSize
.
width
/
2
,
y
:
myBounds
.
size
.
height
/
2
-
textSize
.
height
/
2
,
width
:
textSize
.
width
,
height
:
textSize
.
height
))
let
snapshot
=
UIGraphicsGetImageFromCurrentImageContext
();
UIGraphicsEndImageContext
();
return
Image
(
uiImage
:
snapshot
!
)
}
var
keyRecord
:
KeyRecord
?
{
return
nil
}
}
struct
PseuoMail
:
DisplayMail
{
typealias
U
=
PseudoContact
var
subject
:
String
?
=
"Hello World"
var
body
:
String
?
=
"This is my message."
var
sender
:
U
var
tos
:
[
U
]
var
ccs
:
[
U
]
var
bccs
:
[
U
]
var
routingStops
:
[
Landmark
]
var
signedState
:
SignatureState
var
encState
:
EncryptionState
var
persistentMail
:
PersistentMail
?
{
return
nil
}
}
This diff is collapsed.
Click to expand it.
enzevalos_iphone/SwiftUI/Read/SenderViewMain.swift
+
14
−
117
View file @
e8599065
...
@@ -83,21 +83,30 @@ struct SenderViewMain <M: DisplayMail, C: DisplayContact>: View {
...
@@ -83,21 +83,30 @@ struct SenderViewMain <M: DisplayMail, C: DisplayContact>: View {
private
var
sender
:
some
View
{
private
var
sender
:
some
View
{
VStack
(
alignment
:
.
leading
,
spacing
:
10
)
{
VStack
(
alignment
:
.
leading
,
spacing
:
10
)
{
Button
(
action
:
{
self
.
goToContact
(
contact
:
self
.
mail
.
sender
)})
{
HStack
{
VStack
(
alignment
:
.
leading
)
{
VStack
(
alignment
:
.
leading
)
{
Text
(
NSLocalizedString
(
"Sender"
,
comment
:
"Sender"
))
Text
(
NSLocalizedString
(
"Sender"
,
comment
:
"Sender"
))
.
font
(
.
headline
)
.
font
(
.
headline
)
.
padding
(
.
bottom
,
10
)
Text
(
mail
.
sender
.
name
)
Text
(
mail
.
sender
.
name
)
.
font
(
.
subheadline
)
.
font
(
.
subheadline
)
Text
(
mail
.
sender
.
addr
)
Text
(
mail
.
sender
.
addr
)
// .foregroundColor(.gray)
.
foregroundColor
(
.
gray
)
//TODO: Add last mail date
}
}
Spacer
()
Button
(
action
:
{
self
.
goToContact
(
contact
:
self
.
mail
.
sender
)}){
Image
(
systemName
:
"chevron.right"
)
}
}
.
onTapGesture
{
self
.
goToContact
(
contact
:
self
.
mail
.
sender
)
}
}
HStack
{
HStack
{
Text
(
String
(
format
:
NSLocalizedString
(
"ReadView.Sender.Previous"
,
comment
:
"100 previous received mails"
),
mail
.
sender
.
previousMails
))
Text
(
String
(
format
:
NSLocalizedString
(
"ReadView.Sender.Previous"
,
comment
:
"100 previous received mails"
),
mail
.
sender
.
previousMails
))
Spacer
()
Spacer
()
Text
(
String
(
format
:
NSLocalizedString
(
"ReadView.Sender.Responses"
,
comment
:
"5 previous sent mails"
),
mail
.
sender
.
previousResponses
))
Text
(
String
(
format
:
NSLocalizedString
(
"ReadView.Sender.Responses"
,
comment
:
"5 previous sent mails"
),
mail
.
sender
.
previousResponses
))
// TODO: Add last mail date
// TODO: Go to mailinglists?
}
}
}
}
.
padding
(
10
)
.
padding
(
10
)
...
@@ -154,8 +163,6 @@ struct SenderViewMain <M: DisplayMail, C: DisplayContact>: View {
...
@@ -154,8 +163,6 @@ struct SenderViewMain <M: DisplayMail, C: DisplayContact>: View {
}
}
struct
SenderView_Previews
:
PreviewProvider
{
struct
SenderView_Previews
:
PreviewProvider
{
static
var
previews
:
some
View
{
static
var
previews
:
some
View
{
let
deviceNames
:
[
String
]
=
[
let
deviceNames
:
[
String
]
=
[
"iPhone SE"
,
"iPhone SE"
,
...
@@ -163,15 +170,6 @@ struct SenderView_Previews: PreviewProvider {
...
@@ -163,15 +170,6 @@ struct SenderView_Previews: PreviewProvider {
// "iPad Pro (11-inch)"
// "iPad Pro (11-inch)"
]
]
let
sender
=
PseudoContact
(
name
:
"Alice"
,
addr
:
"alice@example.com"
,
myImage
:
PseudoContact
.
makeImg
(
"Alice"
,
color
:
.
blue
))
let
bob
=
PseudoContact
(
name
:
"Bob"
,
addr
:
"Bob.lord.of.kingsbridge.and.king.of.england@huge.subdomain.with. a.long.long.long.domain.example.com"
,
myImage
:
PseudoContact
.
makeImg
(
"Bob"
,
color
:
.
red
))
let
charlie
=
PseudoContact
(
name
:
"Charlie"
,
addr
:
"charlie@example.com"
,
myImage
:
PseudoContact
.
makeImg
(
"Charlie"
,
color
:
.
green
))
let
landmarks
=
[
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
))
]
let
mail
=
PseuoMail
(
sender
:
sender
,
tos
:
[
bob
,
charlie
],
ccs
:
[
bob
,
charlie
,
bob
,
charlie
,
bob
],
bccs
:
[],
routingStops
:
landmarks
,
signedState
:
.
ValidSignature
,
encState
:
.
ValidedEncryptedWithCurrentKey
)
return
ForEach
(
deviceNames
,
id
:
\
.
self
)
{
deviceName
in
return
ForEach
(
deviceNames
,
id
:
\
.
self
)
{
deviceName
in
SenderViewMain
<
PseuoMail
,
PseudoContact
>
(
mail
:
mail
)
SenderViewMain
<
PseuoMail
,
PseudoContact
>
(
mail
:
mail
)
.
previewDisplayName
(
deviceName
)
.
previewDisplayName
(
deviceName
)
...
@@ -181,104 +179,3 @@ struct SenderView_Previews: PreviewProvider {
...
@@ -181,104 +179,3 @@ struct SenderView_Previews: PreviewProvider {
}
}
}
}
struct
PseudoContact
:
DisplayContact
{
var
previousMails
:
Int
=
10
var
previousResponses
:
Int
=
2
var
name
:
String
var
addr
:
String
var
myImage
:
Image
var
isInContactBook
:
Bool
=
false
var
otherAddresses
:
[
String
]
=
[]
var
keys
:
[
String
]
=
[]
var
hasPreviousMails
:
Bool
=
false
var
hasSimilarContacts
:
Bool
=
false
var
similarContacts
:
[
String
]
=
[]
public
static
func
makeImg
(
_
name
:
String
,
color
:
UIColor
)
->
Image
{
var
text
:
NSAttributedString
var
tag
=
String
()
if
name
.
count
>
0
{
let
seperated
=
name
.
components
(
separatedBy
:
" "
)
tag
=
seperated
.
map
({
if
let
a
=
$0
.
first
{
return
"
\(
a
)
"
};
return
""
})
.
joined
()
}
text
=
NSAttributedString
(
string
:
tag
.
uppercased
(),
attributes
:
[
NSAttributedString
.
Key
.
foregroundColor
:
UIColor
.
white
,
NSAttributedString
.
Key
.
font
:
UIFont
.
systemFont
(
ofSize
:
32.2
)])
var
myBounds
=
CGRect
()
myBounds
.
size
.
width
=
70
myBounds
.
size
.
height
=
70
UIGraphicsBeginImageContextWithOptions
(
myBounds
.
size
,
false
,
2
)
//try 200 here
let
context
=
UIGraphicsGetCurrentContext
()
//
// Clip context to a circle
//
let
path
=
CGPath
(
ellipseIn
:
myBounds
,
transform
:
nil
);
context
!.
addPath
(
path
);
context
!.
clip
();
//
// Fill background of context
//
context
!.
setFillColor
(
color
.
cgColor
)
context
!.
fill
(
CGRect
(
x
:
0
,
y
:
0
,
width
:
myBounds
.
size
.
width
,
height
:
myBounds
.
size
.
height
));
//
// Draw text in the context
//
let
textSize
=
text
.
size
()
text
.
draw
(
in
:
CGRect
(
x
:
myBounds
.
size
.
width
/
2
-
textSize
.
width
/
2
,
y
:
myBounds
.
size
.
height
/
2
-
textSize
.
height
/
2
,
width
:
textSize
.
width
,
height
:
textSize
.
height
))
let
snapshot
=
UIGraphicsGetImageFromCurrentImageContext
();
UIGraphicsEndImageContext
();
return
Image
(
uiImage
:
snapshot
!
)
}
var
keyRecord
:
KeyRecord
?
{
return
nil
}
}
struct
PseuoMail
:
DisplayMail
{
typealias
U
=
PseudoContact
var
subject
:
String
?
=
"Hello World"
var
body
:
String
?
=
"This is my message."
var
sender
:
U
var
tos
:
[
U
]
var
ccs
:
[
U
]
var
bccs
:
[
U
]
var
routingStops
:
[
Landmark
]
var
signedState
:
SignatureState
var
encState
:
EncryptionState
var
persistentMail
:
PersistentMail
?
{
return
nil
}
}
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