Browse Source

Merge branch 'master' of https://git.yishihui.com/iOS/BFRecordScreenKit

* 'master' of https://git.yishihui.com/iOS/BFRecordScreenKit:
  字幕隐藏和显示逻辑调整
  添加国际化内容
  还原国际化
harry 3 năm trước cách đây
mục cha
commit
02e6b2ff9e

+ 37 - 26
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -96,21 +96,21 @@ public class BFRecordScreenController: BFBaseViewController {
             switch itemModel.mediaType {
             case .Image:
                 rscurrentManager = rsimanager
-                recordBtn.setTitle("按住 录制", for: .normal)
+                recordBtn.setTitle("record_lz".BFLocale, for: .normal)
                 progressThumV.isHidden = false
                 cameraProgressThumV.isHidden = true
                 progreddL.isHidden = false
 
             case .Video:
                 rscurrentManager = rsvmanager
-                recordBtn.setTitle("按住 录音", for: .normal)
+                recordBtn.setTitle("record_ly".BFLocale, for: .normal)
                 progressThumV.isHidden = false
                 cameraProgressThumV.isHidden = true
                 progreddL.isHidden = false
 
             case .Camera:
                 rscurrentManager = rscmanager
-                recordBtn.setTitle("按住 录音", for: .normal)
+                recordBtn.setTitle("record_ly".BFLocale, for: .normal)
                 recordBtn.isEnabled = false
                 progressThumV.isHidden = true
                 cameraProgressThumV.isHidden = false
@@ -164,8 +164,7 @@ public class BFRecordScreenController: BFBaseViewController {
             changeVoiceBtn.isHidden = isRecording
             subtitleBtn.isHidden = isRecording
             soundSettingBtn.isHidden = isRecording
-
-            recordBtn.setTitle(isRecording ? "松手 暂停" : (rscurrentManager.recordItem?.mediaType == .Camera ? "按住 录制" : "按住 录音"), for: .normal)
+            recordBtn.setTitle(isRecording ? "record_pause".BFLocale : "record_ly".BFLocale, for: .normal)
             recordBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#389AFF", alpha: isRecording ? 0.6 : 1)
 //            if !isRecording {
 //                BFLog(1, message: "stop")
@@ -289,7 +288,7 @@ public class BFRecordScreenController: BFBaseViewController {
     lazy var recordBtn: UIButton = {
         let btn = UIButton(type: .custom)
         btn.backgroundColor = ThemeStyleColor
-        btn.setTitle("按住 录音", for: .normal)
+        btn.setTitle("record_ly".BFLocale, for: .normal)
         btn.addCorner(corner: 6)
         btn.titleLabel?.font = UIFont.boldSystemFont(ofSize: 18)
         btn.adjustsImageWhenHighlighted = false
@@ -303,7 +302,7 @@ public class BFRecordScreenController: BFBaseViewController {
         let btn = UIButton(type: .custom)
 
         btn.backgroundColor = UIColor.hexColor(hexadecimal: "#FF0000", alpha: 0.3)
-        btn.setTitle("删除录制", for: .normal)
+        btn.setTitle("record_delete".BFLocale, for: .normal)
         btn.adjustsImageWhenHighlighted = false
         btn.titleLabel?.font = UIFont.boldSystemFont(ofSize: 18)
         btn.addCorner(corner: 6)
@@ -316,7 +315,7 @@ public class BFRecordScreenController: BFBaseViewController {
         let btn = UIButton(type: .custom)
         btn.setImage(imageInRecordScreenKit(by: "withdraw_n"), for: .normal)
         btn.setImage(imageInRecordScreenKit(by: "withdraw_h"), for: .highlighted)
-        btn.setTitle("回退", for: .normal)
+        btn.setTitle("record_back".BFLocale, for: .normal)
         btn.setTitleColor(.white, for: .normal)
         btn.setTitleColor(.lightGray, for: .disabled)
         btn.isEnabled = false
@@ -619,11 +618,24 @@ public class BFRecordScreenController: BFBaseViewController {
         // 字幕设置回调
         subtitleSettingView.subtitleSettingCallBack = { [weak self] subtitileModel in
 
-            self?.setSubtitleStyle(settingModel: subtitileModel.setting)
-            // mdf by ak 这里是设置字幕开关回调
-            if self?.subTitleBtnClickHandle != nil {
-                self?.subTitleBtnClickHandle!(subtitileModel.setting.subtitleIsShow)
+            if let wself = self{
+                
+                //1,设置字幕样式
+                wself.setSubtitleStyle(settingModel: subtitileModel.setting)
+                
+                //2,显示设置文字,不显示设置为空
+                if(subtitileModel.setting.subtitleIsShow){
+                    wself.updateSubtitle(time: wself.currentAssetProgress)
+                }else{
+                    wself.subtitleLabel.text = ""
+                }
+        
+                // mdf by ak 这里是设置字幕开关回调
+                if wself.subTitleBtnClickHandle != nil {
+                    wself.subTitleBtnClickHandle!(subtitileModel.setting.subtitleIsShow)
+                }
             }
+         
         }
         // 编辑字幕完成
         subtitleEditView.editSubtitleDone = { [weak self] newtext, index in
@@ -634,6 +646,7 @@ public class BFRecordScreenController: BFBaseViewController {
                     // 删除数据
                     BFLog(message: "清空字幕操作要删除原字幕 sticker 数据")
                     self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers.remove(at: index)
+                    self?.subtitleLabel.text = ""
                 } else {
                     // 更新数据
                     self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers[index].text = newtext
@@ -1024,10 +1037,7 @@ public class BFRecordScreenController: BFBaseViewController {
             } else { // 上
                 subtitleLabel.frame = CGRect(x: leftPoint, y: cScreenHeigth * 0.12, width: cScreenWidth - 37 * 2, height: height)
             }
-            // 打开的时候主动调用一次显示字幕
-            updateSubtitle(time: currentAssetProgress)
-        } else {
-            subtitleLabel.text = ""
+          
         }
     }
 
@@ -1306,7 +1316,7 @@ public class BFRecordScreenController: BFBaseViewController {
         recordEndHandle?(voiceModel)
         BFLog(3, message: "开始录制-取消:currentAssetProgress=\(currentAssetProgress.seconds),cuInde=\(currItemModelIndex),currIndex=\(voiceModel?.currIndex ?? 0),\(String(describing: voiceModel)),\(String(describing: recorderManager?.voiceModel))")
         if voiceModel != nil, currentAssetProgress.seconds - (recorderManager?.voiceModel?.startCMTime.seconds ?? 0) < 1.0 {
-            cShowHUB(superView: nil, msg: "最短录制1秒")
+            cShowHUB(superView: nil, msg: "shoot_tips_least".BFLocale)
             recorderManager?.cancelTitleService()
         }
         // 删除文件
@@ -1631,11 +1641,11 @@ public class BFRecordScreenController: BFBaseViewController {
             BFLog(message: "麦克风权限被拒绝,请在设置中打开")
             if show {
                 let remindData = BFBaseModel()
-                remindData.title = "需要开启「麦克风权限」才可以进行录制"
+                remindData.title = "grant_micpass".BFLocale
                 remindData.summary = ""
                 let remindView = BFRemindView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
                 remindView.isBanned = true
-                remindView.confirmBtn.setTitle("去开启", for: .normal)
+                remindView.confirmBtn.setTitle("grant_open".BFLocale, for: .normal)
                 remindView.confirmBtn.setTitleColor(UIColor.hexColor(hexadecimal: "#389AFF"), for: .normal)
                 UIApplication.shared.keyWindow?.addSubview(remindView)
                 remindView.remindData = remindData
@@ -1999,7 +2009,7 @@ public class BFRecordScreenController: BFBaseViewController {
 
             if wself.isRecording {
                 wself.endRecord()
-                cShowHUB(superView: nil, msg: "此视频已录制到头了哦")
+                cShowHUB(superView: nil, msg: "tips_full".BFLocale)
             }
             wself.playBtn.isSelected = false
             wself.playBtn.isHidden = wself.playBtn.isSelected
@@ -2049,11 +2059,11 @@ public class BFRecordScreenController: BFBaseViewController {
     func changeWithDrawBtnLayout(_ type: Int) {
         switch type {
         case 3:
-            withDrawBtn.setTitle("撤销删除", for: .normal)
+            withDrawBtn.setTitle("record_recover".BFLocale, for: .normal)
         case 2:
-            withDrawBtn.setTitle("撤销录制", for: .normal)
+            withDrawBtn.setTitle("record_undo".BFLocale, for: .normal)
         default:
-            withDrawBtn.setTitle("回退", for: .normal)
+            withDrawBtn.setTitle("record_back".BFLocale, for: .normal)
         }
         withDrawBtn.imageEdgeInsets = UIEdgeInsets(top: -withDrawBtn.imageView!.height, left: 0, bottom: 0, right: -withDrawBtn.titleLabel!.width)
         withDrawBtn.titleEdgeInsets = UIEdgeInsets(top: withDrawBtn.titleLabel!.height + 2, left: -withDrawBtn.imageView!.width, bottom: 0, right: 0)
@@ -2184,7 +2194,8 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
                 return
             }
             guard item != nil else {
-                cShowHUB(superView: nil, msg: "视频获取失败:\(recordItem?.index ?? 0)")
+                BFLog(message: "视频获取失败:\(recordItem?.index ?? 0)")
+                cShowHUB(superView: nil, msg: "视频获取失败")
                 return
             }
             wself.rscurrentManager.resetEnv()
@@ -2213,11 +2224,11 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
     
     func showDeleteCamera(){
         let alertV = UIAlertController(title: nil, message: "你还没有录制内容哦,切换段落将会取消录制,是否确定取消", preferredStyle: .alert)
-        let cancelAction = UIAlertAction(title: "取消", style: .default) {[weak self] _ in
+        let cancelAction = UIAlertAction(title: "option_cancel".BFLocale, style: .default) {[weak self] _ in
             guard let wself = self else { return }
             wself.collectionView.isScrollEnabled = true
         }
-        let okAction = UIAlertAction(title: "确定", style: .default) { [weak self] _ in
+        let okAction = UIAlertAction(title: "option_ok".BFLocale, style: .default) { [weak self] _ in
             guard let wself = self else { return }
             wself.collectionView.isScrollEnabled = true
             wself.removeCameroCell()