移除无用代码

This commit is contained in:
Fin 2025-02-21 14:15:08 +08:00
parent f56bfe82b6
commit accf1008e7
6 changed files with 1 additions and 309 deletions

View File

@ -118,10 +118,6 @@
068EC15A27ED99E700D5D11E /* ServerListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 068EC15927ED99E700D5D11E /* ServerListViewModel.swift */; };
068F66B3247BD84C00DAD25A /* MessageListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 068F66B2247BD84C00DAD25A /* MessageListViewController.swift */; };
0699473D2D223094008D5E40 /* CustomTapTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0699473C2D223094008D5E40 /* CustomTapTextView.swift */; };
06AE3118266F4E2E00B39FBB /* GroupFilterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06AE3117266F4E2E00B39FBB /* GroupFilterViewController.swift */; };
06AE311A266F4E6600B39FBB /* GroupFilterViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06AE3119266F4E6600B39FBB /* GroupFilterViewModel.swift */; };
06AE311C266F54A500B39FBB /* GroupTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06AE311B266F54A500B39FBB /* GroupTableViewCell.swift */; };
06AE311E266F54CC00B39FBB /* GroupCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06AE311D266F54CC00B39FBB /* GroupCellViewModel.swift */; };
06B1158D247BA6D5006D91FB /* CloudKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06B1158C247BA6D5006D91FB /* CloudKit.framework */; };
06B1158F247BB1FB006D91FB /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B1158E247BB1FB006D91FB /* Message.swift */; };
06B11591247BC132006D91FB /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B1158E247BB1FB006D91FB /* Message.swift */; };
@ -367,10 +363,6 @@
068EC15927ED99E700D5D11E /* ServerListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerListViewModel.swift; sourceTree = "<group>"; };
068F66B2247BD84C00DAD25A /* MessageListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageListViewController.swift; sourceTree = "<group>"; };
0699473C2D223094008D5E40 /* CustomTapTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomTapTextView.swift; sourceTree = "<group>"; };
06AE3117266F4E2E00B39FBB /* GroupFilterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupFilterViewController.swift; sourceTree = "<group>"; };
06AE3119266F4E6600B39FBB /* GroupFilterViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupFilterViewModel.swift; sourceTree = "<group>"; };
06AE311B266F54A500B39FBB /* GroupTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupTableViewCell.swift; sourceTree = "<group>"; };
06AE311D266F54CC00B39FBB /* GroupCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupCellViewModel.swift; sourceTree = "<group>"; };
06B1158C247BA6D5006D91FB /* CloudKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CloudKit.framework; path = System/Library/Frameworks/CloudKit.framework; sourceTree = SDKROOT; };
06B1158E247BB1FB006D91FB /* Message.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = "<group>"; };
06B11590247BBC15006D91FB /* NotificationServiceExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NotificationServiceExtension.entitlements; sourceTree = "<group>"; };
@ -492,8 +484,6 @@
06BBB8B62567AC140076F63E /* MessageSettingsViewModel.swift */,
060481ED250F404500BC9799 /* SoundsViewController.swift */,
065BE43F2563D649002A8CA4 /* SoundsViewModel.swift */,
06AE3117266F4E2E00B39FBB /* GroupFilterViewController.swift */,
06AE3119266F4E6600B39FBB /* GroupFilterViewModel.swift */,
06F11E7627D9D5FB00F00298 /* QRScannerViewController.swift */,
068EC15727ED99C900D5D11E /* ServerListViewController.swift */,
068EC15927ED99E700D5D11E /* ServerListViewModel.swift */,
@ -525,8 +515,6 @@
062B98C2251B2762004562E7 /* BKButton.swift */,
06C595352481160F006B98F3 /* BKLabel.swift */,
062B98C7251B27AE004562E7 /* UINavigationItem+Extension.swift */,
06AE311B266F54A500B39FBB /* GroupTableViewCell.swift */,
06AE311D266F54CC00B39FBB /* GroupCellViewModel.swift */,
06C2CF222685B88D0034B127 /* TextCell.swift */,
06C2CF242685BDB80034B127 /* SpacerCell.swift */,
0642B55927EB13F100453D91 /* MutableTextCell.swift */,
@ -1256,7 +1244,6 @@
0603706920E1F89500F4CA05 /* PreviewCardCell.swift in Sources */,
066890082D1946D500E106F2 /* MessageItemView.swift in Sources */,
0627DABB298B6EA2002F3F69 /* DropBoxView.swift in Sources */,
06AE311C266F54A500B39FBB /* GroupTableViewCell.swift in Sources */,
0672CB06256903F700570C9D /* MessageListViewModel.swift in Sources */,
0627DABD2990D615002F3F69 /* BorderTextField.swift in Sources */,
06E62C112D670F62004DC82B /* PushToCurrentIntent.swift in Sources */,
@ -1268,7 +1255,6 @@
0699473D2D223094008D5E40 /* CustomTapTextView.swift in Sources */,
06EEF333291CCFF400CA228A /* CryptoSettingController.swift in Sources */,
0603706D20E23EC000F4CA05 /* BarkSFSafariViewController.swift in Sources */,
06AE311A266F4E6600B39FBB /* GroupFilterViewModel.swift in Sources */,
06F08EA429B098DD006AB9CA /* CryptoSettingManager.swift in Sources */,
0668900B2D19525400E106F2 /* ShowLessAndClearView.swift in Sources */,
06BD4DAA2901352E003364DB /* Object+Dictionary.swift in Sources */,
@ -1295,12 +1281,10 @@
06C5952F248107F5006B98F3 /* iCloudStatusCell.swift in Sources */,
06BBB88725650C6C0076F63E /* ArchiveSettingManager.swift in Sources */,
065BE44B2563D8E1002A8CA4 /* Reusable.swift in Sources */,
06AE311E266F54CC00B39FBB /* GroupCellViewModel.swift in Sources */,
0637FA8620E0AB6600E80174 /* UIColor+Extension.swift in Sources */,
0637FA8A20E0D58800E80174 /* NewServerViewController.swift in Sources */,
067B2EB525693E38008B6BE1 /* MessageSection.swift in Sources */,
0637FA8220E09C4B00E80174 /* BarkNavigationController.swift in Sources */,
06AE3118266F4E2E00B39FBB /* GroupFilterViewController.swift in Sources */,
0637FA7A20E092B300E80174 /* Observable+Extension.swift in Sources */,
060481F0250F51CA00BC9799 /* SoundCell.swift in Sources */,
0667D194247D1BA0005DE2ED /* Date+Extension.swift in Sources */,

View File

@ -1920,7 +1920,7 @@
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Groups"
"value" : "Group"
}
},
"ja" : {

View File

@ -1,101 +0,0 @@
//
// GroupFilterViewController.swift
// Bark
//
// Created by huangfeng on 2021/6/8.
// Copyright © 2021 Fin. All rights reserved.
//
import Material
import MJRefresh
import RealmSwift
import RxCocoa
import RxDataSources
import RxSwift
import UIKit
class GroupFilterViewController: BaseViewController<GroupFilterViewModel> {
let doneButton: BKButton = {
let btn = BKButton()
btn.setTitle(NSLocalizedString("done"), for: .normal)
btn.setTitleColor(BKColor.lightBlue.darken3, for: .normal)
btn.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
btn.fontSize = 14
return btn
}()
let showAllGroupsButton: BKButton = {
let btn = BKButton()
btn.setTitle(NSLocalizedString("hideAllGroups"), for: .selected)
btn.setTitle(NSLocalizedString("showAllGroups"), for: .normal)
btn.setTitleColor(Color.lightBlue.darken3, for: .normal)
btn.fontSize = 14
return btn
}()
let tableView: UITableView = {
let tableView = UITableView(frame: CGRect.zero, style: .insetGrouped)
tableView.separatorStyle = .singleLine
tableView.separatorColor = BKColor.grey.lighten3
tableView.backgroundColor = BKColor.background.primary
tableView.register(GroupTableViewCell.self, forCellReuseIdentifier: "\(GroupTableViewCell.self)")
return tableView
}()
override func makeUI() {
self.title = NSLocalizedString("group")
self.navigationItem.setRightBarButtonItem(item: UIBarButtonItem(customView: doneButton))
self.view.addSubview(tableView)
self.view.addSubview(showAllGroupsButton)
tableView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.bottom.equalToSuperview().offset((kSafeAreaInsets.bottom + 40) * -1)
make.left.right.equalToSuperview()
}
showAllGroupsButton.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.height.equalTo(40)
make.bottom.equalToSuperview().offset(-kSafeAreaInsets.bottom)
}
self.tableView.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.bounds.size.width, height: 20))
}
override func bindViewModel() {
let output = viewModel.transform(
input: GroupFilterViewModel.Input(
showAllGroups: self.showAllGroupsButton.rx
.tap
.compactMap { [weak self] in
guard let strongSelf = self else { return nil }
return !strongSelf.showAllGroupsButton.isSelected
}
.asDriver(onErrorDriveWith: .empty()),
doneTap: self.doneButton.rx.tap.asDriver()
))
let dataSource = RxTableViewSectionedReloadDataSource<SectionModel<String, GroupCellViewModel>> { _, tableView, _, item -> UITableViewCell in
guard let cell = tableView.dequeueReusableCell(withIdentifier: "\(GroupTableViewCell.self)") as? GroupTableViewCell else {
return UITableViewCell()
}
cell.bindViewModel(model: item)
return cell
}
output.groups
.drive(tableView.rx.items(dataSource: dataSource))
.disposed(by: rx.disposeBag)
output.isShowAllGroups
.drive(self.showAllGroupsButton.rx.isSelected)
.disposed(by: rx.disposeBag)
output.dismiss.drive(onNext: { [weak self] in
self?.dismiss(animated: true, completion: nil)
})
.disposed(by: rx.disposeBag)
}
}
extension GroupFilterViewController: UITableViewDelegate {}

View File

@ -1,91 +0,0 @@
//
// GroupFilterViewModel.swift
// Bark
//
// Created by huangfeng on 2021/6/8.
// Copyright © 2021 Fin. All rights reserved.
//
import RealmSwift
import RxCocoa
import RxDataSources
import RxSwift
struct GroupFilterModel {
var name: String?
var checked: Bool
}
class GroupFilterViewModel: ViewModel, ViewModelType {
let groups: [GroupFilterModel]
init(groups: [GroupFilterModel]) {
self.groups = groups
}
struct Input {
var showAllGroups: Driver<Bool>
var doneTap: Driver<Void>
}
struct Output {
var groups: Driver<[SectionModel<String, GroupCellViewModel>]>
var isShowAllGroups: Driver<Bool>
var dismiss: Driver<Void>
}
var done = PublishRelay<[String?]>()
func transform(input: Input) -> Output {
// cellModel
let groupCellModels = self.groups.map { filterModel in
GroupCellViewModel(groupFilterModel: filterModel)
}
// cell checked
input.showAllGroups.drive(onNext: { isShowAllGroups in
for model in groupCellModels {
model.checked.accept(isShowAllGroups)
}
}).disposed(by: rx.disposeBag)
// cell checked
let checkChanged = Observable.merge(groupCellModels.map { model in
model.checked.asObservable()
})
//
let isShowAllGroups =
checkChanged
.map { _ in
groupCellModels.filter { viewModel in
viewModel.checked.value
}.count >= groupCellModels.count
}
input.doneTap.map { () -> [String?] in
let isShowAllGroups = groupCellModels.filter { viewModel in
viewModel.checked.value
}.count >= groupCellModels.count
if isShowAllGroups {
return []
}
return groupCellModels
.filter { $0.checked.value }
.map { $0.name.value }
}
.asObservable()
.bind(to: self.done)
.disposed(by: rx.disposeBag)
let dismiss = PublishRelay<Void>()
input.doneTap.map { _ in () }
.asObservable()
.bind(to: dismiss)
.disposed(by: rx.disposeBag)
return Output(
groups: Driver.just([SectionModel(model: "header", items: groupCellModels)]),
isShowAllGroups: isShowAllGroups.asDriver(onErrorDriveWith: .empty()),
dismiss: dismiss.asDriver(onErrorDriveWith: .empty())
)
}
}

View File

@ -1,22 +0,0 @@
//
// GroupCellViewModel.swift
// Bark
//
// Created by huangfeng on 2021/6/8.
// Copyright © 2021 Fin. All rights reserved.
//
import RxCocoa
import RxDataSources
import RxSwift
import UIKit
class GroupCellViewModel: ViewModel {
let name = BehaviorRelay<String?>(value: nil)
let checked = BehaviorRelay<Bool>(value: false)
init(groupFilterModel: GroupFilterModel) {
self.name.accept(groupFilterModel.name)
self.checked.accept(groupFilterModel.checked)
}
}

View File

@ -1,78 +0,0 @@
//
// GroupTableViewCell.swift
// Bark
//
// Created by huangfeng on 2021/6/8.
// Copyright © 2021 Fin. All rights reserved.
//
import Material
import UIKit
class GroupTableViewCell: BaseTableViewCell<GroupCellViewModel> {
let nameLabel: UILabel = {
let label = UILabel()
label.fontSize = 14
label.textColor = BKColor.grey.darken4
return label
}()
let checkButton: BKButton = {
let btn = BKButton()
btn.setImage(UIImage(named: "baseline_radio_button_unchecked_black_24pt"), for: .normal)
btn.setImage(UIImage(named: "baseline_check_circle_outline_black_24pt"), for: .selected)
btn.tintColor = BKColor.grey.base
btn.isUserInteractionEnabled = false
return btn
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none
self.backgroundColor = BKColor.background.secondary
self.contentView.addSubview(nameLabel)
self.contentView.addSubview(checkButton)
checkButton.snp.makeConstraints { make in
make.width.height.equalTo(24)
make.left.equalToSuperview().offset(15)
make.centerY.equalToSuperview()
}
nameLabel.snp.makeConstraints { make in
make.left.equalTo(checkButton.snp.right).offset(15)
make.top.equalToSuperview().offset(15)
make.bottom.equalToSuperview().offset(-15)
}
let tap = UITapGestureRecognizer()
self.contentView.addGestureRecognizer(tap)
tap.rx.event.subscribe(onNext: { [weak self] _ in
self?.viewModel?.checked.accept(!self!.checkButton.isSelected)
}).disposed(by: rx.disposeBag)
}
@available(*, unavailable)
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func bindViewModel(model: GroupCellViewModel) {
super.bindViewModel(model: model)
model.name
.map { name in
name ?? NSLocalizedString("default")
}
.bind(to: nameLabel.rx.text)
.disposed(by: rx.reuseBag)
model.checked
.bind(to: self.checkButton.rx.isSelected)
.disposed(by: rx.reuseBag)
model.checked.subscribe(
onNext: { [weak self] checked in
self?.checkButton.tintColor = checked ? BKColor.lightBlue.darken3 : BKColor.grey.base
}).disposed(by: rx.reuseBag)
}
}