Commit 65984302 authored by Oliver Wiese's avatar Oliver Wiese

make mail body selectable.

parent 178485d2
......@@ -67,6 +67,7 @@
472F398C1E2519C8009260FB /* CNContactExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 472F398B1E2519C8009260FB /* CNContactExtension.swift */; };
472F398E1E251B8D009260FB /* MailAddress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 472F398D1E251B8D009260FB /* MailAddress.swift */; };
472F39901E252470009260FB /* CNMailAddressesExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 472F398F1E252470009260FB /* CNMailAddressesExtension.swift */; };
47358D92244A5AEA000116D7 /* SelectableTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47358D91244A5AEA000116D7 /* SelectableTextView.swift */; };
474054982244D7A9007CF83B /* MailServerConfigurationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 474054972244D7A9007CF83B /* MailServerConfigurationTest.swift */; };
474994022261E4E6000F8DA5 /* SimpleSendIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 474994012261E4E6000F8DA5 /* SimpleSendIcon.swift */; };
4751C6EE233CA583006B2A4D /* DateExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4751C6ED233CA583006B2A4D /* DateExtension.swift */; };
......@@ -403,6 +404,7 @@
472F398B1E2519C8009260FB /* CNContactExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CNContactExtension.swift; sourceTree = "<group>"; };
472F398D1E251B8D009260FB /* MailAddress.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MailAddress.swift; sourceTree = "<group>"; };
472F398F1E252470009260FB /* CNMailAddressesExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CNMailAddressesExtension.swift; sourceTree = "<group>"; };
47358D91244A5AEA000116D7 /* SelectableTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectableTextView.swift; sourceTree = "<group>"; };
474054972244D7A9007CF83B /* MailServerConfigurationTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MailServerConfigurationTest.swift; sourceTree = "<group>"; };
474994012261E4E6000F8DA5 /* SimpleSendIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleSendIcon.swift; sourceTree = "<group>"; };
4751C6ED233CA583006B2A4D /* DateExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateExtension.swift; sourceTree = "<group>"; };
......@@ -1147,6 +1149,7 @@
isa = PBXGroup;
children = (
476406922416B54D00C7D426 /* VCSwiftUIView.swift */,
47358D91244A5AEA000116D7 /* SelectableTextView.swift */,
);
path = "SwiftUI to UIKit";
sourceTree = "<group>";
......@@ -2370,6 +2373,7 @@
A1083A541E8BFEA6003666B7 /* Onboarding.swift in Sources */,
476406982416B54D00C7D426 /* CiricleImage.swift in Sources */,
A111F6AD1FA77B170060AFDE /* LoggerDetail.swift in Sources */,
47358D92244A5AEA000116D7 /* SelectableTextView.swift in Sources */,
A13526791D955BDF00D3BFE1 /* AppDelegate.swift in Sources */,
476916A2216B86CF00491527 /* EnzevalosContact+CoreDataClass.swift in Sources */,
0EF148052422543E00B3C198 /* Certificate.swift in Sources */,
......
......@@ -155,7 +155,23 @@ struct PseuoMail: DisplayMail {
var subject: String? = "Hello World"
var body: String? = "This is my message."
var body: String? = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent laoreet justo tellus, vitae molestie erat pharetra a. Curabitur porta finibus quam, eget posuere elit luctus vel. In sapien orci, eleifend pharetra nunc id, hendrerit gravida orci. In fringilla tellus mauris, hendrerit cursus enim lacinia vitae. Fusce vel nisl id sem blandit cursus vel quis odio. Aenean accumsan arcu eu quam iaculis, eu malesuada sapien dignissim. Aenean consequat elit nec metus auctor tempor. Aliquam erat volutpat. Proin non mi felis.
www.fu-berlin.de
Sed elementum consectetur diam, ut placerat justo varius eget. Donec sit amet sem arcu. In sit amet purus tellus. Quisque pulvinar vitae metus nec ultricies. Aenean ac risus id quam euismod dapibus sed in nunc. Suspendisse vestibulum id arcu ac ultricies. Sed aliquam quam condimentum efficitur commodo. Cras imperdiet, nisl vel rhoncus aliquam, nisl elit tincidunt arcu, quis congue sem velit ut leo. Cras sodales commodo dolor et placerat. Nunc sit amet finibus lectus. Nam laoreet condimentum lorem, a auctor sem imperdiet sed. In venenatis ut ligula eget rhoncus. Quisque vitae porttitor enim. Integer ac tellus neque.
Sed non porta risus, hendrerit pellentesque diam. Cras sollicitudin ultricies tincidunt. Aliquam erat volutpat. Cras ut est velit. In eleifend, augue quis fringilla pretium, leo purus tincidunt tellus, nec tempus orci mauris in enim. Aliquam sed purus ligula. Cras mattis nisl sit amet porta rutrum. Phasellus quis tempor libero, sit amet finibus purus.
Quisque eleifend pulvinar lacus eu eleifend. Integer ipsum neque, molestie et risus sit amet, volutpat volutpat enim. Suspendisse pulvinar sem et sapien pretium pharetra. Phasellus euismod efficitur neque, ac scelerisque est aliquet quis. Aliquam pulvinar, diam vitae lobortis consectetur, tortor nunc feugiat neque, a fringilla nibh magna non sapien. Aliquam ante ex, rutrum et pellentesque in, convallis at erat. Integer tristique, libero eget congue condimentum, enim erat elementum nisl, vel mollis elit magna eu leo. Maecenas elementum id magna ut pellentesque. Ut in lacus accumsan, suscipit enim semper, tempus nisl. Nulla sit amet tortor semper justo tristique posuere. Donec feugiat ligula arcu, semper tristique dui ultricies vitae. Integer ultrices libero at arcu viverra varius. Duis lacus mi, laoreet vitae consectetur vel, aliquet vitae sem. Curabitur rhoncus tincidunt luctus. Maecenas aliquet lectus quis mauris pulvinar sodales. Suspendisse faucibus consectetur sagittis.
Phasellus tempor pulvinar felis, sed fermentum sem eleifend in. Nullam magna nisl, bibendum tincidunt tellus in, elementum interdum felis. Duis sit amet porttitor sapien. Nam mollis pellentesque odio, a rutrum nulla volutpat sed. Suspendisse at feugiat felis. Nulla efficitur nibh eget mauris ullamcorper cursus. In enim dolor, venenatis quis nunc id, tempor commodo felis. Nam fermentum blandit dui. Nunc congue mauris rutrum magna porttitor, quis rutrum augue tristique. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
Morbi lacinia suscipit lacinia. Donec ultricies turpis neque, fringilla congue nibh pharetra eget. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent eleifend iaculis blandit. Duis eget ipsum nunc. Aliquam vitae posuere magna. Mauris venenatis odio urna, quis condimentum diam blandit ac. In erat nisi, aliquam id sodales eget, malesuada nec diam. Pellentesque non sem justo. Quisque pellentesque erat metus, nec dapibus urna imperdiet vel. Aliquam erat volutpat. Morbi ornare id nisl sed vulputate. Suspendisse aliquam dapibus elit. Suspendisse dapibus, nisl lobortis lobortis dictum, ligula nulla iaculis nulla, id scelerisque est turpis ac tortor.
Sed elementum nibh eget justo porta, nec accumsan justo blandit. Ut vel vestibulum augue. Fusce et placerat diam, vitae faucibus odio. Curabitur lacinia metus lacus, at pulvinar mi ultricies vel. Quisque eu molestie nisi, vitae blandit tortor. Nulla posuere, arcu pulvinar consectetur ultrices, urna nibh ornare enim, non aliquam velit mauris at odio. Cras ultrices luctus tellus sit amet viverra. Suspendisse ut dolor nulla. Integer vehicula lectus vel enim interdum hendrerit. Maecenas ut quam ex. Aenean rutrum vestibulum felis vitae condimentum. Cras molestie fermentum eros, egestas euismod eros posuere sit amet. Nulla ornare faucibus urna eget consequat. Nunc a hendrerit augue, ultrices aliquet risus. Vivamus id facilisis massa. Phasellus vulputate neque quis risus egestas luctus.
"""
var sender: U
......
......@@ -22,12 +22,10 @@ struct MessageViewMain <M: DisplayMail>: View {
var body: some View {
ZStack{
ScrollView{
VStack{
Subjectbar
Divider()
MessageBody.padding(.horizontal)
}
VStack{
Subjectbar
Divider()
MessageBody.padding(.horizontal)
}
.onTapGesture {
self.showExtraButtons = false
......@@ -53,8 +51,15 @@ struct MessageViewMain <M: DisplayMail>: View {
}
var MessageBody : some View {
Text(self.mail.body!)
.padding(.bottom, 2 * innerPadding + outerPadding)
GeometryReader {geometry in
SelectableTextView((self.mail.body ?? ""))
.frame(
width: geometry.size.width,
height: geometry.size.height
)
.padding(.bottom, 2 * self.innerPadding + self.outerPadding)
}
}
var FloatingReplyButtons: some View{
......
//
// SelectableTextView.swift
// enzevalos_iphone
//
// Created by Oliver Wiese on 17.04.20.
// Copyright © 2020 fu-berlin. All rights reserved.
//
import SwiftUI
class TextViewDelegate:NSObject, UITextViewDelegate {
func textView(_ textView: UITextView, shouldInteractWith url: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
if url.scheme == "mailto" {
if let coord = AppDelegate.getAppDelegate().readViewCoordinator {
let to = DataHandler.handler.getMailAddress(url.absoluteString.replacingOccurrences(of: "mailto:", with: ""), temporary: true)
coord.pushComposeView(to: [to], cc: [], bcc: [], subject: "", body: "", responseType: .Reply)
}
return false
}
return true
}
}
struct SelectableTextView: UIViewRepresentable {
var text: String
var textDelegate = TextViewDelegate()
init(_ text: String) {
self.text = text
}
func makeUIView(context: Context) -> UITextView {
let view = UITextView()
view.isSelectable = true
view.isEditable = false
view.isScrollEnabled = true
view.font = .preferredFont(forTextStyle: .body)
view.dataDetectorTypes = .link
view.delegate = textDelegate
return view
}
func updateUIView(_ label: UITextView, context: Context) {
label.text = text
}
}
struct AttributedTextView_Previews: PreviewProvider {
static let text = "Hello World www.fu-berlin.de https://www.google.com"
static var previews: some View {
VStack{
SelectableTextView(text)
Text(text)
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment