From cf9acd05c91ec744998487baebf4fb51aa4a800c Mon Sep 17 00:00:00 2001 From: distiller Date: Thu, 20 Mar 2025 07:08:02 +0000 Subject: [PATCH] Release - swiftui/1.0.3 --- CHANGELOG.md | 13 +++-- Package.swift | 4 +- .../project.pbxproj | 14 +++-- .../CustomSample/CustomSampleSubView.swift | 6 ++ .../CustomSampleSubViewModel.swift | 4 +- Sample/project.yml | 4 +- SendbirdSwiftUI.podspec | 4 +- Sources/SwiftUI/Common/GlobalOptions.swift | 18 ++++++ .../CreateGroupChannelView.swift | 4 +- .../CreateOpenChannelView.swift | 4 +- .../GroupBannedUserListView.swift | 4 +- .../GroupChannel/GroupChannelView.swift | 4 +- .../GroupChannelListView.swift | 4 +- .../GroupChannelPushSettingsView.swift | 4 +- .../GroupChannelRegisterOperatorView.swift | 4 +- .../GroupChannelSettingsView.swift | 4 +- .../GroupMemberList/GroupMemberListView.swift | 4 +- .../GroupModerationsView.swift | 4 +- .../GroupMutedMemberListView.swift | 4 +- .../GroupOperatorListView.swift | 4 +- .../InviteUser/InviteUserView.swift | 4 +- .../MessageSearch/MessageSearchView.swift | 4 +- .../MessageThread/MessageThreadView.swift | 4 +- .../OpenBannedUserListView.swift | 4 +- .../OpenChannel/OpenChannelView.swift | 4 +- .../OpenChannelList/OpenChannelListView.swift | 4 +- .../OpenChannelRegisterOperatorView.swift | 4 +- .../OpenChannelSettingsView.swift | 5 +- .../OpenModerations/OpenModerationsView.swift | 4 +- .../OpenMutedParticipantListView.swift | 4 +- .../OpenOperatorListView.swift | 4 +- .../OpenParticipantListView.swift | 4 +- .../CellView/SBUUserMessageTextView.swift | 57 ++++++++++++++++++- 33 files changed, 177 insertions(+), 44 deletions(-) create mode 100644 Sources/SwiftUI/Common/GlobalOptions.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d25195..d0ab07a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ -## New Interfaces -New view adaptor interfaces for `GroupChannelType.ListItem` have been added. -- `public func quotedFileMessageView(@ViewBuilder content:)` - - An interface that customizes a quoted file message view. -- `public func quotedMultipleFilesMessageView(@ViewBuilder content:)` - - An interface that customizes a quoted multiple files message view. +## New Interfaces +- Added `GlobalOptions.enableViewAdaptorAutoReset` + - This option decides whether to reset customized view adaptors whenever SendbirdSwiftUI View's `onDisappear` is called. + - Set this flag to `false` before a specific SendbirdSwiftUI View appears, if you want to prevent its customized views from resetting, even after its `onDisappear` is called. + +## Improvements +- Fixed customized SendbirdSwiftUI View's customized styles being reset whenever a SendbirdSwiftUI View 's `onDisappear` is called (e.g., when coming back from another `TabView`) diff --git a/Package.swift b/Package.swift index e9c781a..5072def 100644 --- a/Package.swift +++ b/Package.swift @@ -23,8 +23,8 @@ let package = Package( targets: [ .binaryTarget( name: "SendbirdSwiftUI", - url: "https://github.com/sendbird/sendbird-swiftui-ios/releases/download/1.0.2/SendbirdSwiftUI.xcframework.zip", - checksum: "ac1f1a4d878b1564d27f00470f5466bf1ce033b239e647c6fe9e4033c3bcbf62" + url: "https://github.com/sendbird/sendbird-swiftui-ios/releases/download/1.0.3/SendbirdSwiftUI.xcframework.zip", + checksum: "4599d0209a95045c1aee95fb9d90d7caeb6df284d2e9810a057aa6a893ac0120" ), .target( diff --git a/Sample/QuickStartSwiftUI.xcodeproj/project.pbxproj b/Sample/QuickStartSwiftUI.xcodeproj/project.pbxproj index d644590..0cf0444 100644 --- a/Sample/QuickStartSwiftUI.xcodeproj/project.pbxproj +++ b/Sample/QuickStartSwiftUI.xcodeproj/project.pbxproj @@ -244,6 +244,7 @@ 338BE5281B09CD9862D8B40F /* SBUUserMessageTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 608274ACB42DDAE6A5976FC6 /* SBUUserMessageTextView.swift */; }; 33F211B7F47CC6FC91C639AF /* SBUCreateGroupChannelUserCell+SwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A63BAEF80ECC309FA1E7669 /* SBUCreateGroupChannelUserCell+SwiftUI.swift */; }; 3407C53E67355F05BD5568CC /* SBUCoverImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0C6B3B15A2C99291A025E96 /* SBUCoverImageView.swift */; }; + 340E18B59A67E5C046A9241D /* GlobalOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1502118E1864D319404F249C /* GlobalOptions.swift */; }; 3412D19373A8ACC77B9277AA /* OpenOperatorListView+SubViewBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F32A69B02CCE4166DE09F9D /* OpenOperatorListView+SubViewBuilder.swift */; }; 3416FD182734700D48191237 /* SBUOpenBannedUserListUserCell+SwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 934D088DA1735729346CE8C0 /* SBUOpenBannedUserListUserCell+SwiftUI.swift */; }; 34C3EFDD816902E6ABBD97A4 /* SBUMessageFormChipsItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F7C5297FA101765F9784775 /* SBUMessageFormChipsItemView.swift */; }; @@ -1211,6 +1212,7 @@ 149EF5C6D56F66FA509EA283 /* SBUGroupChannelModule.List+SwiftUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SBUGroupChannelModule.List+SwiftUI.swift"; sourceTree = ""; }; 14A5CBF9A05A44B87429CDCC /* FontSet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontSet.swift; sourceTree = ""; }; 14EA076EB6C73BA4290914FE /* CustomOpenMutedParticipantList.ViewConverter.List.profileImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomOpenMutedParticipantList.ViewConverter.List.profileImage.swift; sourceTree = ""; }; + 1502118E1864D319404F249C /* GlobalOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlobalOptions.swift; sourceTree = ""; }; 151589C04C2127E51ABCF91D /* SBUGroupChannelListModule.Header.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SBUGroupChannelListModule.Header.swift; sourceTree = ""; }; 15269264474C5B46CF1910BE /* SBUInviteUserModule.List+SwiftUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SBUInviteUserModule.List+SwiftUI.swift"; sourceTree = ""; }; 1594F63CF9E5FDE4E1A20E4E /* CustomOpenBannedUserList.ViewConverter.Header.titleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomOpenBannedUserList.ViewConverter.Header.titleView.swift; sourceTree = ""; }; @@ -5029,6 +5031,7 @@ A9779DBC3ABC5BEFFBF2DC74 /* Common */ = { isa = PBXGroup; children = ( + 1502118E1864D319404F249C /* GlobalOptions.swift */, 2B50481174F97B1EE25DA725 /* Sendbird.swift */, EB9EAE40ED4B2267D13C0B8C /* Sendbird+Typealias.swift */, ); @@ -6864,6 +6867,7 @@ AEF6E6E5D58A1C14EADDF06B /* Float+SBUIKit.swift in Sources */, 53E5046D24EFD425EE0B8F01 /* FontSet.swift in Sources */, 28B038F489F6B33DF70C5A30 /* Formatter+SBUIKit.swift in Sources */, + 340E18B59A67E5C046A9241D /* GlobalOptions.swift in Sources */, F7F5896DD491728C5E9CBBB6 /* GroupBannedUserListView+Item.swift in Sources */, 93A5253A6300B53E76CB790C /* GroupBannedUserListView+SubViewBuilder.swift in Sources */, 48061E8A6A2CCB8E3B410263 /* GroupBannedUserListView+ViewConverter.swift in Sources */, @@ -7611,7 +7615,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 1.0.2; + MARKETING_VERSION = 1.0.3; PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.swiftui.sample; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -7643,7 +7647,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 1.0.2; + MARKETING_VERSION = 1.0.3; PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.swiftui.sample.SwiftUINotificationService; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -7733,7 +7737,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 1.0.2; + MARKETING_VERSION = 1.0.3; PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.swiftui.sample; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -7820,7 +7824,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 1.0.2; + MARKETING_VERSION = 1.0.3; PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.swiftui.sample.SwiftUINotificationService; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -7877,7 +7881,7 @@ repositoryURL = "https://github.com/sendbird/sendbird-uikit-ios-spm"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 3.30.0; + minimumVersion = 3.30.1; }; }; /* End XCRemoteSwiftPackageReference section */ diff --git a/Sample/QuickStartSwiftUI/CustomSample/CustomSampleSubView.swift b/Sample/QuickStartSwiftUI/CustomSample/CustomSampleSubView.swift index 33a7ba0..2ea7e03 100644 --- a/Sample/QuickStartSwiftUI/CustomSample/CustomSampleSubView.swift +++ b/Sample/QuickStartSwiftUI/CustomSample/CustomSampleSubView.swift @@ -27,6 +27,12 @@ struct CustomSampleSubView: View { Button(action: { Task { await viewModel.loadEnvironment(for: viewItem) + // NOTE: Use the below if you want to change `enableViewAdaptorAutoReset` setting for a specific view. +// if viewItem.viewFullPath == "CustomGroupChannel.ViewConverter.List.fileMessageView" { +// GlobalOptions.enableViewAdaptorAutoReset = false +// } else { +// GlobalOptions.enableViewAdaptorAutoReset = true +// } self.destinationView = AnyView( CustomSampleManager.viewForName(viewItem) .environmentObject(viewModel) diff --git a/Sample/QuickStartSwiftUI/CustomSample/CustomSampleSubViewModel.swift b/Sample/QuickStartSwiftUI/CustomSample/CustomSampleSubViewModel.swift index 87231e7..9a669b1 100644 --- a/Sample/QuickStartSwiftUI/CustomSample/CustomSampleSubViewModel.swift +++ b/Sample/QuickStartSwiftUI/CustomSample/CustomSampleSubViewModel.swift @@ -31,7 +31,9 @@ class CustomSampleSubViewModel: ObservableObject { return } - SBViewConverterSet.resetAll() + // NOTE: No longer need to call this since GlobalOptions.enableViewAdaptorAutoReset was added. + // But use it if you later need it. +// SBViewConverterSet.resetAll() // TODO: messageThread 나 setting 등 처리는 여기서 옵션을 받거나 하는 형태로 처리 switch getRequiredDataContext(viewItem) { diff --git a/Sample/project.yml b/Sample/project.yml index 9d2915d..e7652b4 100644 --- a/Sample/project.yml +++ b/Sample/project.yml @@ -15,7 +15,7 @@ packages: from: 4.25.0 SendbirdUIKit: url: https://github.com/sendbird/sendbird-uikit-ios-spm - from: 3.30.0 + from: 3.30.1 schemes: QuickStartSwiftUI: @@ -43,7 +43,7 @@ settingGroups: FRAMEWORK_SEARCH_PATHS: '' IPHONEOS_DEPLOYMENT_TARGET: '15.0' LD_RUNPATH_SEARCH_PATHS: ["$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks"] - MARKETING_VERSION: '1.0.2' + MARKETING_VERSION: '1.0.3' PRODUCT_NAME: "$(TARGET_NAME)" SDKROOT: iphoneos SWIFT_VERSION: '5.0' diff --git a/SendbirdSwiftUI.podspec b/SendbirdSwiftUI.podspec index e923110..25dcb81 100644 --- a/SendbirdSwiftUI.podspec +++ b/SendbirdSwiftUI.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "SendbirdSwiftUI" - s.version = "1.0.2" + s.version = "1.0.3" s.summary = "Sendbird SwiftUI SDK based on SendbirdChatSDK" s.description = "SendbirdSwiftUI is a framework composed of basic UI components based on SwiftUI and SendbirdChatSDK." s.homepage = "https://sendbird.com" @@ -16,7 +16,7 @@ Pod::Spec.new do |s| "Kai" => "kai.lee@sendbird.com" } s.platform = :ios, "15.0" - s.source = { :http => "https://github.com/sendbird/sendbird-swiftui-ios/releases/download/#{s.version}/SendbirdSwiftUI.zip", :sha1 => "09d1fb86d655f79bcf1186e17fa804293ff3a4cc" } + s.source = { :http => "https://github.com/sendbird/sendbird-swiftui-ios/releases/download/#{s.version}/SendbirdSwiftUI.zip", :sha1 => "7c88cb1fe497fa8a44b0b5e9f890162f15aa544d" } s.ios.vendored_frameworks = 'SendbirdSwiftUI/SendbirdSwiftUI.xcframework' s.ios.frameworks = ["UIKit", "SwiftUI", "Foundation", "CoreData", "SendbirdChatSDK"] s.requires_arc = true diff --git a/Sources/SwiftUI/Common/GlobalOptions.swift b/Sources/SwiftUI/Common/GlobalOptions.swift new file mode 100644 index 0000000..03fded2 --- /dev/null +++ b/Sources/SwiftUI/Common/GlobalOptions.swift @@ -0,0 +1,18 @@ +// +// GlobalOptions.swift +// SendbirdSwiftUI +// +// Created by Celine Moon on 3/18/25. +// + +import Foundation + +/// Class that manages global settings for SendbirdSwiftUI. +/// - Since: 1.0.3 +public class GlobalOptions { + /// Decides whether to reset customized view adaptors whenever SendbirdSwiftUI View's `onDisappear` is called. + /// Set this flag to `false` before a specific SendbirdSwiftUI View appears, if you want to prevent its customized views from resetting, even after its `onDisappear` is called. + /// Set to `true` by default. + /// - Since: 1.0.3 + public static var enableViewAdaptorAutoReset = true +} diff --git a/Sources/SwiftUI/KeyFunctions/CreateGroupChannel/CreateGroupChannelView.swift b/Sources/SwiftUI/KeyFunctions/CreateGroupChannel/CreateGroupChannelView.swift index 7ec8252..457ed64 100644 --- a/Sources/SwiftUI/KeyFunctions/CreateGroupChannel/CreateGroupChannelView.swift +++ b/Sources/SwiftUI/KeyFunctions/CreateGroupChannel/CreateGroupChannelView.swift @@ -50,7 +50,9 @@ public struct CreateGroupChannelView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.CreateGroupChannel = CreateGroupChannelViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.CreateGroupChannel = CreateGroupChannelViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/CreateOpenChannel/CreateOpenChannelView.swift b/Sources/SwiftUI/KeyFunctions/CreateOpenChannel/CreateOpenChannelView.swift index 9025d53..17b63c8 100644 --- a/Sources/SwiftUI/KeyFunctions/CreateOpenChannel/CreateOpenChannelView.swift +++ b/Sources/SwiftUI/KeyFunctions/CreateOpenChannel/CreateOpenChannelView.swift @@ -48,7 +48,9 @@ public struct CreateOpenChannelView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.CreateOpenChannel = CreateOpenChannelViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.CreateOpenChannel = CreateOpenChannelViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/GroupBannedUserList/GroupBannedUserListView.swift b/Sources/SwiftUI/KeyFunctions/GroupBannedUserList/GroupBannedUserListView.swift index 16f9113..e483e9d 100644 --- a/Sources/SwiftUI/KeyFunctions/GroupBannedUserList/GroupBannedUserListView.swift +++ b/Sources/SwiftUI/KeyFunctions/GroupBannedUserList/GroupBannedUserListView.swift @@ -54,7 +54,9 @@ public struct GroupBannedUserListView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.GroupBannedUserList = GroupBannedUserListViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.GroupBannedUserList = GroupBannedUserListViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/GroupChannel/GroupChannelView.swift b/Sources/SwiftUI/KeyFunctions/GroupChannel/GroupChannelView.swift index f1074f7..dd13cf4 100644 --- a/Sources/SwiftUI/KeyFunctions/GroupChannel/GroupChannelView.swift +++ b/Sources/SwiftUI/KeyFunctions/GroupChannel/GroupChannelView.swift @@ -58,7 +58,9 @@ public struct GroupChannelView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.GroupChannel = GroupChannelViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.GroupChannel = GroupChannelViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/GroupChannelList/GroupChannelListView.swift b/Sources/SwiftUI/KeyFunctions/GroupChannelList/GroupChannelListView.swift index b2b830f..d86fb25 100644 --- a/Sources/SwiftUI/KeyFunctions/GroupChannelList/GroupChannelListView.swift +++ b/Sources/SwiftUI/KeyFunctions/GroupChannelList/GroupChannelListView.swift @@ -55,7 +55,9 @@ public struct GroupChannelListView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.GroupChannelList = GroupChannelListViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.GroupChannelList = GroupChannelListViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/GroupChannelPushSettings/GroupChannelPushSettingsView.swift b/Sources/SwiftUI/KeyFunctions/GroupChannelPushSettings/GroupChannelPushSettingsView.swift index 5585e7c..b1f90a6 100644 --- a/Sources/SwiftUI/KeyFunctions/GroupChannelPushSettings/GroupChannelPushSettingsView.swift +++ b/Sources/SwiftUI/KeyFunctions/GroupChannelPushSettings/GroupChannelPushSettingsView.swift @@ -50,7 +50,9 @@ public struct GroupChannelPushSettingsView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.GroupChannelPushSettings = GroupChannelPushSettingsViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.GroupChannelPushSettings = GroupChannelPushSettingsViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/GroupChannelRegisterOperator/GroupChannelRegisterOperatorView.swift b/Sources/SwiftUI/KeyFunctions/GroupChannelRegisterOperator/GroupChannelRegisterOperatorView.swift index 9d567f0..9d488bb 100644 --- a/Sources/SwiftUI/KeyFunctions/GroupChannelRegisterOperator/GroupChannelRegisterOperatorView.swift +++ b/Sources/SwiftUI/KeyFunctions/GroupChannelRegisterOperator/GroupChannelRegisterOperatorView.swift @@ -54,7 +54,9 @@ public struct GroupChannelRegisterOperatorView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.GroupChannelRegisterOperator = GroupChannelRegisterOperatorViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.GroupChannelRegisterOperator = GroupChannelRegisterOperatorViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/GroupChannelSettings/GroupChannelSettingsView.swift b/Sources/SwiftUI/KeyFunctions/GroupChannelSettings/GroupChannelSettingsView.swift index fbae003..a6876a9 100644 --- a/Sources/SwiftUI/KeyFunctions/GroupChannelSettings/GroupChannelSettingsView.swift +++ b/Sources/SwiftUI/KeyFunctions/GroupChannelSettings/GroupChannelSettingsView.swift @@ -50,7 +50,9 @@ public struct GroupChannelSettingsView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.GroupChannelSettings = GroupChannelSettingsViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.GroupChannelSettings = GroupChannelSettingsViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/GroupMemberList/GroupMemberListView.swift b/Sources/SwiftUI/KeyFunctions/GroupMemberList/GroupMemberListView.swift index 1ea1db9..87a0ff4 100644 --- a/Sources/SwiftUI/KeyFunctions/GroupMemberList/GroupMemberListView.swift +++ b/Sources/SwiftUI/KeyFunctions/GroupMemberList/GroupMemberListView.swift @@ -54,7 +54,9 @@ public struct GroupMemberListView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.GroupMemberList = GroupMemberListViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.GroupMemberList = GroupMemberListViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/GroupModerations/GroupModerationsView.swift b/Sources/SwiftUI/KeyFunctions/GroupModerations/GroupModerationsView.swift index 9615e65..83389f3 100644 --- a/Sources/SwiftUI/KeyFunctions/GroupModerations/GroupModerationsView.swift +++ b/Sources/SwiftUI/KeyFunctions/GroupModerations/GroupModerationsView.swift @@ -51,7 +51,9 @@ public struct GroupModerationsView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.GroupModerations = GroupModerationsViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.GroupModerations = GroupModerationsViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/GroupMutedMemberList/GroupMutedMemberListView.swift b/Sources/SwiftUI/KeyFunctions/GroupMutedMemberList/GroupMutedMemberListView.swift index 4150886..96204c1 100644 --- a/Sources/SwiftUI/KeyFunctions/GroupMutedMemberList/GroupMutedMemberListView.swift +++ b/Sources/SwiftUI/KeyFunctions/GroupMutedMemberList/GroupMutedMemberListView.swift @@ -54,7 +54,9 @@ public struct GroupMutedMemberListView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.GroupMutedMemberList = GroupMutedMemberListViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.GroupMutedMemberList = GroupMutedMemberListViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/GroupOperatorList/GroupOperatorListView.swift b/Sources/SwiftUI/KeyFunctions/GroupOperatorList/GroupOperatorListView.swift index 6c74d82..315b57d 100644 --- a/Sources/SwiftUI/KeyFunctions/GroupOperatorList/GroupOperatorListView.swift +++ b/Sources/SwiftUI/KeyFunctions/GroupOperatorList/GroupOperatorListView.swift @@ -54,7 +54,9 @@ public struct GroupOperatorListView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.GroupOperatorList = GroupOperatorListViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.GroupOperatorList = GroupOperatorListViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/InviteUser/InviteUserView.swift b/Sources/SwiftUI/KeyFunctions/InviteUser/InviteUserView.swift index 9f300a5..739bcd7 100644 --- a/Sources/SwiftUI/KeyFunctions/InviteUser/InviteUserView.swift +++ b/Sources/SwiftUI/KeyFunctions/InviteUser/InviteUserView.swift @@ -53,7 +53,9 @@ public struct InviteUserView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.InviteUser = InviteUserViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.InviteUser = InviteUserViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/MessageSearch/MessageSearchView.swift b/Sources/SwiftUI/KeyFunctions/MessageSearch/MessageSearchView.swift index a4264cb..a3cedc1 100644 --- a/Sources/SwiftUI/KeyFunctions/MessageSearch/MessageSearchView.swift +++ b/Sources/SwiftUI/KeyFunctions/MessageSearch/MessageSearchView.swift @@ -51,7 +51,9 @@ public struct MessageSearchView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.MessageSearch = MessageSearchViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.MessageSearch = MessageSearchViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/MessageThread/MessageThreadView.swift b/Sources/SwiftUI/KeyFunctions/MessageThread/MessageThreadView.swift index 7e6cc59..4ad4f81 100644 --- a/Sources/SwiftUI/KeyFunctions/MessageThread/MessageThreadView.swift +++ b/Sources/SwiftUI/KeyFunctions/MessageThread/MessageThreadView.swift @@ -58,7 +58,9 @@ public struct MessageThreadView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.MessageThread = MessageThreadViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.MessageThread = MessageThreadViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/OpenBannedUserList/OpenBannedUserListView.swift b/Sources/SwiftUI/KeyFunctions/OpenBannedUserList/OpenBannedUserListView.swift index 102fc43..bc1c822 100644 --- a/Sources/SwiftUI/KeyFunctions/OpenBannedUserList/OpenBannedUserListView.swift +++ b/Sources/SwiftUI/KeyFunctions/OpenBannedUserList/OpenBannedUserListView.swift @@ -54,7 +54,9 @@ public struct OpenBannedUserListView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.OpenBannedUserList = OpenBannedUserListViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.OpenBannedUserList = OpenBannedUserListViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/OpenChannel/OpenChannelView.swift b/Sources/SwiftUI/KeyFunctions/OpenChannel/OpenChannelView.swift index 8bb7482..acc8eca 100644 --- a/Sources/SwiftUI/KeyFunctions/OpenChannel/OpenChannelView.swift +++ b/Sources/SwiftUI/KeyFunctions/OpenChannel/OpenChannelView.swift @@ -53,7 +53,9 @@ public struct OpenChannelView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.OpenChannel = OpenChannelViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.OpenChannel = OpenChannelViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/OpenChannelList/OpenChannelListView.swift b/Sources/SwiftUI/KeyFunctions/OpenChannelList/OpenChannelListView.swift index 0c6890f..b94ad8c 100644 --- a/Sources/SwiftUI/KeyFunctions/OpenChannelList/OpenChannelListView.swift +++ b/Sources/SwiftUI/KeyFunctions/OpenChannelList/OpenChannelListView.swift @@ -50,7 +50,9 @@ public struct OpenChannelListView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.OpenChannelList = OpenChannelListViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.OpenChannelList = OpenChannelListViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/OpenChannelRegisterOperator/OpenChannelRegisterOperatorView.swift b/Sources/SwiftUI/KeyFunctions/OpenChannelRegisterOperator/OpenChannelRegisterOperatorView.swift index ca5bfe6..d42004c 100644 --- a/Sources/SwiftUI/KeyFunctions/OpenChannelRegisterOperator/OpenChannelRegisterOperatorView.swift +++ b/Sources/SwiftUI/KeyFunctions/OpenChannelRegisterOperator/OpenChannelRegisterOperatorView.swift @@ -54,7 +54,9 @@ public struct OpenChannelRegisterOperatorView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.OpenChannelRegisterOperator = OpenChannelRegisterOperatorViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.OpenChannelRegisterOperator = OpenChannelRegisterOperatorViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/OpenChannelSettings/OpenChannelSettingsView.swift b/Sources/SwiftUI/KeyFunctions/OpenChannelSettings/OpenChannelSettingsView.swift index 0b60a20..345e6d4 100644 --- a/Sources/SwiftUI/KeyFunctions/OpenChannelSettings/OpenChannelSettingsView.swift +++ b/Sources/SwiftUI/KeyFunctions/OpenChannelSettings/OpenChannelSettingsView.swift @@ -51,9 +51,10 @@ public struct OpenChannelSettingsView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.OpenChannelSettings = OpenChannelSettingsViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.OpenChannelSettings = OpenChannelSettingsViewConverter() + } } - } // MARK: - Methods diff --git a/Sources/SwiftUI/KeyFunctions/OpenModerations/OpenModerationsView.swift b/Sources/SwiftUI/KeyFunctions/OpenModerations/OpenModerationsView.swift index d756a60..e181417 100644 --- a/Sources/SwiftUI/KeyFunctions/OpenModerations/OpenModerationsView.swift +++ b/Sources/SwiftUI/KeyFunctions/OpenModerations/OpenModerationsView.swift @@ -51,7 +51,9 @@ public struct OpenModerationsView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.OpenModerations = OpenModerationsViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.OpenModerations = OpenModerationsViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/OpenMutedParticipantList/OpenMutedParticipantListView.swift b/Sources/SwiftUI/KeyFunctions/OpenMutedParticipantList/OpenMutedParticipantListView.swift index 9a9883d..52d8e64 100644 --- a/Sources/SwiftUI/KeyFunctions/OpenMutedParticipantList/OpenMutedParticipantListView.swift +++ b/Sources/SwiftUI/KeyFunctions/OpenMutedParticipantList/OpenMutedParticipantListView.swift @@ -54,7 +54,9 @@ public struct OpenMutedParticipantListView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.OpenMutedParticipantList = OpenMutedParticipantListViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.OpenMutedParticipantList = OpenMutedParticipantListViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/OpenOperatorList/OpenOperatorListView.swift b/Sources/SwiftUI/KeyFunctions/OpenOperatorList/OpenOperatorListView.swift index 1078367..9b43785 100644 --- a/Sources/SwiftUI/KeyFunctions/OpenOperatorList/OpenOperatorListView.swift +++ b/Sources/SwiftUI/KeyFunctions/OpenOperatorList/OpenOperatorListView.swift @@ -54,7 +54,9 @@ public struct OpenOperatorListView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.OpenOperatorList = OpenOperatorListViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.OpenOperatorList = OpenOperatorListViewConverter() + } } } diff --git a/Sources/SwiftUI/KeyFunctions/OpenParticipantList/OpenParticipantListView.swift b/Sources/SwiftUI/KeyFunctions/OpenParticipantList/OpenParticipantListView.swift index 07e413b..009c01b 100644 --- a/Sources/SwiftUI/KeyFunctions/OpenParticipantList/OpenParticipantListView.swift +++ b/Sources/SwiftUI/KeyFunctions/OpenParticipantList/OpenParticipantListView.swift @@ -54,7 +54,9 @@ public struct OpenParticipantListView: View { } .switchUIKitNavigationBar() .onDisappear { - SBViewConverterSet.OpenParticipantList = OpenParticipantListViewConverter() + if GlobalOptions.enableViewAdaptorAutoReset { + SBViewConverterSet.OpenParticipantList = OpenParticipantListViewConverter() + } } } diff --git a/Sources/uikit/View/Channel/CellView/SBUUserMessageTextView.swift b/Sources/uikit/View/Channel/CellView/SBUUserMessageTextView.swift index 398ec27..e964150 100644 --- a/Sources/uikit/View/Channel/CellView/SBUUserMessageTextView.swift +++ b/Sources/uikit/View/Channel/CellView/SBUUserMessageTextView.swift @@ -51,7 +51,7 @@ open class SBUUserMessageTextView: SBUView { public var channelType: ChannelType = .group public var isWebType = false - var longPressHandler: ((URL) -> Void)? + var longPressHandler: ((URL?) -> Void)? public var mentionManager: SBUMentionManager? @@ -222,6 +222,9 @@ open class SBUUserMessageTextView: SBUView { } extension SBUUserMessageTextView: UITextViewDelegate { + + /// Handles tap and longpress on a URL link or a mentioned user for iOS below 17.0. + @available(iOS, deprecated: 17.0) open func textView( _ textView: UITextView, shouldInteractWith URL: URL, @@ -231,18 +234,70 @@ extension SBUUserMessageTextView: UITextViewDelegate { if let mentionManager = mentionManager { if let mention = mentionManager.findMentions(with: characterRange).first, interaction == .invokeDefaultAction { + // Mention tapped self.delegate?.userMessageTextView(self, didTapMention: mention.user) return false } else { + // Mention longpressed (self.superview as? SBUUserMessageCell)?.longPressHandlerToContent?() } } if interaction == .presentActions { + // URL link longpressed self.longPressHandler?(URL) } else if interaction == .invokeDefaultAction { + // URL link tapped URL.open() } return false } + + /// Handles tap on a URL link or a mentioned user for iOS 17.0 or above. + /// - Since: 3.30.1 + @available(iOS 17.0, *) + open func textView( + _ textView: UITextView, + primaryActionFor textItem: UITextItem, + defaultAction: UIAction + ) -> UIAction? { + let characterRange = textItem.range + if let mentionManager = mentionManager { + if let mention = mentionManager.findMentions(with: characterRange).first { + // Mention tapped + return UIAction(title: "Mention Tapped") { _ in + self.delegate?.userMessageTextView(self, didTapMention: mention.user) + } + } + } else if let tappedURL = textView.textStorage.attribute(.link, at: characterRange.location, effectiveRange: nil) as? URL { + // URL link tapped + return UIAction(title: "Link Tapped") { _ in + tappedURL.open() + } + } + + return nil + } + + /// Handles longpress on a URL link or a mentioned user for iOS 17.0 or above. + /// - Since: 3.30.1 + @available(iOS 17.0, *) + open func textView( + _ textView: UITextView, + menuConfigurationFor textItem: UITextItem, + defaultMenu: UIMenu + ) -> UITextItem.MenuConfiguration? { + let characterRange = textItem.range + if let mentionManager = mentionManager { + if mentionManager.findMentions(with: characterRange).first != nil { + // Mention longpressed + self.longPressHandler?(nil) + } + } else if let tappedURL = textView.textStorage.attribute(.link, at: characterRange.location, effectiveRange: nil) as? URL { + // URL link longpressed + self.longPressHandler?(tappedURL) + } + + return nil + } }