Skip to content

Commit

Permalink
🧑‍💻🐳 chore: 调整 android iOS 风格 保持一致
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxiang4 committed Feb 14, 2023
1 parent 2b6887d commit c959bf7
Show file tree
Hide file tree
Showing 15 changed files with 144 additions and 146 deletions.
86 changes: 43 additions & 43 deletions Dolphin.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Dolphin/Modules/Main/HomeTabBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import WhatsNewKit
enum HomeTabBarItem: Int, CaseIterable {

// 导航栏包含(首页,工作台,消息,设置)
case home, workbench, message, settings
case home, workbench, message, user

private func controller(with viewModel: ViewModel) -> UIViewController {
switch self {
Expand All @@ -27,8 +27,8 @@ enum HomeTabBarItem: Int, CaseIterable {
case .message:
let vc = MessageViewController(viewModel: viewModel)
return NavigationController(rootViewController: vc)
case .settings:
let vc = SettingsViewController(viewModel: viewModel)
case .user:
let vc = UserViewController(viewModel: viewModel)
return NavigationController(rootViewController: vc)
}
}
Expand All @@ -39,7 +39,7 @@ enum HomeTabBarItem: Int, CaseIterable {
case .home: return R.image.icon_tabbar_home()
case .workbench: return R.image.icon_tabbar_workbench()
case .message: return R.image.icon_tabbar_activity()
case .settings: return R.image.icon_tabbar_settings()
case .user: return R.image.icon_tabbar_settings()
}
}

Expand All @@ -49,7 +49,7 @@ enum HomeTabBarItem: Int, CaseIterable {
case .home: return R.string.localizable.homeTabBarHomeTitle.key.localized()
case .workbench: return R.string.localizable.homeTabBarWorkbenchTitle.key.localized()
case .message: return R.string.localizable.homeTabBarMessageTitle.key.localized()
case .settings: return R.string.localizable.homeTabBarSettingsTitle.key.localized()
case .user: return R.string.localizable.homeTabBarUserTitle.key.localized()
}
}

Expand All @@ -59,7 +59,7 @@ enum HomeTabBarItem: Int, CaseIterable {
case .home: animation = RAMBounceAnimation()
case .workbench: animation = RAMBounceAnimation()
case .message: animation = RAMBounceAnimation()
case .settings: animation = RAMRightRotationAnimation()
case .user: animation = RAMRightRotationAnimation()
}
animation.theme.iconSelectedColor = themeService.attribute { $0.secondary }
animation.theme.textSelectedColor = themeService.attribute { $0.secondary }
Expand Down
4 changes: 2 additions & 2 deletions Dolphin/Modules/Main/HomeTabBarViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class HomeTabBarViewModel: ViewModel, ViewModelType {
case .message:
let viewModel = MessageViewModel()
return viewModel
case .settings:
let viewModel = SettingsViewModel()
case .user:
let viewModel = UserViewModel()
return viewModel
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//

import SwiftUI
class SettingCell: DefaultTableViewCell {
class UserCell: DefaultTableViewCell {

override func makeUI() {
super.makeUI()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="SettingCell" id="KGk-i7-Jjw" customClass="SettingCell" customModule="康来呼叫器" customModuleProvider="target">
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="UserCell" id="KGk-i7-Jjw" userLabel="UserCell" customClass="UserCell" customModule="海豚生态" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<point key="canvasLocation" x="41" y="21"/>
</tableViewCell>
</objects>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Foundation
import RxSwift
import RxCocoa

class SettingCellViewModel: DefaultTableViewCellViewModel {
class UserCellViewModel: DefaultTableViewCellViewModel {

init(with title: String, detail: String?, image: UIImage?, hidesDisclosure: Bool) {
super.init()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import SwiftUI

class SettingSwitchCell: DefaultTableViewCell {
class UserSwitchCell: DefaultTableViewCell {

lazy var switchView: Switch = {
let view = Switch()
Expand All @@ -26,7 +26,7 @@ class SettingSwitchCell: DefaultTableViewCell {

override func bind(to viewModel: TableViewCellViewModel) {
super.bind(to: viewModel)
guard let viewModel = viewModel as? SettingSwitchCellViewModel else { return }
guard let viewModel = viewModel as? UserSwitchCellViewModel else { return }
viewModel.isEnabled.asDriver().drive(switchView.rx.isOn).disposed(by: rx.disposeBag)
switchView.rx.isOn.bind(to: viewModel.switchChanged).disposed(by: rx.disposeBag)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="SettingSwitchCell" id="KGk-i7-Jjw" customClass="SettingSwitchCell" customModule="康来呼叫器" customModuleProvider="target">
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="UserSwitchCell" id="KGk-i7-Jjw" userLabel="UserSwitchCell" customClass="UserSwitchCell" customModule="海豚生态" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<point key="canvasLocation" x="106" y="21"/>
</tableViewCell>
</objects>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Foundation
import RxSwift
import RxCocoa

class SettingSwitchCellViewModel: DefaultTableViewCellViewModel {
class UserSwitchCellViewModel: DefaultTableViewCellViewModel {

let isEnabled = BehaviorRelay<Bool>(value: false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@
import Foundation
import RxDataSources

enum SettingsSection {
case setting(title: String, items: [SettingsSectionItem])
enum UserSection {
case setting(title: String, items: [UserSectionItem])
}

enum SettingsSectionItem {
enum UserSectionItem {

// 夜间模式
case nightModeItem(viewModel: SettingSwitchCellViewModel)
case nightModeItem(viewModel: UserSwitchCellViewModel)

// 切换主题颜色
case themeItem(viewModel: SettingCellViewModel)
case themeItem(viewModel: UserCellViewModel)

// 切换国际化语言
case languageItem(viewModel: SettingCellViewModel)
case languageItem(viewModel: UserCellViewModel)

// 清除图片缓存
case removeCacheItem(viewModel: SettingCellViewModel)
case removeCacheItem(viewModel: UserCellViewModel)

// 新特性
case whatsNewItem(viewModel: SettingCellViewModel)
case whatsNewItem(viewModel: UserCellViewModel)

// 登出
case logoutItem(viewModel: SettingCellViewModel)
case logoutItem(viewModel: UserCellViewModel)
}

extension SettingsSectionItem: IdentifiableType {
extension UserSectionItem: IdentifiableType {
typealias Identity = String
var identity: Identity {
switch self {
Expand All @@ -46,14 +46,14 @@ extension SettingsSectionItem: IdentifiableType {
}
}

extension SettingsSectionItem: Equatable {
static func == (lhs: SettingsSectionItem, rhs: SettingsSectionItem) -> Bool {
extension UserSectionItem: Equatable {
static func == (lhs: UserSectionItem, rhs: UserSectionItem) -> Bool {
return lhs.identity == rhs.identity
}
}

extension SettingsSection: AnimatableSectionModelType, IdentifiableType {
typealias Item = SettingsSectionItem
extension UserSection: AnimatableSectionModelType, IdentifiableType {
typealias Item = UserSectionItem

typealias Identity = String
var identity: Identity { return title }
Expand All @@ -64,13 +64,13 @@ extension SettingsSection: AnimatableSectionModelType, IdentifiableType {
}
}

var items: [SettingsSectionItem] {
var items: [UserSectionItem] {
switch self {
case .setting(_, let items): return items.map {$0}
}
}

init(original: SettingsSection, items: [Item]) {
init(original: UserSection, items: [Item]) {
switch original {
case .setting(let title, let items): self = .setting(title: title, items: items)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,52 @@ import RxDataSources
import WhatsNewKit
import Toast_Swift

private let switchReuseIdentifier = R.reuseIdentifier.settingSwitchCell.identifier
private let reuseIdentifier = R.reuseIdentifier.settingCell.identifier
class SettingsViewController: TableViewController {
private let switchReuseIdentifier = R.reuseIdentifier.userSwitchCell.identifier
private let reuseIdentifier = R.reuseIdentifier.userCell.identifier
class UserViewController: TableViewController {

override func viewDidLoad() {
super.viewDidLoad()
}

// 懒加载顶部头视图
private lazy var headerView: SettingsHeaderView = {
let view = SettingsHeaderView()
private lazy var headerView: UserHeaderView = {
let view = UserHeaderView()
view.delegate = self
return view
}()

override func makeUI() {
super.makeUI()
languageChanged.subscribe(onNext: { [weak self] () in
self?.navigationTitle = R.string.localizable.homeTabBarSettingsTitle.key.localized()
self?.navigationTitle = R.string.localizable.homeTabBarUserTitle.key.localized()
}).disposed(by: rx.disposeBag)
stackView.insertArrangedSubview(headerView, at: 0)
tableView.register(R.nib.settingCell)
tableView.register(R.nib.settingSwitchCell)
tableView.register(R.nib.userCell)
tableView.register(R.nib.userSwitchCell)
tableView.headRefreshControl = nil
tableView.footRefreshControl = nil
}

override func bindViewModel() {
super.bindViewModel()
guard let viewModel = viewModel as? SettingsViewModel else { return }
guard let viewModel = viewModel as? UserViewModel else { return }
let refresh = Observable.of(rx.viewWillAppear.mapToVoid(), languageChanged.asObservable()).merge()
let input = SettingsViewModel.Input(trigger: refresh, selection: tableView.rx.modelSelected(SettingsSectionItem.self).asDriver())
let input = UserViewModel.Input(trigger: refresh, selection: tableView.rx.modelSelected(UserSectionItem.self).asDriver())
let output = viewModel.transform(input: input)

let dataSource = RxTableViewSectionedReloadDataSource<SettingsSection>(configureCell: { dataSource, tableView, indexPath, item in
let dataSource = RxTableViewSectionedReloadDataSource<UserSection>(configureCell: { dataSource, tableView, indexPath, item in
switch item {
case .nightModeItem(let viewModel):
let cell = (tableView.dequeueReusableCell(withIdentifier: switchReuseIdentifier, for: indexPath) as? SettingSwitchCell)!
let cell = (tableView.dequeueReusableCell(withIdentifier: switchReuseIdentifier, for: indexPath) as? UserSwitchCell)!
cell.bind(to: viewModel)
return cell
case .themeItem(let viewModel),
.languageItem(let viewModel),
.removeCacheItem(let viewModel),
.whatsNewItem(let viewModel),
.logoutItem(let viewModel):
let cell = (tableView.dequeueReusableCell(withIdentifier: reuseIdentifier, for: indexPath) as? SettingCell)!
let cell = (tableView.dequeueReusableCell(withIdentifier: reuseIdentifier, for: indexPath) as? UserCell)!
cell.bind(to: viewModel)
return cell
}
Expand Down Expand Up @@ -112,9 +112,9 @@ class SettingsViewController: TableViewController {
}

func logoutAction() {
let alertController = UIAlertController(title: "温馨提示", message: R.string.localizable.settingsLogoutAlertMessage.key.localized(), preferredStyle: UIAlertController.Style.alert)
let alertController = UIAlertController(title: "温馨提示", message: R.string.localizable.userLogoutAlertMessage.key.localized(), preferredStyle: UIAlertController.Style.alert)

let logoutAction = UIAlertAction(title: R.string.localizable.settingsLogoutAlertConfirmButtonTitle.key.localized(), style: .destructive) { [weak self] (result: UIAlertAction) in
let logoutAction = UIAlertAction(title: R.string.localizable.userLogoutAlertConfirmButtonTitle.key.localized(), style: .destructive) { [weak self] (result: UIAlertAction) in
PermissionUtil.logout()
}

Expand All @@ -127,7 +127,7 @@ class SettingsViewController: TableViewController {

}

extension SettingsViewController: SettingsHeaderViewDelegate {
extension UserViewController: UserHeaderViewDelegate {

// 图片点击
func imgViewClick(imgView: UIImageView) {
Expand Down
Loading

0 comments on commit c959bf7

Please sign in to comment.