Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
repos:
- repo: https://github.com/nicklockwood/SwiftFormat
rev: 0.54.0
rev: 0.61.0
hooks:
- id: swiftformat
4 changes: 2 additions & 2 deletions Demo/Demo/AppConfigs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ enum Region: String, CaseIterable, RawStringValueRepresentable {
case west
}

// Wanna make it more readable instead of just showing integer values?
// Then conform to `CustomStringConvertible`
/// Wanna make it more readable instead of just showing integer values?
/// Then conform to `CustomStringConvertible`
enum AccountType: Int, CaseIterable, RawStringValueRepresentable, CustomStringConvertible {
case guest = 0
case member = 1
Expand Down
20 changes: 10 additions & 10 deletions Demo/DemoTests/SnapshotTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class SnapshotTests: XCTestCase {

// MARK: - Snapshots ViewControllers

func testInAppModificationDisabled() throws {
func testInAppModificationDisabled() {
assertVCSnapshotWithActionFromHost {
try? XConfigs.show(from: $0, animated: false)
}
Expand All @@ -32,28 +32,28 @@ final class SnapshotTests: XCTestCase {
}
}

func testInputValueViewController() throws {
func testInputValueViewController() {
let vc = InputValueViewController(viewModel: .init(model: .init(key: "Hello", value: "World", displayName: "Hello"))).wrapInsideNavVC().preferAsHalfSheet()
assertVCSnapshotWithActionFromHost {
$0.present(vc, animated: false)
}
}

func testInputValueViewControllerJSON() throws {
func testInputValueViewControllerJSON() {
let vc = InputValueViewController(viewModel: .init(model: .init(key: "JSON", value: "{\"name\":\"Kel\", \"city\": \"Melbourne\" }", displayName: "Contact"))).wrapInsideNavVC().preferAsHalfSheet()
assertVCSnapshotWithActionFromHost {
$0.present(vc, animated: false)
}
}

func testInputValueViewControllerURL() throws {
func testInputValueViewControllerURL() {
let vc = InputValueViewController(viewModel: .init(model: .init(key: "URL", value: "https://google.com", displayName: "URL"))).wrapInsideNavVC().preferAsHalfSheet()
assertVCSnapshotWithActionFromHost {
$0.present(vc, animated: false)
}
}

func testOptionViewController() throws {
func testOptionViewController() {
let choices = [1, 2, 3, 4].map { "Value\($0)" }.map { Choice(displayName: $0, value: $0) }
let vc = OptionViewController(viewModel: .init(model: .init(key: "Name", value: "Value1", choices: choices, displayName: "Name"))).wrapInsideNavVC().preferAsHalfSheet()
assertVCSnapshotWithActionFromHost {
Expand All @@ -63,39 +63,39 @@ final class SnapshotTests: XCTestCase {

// MARK: - Snapshots - Views

func testActionView() throws {
func testActionView() {
let view = ActionView().apply {
$0.configure(with: "Action name")
$0.widthAnchor.constraint(equalToConstant: 320).isActive = true
}
assertSnapshot(matching: view, as: .image(precision: 0.95))
}

func testKeyValueView() throws {
func testKeyValueView() {
let view = KeyValueView().apply {
$0.configure(with: ("Name", "Value"))
$0.widthAnchor.constraint(equalToConstant: 320).isActive = true
}
assertSnapshot(matching: view, as: .image(precision: 0.95))
}

func testKeyValueViewWithLongValue() throws {
func testKeyValueViewWithLongValue() {
let view = KeyValueView().apply {
$0.configure(with: ("Name", "This a long value. Lorem ipsum sit dolor amet."))
$0.widthAnchor.constraint(equalToConstant: 320).isActive = true
}
assertSnapshot(matching: view, as: .image(precision: 0.95))
}

func testToggleView() throws {
func testToggleView() {
let view = ToggleView().apply {
$0.configure(with: ("Name", false))
$0.widthAnchor.constraint(equalToConstant: 320).isActive = true
}
assertSnapshot(matching: view, as: .image(precision: 0.95))
}

func testToggleViewWithOnValue() throws {
func testToggleViewWithOnValue() {
let view = ToggleView().apply {
$0.configure(with: ("Name", true))
$0.widthAnchor.constraint(equalToConstant: 320).isActive = true
Expand Down
2 changes: 1 addition & 1 deletion Demo/DemoTests/XConfigsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ final class XConfigsTests: XCTestCase {
))
}

func testTitles() throws {
func testTitles() {
var title = ""
var searchPlaceholderTitle = ""
output.title.sink { title = $0 }.store(in: &subscriptions)
Expand Down
2 changes: 1 addition & 1 deletion Sources/XConfigs/Extensions/UIView++.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Combine
import UIKit

// Provide a default `reuseIdentifier` equal to the class name.
/// Provide a default `reuseIdentifier` equal to the class name.
private extension UITableViewCell {
static var reuseIdentifier: String {
String(describing: self)
Expand Down
6 changes: 1 addition & 5 deletions Sources/XConfigs/Models/SectionItemsModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ struct SectionItemsModel<Section: Hashable, Item: Hashable>: Hashable {

// MARK: Equatable

extension SectionItemsModel: Equatable {
public static func == (lhs: Self, rhs: Self) -> Bool {
lhs.section == rhs.section && lhs.items == rhs.items
}
}
extension SectionItemsModel: Equatable {}

// MARK: - SectionItemsModel + NSDiffableDataSourceSnapshot

Expand Down
6 changes: 3 additions & 3 deletions Sources/XConfigs/ViewControllers/XConfigsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
return self.datasource.itemIdentifier(for: indexPath)
}.eraseToAnyPublisher(),
dismissPublisher: doneButton.tapPublisher
))
)
)

output.searchPlaceholderTitle.compactMap { $0 }.assign(to: \UISearchBar.placeholder, on: searchController.searchBar).store(in: &subscriptions)
output.title.compactMap { $0 }.assign(to: \UIViewController.title, on: self).store(in: &subscriptions)
Expand Down Expand Up @@ -188,11 +189,10 @@
}

private func createCopyAction(_ value: String) -> UIAction {
let copyAction = UIAction(title: "Copy \"\(value)\"") { _ in
UIAction(title: "Copy \"\(value)\"") { _ in
let pasteboard = UIPasteboard.general
pasteboard.string = value
}
return copyAction
}

@available(iOS 13.0, *)
Expand Down
4 changes: 2 additions & 2 deletions Sources/XConfigs/ViewModels/XConfigsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct XConfigsViewModel: ViewModelType {
)
}

// Transform [ConfigInfo] to [SectionItemModel]
/// Transform [ConfigInfo] to [SectionItemModel]
func mapConfigInfosToSectionItemsModels(searchText: String, infos: [ConfigInfo]) -> [SectionItemsModel<Section, Item>] {
var mainItems: [Item] = [.inAppModification(
title: NSLocalizedString("Enable In-app modification?", comment: ""),
Expand Down Expand Up @@ -127,7 +127,7 @@ struct XConfigsViewModel: ViewModelType {
return sections
}

// Transform ConfigInfo to Item
/// Transform ConfigInfo to Item
func mapConfigInfoToItem(_ info: ConfigInfo) -> Item? {
guard !info.readonly else {
var value = info.configValue.rawString
Expand Down
Loading