75 lines
2.3 KiB
Swift
75 lines
2.3 KiB
Swift
//
|
|
// CreateGroupVC.swift
|
|
// QuickLocation
|
|
//
|
|
// Created by 八条 on 2026/6/2.
|
|
//
|
|
|
|
import UIKit
|
|
import RxSwift
|
|
import RxCocoa
|
|
import RxDataSources
|
|
|
|
class CreateGroupVC: BaseViewController {
|
|
|
|
fileprivate var rootView: CreateGroupView!
|
|
|
|
override func loadView() {
|
|
rootView = CreateGroupView(frame: UIScreen.main.bounds)
|
|
view = rootView
|
|
}
|
|
|
|
private var viewModel = CreateGroupViewModel()
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
bindViewModel()
|
|
reactiveAction()
|
|
|
|
viewModel.loadData()
|
|
}
|
|
|
|
private func reactiveAction() {
|
|
rootView.groupIconInputView.rx.tapGesture.subscribe { _ in
|
|
let vc = GroupIconListVC(iconIndex: "1")
|
|
vc.onSelectIcon = { index in
|
|
self.viewModel.iconIndex = index
|
|
self.rootView.groupIconImgView.image = UIImage(named: "GroupIcon/\(index)")
|
|
}
|
|
self.navigationController?.pushViewController(vc, animated: true)
|
|
}.disposed(by: disposeBag)
|
|
|
|
rootView.submitBtn.rx.tap.subscribe(onNext: { _ in
|
|
self.viewModel.requestCreateGroup()
|
|
}).disposed(by: disposeBag)
|
|
}
|
|
|
|
private func bindViewModel() {
|
|
rootView.groupNameTF.rx.text.orEmpty
|
|
.bind(to: viewModel.groupName)
|
|
.disposed(by: disposeBag)
|
|
|
|
rootView.groupContentTV.rx.text.orEmpty
|
|
.bind(to: viewModel.groupDesc)
|
|
.disposed(by: disposeBag)
|
|
|
|
viewModel.output.sectionedItems
|
|
.bind(to: rootView.tagView.rx.items(dataSource: dataSource))
|
|
.disposed(by: disposeBag)
|
|
|
|
rootView.tagView.rx.modelSelected(String.self)
|
|
.subscribe(viewModel.cellAction.inputs)
|
|
.disposed(by: disposeBag)
|
|
}
|
|
|
|
// MARK: - dataSource
|
|
private lazy var dataSource: RxCollectionViewSectionedReloadDataSource<GroupTagListSectionModel> = {
|
|
RxCollectionViewSectionedReloadDataSource<GroupTagListSectionModel> { datasource, collectionView, indexPath, item in
|
|
let cell: TagCell = collectionView.dequeueReusableCell(for: indexPath)
|
|
cell.configure(item, isSelected: self.viewModel.isSelected(tag: item))
|
|
return cell
|
|
}
|
|
}()
|
|
}
|