Skip to content

Commit

Permalink
fix: adds equatable property to DataTableConfiguration and DataTableC…
Browse files Browse the repository at this point in the history
…olumnOrder, configuration tests passing
  • Loading branch information
pavankataria committed Jun 18, 2019
1 parent 2bb449f commit 817ad14
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 160 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1
5.0
240 changes: 138 additions & 102 deletions Example/SwiftDataTables.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@
ReferencedContainer = "container:SwiftDataTables.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "05D66E6B22B94942003004D9"
BuildableName = "SwiftDataTablesTests.xctest"
BlueprintName = "SwiftDataTablesTests"
ReferencedContainer = "container:SwiftDataTables.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
Expand Down
4 changes: 1 addition & 3 deletions Example/Tests/Info.plist → Example/SwiftDataTablesTests/Info.plist
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand All @@ -16,8 +16,6 @@
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
Expand Down
27 changes: 27 additions & 0 deletions Example/SwiftDataTablesTests/SwiftDataTablesTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// SwiftDataTablesTests.swift
// SwiftDataTablesTests
//
// Created by Pavan Kataria on 18/06/2019.
// Copyright © 2019 CocoaPods. All rights reserved.
//

import XCTest
@testable import SwiftDataTables_Example

class SwiftDataTablesTests: XCTestCase {

func test_swiftDataTable_withConfigurationOptions_initialises() {
var configuration : DataTableConfiguration = DataTableConfiguration()
configuration.highlightedAlternatingRowColors = [
.init(1, 0.7, 0.7), .init(1, 0.7, 0.5), .init(1, 1, 0.5), .init(0.5, 1, 0.5), .init(0.5, 0.7, 1), .init(0.5, 0.5, 1), .init(1, 0.5, 0.5)
]
configuration.unhighlightedAlternatingRowColors = [
.init(1, 0.90, 0.90), .init(1, 0.90, 0.7), .init(1, 1, 0.7), .init(0.7, 1, 0.7), .init(0.7, 0.9, 1), .init(0.7, 0.7, 1), .init(1, 0.7, 0.7)
]

let dataTable = SwiftDataTable(data: [[String]](), headerTitles: [], options: configuration, frame: .zero)

XCTAssertEqual(dataTable.options, configuration)
}
}
50 changes: 0 additions & 50 deletions Example/Tests/Tests.swift

This file was deleted.

1 change: 1 addition & 0 deletions SwiftDataTables.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Pod::Spec.new do |s|
s.name = 'SwiftDataTables'
s.version = '0.7.4'
s.summary = 'A Swift Data Table package that allows ordering, searching, and paging with extensible options.'
s.swift_version = '5.0'

# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
Expand Down
4 changes: 2 additions & 2 deletions SwiftDataTables/Classes/DataTableConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import UIKit

public struct DataTableColumnOrder {
public struct DataTableColumnOrder: Equatable {
//MARK: - Properties
let index: Int
let order: DataTableSortType
Expand All @@ -18,7 +18,7 @@ public struct DataTableColumnOrder {
self.order = order
}
}
public struct DataTableConfiguration {
public struct DataTableConfiguration: Equatable {
public var defaultOrdering: DataTableColumnOrder? = nil
public var heightForSectionFooter: CGFloat = 44
public var heightForSectionHeader: CGFloat = 44
Expand Down
6 changes: 4 additions & 2 deletions SwiftDataTables/Classes/SwiftDataTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ public class SwiftDataTable: UIView {

public init(data: DataTableContent,
headerTitles: [String],
options: DataTableConfiguration? = DataTableConfiguration(),
options: DataTableConfiguration = DataTableConfiguration(),
frame: CGRect = .zero)
{
self.options = options!
self.options = options
super.init(frame: frame)
self.set(data: data, headerTitles: headerTitles, options: options, shouldReplaceLayout: true)
self.registerObservers()
Expand All @@ -172,6 +172,7 @@ public class SwiftDataTable: UIView {
self.init(
data: data.map { $0.map { .string($0) }},
headerTitles: headerTitles,
options: options,
frame: frame
)
}
Expand All @@ -180,6 +181,7 @@ public class SwiftDataTable: UIView {
fatalError("init(coder:) has not been implemented")
}


deinit {
NotificationCenter.default.removeObserver(self, name: UIApplication.willChangeStatusBarOrientationNotification, object: nil)
}
Expand Down

0 comments on commit 817ad14

Please sign in to comment.