Skip to content
Snippets Groups Projects
Commit e9b90994 authored by Oliver Wiese's avatar Oliver Wiese
Browse files

first approach (warnings etc placed in map)

parent 2a2c74ca
Branches
Tags
No related merge requests found
...@@ -60,10 +60,6 @@ struct ReadMainView <M: DisplayMail>: View { ...@@ -60,10 +60,6 @@ struct ReadMainView <M: DisplayMail>: View {
} }
var moreInfoButton: some View{ var moreInfoButton: some View{
/* NavigationLink(destination: DialogView(option: SecurityState(mail: mail).dialog, ctaAction: nil, additionalAction: nil, dismissAction: nil), label: {
Image(systemName: isSecIndExpanded ? "arrow.up.circle" : "info.circle")
})
.isDetailLink(false)*/
Button(action: { Button(action: {
self.isSecIndExpanded.toggle() self.isSecIndExpanded.toggle()
...@@ -79,12 +75,12 @@ struct ReadMainView <M: DisplayMail>: View { ...@@ -79,12 +75,12 @@ struct ReadMainView <M: DisplayMail>: View {
let dialog = SecurityState(mail: mail).dialog let dialog = SecurityState(mail: mail).dialog
return DialogView(option: dialog, ctaAction: { return DialogView(option: dialog, ctaAction: {
self.isSecIndExpanded = false self.isSecIndExpanded = false
}, additionalAction: nil, dismissAction: nil) }, additionalAction: nil, dismissAction: nil, extend: false)
} }
} }
struct Tab{ struct Tab {
let id = UUID() let id = UUID()
var image : Image = Image(systemName: "tag.fill") var image : Image = Image(systemName: "tag.fill")
...@@ -93,108 +89,6 @@ struct Tab{ ...@@ -93,108 +89,6 @@ struct Tab{
} }
struct SecInd:View{
var secNum:UInt8=0 //1: trouble ; 2:safe ; 3 not safe
@Binding var isExpanded:Bool
var color:Color
@State private var pullInfo:Bool = true;
var body : some View {
VStack(spacing:0){
Rectangle()
.fill(color)
.frame(height: 2)
.frame(height: 2)
if isExpanded {
expandedSecInd(secNum: secNum).onTapGesture {
self.isExpanded = false
}
.padding(/*[.leading, .bottom, .trailing],*/20)
.background(RoundedCorners(color: color, tl: 0, tr: 0, bl: 30, br: 30))
}
if pullInfo {Text("tap info-icon to get more info").font(.system(size: 8)).padding(.vertical,4)}
}
.padding(0)
.background((isExpanded || !pullInfo) ? RoundedCorners(color: color, tl: 0, tr: 0, bl: 30, br: 30) : nil)
.animation(.easeInOut(duration: 1))
.onAppear(perform:{
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
self.pullInfo=false
}}
)
}
}
struct expandedSecInd: View {
var secNum:UInt8 //1: trouble ; 2:safe ; 3 not safe & subcases of unsecure(4,5,6)
var icon = LogData.IndicatorButton.self
var body: some View {
VStack(){
if secNum == 1 {
layout(
title: NSLocalizedString("LetterDamaged", comment: "Modified email received")/*"Angerissener Brief"*/,
text: NSLocalizedString("ReceiveDamagedInfo", comment: "Modified email infotext"),
icon: Image(icon.error.name)//TODO: ask oli how to do this correctly
)
} else if secNum == 2 {
layout(
title: NSLocalizedString("Letter", comment: "letter label"),
text: NSLocalizedString("ReceiveSecureInfo", comment: "Letter infotext"),
icon: Image(icon.confidential.name)//TODO: ask oli how to do this correctly
)
}else if secNum==4 {
layout(
title: NSLocalizedString("Postcard", comment: "postcard label"),
text: NSLocalizedString("ReceiveInsecureInfoVerified", comment: "Postcard infotext"),
icon: Image(icon.signedOnly.name)//TODO: ask oli how to do this correctly
)
} else if secNum==5 {
layout(
title: NSLocalizedString("Postcard", comment: "postcard label"),
text: NSLocalizedString("ReceiveInsecureInfoEncrypted", comment: "Postcard infotext"),
icon: Image(icon.encryptedOnly.name)//TODO: ask oli how to do this correctly
)
} else if secNum==6 {
layout(
title: NSLocalizedString("Postcard", comment: "postcard label"),
text: NSLocalizedString("ReceiveInsecureInfoDecryptionFailed", comment: "Postcard infotext"),
icon: Image(icon.unableToDecrypt.name)//TODO: ask oli how to do this correctly
)
}else if secNum == 3 {
layout(
title: NSLocalizedString("Postcard", comment: "postcard label"),
text: NSLocalizedString("ReceiveInsecureInfo", comment: "Postcard infotext"),
icon: Image("work")//Image(icon.notConfidential.name)//TODO: ask oli how to do this correctly
)
}
}
}
func layout(title:String, text:String, icon:Image)->some View{
//TODO: add a cool layout
return VStack{
HStack{
Spacer()
icon.resizable()
.scaledToFit()
.frame(width:30,height: 30)
Text(title).font(.system(size:22)).fontWeight(.light)
Spacer()
}
Text(text).font(.caption).multilineTextAlignment(.center)
}
}
}
#if DEBUG #if DEBUG
struct Layout_Previews: PreviewProvider { struct Layout_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
......
...@@ -32,7 +32,7 @@ struct MessageViewMain <M: DisplayMail>: View { ...@@ -32,7 +32,7 @@ struct MessageViewMain <M: DisplayMail>: View {
Divider() Divider()
if mail.warnings.count > 0 { if mail.warnings.count > 0 {
ForEach(0..<mail.warnings.count) { index in ForEach(0..<mail.warnings.count) { index in
DialogView(option: self.mail.warnings[index], ctaAction: self.action, additionalAction: self.action, dismissAction: self.action) DialogView(option: self.mail.warnings[index], ctaAction: self.action, additionalAction: self.action, dismissAction: self.action, extend: false)
} }
Divider() Divider()
MessageBody.padding(.horizontal) MessageBody.padding(.horizontal)
...@@ -105,17 +105,16 @@ struct MessageViewMain <M: DisplayMail>: View { ...@@ -105,17 +105,16 @@ struct MessageViewMain <M: DisplayMail>: View {
deleteButton.offset(x: showExtraButtons ? -innerPadding*9 : 0) deleteButton.offset(x: showExtraButtons ? -innerPadding*9 : 0)
archiveButton.offset(x: showExtraButtons ? -innerPadding*13.5 : 0) archiveButton.offset(x: showExtraButtons ? -innerPadding*13.5 : 0)
} }
//options
//options FloatingActionButton(
FloatingActionButton( //radius: innerPadding,
//radius: innerPadding, onShortPress: {self.showExtraButtons.toggle()}/*TODO: fill in stuff*/
onShortPress: {self.showExtraButtons.toggle()}/*TODO: fill in stuff*/ ){
){ VStack{
VStack{ Image(systemName: "arrowshape.turn.up.left.fill")
Image(systemName: "arrowshape.turn.up.left.fill") Text("options").font(.system(size: 7)).fontWeight(.none)
Text("options").font(.system(size: 7)).fontWeight(.none) }
} }.opacity(showExtraButtons ? 0 : 1)
}.opacity(showExtraButtons ? 0 : 1)
}.animation(.easeInOut(duration: 0.2)) }.animation(.easeInOut(duration: 0.2))
}.padding(outerPadding) }.padding(outerPadding)
}.padding(outerPadding) }.padding(outerPadding)
......
...@@ -25,17 +25,31 @@ import CoreLocation ...@@ -25,17 +25,31 @@ import CoreLocation
struct SenderViewMain <M: DisplayMail>: View { struct SenderViewMain <M: DisplayMail>: View {
let mail: M let mail: M
let secState: SecurityState<M>
@State var selectedLandmark: Landmark? = nil @State var selectedLandmark: Landmark? = nil
@State var showingLandmarkDetails = false @State var showingLandmarkDetails = false
init(mail: M) {
self.mail = mail
secState = SecurityState(mail: mail)
}
var body: some View { var body: some View {
ScrollView { ScrollView {
map if secState.warnings.count > 0 {
ForEach(0..<secState.warnings.count) { index in
DialogView(option: self.secState.warnings[index], ctaAction: {print("Hello")}, additionalAction: {print("Hello")}, dismissAction: {print("Hello")}, extend: (index == (self.secState.warnings.count - 1)))
}
} else {
map
}
icon icon
sender sender
.offset(y: (-110/2 + 5)) .offset(y: (-110/2 + 20))
Divider() Divider()
SmallContactListView(contacts: mail.tos, title: NSLocalizedString("To", comment: "To")) SmallContactListView(contacts: mail.tos, title: NSLocalizedString("To", comment: "To"))
Divider() Divider()
...@@ -166,15 +180,13 @@ struct SenderView_Previews: PreviewProvider { ...@@ -166,15 +180,13 @@ struct SenderView_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
let deviceNames: [String] = [ let deviceNames: [String] = [
"iPhone SE", "iPhone SE",
"iPhone 11 Pro Max"//, "iPhone 11 Pro Max"
// "iPad Pro (11-inch)"
] ]
return ForEach(deviceNames, id: \.self) {deviceName in return ForEach(deviceNames, id: \.self) {deviceName in
SenderViewMain<PseuoMail>(mail: mail) SenderViewMain<PseuoMail>(mail: mail)
.previewDisplayName(deviceName) .previewDisplayName(deviceName)
.previewDevice(.init(rawValue: deviceName)) .previewDevice(.init(rawValue: deviceName))
//.colorScheme(.dark)
} }
} }
......
...@@ -14,6 +14,7 @@ struct DialogView <D: Dialog> : View { ...@@ -14,6 +14,7 @@ struct DialogView <D: Dialog> : View {
var ctaAction: (() -> Void)? var ctaAction: (() -> Void)?
var additionalAction: (() -> Void)? var additionalAction: (() -> Void)?
var dismissAction: (() -> Void)? var dismissAction: (() -> Void)?
var extend: Bool
private let color = Color(UIColor.systemGray6) private let color = Color(UIColor.systemGray6)
...@@ -30,19 +31,12 @@ struct DialogView <D: Dialog> : View { ...@@ -30,19 +31,12 @@ struct DialogView <D: Dialog> : View {
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.padding(.vertical, 20) .padding(.vertical, 20)
.addBorder(option.dialogColor, width: 2, cornerRadius: 30) .addBorder(option.dialogColor, width: 2, cornerRadius: 30)
HStack{ Text(option.body)
option.img .fontWeight(.light)
.resizable() .font(.body)
.frame(width: 60, height: 60)
.foregroundColor(option.dialogColor)
.padding(.trailing, 20)
Text(option.body)
.fontWeight(.light)
.font(.body)
.lineLimit(10) .lineLimit(10)
.fixedSize(horizontal: false, vertical: true) .fixedSize(horizontal: false, vertical: true)
} .padding(20)
.padding(20)
if option.ctaButtonTitle != nil && ctaAction != nil { if option.ctaButtonTitle != nil && ctaAction != nil {
Button(action: ctaAction!) { Button(action: ctaAction!) {
Text(option.ctaButtonTitle!) Text(option.ctaButtonTitle!)
...@@ -73,8 +67,11 @@ struct DialogView <D: Dialog> : View { ...@@ -73,8 +67,11 @@ struct DialogView <D: Dialog> : View {
.background(RoundedCorners(color: color, radius: 30)) .background(RoundedCorners(color: color, radius: 30))
.padding(.vertical, 10) .padding(.vertical, 10)
.padding(.horizontal, 20) .padding(.horizontal, 20)
} }
} }
if extend {
Text("").padding(20)
}
} }
.background(RoundedCorners(color: color, radius: 30)) .background(RoundedCorners(color: color, radius: 30))
.padding(10) .padding(10)
...@@ -85,10 +82,10 @@ struct DialogView <D: Dialog> : View { ...@@ -85,10 +82,10 @@ struct DialogView <D: Dialog> : View {
struct DialogView_Previews: PreviewProvider { struct DialogView_Previews: PreviewProvider {
static let options = SecurityState.init(mail: mail) static let options = SecurityState.init(mail: mail)
static var previews: some View { static var previews: some View {
VStack{ ScrollView{
DialogView(option: options.dialog, ctaAction: action, additionalAction: action, dismissAction: action) DialogView(option: options.dialog, ctaAction: action, additionalAction: action, dismissAction: action, extend: false)
//DialogView(option: DialogOption.corrupted, ctaAction: action, additionalAction: action, dismissAction: action) DialogView(option: DialogOption.corrupted, ctaAction: action, additionalAction: action, dismissAction: action, extend: false)
// DialogView(option: DialogOption.couldNotDecrypt, ctaAction: action, additionalAction: action, dismissAction: action) DialogView(option: DialogOption.couldNotDecrypt, ctaAction: action, additionalAction: action, dismissAction: action, extend: false)
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment