diff --git a/enzevalos_iphone/GeometryGetter.swift b/enzevalos_iphone/GeometryGetter.swift new file mode 100644 index 0000000000000000000000000000000000000000..ec0ee279d26376ed7e8032f7cc554cf06c1dd5ed --- /dev/null +++ b/enzevalos_iphone/GeometryGetter.swift @@ -0,0 +1,25 @@ +// +// 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) + } + } + } +} diff --git a/enzevalos_iphone/KeyboardChecker.swift b/enzevalos_iphone/KeyboardChecker.swift new file mode 100644 index 0000000000000000000000000000000000000000..360b578028eecd396df696a04425d642368b15c0 --- /dev/null +++ b/enzevalos_iphone/KeyboardChecker.swift @@ -0,0 +1,36 @@ +// +// KeyboardChecker.swift +// enzevalos_iphone +// +// Created by hanneh00 on 17.03.20. +// Copyright © 2020 fu-berlin. All rights reserved. +// + +//-------------------this file should be moved to the reusable swiftUI views----------------- + +import SwiftUI + +final class KeyboardResponder: ObservableObject { + private var notificationCenter: NotificationCenter + @Published private(set) var currentHeight: CGFloat = 0 + + init(center: NotificationCenter = .default) { + notificationCenter = center + notificationCenter.addObserver(self, selector: #selector(keyBoardWillShow(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil) + notificationCenter.addObserver(self, selector: #selector(keyBoardWillHide(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil) + } + + deinit { + notificationCenter.removeObserver(self) + } + + @objc func keyBoardWillShow(notification: Notification) { + if let keyboardSize = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue { + currentHeight = keyboardSize.height + } + } + + @objc func keyBoardWillHide(notification: Notification) { + currentHeight = 0 + } +} diff --git a/enzevalos_iphone/OnboardingIntroInfoSection.swift b/enzevalos_iphone/OnboardingIntroInfoSection.swift new file mode 100644 index 0000000000000000000000000000000000000000..61ef9f0279af9723213cb0c85e6f988db1b14f1b --- /dev/null +++ b/enzevalos_iphone/OnboardingIntroInfoSection.swift @@ -0,0 +1,86 @@ +// +// OnboardingIntroInfosection.swift +// enzevalos_iphone +// +// Created by melicoa97 on 03.03.20. +// Copyright © 2020 fu-berlin. All rights reserved. +// + +import SwiftUI + +struct OnboardingIntroInfosection: View { + + var sections:[OnboardingIntroInfoSubsection] = [ + OnboardingIntroInfoSubsection( + headline:NSLocalizedString("OnboardingIntroSection.Confidential.headline", comment: ""), + previewText:NSLocalizedString("OnboardingIntroSection.Confidential.preview", comment: ""), + description:NSLocalizedString("OnboardingIntroSection.Confidential.description", comment: ""), + image: StudySettings.securityIndicator.imageOfSecureIndicatorSwiftUI(background: false, open: false, button: false)), + OnboardingIntroInfoSubsection( + headline:NSLocalizedString("OnboardingIntroSection.Detection.headline", comment: ""), + previewText:NSLocalizedString("OnboardingIntroSection.Detection.preview", comment: ""), + description:NSLocalizedString("OnboardingIntroSection.Detection.description", comment: ""), + image: StudySettings.securityIndicator.imageOfInsecureIndicatorSwiftUI(background: false, button: false)) + ] + + var body: some View { + VStack(alignment: .leading){ + ForEach(sections,id: \.id){section in + OnboardingIntroInfosubsection(image: section.image, headline: section.headline, previewText: section.previewText, description: section.description).padding(.vertical, 10) + } + } + .padding(.horizontal, 40) + } +} + +struct OnboardingIntroInfosubsection: View { + + var image:Image + var headline:String + var previewText:String + var description:String + @State private var pressed:Bool=true + + + var body: some View { + Button(action: { + self.pressed.toggle() + }){ + HStack(alignment: .top){ + image + .renderingMode(Image.TemplateRenderingMode?.init(Image.TemplateRenderingMode.original)) + .resizable() + .frame(width: 49, height:37) + VStack(alignment: .leading){ + Text(headline).font(.body).fontWeight(.bold) + if(pressed){ + Text(previewText).fontWeight(.thin).font(.subheadline) + }else { + Text(description) + .fontWeight(.thin) + .font(.subheadline) + } + }.padding(.leading, 20) + Spacer() + } + } + .foregroundColor(.primary) + + } +} + +class OnboardingIntroInfoSubsection{ + var image:Image + var headline:String + var previewText:String + var description:String + var id:UUID + init(headline:String, previewText:String, description:String, image:Image){ + self.id = UUID() + self.headline = headline + self.previewText = previewText + self.description = description + self.image = image + } + +}