diff --git a/enzevalos_iphone/SwiftUI/Read/ReadMainView.swift b/enzevalos_iphone/SwiftUI/Read/ReadMainView.swift index a3b03991ae714284b020263ecf92002e7269cde7..c4b5aefc441abb6b0ffd46398e354294126d2b54 100644 --- a/enzevalos_iphone/SwiftUI/Read/ReadMainView.swift +++ b/enzevalos_iphone/SwiftUI/Read/ReadMainView.swift @@ -60,10 +60,6 @@ struct ReadMainView <M: DisplayMail>: 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: { self.isSecIndExpanded.toggle() @@ -79,12 +75,12 @@ struct ReadMainView <M: DisplayMail>: View { let dialog = SecurityState(mail: mail).dialog return DialogView(option: dialog, ctaAction: { self.isSecIndExpanded = false - }, additionalAction: nil, dismissAction: nil) + }, additionalAction: nil, dismissAction: nil, extend: false) } } -struct Tab{ +struct Tab { let id = UUID() var image : Image = Image(systemName: "tag.fill") @@ -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 struct Layout_Previews: PreviewProvider { static var previews: some View { diff --git a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/MessageViewMain.swift b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/MessageViewMain.swift index 49d4cc0bc24038d75ee01df403c74a39c1451787..4854f0724c7f4312eaf3e699c1449b8d1ed3ab74 100644 --- a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/MessageViewMain.swift +++ b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/MessageViewMain.swift @@ -32,7 +32,7 @@ struct MessageViewMain <M: DisplayMail>: View { Divider() if mail.warnings.count > 0 { 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() MessageBody.padding(.horizontal) @@ -105,17 +105,16 @@ struct MessageViewMain <M: DisplayMail>: View { deleteButton.offset(x: showExtraButtons ? -innerPadding*9 : 0) archiveButton.offset(x: showExtraButtons ? -innerPadding*13.5 : 0) } - - //options - FloatingActionButton( - //radius: innerPadding, - onShortPress: {self.showExtraButtons.toggle()}/*TODO: fill in stuff*/ - ){ - VStack{ - Image(systemName: "arrowshape.turn.up.left.fill") - Text("options").font(.system(size: 7)).fontWeight(.none) - } - }.opacity(showExtraButtons ? 0 : 1) + //options + FloatingActionButton( + //radius: innerPadding, + onShortPress: {self.showExtraButtons.toggle()}/*TODO: fill in stuff*/ + ){ + VStack{ + Image(systemName: "arrowshape.turn.up.left.fill") + Text("options").font(.system(size: 7)).fontWeight(.none) + } + }.opacity(showExtraButtons ? 0 : 1) }.animation(.easeInOut(duration: 0.2)) }.padding(outerPadding) }.padding(outerPadding) diff --git a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewMain.swift b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewMain.swift index f711db6b4d4b79966939f60438a83f82ec36882d..f88d70bcca3c7fcb3ae3128e67fdd6729daaee58 100644 --- a/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewMain.swift +++ b/enzevalos_iphone/SwiftUI/Read/Tabbed Views/SenderViewMain.swift @@ -25,17 +25,31 @@ import CoreLocation struct SenderViewMain <M: DisplayMail>: View { let mail: M + let secState: SecurityState<M> @State var selectedLandmark: Landmark? = nil @State var showingLandmarkDetails = false + init(mail: M) { + self.mail = mail + secState = SecurityState(mail: mail) + } + var body: some View { 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 sender - .offset(y: (-110/2 + 5)) + .offset(y: (-110/2 + 20)) Divider() SmallContactListView(contacts: mail.tos, title: NSLocalizedString("To", comment: "To")) Divider() @@ -166,15 +180,13 @@ struct SenderView_Previews: PreviewProvider { static var previews: some View { let deviceNames: [String] = [ "iPhone SE", - "iPhone 11 Pro Max"//, - // "iPad Pro (11-inch)" + "iPhone 11 Pro Max" ] return ForEach(deviceNames, id: \.self) {deviceName in SenderViewMain<PseuoMail>(mail: mail) .previewDisplayName(deviceName) .previewDevice(.init(rawValue: deviceName)) - //.colorScheme(.dark) } } diff --git a/enzevalos_iphone/SwiftUI/SupportingViews/DialogView.swift b/enzevalos_iphone/SwiftUI/SupportingViews/DialogView.swift index 9149d5131d7c449c02b7e83812692728c3bff0e9..5679176d17878b1716601c5ed5a32439c9f2ccdc 100644 --- a/enzevalos_iphone/SwiftUI/SupportingViews/DialogView.swift +++ b/enzevalos_iphone/SwiftUI/SupportingViews/DialogView.swift @@ -14,6 +14,7 @@ struct DialogView <D: Dialog> : View { var ctaAction: (() -> Void)? var additionalAction: (() -> Void)? var dismissAction: (() -> Void)? + var extend: Bool private let color = Color(UIColor.systemGray6) @@ -30,19 +31,12 @@ struct DialogView <D: Dialog> : View { .frame(maxWidth: .infinity) .padding(.vertical, 20) .addBorder(option.dialogColor, width: 2, cornerRadius: 30) - HStack{ - option.img - .resizable() - .frame(width: 60, height: 60) - .foregroundColor(option.dialogColor) - .padding(.trailing, 20) - Text(option.body) - .fontWeight(.light) - .font(.body) + Text(option.body) + .fontWeight(.light) + .font(.body) .lineLimit(10) .fixedSize(horizontal: false, vertical: true) - } - .padding(20) + .padding(20) if option.ctaButtonTitle != nil && ctaAction != nil { Button(action: ctaAction!) { Text(option.ctaButtonTitle!) @@ -73,8 +67,11 @@ struct DialogView <D: Dialog> : View { .background(RoundedCorners(color: color, radius: 30)) .padding(.vertical, 10) .padding(.horizontal, 20) - } + } } + if extend { + Text("").padding(20) + } } .background(RoundedCorners(color: color, radius: 30)) .padding(10) @@ -85,10 +82,10 @@ struct DialogView <D: Dialog> : View { struct DialogView_Previews: PreviewProvider { static let options = SecurityState.init(mail: mail) static var previews: some View { - VStack{ - DialogView(option: options.dialog, ctaAction: action, additionalAction: action, dismissAction: action) - //DialogView(option: DialogOption.corrupted, ctaAction: action, additionalAction: action, dismissAction: action) - // DialogView(option: DialogOption.couldNotDecrypt, ctaAction: action, additionalAction: action, dismissAction: action) + ScrollView{ + DialogView(option: options.dialog, ctaAction: action, additionalAction: action, dismissAction: action, extend: false) + DialogView(option: DialogOption.corrupted, ctaAction: action, additionalAction: action, dismissAction: action, extend: false) + DialogView(option: DialogOption.couldNotDecrypt, ctaAction: action, additionalAction: action, dismissAction: action, extend: false) } }