forked from mirrors/linphone-iphone
Revert ShareSheetController deletion
This commit is contained in:
parent
50d8bfaf15
commit
311e245861
2 changed files with 95 additions and 0 deletions
|
|
@ -70,6 +70,7 @@
|
|||
D71707202AC5989C0037746F /* TextExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D717071F2AC5989C0037746F /* TextExtension.swift */; };
|
||||
D7173EBE2B7A5C0A00BCC481 /* LinphoneUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7173EBD2B7A5C0A00BCC481 /* LinphoneUtils.swift */; };
|
||||
D717630D2BD7BD0E00464097 /* ParticipantsListFragment.swift in Sources */ = {isa = PBXBuildFile; fileRef = D717630C2BD7BD0E00464097 /* ParticipantsListFragment.swift */; };
|
||||
D717A10E2CEB772300849D92 /* ShareSheetController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D717A10D2CEB770D00849D92 /* ShareSheetController.swift */; };
|
||||
D71968922B86369D00DF4459 /* ChatBubbleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D71968912B86369D00DF4459 /* ChatBubbleView.swift */; };
|
||||
D719ABB72ABC67BF00B41C10 /* LinphoneApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D719ABB62ABC67BF00B41C10 /* LinphoneApp.swift */; };
|
||||
D719ABB92ABC67BF00B41C10 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D719ABB82ABC67BF00B41C10 /* ContentView.swift */; };
|
||||
|
|
@ -258,6 +259,7 @@
|
|||
D717071F2AC5989C0037746F /* TextExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextExtension.swift; sourceTree = "<group>"; };
|
||||
D7173EBD2B7A5C0A00BCC481 /* LinphoneUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinphoneUtils.swift; sourceTree = "<group>"; };
|
||||
D717630C2BD7BD0E00464097 /* ParticipantsListFragment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParticipantsListFragment.swift; sourceTree = "<group>"; };
|
||||
D717A10D2CEB770D00849D92 /* ShareSheetController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareSheetController.swift; sourceTree = "<group>"; };
|
||||
D71968912B86369D00DF4459 /* ChatBubbleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatBubbleView.swift; sourceTree = "<group>"; };
|
||||
D719ABB32ABC67BF00B41C10 /* Linphone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Linphone.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D719ABB62ABC67BF00B41C10 /* LinphoneApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinphoneApp.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -500,6 +502,7 @@
|
|||
D717071C2AC591EF0037746F /* Utils */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D717A10D2CEB770D00849D92 /* ShareSheetController.swift */,
|
||||
66C491F72B24D25A00CEA16D /* Extensions */,
|
||||
66C491FC2B24D36500CEA16D /* AudioRouteUtils.swift */,
|
||||
D7ADF5FF2AFE356400212231 /* Avatar.swift */,
|
||||
|
|
@ -1114,6 +1117,7 @@
|
|||
D7C2DA1D2CA44DE400A2441B /* EventModel.swift in Sources */,
|
||||
D719ABC92ABC6FD700B41C10 /* CoreContext.swift in Sources */,
|
||||
D70A26F22B7F5D95006CC8FC /* ConversationFragment.swift in Sources */,
|
||||
D717A10E2CEB772300849D92 /* ShareSheetController.swift in Sources */,
|
||||
66C491FD2B24D36500CEA16D /* AudioRouteUtils.swift in Sources */,
|
||||
D70959F12B8DF3EC0014AC0B /* ConversationModel.swift in Sources */,
|
||||
C6DC4E3D2C199C4E009096FD /* BundleExtenion.swift in Sources */,
|
||||
|
|
|
|||
91
Linphone/Utils/ShareSheetController.swift
Normal file
91
Linphone/Utils/ShareSheetController.swift
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright (c) 2010-2023 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of linphone-iphone
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
import linphonesw
|
||||
|
||||
struct ShareSheet: UIViewControllerRepresentable {
|
||||
typealias Callback = (_ activityType: UIActivity.ActivityType?, _ completed: Bool, _ returnedItems: [Any]?, _ error: Error?) -> Void
|
||||
|
||||
let friendToShare: Friend
|
||||
var activityItems: [Any] = []
|
||||
let applicationActivities: [UIActivity]? = nil
|
||||
let excludedActivityTypes: [UIActivity.ActivityType]? = nil
|
||||
let callback: Callback? = nil
|
||||
|
||||
func makeUIViewController(context: Context) -> UIActivityViewController {
|
||||
let directoryURL = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first
|
||||
|
||||
if directoryURL != nil {
|
||||
if friendToShare.name != nil {
|
||||
let filename = friendToShare.name!.replacingOccurrences(of: " ", with: "")
|
||||
|
||||
let fileURL = directoryURL!
|
||||
.appendingPathComponent(filename)
|
||||
.appendingPathExtension("vcf")
|
||||
|
||||
if friendToShare.vcard != nil {
|
||||
try? friendToShare.vcard!.asVcard4String().write(to: fileURL, atomically: false, encoding: String.Encoding.utf8)
|
||||
|
||||
let controller = UIActivityViewController(
|
||||
activityItems: [fileURL],
|
||||
applicationActivities: applicationActivities
|
||||
)
|
||||
controller.excludedActivityTypes = excludedActivityTypes
|
||||
controller.completionWithItemsHandler = callback
|
||||
return controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let controller = UIActivityViewController(
|
||||
activityItems: activityItems,
|
||||
applicationActivities: applicationActivities)
|
||||
controller.excludedActivityTypes = excludedActivityTypes
|
||||
controller.completionWithItemsHandler = callback
|
||||
return controller
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
func shareContacts(friend: String) {
|
||||
|
||||
let directoryURL = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first
|
||||
|
||||
if directoryURL != nil {
|
||||
let filename = NSUUID().uuidString
|
||||
|
||||
let fileURL = directoryURL!
|
||||
.appendingPathComponent(filename)
|
||||
.appendingPathExtension("vcf")
|
||||
|
||||
try? friend.write(to: fileURL, atomically: false, encoding: String.Encoding.utf8)
|
||||
}
|
||||
|
||||
/*
|
||||
let activityViewController = UIActivityViewController(
|
||||
activityItems: [fileURL],
|
||||
applicationActivities: nil
|
||||
)
|
||||
*/
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue