Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ruixhuang committed Nov 7, 2023
1 parent 411b3fa commit 2642504
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 119 deletions.
105 changes: 52 additions & 53 deletions PlatformUIJedio/PlatformUIJedio/Presenters/SettingsViewPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Created by Rui Huang on 3/21/23.
//


import Utilities
import dydxViews
import PlatformParticles
Expand All @@ -17,27 +16,27 @@ import JedioKit
open class SettingsViewPresenter: BaseSettingsViewPresenter {
private let keyValueStore: KeyValueStoreProtocol?
private let appScheme: String?

public init(definitionFile: String, keyValueStore: KeyValueStoreProtocol?, appScheme: String?) {
self.keyValueStore = keyValueStore
self.appScheme = appScheme
super.init(definitionFile: definitionFile)
}

override open func start() {
super.start()

loadSettings()
}

private func loadSettings() {
var sections = [SettingsViewModel.SectionViewModel]()
for fieldList in fieldLists ?? [] {
sections.append(createSection(group: fieldList))
}
viewModel?.sections = sections
}

private func createSection(group: FieldListInteractor) -> SettingsViewModel.SectionViewModel {
let listViewModel = PlatformListViewModel(firstListItemTopSeparator: true, lastListItemBottomSeparator: true)
listViewModel.width = UIScreen.main.bounds.width - 16
Expand All @@ -52,12 +51,12 @@ open class SettingsViewPresenter: BaseSettingsViewPresenter {
}
return SettingsViewModel.SectionViewModel(title: group.title, items: listViewModel)
}

private func createInput(input: FieldInput) -> PlatformViewModel? {
guard let fieldInputDefinition = input.fieldInput else {
return nil
}

if let fieldName = input.fieldName,
let value = keyValueStore?.value(forKey: fieldName) {
input.value = value
Expand All @@ -84,61 +83,61 @@ open class SettingsViewPresenter: BaseSettingsViewPresenter {
} else {
return FieldInputTextsInputViewModel(input: input, valueChanged: valueChanged)
}
// case .int:
// if hasOptions {
// return "field_input_grid_int"
// } else if fieldInput.min != nil && fieldInput.max != nil {
// return "field_input_slider_int"
// } else {
// return "field_input_textfield_int"
// }
//
// case .float:
// if fieldInput.min != nil && fieldInput.max != nil {
// return "field_input_slider_float"
// } else {
// return "field_input_textfield_float"
// }
//
// case .percent:
// return "field_input_slider_percent"
//
// case .strings:
// return "field_input_grid_strings"

// case .int:
// if hasOptions {
// return "field_input_grid_int"
// } else if fieldInput.min != nil && fieldInput.max != nil {
// return "field_input_slider_int"
// } else {
// return "field_input_textfield_int"
// }
//
// case .float:
// if fieldInput.min != nil && fieldInput.max != nil {
// return "field_input_slider_float"
// } else {
// return "field_input_textfield_float"
// }
//
// case .percent:
// return "field_input_slider_percent"
//
// case .strings:
// return "field_input_grid_strings"

case .bool:
return FieldInputSwitchViewModel(input: input, valueChanged: valueChanged)

// case .image:
// #if _iOS
// return "field_button_image"
// #else
// return "field_blank"
// #endif
//
// case .images:
// #if _iOS
// return "field_input_grid_images"
// #else
// return "field_blank"
// #endif
//
// case .signature:
// #if _iOS
// return "field_input_button_signature"
// #else
// return "field_blank"
// #endif
// case .image:
// #if _iOS
// return "field_button_image"
// #else
// return "field_blank"
// #endif
//
// case .images:
// #if _iOS
// return "field_input_grid_images"
// #else
// return "field_blank"
// #endif
//
// case .signature:
// #if _iOS
// return "field_input_button_signature"
// #else
// return "field_blank"
// #endif

default:
//assertionFailure("Not implemented")
// assertionFailure("Not implemented")
break
}
}
return nil
}

private func createOutput(output: FieldOutput) -> PlatformViewModel? {
if let xib = output.field?.xib {
// TODO: ...
Expand Down
12 changes: 6 additions & 6 deletions RoutingKit/RoutingKit/_Router/MappedRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public enum RoutingPresentation: Int {
case drawer
}

fileprivate struct PathTuple {
private struct PathTuple {
let path: String
let params: [String]?
}
Expand Down Expand Up @@ -123,20 +123,20 @@ open class MappedRouter: NSObject, RouterProtocol, ParsingProtocol, CombineObser
public var defaults: [String: String]?
public var aliases: [String: String]?
public var maps: [String: [String: [String: RoutingMap]]]? // ["http":["www.domain.com": ["/": "Home]]]
// public var shared: [String: RoutingMap]
// public var shared: [String: RoutingMap]
public init(file: String) {
super.init()
let shared = JsonLoader.load(bundles: Bundle.particles, fileName: "routing_shared.json") as? [String: Any]
if let destinations = JsonLoader.load(bundles: Bundle.particles, fileName: file) as? [String: Any] {
parse(dictionary: destinations, shared: shared)
}
}

public init(jsonString: String) {
super.init()
let shared = JsonLoader.load(bundles: Bundle.particles, fileName: "routing_shared.json") as? [String: Any]
if let data = jsonString.data(using: .utf8),
let destinations = JsonLoader.load(data: data) as? [String: Any] {
let destinations = JsonLoader.load(data: data) as? [String: Any] {
parse(dictionary: destinations, shared: shared)
}
}
Expand Down Expand Up @@ -185,7 +185,7 @@ open class MappedRouter: NSObject, RouterProtocol, ParsingProtocol, CombineObser
let pathTuple = parsePath(path: key)
let routing = map(destination: destination, params: pathTuple.params)
routing.parse(dictionary: dictionary)
assert(!maps.keys.contains { $0 == pathTuple.path },
assert(!maps.keys.contains { $0 == pathTuple.path },
"collision on paths \(maps.keys.filter {$0 == pathTuple.path}), remove the duplicate route in routing_swiftui.json")
maps[pathTuple.path] = routing
}
Expand Down Expand Up @@ -240,7 +240,7 @@ open class MappedRouter: NSObject, RouterProtocol, ParsingProtocol, CombineObser
}

open func didSetAppState(oldValue: AppState?) {
changeObservation(from: oldValue, to: appState, keyPath: #keyPath(AppState.background)) {[weak self] observer, obj, change, animated in
changeObservation(from: oldValue, to: appState, keyPath: #keyPath(AppState.background)) {[weak self] _, _, _, _ in
self?.sendPending()
}
}
Expand Down
2 changes: 1 addition & 1 deletion Utilities/Utilities/_Utils/JsonLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import Foundation
@objc public class func load(bundled fileName: String?) -> Any? {
return load(bundle: Bundle.main, fileName: fileName)
}

@objc public class func load(data: Data) -> Any? {
return try? JSONSerialization.jsonObject(with: data, options: [])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ final class dydxCarteraConfigWorker: BaseWorker {

override init() {
let filePath = "configs/wallets.json"
#if DEBUG
#if DEBUG
let url: String? = nil
#else
#else
let url = AbacusStateManager.shared.deploymentUri + "/" + filePath
#endif
#endif
CachedFileLoader.shared.loadData(filePath: filePath, url: url) { walletJson in
if let walletJson = walletJson {
CarteraConfig.shared.registerWallets(configJsonData: walletJson)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class dydxMarketInfoViewBuilder: NSObject, ObjectBuilderProtocol {

private class dydxMarketInfoViewController: HostingViewController<PlatformView, dydxMarketInfoViewModel> {
override public func arrive(to request: RoutingRequest?, animated: Bool) -> Bool {
if request?.path == "/trade" || request?.path == "/market", let presenter = presenter as? dydxMarketInfoViewPresenter {
if request?.path == "/trade" || request?.path == "/market", let presenter = presenter as? dydxMarketInfoViewPresenter {
presenter.marketId = request?.params?["market"] as? String ?? "ETH-USD"
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
if request?.path == "/trade" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,34 +47,34 @@ private class dydxHelpViewPresenter: HostedViewPresenter<dydxHelpViewModel>, dyd
title: DataLocalizer.localize(path: "APP.HELP_MODAL.LIVE_CHAT"),
subtitle: DataLocalizer.localize(path: "APP.HELP_MODAL.LIVE_CHAT_DESCRIPTION"),
onTapAction: { [weak self] in
self?.handleLink(link: help)
}))
self?.handleLink(link: help)
}))
}

if let community = AbacusStateManager.shared.environment?.links?.community {
items.append(dydxHelpViewModel.Item(icon: "help_discord",
title: DataLocalizer.localize(path: "APP.HELP_MODAL.JOIN_DISCORD"),
subtitle: DataLocalizer.localize(path: "APP.HELP_MODAL.JOIN_DISCORD_DESCRIPTION"),
onTapAction: { [weak self] in
self?.handleLink(link: community)
}))
self?.handleLink(link: community)
}))
}

if let feedback = AbacusStateManager.shared.environment?.links?.feedback {
items.append(dydxHelpViewModel.Item(icon: "help_feedback",
title: DataLocalizer.localize(path: "APP.HELP_MODAL.PROVIDE_FEEDBACK"),
subtitle: DataLocalizer.localize(path: "APP.HELP_MODAL.PROVIDE_FEEDBACK_DESCRIPTION"),
onTapAction: { [weak self] in
self?.handleLink(link: feedback)
}))
self?.handleLink(link: feedback)
}))
}
if let documentation = AbacusStateManager.shared.environment?.links?.documentation {
items.append(dydxHelpViewModel.Item(icon: "help_api",
title: DataLocalizer.localize(path: "APP.HEADER.API_DOCUMENTATION"),
subtitle: DataLocalizer.localize(path: "APP.HELP_MODAL.API_DOCUMENTATION_DESCRIPTION"),
onTapAction: { [weak self] in
self?.handleLink(link: documentation)
}))
self?.handleLink(link: documentation)
}))
}

viewModel?.items = items
Expand Down
Loading

0 comments on commit 2642504

Please sign in to comment.