8
Podfile
|
|
@ -23,6 +23,7 @@ target 'QuickLocation' do
|
|||
pod 'KingfisherWebP'
|
||||
pod 'Masonry'
|
||||
|
||||
|
||||
#工具
|
||||
#pod 'FLEX', :configurations => ['Debug', 'AdHoc']
|
||||
pod 'HXPHPicker'
|
||||
|
|
@ -30,7 +31,12 @@ target 'QuickLocation' do
|
|||
pod 'SGQRCode', '~> 4.1.0' #扫描
|
||||
#pod 'PGDatePicker'
|
||||
pod 'IQKeyboardManagerSwift'
|
||||
|
||||
pod 'YBImageBrowser'
|
||||
pod 'YBImageBrowser/Video' #视频功能
|
||||
pod 'YYImage' #, :git => 'https://github.com/QiuYeHong90/YYImage.git'
|
||||
pod 'YYImage/WebP'
|
||||
|
||||
|
||||
#UI
|
||||
pod 'SnapKit'
|
||||
pod 'MJRefresh'
|
||||
|
|
|
|||
22
Podfile.lock
|
|
@ -152,6 +152,18 @@ PODS:
|
|||
- SwiftyUserDefaults (5.3.0)
|
||||
- TagListView (1.4.1)
|
||||
- URLNavigator (2.5.1)
|
||||
- YBImageBrowser (3.0.9):
|
||||
- YBImageBrowser/Core (= 3.0.9)
|
||||
- YBImageBrowser/Core (3.0.9):
|
||||
- SDWebImage (>= 5.0.0)
|
||||
- YYImage
|
||||
- YBImageBrowser/Video (3.0.9):
|
||||
- YBImageBrowser/Core
|
||||
- YYImage (1.0.4):
|
||||
- YYImage/Core (= 1.0.4)
|
||||
- YYImage/Core (1.0.4)
|
||||
- YYImage/WebP (1.0.4):
|
||||
- YYImage/Core
|
||||
- ZXSDK (3.3.2)
|
||||
|
||||
DEPENDENCIES:
|
||||
|
|
@ -185,6 +197,10 @@ DEPENDENCIES:
|
|||
- SwiftyUserDefaults
|
||||
- TagListView (~> 1.0)
|
||||
- URLNavigator
|
||||
- YBImageBrowser
|
||||
- YBImageBrowser/Video
|
||||
- YYImage
|
||||
- YYImage/WebP
|
||||
|
||||
SPEC REPOS:
|
||||
https://gitee.com/mirrors/CocoaPods-Specs.git:
|
||||
|
|
@ -234,6 +250,8 @@ SPEC REPOS:
|
|||
- SwiftyUserDefaults
|
||||
- TagListView
|
||||
- URLNavigator
|
||||
- YBImageBrowser
|
||||
- YYImage
|
||||
- ZXSDK
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
|
|
@ -293,8 +311,10 @@ SPEC CHECKSUMS:
|
|||
SwiftyUserDefaults: 63f80248cf5bfb3458825d9a78f2eb7e1293a040
|
||||
TagListView: a1c236d17960a0cf64156725a76ce6d73ebce2be
|
||||
URLNavigator: e9c0426ba6e6ac57f34d018bbf3df840797f984d
|
||||
YBImageBrowser: 7ecc8bf33ffa5f3b94c397c29b4f3638dd37f527
|
||||
YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54
|
||||
ZXSDK: 786338c0a18e98e03eda00699c3bfd2700b97117
|
||||
|
||||
PODFILE CHECKSUM: d9389fd0d3da8895e9ddac8adbec655edaf9bb3d
|
||||
PODFILE CHECKSUM: 7834e369bb92eca27bfaa0253f39e8e939801cd4
|
||||
|
||||
COCOAPODS: 1.16.2
|
||||
|
|
|
|||
|
|
@ -189,6 +189,8 @@
|
|||
30DC185C2FD11E7A0041DCD1 /* WebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30DC18572FD11E7A0041DCD1 /* WebViewController.swift */; };
|
||||
30DC185E2FD1211D0041DCD1 /* VipRightsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30DC185D2FD1211D0041DCD1 /* VipRightsVC.swift */; };
|
||||
30DC18602FD12A020041DCD1 /* VipWaivePopView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30DC185F2FD12A020041DCD1 /* VipWaivePopView.swift */; };
|
||||
30EFF2992FD65FB000EB35D4 /* VoicePlayerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30EFF2982FD65FB000EB35D4 /* VoicePlayerManager.swift */; };
|
||||
30EFF29B2FD668C900EB35D4 /* VoiceRecordView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30EFF29A2FD668C900EB35D4 /* VoiceRecordView.swift */; };
|
||||
C49B37352A45A02C28FF41BA /* Pods_QuickLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D1C77B42994F352054070537 /* Pods_QuickLocation.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
|
|
@ -383,6 +385,8 @@
|
|||
30DC18572FD11E7A0041DCD1 /* WebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewController.swift; sourceTree = "<group>"; };
|
||||
30DC185D2FD1211D0041DCD1 /* VipRightsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VipRightsVC.swift; sourceTree = "<group>"; };
|
||||
30DC185F2FD12A020041DCD1 /* VipWaivePopView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VipWaivePopView.swift; sourceTree = "<group>"; };
|
||||
30EFF2982FD65FB000EB35D4 /* VoicePlayerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoicePlayerManager.swift; sourceTree = "<group>"; };
|
||||
30EFF29A2FD668C900EB35D4 /* VoiceRecordView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceRecordView.swift; sourceTree = "<group>"; };
|
||||
3E4359082FC48D26003470A5 /* QuickLocation.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QuickLocation.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
93647DF3683AA5E71EC2FB1A /* Pods-QuickLocation.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-QuickLocation.release.xcconfig"; path = "Target Support Files/Pods-QuickLocation/Pods-QuickLocation.release.xcconfig"; sourceTree = "<group>"; };
|
||||
D1C77B42994F352054070537 /* Pods_QuickLocation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_QuickLocation.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
|
@ -392,6 +396,8 @@
|
|||
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
||||
3070777D2FD2A214004C37CC /* lotties */ = {
|
||||
isa = PBXFileSystemSynchronizedRootGroup;
|
||||
exceptions = (
|
||||
);
|
||||
path = lotties;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
|
|
@ -1031,6 +1037,8 @@
|
|||
307073E22FD18A20004C37CC /* GroupChatVC.swift */,
|
||||
307073E32FD18A20004C37CC /* GroupChatView.swift */,
|
||||
307073E92FD2715A004C37CC /* GroupChatViewModel.swift */,
|
||||
30EFF2982FD65FB000EB35D4 /* VoicePlayerManager.swift */,
|
||||
30EFF29A2FD668C900EB35D4 /* VoiceRecordView.swift */,
|
||||
);
|
||||
path = GroupChat;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -1208,14 +1216,10 @@
|
|||
inputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-QuickLocation/Pods-QuickLocation-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-QuickLocation/Pods-QuickLocation-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-QuickLocation/Pods-QuickLocation-frameworks.sh\"\n";
|
||||
|
|
@ -1229,14 +1233,10 @@
|
|||
inputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-QuickLocation/Pods-QuickLocation-resources-${CONFIGURATION}-input-files.xcfilelist",
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-QuickLocation/Pods-QuickLocation-resources-${CONFIGURATION}-output-files.xcfilelist",
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-QuickLocation/Pods-QuickLocation-resources.sh\"\n";
|
||||
|
|
@ -1368,6 +1368,7 @@
|
|||
305A76E92FCA8C7000227D26 /* LoginViewModel.swift in Sources */,
|
||||
3062E8BC2FCEAC7100CEF511 /* CreateGroupVC.swift in Sources */,
|
||||
30BAB8632FCD716C00C33B5C /* JoinGroupVC.swift in Sources */,
|
||||
30EFF2992FD65FB000EB35D4 /* VoicePlayerManager.swift in Sources */,
|
||||
305A76EA2FCA8C7000227D26 /* OneTapLoginView.swift in Sources */,
|
||||
305A76EB2FCA8C7000227D26 /* CircleMember.swift in Sources */,
|
||||
305A76EC2FCA8C7000227D26 /* MemberAnnotation.swift in Sources */,
|
||||
|
|
@ -1414,6 +1415,7 @@
|
|||
307073EA2FD2715A004C37CC /* GroupChatViewModel.swift in Sources */,
|
||||
305A770E2FCA8C7000227D26 /* DLAlertPopVC.swift in Sources */,
|
||||
305A770F2FCA8C7000227D26 /* DLCustomPopVC.swift in Sources */,
|
||||
30EFF29B2FD668C900EB35D4 /* VoiceRecordView.swift in Sources */,
|
||||
305A77102FCA8C7000227D26 /* DLSheetPopVC.swift in Sources */,
|
||||
305A77112FCA8C7000227D26 /* DLViewTransition.m in Sources */,
|
||||
3062E8BA2FCEAC6500CEF511 /* CreateGroupView.swift in Sources */,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Plus@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Plus@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_2164@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_2164@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 6.2 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_2168@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_2168@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Icons_Photo@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Icons_Photo@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_2166@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_2166@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Mask_group@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Mask_group@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 8.9 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
|
@ -2,15 +2,22 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>您的相机将被用于扫描二维码、拍摄照片和视频。</string>
|
||||
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
|
||||
<string>需要获取您的位置信息以在地图上显示您的位置</string>
|
||||
<key>NSLocationWhenInUseUsageDescription</key>
|
||||
<string>需要获取您的位置信息以在地图上显示您的位置</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>我们需要使用您的麦克风,以便您使用麦克风进行音频录制。</string>
|
||||
<key>UIAppFonts</key>
|
||||
<array>
|
||||
<string>douyu.otf</string>
|
||||
</array>
|
||||
<key>NSLocationWhenInUseUsageDescription</key>
|
||||
<string>需要获取您的位置信息以在地图上显示您的位置</string>
|
||||
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
|
||||
<string>需要获取您的位置信息以在地图上显示您的位置</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
import UIKit
|
||||
import RxCocoa
|
||||
import RxSwift
|
||||
import YBImageBrowser
|
||||
#if DEBUG || AdHoc
|
||||
//import FLEX
|
||||
#endif
|
||||
|
|
@ -158,36 +159,36 @@ extension BaseViewController {
|
|||
// MARK: - 查看大图
|
||||
extension BaseViewController {
|
||||
func showBigImage(imgUrlList: [String], currentPage: Int, projectiveView: UIView?=nil) {
|
||||
// var tempProjectiveView = projectiveView
|
||||
// if tempProjectiveView == nil {
|
||||
// tempProjectiveView = UIView(frame: CGRect(origin: CGPoint(x: kScreenWidth * 0.5, y: kScreenHeight), size: CGSize(width: 1, height: 1)))
|
||||
// }
|
||||
// var datas: [YBIBDataProtocol] = []
|
||||
// GlobalAsync {
|
||||
// for mediaUrl in imgUrlList {
|
||||
// // 网络视频
|
||||
// if mediaUrl.hasSuffix(".mp4") {
|
||||
// let videoData = YBIBVideoData()
|
||||
// videoData.videoURL = URL(string: mediaUrl)
|
||||
// videoData.projectiveView = tempProjectiveView
|
||||
// datas.append(videoData)
|
||||
// }
|
||||
// // 网络图片
|
||||
// else if mediaUrl.hasPrefix("http") {
|
||||
// let imageData = YBIBImageData()
|
||||
// imageData.imageURL = URL(string: mediaUrl)
|
||||
// imageData.projectiveView = tempProjectiveView
|
||||
// datas.append(imageData)
|
||||
// }
|
||||
// }
|
||||
// MainAsync {
|
||||
// // 预览图片/视频
|
||||
// let browser = YBImageBrowser()
|
||||
// browser.dataSourceArray = datas
|
||||
// browser.currentPage = currentPage
|
||||
// browser.show()
|
||||
// }
|
||||
// }
|
||||
var tempProjectiveView = projectiveView
|
||||
if tempProjectiveView == nil {
|
||||
tempProjectiveView = UIView(frame: CGRect(origin: CGPoint(x: kScreenWidth * 0.5, y: kScreenHeight), size: CGSize(width: 1, height: 1)))
|
||||
}
|
||||
var datas: [YBIBDataProtocol] = []
|
||||
GlobalAsync {
|
||||
for mediaUrl in imgUrlList {
|
||||
// 网络视频
|
||||
if mediaUrl.hasSuffix(".mp4") {
|
||||
let videoData = YBIBVideoData()
|
||||
videoData.videoURL = URL(string: mediaUrl)
|
||||
videoData.projectiveView = tempProjectiveView
|
||||
datas.append(videoData)
|
||||
}
|
||||
// 网络图片
|
||||
else if mediaUrl.hasPrefix("http") {
|
||||
let imageData = YBIBImageData()
|
||||
imageData.imageURL = URL(string: mediaUrl)
|
||||
imageData.projectiveView = tempProjectiveView
|
||||
datas.append(imageData)
|
||||
}
|
||||
}
|
||||
MainAsync {
|
||||
// 预览图片/视频
|
||||
let browser = YBImageBrowser()
|
||||
browser.dataSourceArray = datas
|
||||
browser.currentPage = currentPage
|
||||
browser.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -208,36 +209,36 @@ extension BaseViewController {
|
|||
// MAKR: - UIView查看大图
|
||||
extension UIView {
|
||||
func showBigImage(imgUrlList: [String], currentPage: Int, projectiveView: UIView?=nil) {
|
||||
// var tempProjectiveView = projectiveView
|
||||
// if tempProjectiveView == nil {
|
||||
// tempProjectiveView = UIView(frame: CGRect(origin: CGPoint(x: kScreenWidth * 0.5, y: kScreenHeight), size: CGSize(width: 1, height: 1)))
|
||||
// }
|
||||
// var datas: [YBIBDataProtocol] = []
|
||||
// GlobalAsync {
|
||||
// for mediaUrl in imgUrlList {
|
||||
// // 网络视频
|
||||
// if mediaUrl.hasSuffix(".mp4") {
|
||||
// let videoData = YBIBVideoData()
|
||||
// videoData.videoURL = URL(string: mediaUrl)
|
||||
// videoData.projectiveView = tempProjectiveView
|
||||
// datas.append(videoData)
|
||||
// }
|
||||
// // 网络图片
|
||||
// else if mediaUrl.hasPrefix("http") {
|
||||
// let imageData = YBIBImageData()
|
||||
// imageData.imageURL = URL(string: mediaUrl)
|
||||
// imageData.projectiveView = tempProjectiveView
|
||||
// datas.append(imageData)
|
||||
// }
|
||||
// }
|
||||
// MainAsync {
|
||||
// // 预览图片/视频
|
||||
// let browser = YBImageBrowser()
|
||||
// browser.dataSourceArray = datas
|
||||
// browser.currentPage = currentPage
|
||||
// browser.show()
|
||||
// }
|
||||
// }
|
||||
var tempProjectiveView = projectiveView
|
||||
if tempProjectiveView == nil {
|
||||
tempProjectiveView = UIView(frame: CGRect(origin: CGPoint(x: kScreenWidth * 0.5, y: kScreenHeight), size: CGSize(width: 1, height: 1)))
|
||||
}
|
||||
var datas: [YBIBDataProtocol] = []
|
||||
GlobalAsync {
|
||||
for mediaUrl in imgUrlList {
|
||||
// 网络视频
|
||||
if mediaUrl.hasSuffix(".mp4") {
|
||||
let videoData = YBIBVideoData()
|
||||
videoData.videoURL = URL(string: mediaUrl)
|
||||
videoData.projectiveView = tempProjectiveView
|
||||
datas.append(videoData)
|
||||
}
|
||||
// 网络图片
|
||||
else if mediaUrl.hasPrefix("http") {
|
||||
let imageData = YBIBImageData()
|
||||
imageData.imageURL = URL(string: mediaUrl)
|
||||
imageData.projectiveView = tempProjectiveView
|
||||
datas.append(imageData)
|
||||
}
|
||||
}
|
||||
MainAsync {
|
||||
// 预览图片/视频
|
||||
let browser = YBImageBrowser()
|
||||
browser.dataSourceArray = datas
|
||||
browser.currentPage = currentPage
|
||||
browser.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import RxSwift
|
|||
import RxCocoa
|
||||
import RxDataSources
|
||||
import OpenIMSDK
|
||||
import AVFoundation
|
||||
import AudioToolbox
|
||||
|
||||
final class GroupChatVC: BaseViewController {
|
||||
|
||||
|
|
@ -36,10 +38,30 @@ final class GroupChatVC: BaseViewController {
|
|||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
fd_interactivePopDisabled = true
|
||||
bindViewModel()
|
||||
requestGroupInfoByKey()
|
||||
reactiveAction()
|
||||
setupMessageListener()
|
||||
setupVoiceRecording()
|
||||
setupPanelDismiss()
|
||||
}
|
||||
|
||||
private func setupPanelDismiss() {
|
||||
// 用户开始拖拽 tableview 时收起面板
|
||||
rootView.tableView.panGestureRecognizer.rx.event
|
||||
.filter { $0.state == .began }
|
||||
.subscribe(onNext: { [weak self] _ in
|
||||
self?.rootView.dismissAllPanels()
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
// 点击 cell 收起面板
|
||||
rootView.tableView.rx.itemSelected
|
||||
.subscribe(onNext: { [weak self] _ in
|
||||
self?.rootView.dismissAllPanels()
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
// MARK: - Bindings
|
||||
|
|
@ -75,6 +97,11 @@ final class GroupChatVC: BaseViewController {
|
|||
}
|
||||
}
|
||||
|
||||
override func viewWillDisappear(_ animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
VoicePlayerManager.shared.stop()
|
||||
}
|
||||
|
||||
private func scrollToBottom() {
|
||||
let count = dataSource.sectionModels.first?.items.count ?? 0
|
||||
guard count > 0 else { return }
|
||||
|
|
@ -113,6 +140,14 @@ final class GroupChatVC: BaseViewController {
|
|||
let cell: VoiceReceivedMsgCell = tableView.dequeueReusableCell(for: indexPath)
|
||||
cell.configure(msg)
|
||||
return cell
|
||||
case let .imageSend(msg):
|
||||
let cell: ImageSendMsgCell = tableView.dequeueReusableCell(for: indexPath)
|
||||
cell.configure(msg)
|
||||
return cell
|
||||
case let .imageReceived(msg):
|
||||
let cell: ImageReceivedMsgCell = tableView.dequeueReusableCell(for: indexPath)
|
||||
cell.configure(msg)
|
||||
return cell
|
||||
case let .notification(text):
|
||||
let cell: NotificationMsgCell = tableView.dequeueReusableCell(for: indexPath)
|
||||
cell.configure(text)
|
||||
|
|
@ -153,10 +188,12 @@ final class GroupChatVC: BaseViewController {
|
|||
guard let self = self else { return }
|
||||
let show = self.rootView.emojiPanelView.isHidden
|
||||
self.rootView.emojiPanelView.isHidden = !show
|
||||
let offset: CGFloat = show ? -220 : 0
|
||||
let offset: CGFloat = show ? 220 : 0
|
||||
UIView.animate(withDuration: 0.25) {
|
||||
self.rootView.bottomBar.transform = CGAffineTransform(translationX: 0, y: offset)
|
||||
self.rootView.tableView.transform = CGAffineTransform(translationX: 0, y: offset)
|
||||
self.rootView.bottomBar.layoutChain.bottom(kSafeBottomMargin + 20 + offset)
|
||||
} completion: { _ in
|
||||
let offset: CGFloat = self.rootView.tableView.contentSize.height
|
||||
self.rootView.tableView.setContentOffset(CGPointMake(0, offset), animated: false)
|
||||
}
|
||||
if show {
|
||||
self.rootView.textField.resignFirstResponder()
|
||||
|
|
@ -172,6 +209,8 @@ final class GroupChatVC: BaseViewController {
|
|||
})
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
|
||||
|
||||
let sendText = Observable.merge(
|
||||
rootView.sendBtn.rx.tap.map { [weak self] _ in self?.rootView.textField.text ?? "" },
|
||||
rootView.textField.rx.controlEvent(.editingDidEndOnExit)
|
||||
|
|
@ -185,6 +224,103 @@ final class GroupChatVC: BaseViewController {
|
|||
.disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
// MARK: - Voice Recording
|
||||
private var audioRecorder: AVAudioRecorder?
|
||||
private var recordFileURL: URL?
|
||||
private var recordTimer: Timer?
|
||||
private var recordDuration: Int = 0
|
||||
private func setupVoiceRecording() {
|
||||
let longPress = UILongPressGestureRecognizer(target: self, action: #selector(handleVoiceLongPress(_:)))
|
||||
longPress.minimumPressDuration = 0.2
|
||||
rootView.voiceRecordView.speakBtn.addGestureRecognizer(longPress)
|
||||
}
|
||||
|
||||
@objc private func handleVoiceLongPress(_ gesture: UILongPressGestureRecognizer) {
|
||||
let location = gesture.location(in: rootView.voiceRecordView)
|
||||
let btnCenterX = rootView.voiceRecordView.speakBtn.center.x
|
||||
let isCancel = location.x < btnCenterX - 100
|
||||
|
||||
switch gesture.state {
|
||||
case .began:
|
||||
AudioServicesPlaySystemSound(1519)
|
||||
rootView.voiceRecordView.state = .recording
|
||||
startRecording()
|
||||
case .changed:
|
||||
let wasRecording = rootView.voiceRecordView.state == .recording
|
||||
rootView.voiceRecordView.state = isCancel ? .canceling : .recording
|
||||
rootView.voiceRecordView.cancelBtn.isSelected = isCancel
|
||||
if isCancel && wasRecording {
|
||||
AudioServicesPlaySystemSound(1519)
|
||||
}
|
||||
case .ended:
|
||||
stopRecording(cancel: isCancel)
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
private func startRecording() {
|
||||
let session = AVAudioSession.sharedInstance()
|
||||
try? session.setCategory(.playAndRecord, mode: .default)
|
||||
try? session.setActive(true)
|
||||
|
||||
let dir = NSTemporaryDirectory()
|
||||
let filename = "voice_\(Int(Date().timeIntervalSince1970)).wav"
|
||||
recordFileURL = URL(fileURLWithPath: dir + filename)
|
||||
|
||||
let settings: [String: Any] = [
|
||||
AVFormatIDKey: kAudioFormatLinearPCM,
|
||||
AVSampleRateKey: 8000,
|
||||
AVNumberOfChannelsKey: 1,
|
||||
AVLinearPCMBitDepthKey: 16,
|
||||
AVLinearPCMIsFloatKey: false
|
||||
]
|
||||
|
||||
guard let url = recordFileURL else { return }
|
||||
audioRecorder = try? AVAudioRecorder(url: url, settings: settings)
|
||||
audioRecorder?.record()
|
||||
|
||||
recordDuration = 0
|
||||
recordTimer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { [weak self] _ in
|
||||
self?.recordDuration += 1
|
||||
}
|
||||
}
|
||||
|
||||
private func stopRecording(cancel: Bool) {
|
||||
audioRecorder?.stop()
|
||||
recordTimer?.invalidate()
|
||||
recordTimer = nil
|
||||
rootView.voiceRecordView.stopRotating()
|
||||
|
||||
try? AVAudioSession.sharedInstance().setActive(false)
|
||||
|
||||
if cancel {
|
||||
self.rootView.voiceRecordView.cancelBtn.isSelected = false
|
||||
if let url = recordFileURL { try? FileManager.default.removeItem(at: url) }
|
||||
return
|
||||
}
|
||||
|
||||
guard let url = recordFileURL, recordDuration >= 1 else {
|
||||
DLToast.show(text: "说话时间太短")
|
||||
if let url = recordFileURL { try? FileManager.default.removeItem(at: url) }
|
||||
return
|
||||
}
|
||||
|
||||
// Send voice message via OpenIM
|
||||
let msg = OIMMessageInfo.createSoundMessage(fromFullPath: url.path, duration: recordDuration * 1000)
|
||||
OIMManager.manager.sendMessage(msg,
|
||||
recvID: "",
|
||||
groupID: viewModel.groupId,
|
||||
offlinePushInfo: nil,
|
||||
onSuccess: { [weak self] _ in
|
||||
self?.viewModel.onReceiveMessage(msg)
|
||||
},
|
||||
onProgress: nil as OIMNumberCallback?,
|
||||
onFailure: { code, errMsg in
|
||||
print("Voice send failed: \(code) \(errMsg ?? "")")
|
||||
})
|
||||
}
|
||||
|
||||
// MARK: - API
|
||||
private func requestGroupInfoByKey() {
|
||||
GroupService.groupInfoByKey(viewModel.groupId).subscribe { response in
|
||||
|
|
|
|||
|
|
@ -9,6 +9,13 @@ import UIKit
|
|||
import RxSwift
|
||||
import RxCocoa
|
||||
import Lottie
|
||||
import AVFoundation
|
||||
|
||||
enum VoiceRecordState {
|
||||
case began
|
||||
case canceling
|
||||
case ended(URL?) // nil = cancelled
|
||||
}
|
||||
|
||||
// MARK: - Message Model
|
||||
struct ChatMessage {
|
||||
|
|
@ -17,6 +24,10 @@ struct ChatMessage {
|
|||
let avatar: UIImage
|
||||
let senderName: String
|
||||
let content: String
|
||||
let voiceUrl: String
|
||||
let imageUrl: String
|
||||
let imageWidth: CGFloat
|
||||
let imageHeight: CGFloat
|
||||
let timestamp: TimeInterval
|
||||
var showTime: Bool = false
|
||||
}
|
||||
|
|
@ -29,7 +40,61 @@ class GroupChatView: UIView {
|
|||
var scrollToBottom: (() -> Void)?
|
||||
/// bottomBar 底部约束
|
||||
var bottomBarBottomConstraint: NSLayoutConstraint?
|
||||
/// 语音录制回调
|
||||
var onVoiceRecordState: ((VoiceRecordState) -> Void)?
|
||||
|
||||
private func setupRx() {
|
||||
voiceBtn.rx.tap.subscribe(onNext: { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
let status = AVCaptureDevice.authorizationStatus(for: .audio)
|
||||
switch status {
|
||||
case .authorized:
|
||||
break
|
||||
case .notDetermined:
|
||||
AVAudioSession.sharedInstance().requestRecordPermission { granted in
|
||||
guard granted else { return }
|
||||
DispatchQueue.main.async {
|
||||
self.toggleVoicePanel()
|
||||
}
|
||||
}
|
||||
return
|
||||
default:
|
||||
Permission.openAppSetting(title: "请开启麦克风权限",
|
||||
message: "请在iPhone的“设置-隐私-麦克风”选项中允许\(kAppName)访问你的麦克风。")
|
||||
return
|
||||
}
|
||||
self.toggleVoicePanel()
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
private func toggleVoicePanel() {
|
||||
let show = voiceRecordView.isHidden
|
||||
voiceRecordView.isHidden = !show
|
||||
let offset: CGFloat = show ? 252 : 0
|
||||
UIView.animate(withDuration: 0.25) {
|
||||
self.bottomBar.layoutChain.bottom(show ? offset - self.bottomBar.dl.height : kSafeBottomMargin + 20)
|
||||
self.voiceRecordView.layoutChain.bottom(offset - 252 + kSafeBottomMargin)
|
||||
} completion: { _ in
|
||||
let offset: CGFloat = self.tableView.contentSize.height
|
||||
self.tableView.setContentOffset(CGPointMake(0, offset), animated: false)
|
||||
}
|
||||
}
|
||||
|
||||
/// 收起所有浮层面板
|
||||
func dismissAllPanels() {
|
||||
let needsReset = !emojiPanelView.isHidden || !voiceRecordView.isHidden || !voiceRecordView.isHidden
|
||||
guard needsReset else { return }
|
||||
emojiPanelView.isHidden = true
|
||||
voiceRecordView.isHidden = true
|
||||
textField.resignFirstResponder()
|
||||
UIView.animate(withDuration: 0.25) {
|
||||
self.bottomBar.layoutChain.bottom(kSafeBottomMargin + 20)
|
||||
self.voiceRecordView.layoutChain.bottom(-252)
|
||||
self.layoutIfNeeded()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Setup
|
||||
private func setupUI() {
|
||||
backgroundColor = UIColor(hexStr: "#F5FBFB")
|
||||
|
|
@ -48,6 +113,7 @@ class GroupChatView: UIView {
|
|||
addSubview(tableView)
|
||||
addSubview(bottomBar)
|
||||
bottomBar.addSubview(bottomBarCornerView)
|
||||
addSubview(voiceRecordView)
|
||||
addSubview(emojiPanelView)
|
||||
emojiPanelView.addSubview(emojiCollectionView)
|
||||
emojiPanelView.addSubview(emojiPageControl)
|
||||
|
|
@ -141,6 +207,12 @@ class GroupChatView: UIView {
|
|||
.centerY()
|
||||
.height(36)
|
||||
|
||||
voiceRecordView.layoutChain
|
||||
.edgesHorzontal()
|
||||
.bottom(-252)
|
||||
.height(252)
|
||||
// .heightToWidth(252/375)
|
||||
|
||||
emojiPanelView.layoutChain
|
||||
.edgesHorzontal()
|
||||
.bottom()
|
||||
|
|
@ -237,6 +309,8 @@ class GroupChatView: UIView {
|
|||
tv.register(EmojiReceivedMsgCell.self)
|
||||
tv.register(VoiceSendMsgCell.self)
|
||||
tv.register(VoiceReceivedMsgCell.self)
|
||||
tv.register(ImageSendMsgCell.self)
|
||||
tv.register(ImageReceivedMsgCell.self)
|
||||
tv.register(NotificationMsgCell.self)
|
||||
tv.rowHeight = UITableView.automaticDimension
|
||||
tv.contentInset = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0)
|
||||
|
|
@ -303,6 +377,13 @@ class GroupChatView: UIView {
|
|||
return btn
|
||||
}()
|
||||
|
||||
/// 语音面板
|
||||
lazy var voiceRecordView: VoiceRecordView = {
|
||||
let v = VoiceRecordView()
|
||||
v.isHidden = true
|
||||
return v
|
||||
}()
|
||||
|
||||
// MARK: - 表情面板
|
||||
lazy var emojiPanelView: UIView = {
|
||||
let v = UIView()
|
||||
|
|
@ -346,6 +427,7 @@ class GroupChatView: UIView {
|
|||
super.init(frame: .zero)
|
||||
backgroundColor = .clear
|
||||
setupUI()
|
||||
setupRx()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
|
|
@ -849,7 +931,7 @@ final class EmojiPanelCell: UICollectionViewCell {
|
|||
}
|
||||
|
||||
// MARK: - 发送的语音消息
|
||||
final class VoiceSendMsgCell: UITableViewCell {
|
||||
final class VoiceSendMsgCell: UITableViewCell, VoicePlaybackView {
|
||||
|
||||
private let timeLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
|
|
@ -889,7 +971,7 @@ final class VoiceSendMsgCell: UITableViewCell {
|
|||
private let durationLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 14)
|
||||
label.textColor = .white
|
||||
label.textColor = UIColor(hexStr: "#1A1A1A")
|
||||
return label
|
||||
}()
|
||||
|
||||
|
|
@ -912,17 +994,17 @@ final class VoiceSendMsgCell: UITableViewCell {
|
|||
.right(12).width(30).height(30)
|
||||
|
||||
bubbleView.layoutChain
|
||||
.topToView(avatarView, offset: -15)
|
||||
.topToBottomOfView(avatarView, offset: -15)
|
||||
.rightToView(avatarView, offset: -13)
|
||||
.width(105).height(39).bottom(10)
|
||||
|
||||
|
||||
playAnimation.layoutChain
|
||||
.right(36)
|
||||
.centerY()
|
||||
.width(20).height(20)
|
||||
|
||||
durationLabel.layoutChain
|
||||
.leftToRightOfView(playAnimation, offset: 4)
|
||||
.rightToLeftOfView(playAnimation, offset: -4)
|
||||
.centerY()
|
||||
}
|
||||
|
||||
|
|
@ -936,16 +1018,29 @@ final class VoiceSendMsgCell: UITableViewCell {
|
|||
avatarView.image = msg.avatar
|
||||
let dur = msg.content.int / 1000
|
||||
durationLabel.text = dur > 0 ? "\(dur)''" : ""
|
||||
voiceUrl = msg.voiceUrl
|
||||
}
|
||||
|
||||
private var voiceUrl: String?
|
||||
|
||||
@objc private func togglePlay() {
|
||||
if playAnimation.isAnimationPlaying {
|
||||
guard let url = voiceUrl, !url.isEmpty else { return }
|
||||
if VoicePlayerManager.shared.state == .playing, VoicePlayerManager.shared.isCurrent(url: url) {
|
||||
VoicePlayerManager.shared.pause()
|
||||
playAnimation.stop()
|
||||
} else {
|
||||
playAnimation.play()
|
||||
VoicePlayerManager.shared.play(urlString: url, playbackView: self) { [weak self] state in
|
||||
if state == .paused { self?.playAnimation.stop() }
|
||||
else { self?.playAnimation.play() }
|
||||
} onFinished: { [weak self] in
|
||||
self?.playAnimation.stop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func play() { playAnimation.play() }
|
||||
func stop() { playAnimation.stop() }
|
||||
|
||||
override func prepareForReuse() {
|
||||
super.prepareForReuse()
|
||||
playAnimation.stop()
|
||||
|
|
@ -973,8 +1068,50 @@ final class VoiceSendMsgCell: UITableViewCell {
|
|||
}
|
||||
|
||||
// MARK: - 收到的语音消息
|
||||
final class VoiceReceivedMsgCell: UITableViewCell {
|
||||
final class VoiceReceivedMsgCell: UITableViewCell, VoicePlaybackView {
|
||||
|
||||
func configure(_ msg: ChatMessage) {
|
||||
timeLabel.isHidden = !msg.showTime
|
||||
timeLabel.text = msg.showTime ? formatTime(msg.timestamp) : nil
|
||||
avatarView.image = msg.avatar
|
||||
nameLabel.text = msg.senderName
|
||||
let dur = msg.content.int / 1000
|
||||
durationLabel.text = dur > 0 ? "\(dur)''" : ""
|
||||
voiceUrl = msg.voiceUrl
|
||||
}
|
||||
|
||||
private var voiceUrl: String?
|
||||
|
||||
@objc private func togglePlay() {
|
||||
guard let url = voiceUrl, !url.isEmpty else { return }
|
||||
if VoicePlayerManager.shared.state == .playing, VoicePlayerManager.shared.isCurrent(url: url) {
|
||||
VoicePlayerManager.shared.pause()
|
||||
playAnimation.stop()
|
||||
} else {
|
||||
VoicePlayerManager.shared.play(urlString: url, playbackView: self) { [weak self] state in
|
||||
if state == .paused { self?.playAnimation.stop() }
|
||||
else { self?.playAnimation.play() }
|
||||
} onFinished: { [weak self] in
|
||||
self?.playAnimation.stop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func play() { playAnimation.play() }
|
||||
func stop() { playAnimation.stop() }
|
||||
|
||||
private func formatTime(_ t: TimeInterval) -> String {
|
||||
let date = Date(timeIntervalSince1970: t)
|
||||
let now = Date()
|
||||
let calendar = Calendar.current
|
||||
let f = DateFormatter()
|
||||
if calendar.isDateInToday(date) { f.dateFormat = "HH:mm" }
|
||||
else if calendar.isDateInYesterday(date) { f.dateFormat = "'昨天' HH:mm" }
|
||||
else if calendar.isDate(date, equalTo: now, toGranularity: .year) { f.dateFormat = "M-d HH:mm" }
|
||||
else { f.dateFormat = "yyyy-M-d HH:mm" }
|
||||
return f.string(from: date)
|
||||
}
|
||||
|
||||
private let timeLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 12)
|
||||
|
|
@ -1004,7 +1141,6 @@ final class VoiceReceivedMsgCell: UITableViewCell {
|
|||
private let bubbleView: UIView = {
|
||||
let v = UIView()
|
||||
v.backgroundColor = UIColor(hexStr: "#CCEAFF")
|
||||
v.cornerRadius = 8
|
||||
return v
|
||||
}()
|
||||
|
||||
|
|
@ -1015,6 +1151,7 @@ final class VoiceReceivedMsgCell: UITableViewCell {
|
|||
}
|
||||
v.loopMode = .loop
|
||||
v.contentMode = .scaleAspectFit
|
||||
v.transform = CGAffineTransform(rotationAngle: .pi)
|
||||
return v
|
||||
}()
|
||||
|
||||
|
|
@ -1071,26 +1208,41 @@ final class VoiceReceivedMsgCell: UITableViewCell {
|
|||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func prepareForReuse() {
|
||||
super.prepareForReuse()
|
||||
playAnimation.stop()
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
bubbleView.setNeedsLayout()
|
||||
bubbleView.layoutIfNeeded()
|
||||
bubbleView.setCornerRadius(corners: [.topLeft , .topRight, .bottomRight],
|
||||
withCornerRadii: CGSize(width: bubbleView.dl.height / 2, height: bubbleView.dl.height / 2))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - 发送的图片消息
|
||||
final class ImageSendMsgCell: UITableViewCell {
|
||||
|
||||
func configure(_ msg: ChatMessage) {
|
||||
timeLabel.isHidden = !msg.showTime
|
||||
timeLabel.text = msg.showTime ? formatTime(msg.timestamp) : nil
|
||||
avatarView.image = msg.avatar
|
||||
nameLabel.text = msg.senderName
|
||||
let dur = msg.content.int / 1000
|
||||
durationLabel.text = dur > 0 ? "\(dur)''" : ""
|
||||
}
|
||||
|
||||
@objc func togglePlay() {
|
||||
if playAnimation.isAnimationPlaying {
|
||||
playAnimation.stop()
|
||||
} else {
|
||||
playAnimation.play()
|
||||
if !msg.imageUrl.isEmpty {
|
||||
photoView.dl.setImage(with: msg.imageUrl)
|
||||
}
|
||||
photoView.layoutChain.width(msg.imageWidth).height(msg.imageHeight)
|
||||
}
|
||||
|
||||
override func prepareForReuse() {
|
||||
super.prepareForReuse()
|
||||
playAnimation.stop()
|
||||
private static func displaySize(w: CGFloat, h: CGFloat) -> CGSize {
|
||||
guard w > 0, h > 0 else { return CGSize(width: 160, height: 160) }
|
||||
let maxW: CGFloat = 200, maxH: CGFloat = 250, minW: CGFloat = 80
|
||||
var dw = maxW, dh = dw * (h / w)
|
||||
if dh > maxH { dh = maxH; dw = dh * (w / h) }
|
||||
if dw < minW { dw = minW; dh = dw * (h / w) }
|
||||
return CGSize(width: dw, height: dh)
|
||||
}
|
||||
|
||||
private func formatTime(_ t: TimeInterval) -> String {
|
||||
|
|
@ -1105,12 +1257,157 @@ final class VoiceReceivedMsgCell: UITableViewCell {
|
|||
return f.string(from: date)
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
bubbleView.setNeedsLayout()
|
||||
bubbleView.layoutIfNeeded()
|
||||
bubbleView.setCornerRadius(corners: [.topLeft , .topRight, .bottomRight],
|
||||
withCornerRadii: CGSize(width: bubbleView.dl.height / 2, height: bubbleView.dl.height / 2))
|
||||
private let timeLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 12)
|
||||
label.textColor = UIColor(hexStr: "#999999")
|
||||
label.textAlignment = .center
|
||||
return label
|
||||
}()
|
||||
|
||||
private let avatarView: UIImageView = {
|
||||
let iv = UIImageView()
|
||||
iv.contentMode = .scaleAspectFill
|
||||
iv.cornerRadius = 15
|
||||
iv.clipsToBounds = true
|
||||
iv.backgroundColor = UIColor(hexStr: "#E0E0E0")
|
||||
iv.borderWidth = 2
|
||||
iv.borderColor = .white
|
||||
return iv
|
||||
}()
|
||||
|
||||
private let photoView: UIImageView = {
|
||||
let iv = UIImageView()
|
||||
iv.contentMode = .scaleAspectFill
|
||||
iv.cornerRadius = 8
|
||||
iv.clipsToBounds = true
|
||||
iv.backgroundColor = UIColor(hexStr: "#F0F0F0")
|
||||
return iv
|
||||
}()
|
||||
|
||||
override init(style: CellStyle, reuseIdentifier: String?) {
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
selectionStyle = .none
|
||||
backgroundColor = .clear
|
||||
contentView.addSubview(timeLabel)
|
||||
contentView.addSubview(avatarView)
|
||||
contentView.addSubview(photoView)
|
||||
|
||||
timeLabel.layoutChain.top().centerX()
|
||||
avatarView.layoutChain
|
||||
.topToBottomOfView(timeLabel, offset: 14)
|
||||
.right(12).width(30).height(30)
|
||||
|
||||
photoView.layoutChain
|
||||
.topToBottomOfView(avatarView, offset: -15)
|
||||
.rightToView(avatarView, offset: -13)
|
||||
.bottom(10)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - 收到的图片消息
|
||||
final class ImageReceivedMsgCell: UITableViewCell {
|
||||
|
||||
func configure(_ msg: ChatMessage) {
|
||||
timeLabel.isHidden = !msg.showTime
|
||||
timeLabel.text = msg.showTime ? formatTime(msg.timestamp) : nil
|
||||
avatarView.image = msg.avatar
|
||||
nameLabel.text = msg.senderName
|
||||
if !msg.imageUrl.isEmpty {
|
||||
photoView.dl.setImage(with: msg.imageUrl)
|
||||
}
|
||||
photoView.layoutChain.width(msg.imageWidth).height(msg.imageHeight)
|
||||
}
|
||||
|
||||
private static func displaySize(w: CGFloat, h: CGFloat) -> CGSize {
|
||||
guard w > 0, h > 0 else { return CGSize(width: 160, height: 160) }
|
||||
let maxW: CGFloat = 200, maxH: CGFloat = 250, minW: CGFloat = 80
|
||||
var dw = maxW, dh = dw * (h / w)
|
||||
if dh > maxH { dh = maxH; dw = dh * (w / h) }
|
||||
if dw < minW { dw = minW; dh = dw * (h / w) }
|
||||
return CGSize(width: dw, height: dh)
|
||||
}
|
||||
|
||||
private func formatTime(_ t: TimeInterval) -> String {
|
||||
let date = Date(timeIntervalSince1970: t)
|
||||
let now = Date()
|
||||
let calendar = Calendar.current
|
||||
let f = DateFormatter()
|
||||
if calendar.isDateInToday(date) { f.dateFormat = "HH:mm" }
|
||||
else if calendar.isDateInYesterday(date) { f.dateFormat = "'昨天' HH:mm" }
|
||||
else if calendar.isDate(date, equalTo: now, toGranularity: .year) { f.dateFormat = "M-d HH:mm" }
|
||||
else { f.dateFormat = "yyyy-M-d HH:mm" }
|
||||
return f.string(from: date)
|
||||
}
|
||||
|
||||
private let timeLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 12)
|
||||
label.textColor = UIColor(hexStr: "#999999")
|
||||
label.textAlignment = .center
|
||||
return label
|
||||
}()
|
||||
|
||||
private let avatarView: UIImageView = {
|
||||
let iv = UIImageView()
|
||||
iv.contentMode = .scaleAspectFill
|
||||
iv.cornerRadius = 15
|
||||
iv.clipsToBounds = true
|
||||
iv.backgroundColor = UIColor(hexStr: "#E0E0E0")
|
||||
iv.borderWidth = 2
|
||||
iv.borderColor = .white
|
||||
return iv
|
||||
}()
|
||||
|
||||
private let nameLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .systemFont(ofSize: 10, weight: .regular)
|
||||
label.textColor = UIColor(hexStr: "#666666")
|
||||
return label
|
||||
}()
|
||||
|
||||
private let photoView: UIImageView = {
|
||||
let iv = UIImageView()
|
||||
iv.contentMode = .scaleAspectFill
|
||||
iv.cornerRadius = 8
|
||||
iv.clipsToBounds = true
|
||||
iv.backgroundColor = UIColor(hexStr: "#F0F0F0")
|
||||
return iv
|
||||
}()
|
||||
|
||||
override init(style: CellStyle, reuseIdentifier: String?) {
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
selectionStyle = .none
|
||||
backgroundColor = .clear
|
||||
contentView.addSubview(timeLabel)
|
||||
contentView.addSubview(nameLabel)
|
||||
contentView.addSubview(photoView)
|
||||
contentView.addSubview(avatarView)
|
||||
|
||||
timeLabel.layoutChain.top().centerX()
|
||||
|
||||
photoView.layoutChain
|
||||
.topToBottomOfView(timeLabel, offset: 14)
|
||||
.width(160).height(160)
|
||||
|
||||
avatarView.layoutChain
|
||||
.topToBottomOfView(photoView, offset: -15)
|
||||
.left(12)
|
||||
.width(30).height(30)
|
||||
.bottom(10)
|
||||
|
||||
photoView.layoutChain.leftToView(avatarView, offset: 13)
|
||||
|
||||
nameLabel.layoutChain
|
||||
.leftToRightOfView(avatarView, offset: 5)
|
||||
.bottomToView(avatarView)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ enum ChatSectionItem {
|
|||
case emojiReceived(ChatMessage)
|
||||
case voiceSend(ChatMessage)
|
||||
case voiceReceived(ChatMessage)
|
||||
case imageSend(ChatMessage)
|
||||
case imageReceived(ChatMessage)
|
||||
case notification(String)
|
||||
}
|
||||
|
||||
|
|
@ -161,7 +163,7 @@ final class GroupChatViewModel {
|
|||
private func timestampFrom(item: ChatSectionItem) -> TimeInterval {
|
||||
switch item {
|
||||
case let .send(m), let .received(m), let .emojiSend(m), let .emojiReceived(m),
|
||||
let .voiceSend(m), let .voiceReceived(m):
|
||||
let .voiceSend(m), let .voiceReceived(m), let .imageSend(m), let .imageReceived(m):
|
||||
return m.timestamp
|
||||
case .notification: return 0
|
||||
}
|
||||
|
|
@ -175,6 +177,8 @@ final class GroupChatViewModel {
|
|||
case var .emojiReceived(m):m.showTime = show; return .emojiReceived(m)
|
||||
case var .voiceSend(m): m.showTime = show; return .voiceSend(m)
|
||||
case var .voiceReceived(m):m.showTime = show; return .voiceReceived(m)
|
||||
case var .imageSend(m): m.showTime = show; return .imageSend(m)
|
||||
case var .imageReceived(m):m.showTime = show; return .imageReceived(m)
|
||||
case .notification: return item
|
||||
}
|
||||
}
|
||||
|
|
@ -183,10 +187,42 @@ final class GroupChatViewModel {
|
|||
let isSelf = msg.isSelf()
|
||||
let ts = TimeInterval(msg.sendTime) / 1000.0
|
||||
let content: String
|
||||
let voiceUrl: String
|
||||
let imageUrl: String
|
||||
let imageW: CGFloat
|
||||
let imageH: CGFloat
|
||||
|
||||
// 图片消息: 计算图片的显示宽高
|
||||
let maxWH: CGFloat = 200
|
||||
var msgImageW: CGFloat = 0
|
||||
var msgImageH: CGFloat = 0
|
||||
if let width = msg.pictureElem?.sourcePicture?.width,
|
||||
let height = msg.pictureElem?.bigPicture?.height {
|
||||
if width >= height {
|
||||
msgImageW = maxWH
|
||||
msgImageH = maxWH * CGFloat(height) / CGFloat(width)
|
||||
} else {
|
||||
msgImageH = maxWH
|
||||
msgImageW = maxWH * CGFloat(width) / CGFloat(height)
|
||||
}
|
||||
}
|
||||
|
||||
if let sound = msg.soundElem {
|
||||
content = "\(sound.duration)"
|
||||
voiceUrl = sound.sourceUrl ?? ""
|
||||
imageUrl = ""
|
||||
imageW = 0; imageH = 0
|
||||
} else if let pic = msg.pictureElem {
|
||||
content = ""
|
||||
voiceUrl = ""
|
||||
imageUrl = pic.sourcePicture?.url ?? pic.bigPicture?.url ?? pic.sourcePath ?? ""
|
||||
imageW = msgImageW
|
||||
imageH = msgImageH
|
||||
} else {
|
||||
content = msg.textElem?.content ?? ""
|
||||
voiceUrl = ""
|
||||
imageUrl = ""
|
||||
imageW = 0; imageH = 0
|
||||
}
|
||||
|
||||
return ChatMessage(
|
||||
|
|
@ -195,6 +231,10 @@ final class GroupChatViewModel {
|
|||
avatar: getUserAvatar(id: msg.sendID ?? ""),
|
||||
senderName: msg.senderNickname ?? "",
|
||||
content: content,
|
||||
voiceUrl: voiceUrl,
|
||||
imageUrl: imageUrl,
|
||||
imageWidth: imageW,
|
||||
imageHeight: imageH,
|
||||
timestamp: ts,
|
||||
showTime: false
|
||||
)
|
||||
|
|
@ -215,6 +255,11 @@ final class GroupChatViewModel {
|
|||
let chatMsg = convert(msg)
|
||||
return chatMsg.isSelf ? .voiceSend(chatMsg) : .voiceReceived(chatMsg)
|
||||
}
|
||||
// 图片消息
|
||||
if msg.contentType.rawValue == 102 {
|
||||
let chatMsg = convert(msg)
|
||||
return chatMsg.isSelf ? .imageSend(chatMsg) : .imageReceived(chatMsg)
|
||||
}
|
||||
// 普通文本消息
|
||||
let chatMsg = convert(msg)
|
||||
if chatMsg.content.isEmpty { return nil }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,99 @@
|
|||
//
|
||||
// VoicePlayerManager.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/5.
|
||||
//
|
||||
|
||||
import AVFoundation
|
||||
|
||||
final class VoicePlayerManager {
|
||||
|
||||
static let shared = VoicePlayerManager()
|
||||
|
||||
private var player: AVPlayer?
|
||||
private var timeObserver: Any?
|
||||
private var currentURL: String?
|
||||
private var onStateChange: ((State) -> Void)?
|
||||
private var onFinished: (() -> Void)?
|
||||
|
||||
enum State { case idle, playing, paused }
|
||||
|
||||
private(set) var state: State = .idle
|
||||
|
||||
private init() {}
|
||||
|
||||
func play(urlString: String,
|
||||
playbackView: VoicePlaybackView,
|
||||
onStateChange: @escaping (State) -> Void,
|
||||
onFinished: @escaping () -> Void) {
|
||||
// Stop current if different source
|
||||
if currentURL != urlString {
|
||||
stop()
|
||||
}
|
||||
|
||||
guard let url = URL(string: urlString) else { return }
|
||||
currentURL = urlString
|
||||
self.onStateChange = onStateChange
|
||||
self.onFinished = onFinished
|
||||
|
||||
if player == nil {
|
||||
player = AVPlayer(url: url)
|
||||
}
|
||||
|
||||
if state == .paused {
|
||||
player?.play()
|
||||
state = .playing
|
||||
onStateChange(.playing)
|
||||
playbackView.play()
|
||||
} else {
|
||||
player?.replaceCurrentItem(with: AVPlayerItem(url: url))
|
||||
player?.play()
|
||||
state = .playing
|
||||
onStateChange(.playing)
|
||||
playbackView.play()
|
||||
|
||||
if let obs = timeObserver {
|
||||
player?.removeTimeObserver(obs)
|
||||
}
|
||||
timeObserver = player?.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 10),
|
||||
queue: .main) { [weak self] time in
|
||||
guard let self = self,
|
||||
let duration = self.player?.currentItem?.duration,
|
||||
duration.isValid, !duration.isIndefinite,
|
||||
CMTimeCompare(time, duration) >= 0 else { return }
|
||||
self.stop()
|
||||
self.onFinished?()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func isCurrent(url: String) -> Bool { currentURL == url }
|
||||
|
||||
func pause() {
|
||||
player?.pause()
|
||||
state = .paused
|
||||
onStateChange?(.paused)
|
||||
}
|
||||
|
||||
func stop() {
|
||||
player?.pause()
|
||||
player?.replaceCurrentItem(with: nil)
|
||||
if let obs = timeObserver {
|
||||
player?.removeTimeObserver(obs)
|
||||
timeObserver = nil
|
||||
}
|
||||
let prevFinished = onFinished
|
||||
onStateChange = nil
|
||||
onFinished = nil
|
||||
player = nil
|
||||
currentURL = nil
|
||||
state = .idle
|
||||
prevFinished?()
|
||||
}
|
||||
}
|
||||
|
||||
protocol VoicePlaybackView: AnyObject {
|
||||
func play()
|
||||
func stop()
|
||||
}
|
||||
|
|
@ -0,0 +1,262 @@
|
|||
//
|
||||
// VoiceRecordView.swift
|
||||
// QuickLocation
|
||||
//
|
||||
// Created by 八条 on 2026/6/6.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Lottie
|
||||
|
||||
final class VoiceRecordView: UIView {
|
||||
|
||||
enum State {
|
||||
case recording
|
||||
case canceling
|
||||
}
|
||||
|
||||
var state: State = .recording {
|
||||
didSet {
|
||||
updateUI()
|
||||
}
|
||||
}
|
||||
|
||||
private func updateUI() {
|
||||
switch state {
|
||||
case .recording:
|
||||
tipsLab.text = "松开发送"
|
||||
startRotating()
|
||||
case .canceling:
|
||||
tipsLab.text = "松开取消"
|
||||
}
|
||||
}
|
||||
|
||||
lazy var bgView: UIView = {
|
||||
let v = UIView()
|
||||
v.backgroundColor = .clear
|
||||
v.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.1).cgColor
|
||||
v.layer.shadowOffset = CGSize(width: 0, height: 0)
|
||||
v.layer.shadowOpacity = 1
|
||||
v.layer.shadowRadius = 8
|
||||
return v
|
||||
}()
|
||||
|
||||
lazy var topContainer: UIView = {
|
||||
let v = UIView()
|
||||
v.backgroundColor = .white
|
||||
return v
|
||||
}()
|
||||
|
||||
lazy var keyboardBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "IM/keyboard"), for: .normal)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var titleView: UIView = {
|
||||
let v = UIView()
|
||||
v.layer.shadowColor = UIColor(red: 0.06, green: 0.16, blue: 0.27, alpha: 0.1).cgColor
|
||||
v.layer.shadowOffset = CGSize(width: 0, height: 0)
|
||||
v.layer.shadowOpacity = 1
|
||||
v.layer.shadowRadius = 9
|
||||
|
||||
let cornerView = UIView()
|
||||
cornerView.backgroundColor = .white
|
||||
cornerView.cornerRadius = 19
|
||||
|
||||
let label = UILabel()
|
||||
label.text = "正在录入语音..."
|
||||
label.font = .systemFont(ofSize: 12)
|
||||
label.textColor = ThemeManager.shared.color.subTitleColor
|
||||
label.textAlignment = .center
|
||||
|
||||
v.addSubview(cornerView)
|
||||
v.addSubview(label)
|
||||
|
||||
cornerView.layoutChain.edges()
|
||||
label.layoutChain.centerX().centerY()
|
||||
|
||||
return v
|
||||
}()
|
||||
|
||||
lazy var emojiBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "IM/emoji_off"), for: .normal)
|
||||
btn.extendEdgeInsets = UIEdgeInsets(top: 15, left: 15, bottom: 15, right: 0)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var addBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "IM/add_off"), for: .normal)
|
||||
btn.extendEdgeInsets = UIEdgeInsets(top: 15, left: 0, bottom: 15, right: 15)
|
||||
return btn
|
||||
}()
|
||||
|
||||
lazy var containerView: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = .white
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var tipsLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = " "
|
||||
label.font = .systemFont(ofSize: 12, weight: .medium)
|
||||
label.textColor = ThemeManager.shared.color.titleAuxColor
|
||||
label.textAlignment = .center
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var speakingImgView: UIImageView = {
|
||||
let view = UIImageView(image: UIImage(named: "IM/speaking"))
|
||||
view.isHidden = true
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var speakBtn: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = UIColor(hexStr: "#E7F7FF")
|
||||
view.cornerRadius = 48
|
||||
|
||||
let icon = UIImageView(image: UIImage(named: "IM/speak"))
|
||||
view.addSubview(icon)
|
||||
icon.layoutChain
|
||||
.centerX()
|
||||
.centerY()
|
||||
|
||||
return view
|
||||
}()
|
||||
|
||||
lazy var cancelLab: UILabel = {
|
||||
let label = UILabel()
|
||||
label.text = "左滑取消"
|
||||
label.font = .systemFont(ofSize: 12, weight: .regular)
|
||||
label.textColor = ThemeManager.shared.color.contentColor
|
||||
return label
|
||||
}()
|
||||
|
||||
lazy var cancelBtn: UIButton = {
|
||||
let btn = UIButton(type: .custom)
|
||||
btn.setImage(UIImage(named: "IM/cancel_off"), for: .normal)
|
||||
btn.setImage(UIImage(named: "IM/cancel"), for: .selected)
|
||||
btn.isUserInteractionEnabled = false
|
||||
return btn
|
||||
}()
|
||||
|
||||
// MARK: - Init
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
backgroundColor = .clear
|
||||
|
||||
addSubview(bgView)
|
||||
bgView.addSubview(topContainer)
|
||||
topContainer.addSubview(keyboardBtn)
|
||||
topContainer.addSubview(titleView)
|
||||
topContainer.addSubview(emojiBtn)
|
||||
topContainer.addSubview(addBtn)
|
||||
|
||||
bgView.addSubview(containerView)
|
||||
containerView.addSubview(tipsLab)
|
||||
containerView.addSubview(speakBtn)
|
||||
containerView.addSubview(speakingImgView)
|
||||
containerView.addSubview(cancelLab)
|
||||
containerView.addSubview(cancelBtn)
|
||||
|
||||
bgView.layoutChain.edges()
|
||||
|
||||
topContainer.layoutChain
|
||||
.edges(excludingEdge: .bottom)
|
||||
.height(58)
|
||||
|
||||
keyboardBtn.layoutChain
|
||||
.left(22)
|
||||
.centerY()
|
||||
.width(36)
|
||||
.height(36)
|
||||
|
||||
addBtn.layoutChain
|
||||
.right(22)
|
||||
.centerY()
|
||||
.width(24)
|
||||
.height(24)
|
||||
|
||||
emojiBtn.layoutChain
|
||||
.rightToLeftOfView(addBtn, offset: -8)
|
||||
.centerY()
|
||||
.width(24)
|
||||
.height(24)
|
||||
|
||||
titleView.layoutChain
|
||||
.top(10)
|
||||
.leftToRightOfView(keyboardBtn, offset: 7)
|
||||
.rightToLeftOfView(emojiBtn, offset: -12)
|
||||
.bottom(10)
|
||||
|
||||
containerView.layoutChain
|
||||
.topToBottomOfView(topContainer, offset: 0)
|
||||
.edges(excludingEdge: .top)
|
||||
|
||||
tipsLab.layoutChain
|
||||
.top(18)
|
||||
.centerX()
|
||||
|
||||
speakBtn.layoutChain
|
||||
.height(96)
|
||||
.widthToHeight(1)
|
||||
.centerY()
|
||||
.centerX()
|
||||
|
||||
speakingImgView.layoutChain
|
||||
.topToView(speakBtn, offset: -6)
|
||||
.leftToView(speakBtn, offset: -6)
|
||||
.rightToView(speakBtn, offset: 6)
|
||||
.bottomToView(speakBtn, offset: 6)
|
||||
|
||||
cancelBtn.layoutChain
|
||||
.rightToLeftOfView(speakBtn, offset: -47)
|
||||
.centerY(speakBtn)
|
||||
.width(41)
|
||||
.heightToWidth(1)
|
||||
|
||||
cancelLab.layoutChain
|
||||
.bottomToTopOfView(cancelBtn, offset: -7)
|
||||
.centerX(cancelBtn)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
topContainer.setNeedsLayout()
|
||||
topContainer.layoutIfNeeded()
|
||||
topContainer.setCornerRadius(corners: [.topRight, .topLeft], withCornerRadii: CGSize(width: 20, height: 20))
|
||||
}
|
||||
}
|
||||
|
||||
extension VoiceRecordView {
|
||||
func startRotating() {
|
||||
guard speakingImgView.isHidden == true else { return }
|
||||
speakingImgView.isHidden = false
|
||||
// 避免重复添加动画
|
||||
speakingImgView.layer.removeAnimation(forKey: "rotationAnimation")
|
||||
|
||||
let rotationAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
|
||||
rotationAnimation.fromValue = 0
|
||||
rotationAnimation.toValue = Double.pi * 2 // 360°
|
||||
rotationAnimation.duration = 1.0
|
||||
rotationAnimation.repeatCount = .infinity // 无限循环
|
||||
rotationAnimation.isRemovedOnCompletion = false
|
||||
rotationAnimation.fillMode = .forwards
|
||||
|
||||
speakingImgView.layer.add(rotationAnimation, forKey: "rotationAnimation")
|
||||
}
|
||||
|
||||
func stopRotating() {
|
||||
tipsLab.text = " "
|
||||
speakingImgView.isHidden = true
|
||||
speakingImgView.layer.removeAnimation(forKey: "rotationAnimation")
|
||||
}
|
||||
}
|
||||
|
|
@ -43,11 +43,6 @@ final class GroupViewController: BaseViewController {
|
|||
self?.requestIMGroups(retryCount: 3)
|
||||
}
|
||||
}
|
||||
GroupIMService.shared.setConversationListener { [weak self] _ in
|
||||
GroupIMService.shared.getConversationList { conversations in
|
||||
self?.viewModel.updateConversations(conversations)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func refreshIMData() {
|
||||
|
|
@ -66,11 +61,19 @@ final class GroupViewController: BaseViewController {
|
|||
group.leave()
|
||||
}
|
||||
group.notify(queue: .main) { [weak self] in
|
||||
DLToast.dismiss()
|
||||
self?.viewModel.loadIMGroups(groups, conversations: conversations)
|
||||
|
||||
// GroupIMService.shared.setConversationListener { [weak self] _ in
|
||||
// GroupIMService.shared.getConversationList { conversations in
|
||||
// self?.viewModel.updateConversations(conversations)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private func requestIMGroups(retryCount: Int = 3) {
|
||||
DLToast.showLoading(text: "消息获取中...")
|
||||
GroupIMService.shared.getJoinedGroups { [weak self] groups in
|
||||
guard let self = self else { return }
|
||||
if groups.isEmpty && retryCount > 0 {
|
||||
|
|
|
|||