Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
stason314 committed Jul 31, 2020
2 parents 58d9ccf + 5868ac7 commit 41d8de9
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Deboogger.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
8586C8F923951D10006DC167 /* PerformanceMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8586C8F823951D10006DC167 /* PerformanceMonitor.swift */; };
8597BD68239A062B000FBE9F /* PaddingLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8597BD67239A062B000FBE9F /* PaddingLabel.swift */; };
85A1A35023952708005A6F6B /* PerformanceWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85A1A34F23952708005A6F6B /* PerformanceWindow.swift */; };
85B95AA8243C33BB00035F87 /* TextFieldPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85B95AA7243C33BB00035F87 /* TextFieldPlugin.swift */; };
85B95AAB243C342400035F87 /* TextFieldTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85B95AAA243C342400035F87 /* TextFieldTableViewCell.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -84,6 +86,8 @@
8586C8F823951D10006DC167 /* PerformanceMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PerformanceMonitor.swift; sourceTree = "<group>"; };
8597BD67239A062B000FBE9F /* PaddingLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaddingLabel.swift; sourceTree = "<group>"; };
85A1A34F23952708005A6F6B /* PerformanceWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PerformanceWindow.swift; sourceTree = "<group>"; };
85B95AA7243C33BB00035F87 /* TextFieldPlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldPlugin.swift; sourceTree = "<group>"; };
85B95AAA243C342400035F87 /* TextFieldTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldTableViewCell.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -234,6 +238,7 @@
840870331FD7B237007741AB /* SegmentTableViewCell */,
840870391FD7B238007741AB /* SwitchTableViewCell */,
840F80481FDA401100A9B466 /* SliderTableViewCell */,
85B95AA9243C340700035F87 /* TextFieldTableViewCell */,
2EED8CA42385127800738BD8 /* SectionTableViewCell */,
);
path = Cells;
Expand Down Expand Up @@ -262,6 +267,7 @@
840870471FD7B2C0007741AB /* SegmentPlugin.swift */,
84459B9C1FDA43BA00398995 /* SliderPlugin.swift */,
2EED8CC82386445E00738BD8 /* NavigationPlugin.swift */,
85B95AA7243C33BB00035F87 /* TextFieldPlugin.swift */,
);
path = Plugins;
sourceTree = "<group>";
Expand Down Expand Up @@ -301,6 +307,14 @@
path = Views;
sourceTree = "<group>";
};
85B95AA9243C340700035F87 /* TextFieldTableViewCell */ = {
isa = PBXGroup;
children = (
85B95AAA243C342400035F87 /* TextFieldTableViewCell.swift */,
);
path = TextFieldTableViewCell;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -390,6 +404,7 @@
849B836D1EC7564000B0DF9D /* PluginViewController.swift in Sources */,
06986A2A241F25BE00A7144F /* Keychain.swift in Sources */,
01AAB6CA23DAD18800C2DB68 /* FavoriteService.swift in Sources */,
85B95AA8243C33BB00035F87 /* TextFieldPlugin.swift in Sources */,
2EED8CA6238512A400738BD8 /* SectionTableViewCell.swift in Sources */,
840870441FD7B238007741AB /* SwitchTableViewCell.swift in Sources */,
847458621FE38E7C00C3B0FA /* Configuration.swift in Sources */,
Expand All @@ -398,6 +413,7 @@
06986A28241F218C00A7144F /* Deboogger+Storage.swift in Sources */,
840870401FD7B238007741AB /* SegmentTableViewCell.swift in Sources */,
85A1A35023952708005A6F6B /* PerformanceWindow.swift in Sources */,
85B95AAB243C342400035F87 /* TextFieldTableViewCell.swift in Sources */,
847458641FE38EDD00C3B0FA /* SectionsConfiguration.swift in Sources */,
849B836C1EC7564000B0DF9D /* TextPlugin.swift in Sources */,
849B835B1EC7564000B0DF9D /* AssistiveButton.swift in Sources */,
Expand Down
4 changes: 4 additions & 0 deletions Example/DebooggerExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
849B83891EC757B800B0DF9D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 849B83871EC757B800B0DF9D /* Main.storyboard */; };
849B838B1EC757B800B0DF9D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 849B838A1EC757B800B0DF9D /* Assets.xcassets */; };
849B838E1EC757B800B0DF9D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 849B838C1EC757B800B0DF9D /* LaunchScreen.storyboard */; };
85B95AAD243C41FE00035F87 /* TextFieldTestPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85B95AAC243C41FE00035F87 /* TextFieldTestPlugin.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -67,6 +68,7 @@
849B838A1EC757B800B0DF9D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
849B838D1EC757B800B0DF9D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
849B838F1EC757B800B0DF9D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
85B95AAC243C41FE00035F87 /* TextFieldTestPlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldTestPlugin.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -97,6 +99,7 @@
8411201E1FE2286600513333 /* SegmentTestPlugin.swift */,
841120201FE22FFF00513333 /* ButtonTestPlugin.swift */,
06482CF82418BB4000C0D7F0 /* DefaultsTestPlugin.swift */,
85B95AAC243C41FE00035F87 /* TextFieldTestPlugin.swift */,
);
path = Plugins;
sourceTree = "<group>";
Expand Down Expand Up @@ -225,6 +228,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
85B95AAD243C41FE00035F87 /* TextFieldTestPlugin.swift in Sources */,
841120211FE22FFF00513333 /* ButtonTestPlugin.swift in Sources */,
8463C62A1EC8C0BD00AF7779 /* SwitchTestPlugin.swift in Sources */,
849B83861EC757B800B0DF9D /* ViewController.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions Example/DebooggerExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
SectionPlugin(title: "Content", style: .nested) {
SwitchTestPlugin(title: .init(string: "Drop connection"))
SliderTestPlugin(title: .init(string: "Response delay"))
TextFieldTestPlugin()
SectionPlugin(title: "Profile") {
SectionPlugin(title: "Authentication") {
ButtonTestPlugin(title: .init(string: "Expire the token"))
Expand Down
18 changes: 18 additions & 0 deletions Example/DebooggerExample/Plugins/TextFieldTestPlugin.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Copyright © 2020 Rosberry. All rights reserved.
//

import Deboogger

final class TextFieldTestPlugin: TextFieldPlugin {
var placeholder: String = "test"
var title: NSAttributedString = .init(string: "TextFieldPlugin")

func textFieldValueChanged(_ textField: UITextField) {
guard let text = textField.text else {
return
}
print(#function, text)
}

}
57 changes: 57 additions & 0 deletions Sources/Cells/TextFieldTableViewCell/TextFieldTableViewCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// Copyright © 2019 Rosberry. All rights reserved.
//

import UIKit

final class TextFieldTableViewCell: BaseTableViewCell {

private var plugin: TextFieldPlugin?

// MARK: - Subviews

private lazy var textField: UITextField = {
let view = UITextField()
view.borderStyle = .roundedRect
view.delegate = self
view.addTarget(self, action: #selector(textFieldValueChanged), for: .editingChanged)
return view
}()

// MARK: - Lifecycle

override func setup() {
super.setup()
accessoryView = textField
}

override func configure(with plugin: Plugin) {
super.configure(with: plugin)
self.plugin = plugin as? TextFieldPlugin

if let plugin = self.plugin {
textField.placeholder = plugin.placeholder
textField.text = plugin.initialValue
textField.keyboardType = plugin.keyboardType
}
}

override func layoutSubviews() {
textField.bounds = CGRect(origin: .zero, size: .init(width: bounds.midX, height: 40))
super.layoutSubviews()
}

// MARK: - Actions

@objc private func textFieldValueChanged(_ sender: UITextField) {
plugin?.textFieldValueChanged(sender)
}
}

// MARK: - UITextFieldDelegate

extension TextFieldTableViewCell: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
endEditing(true)
}
}
30 changes: 30 additions & 0 deletions Sources/Plugins/TextFieldPlugin.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Copyright © 2020 Rosberry. All rights reserved.
//

public protocol TextFieldPlugin: Plugin {

var placeholder: String { get }
var keyboardType: UIKeyboardType { get }
var initialValue: String? { get }

func textFieldValueChanged(_ textField: UITextField)
}

public extension TextFieldPlugin {
var cellClass: BaseTableViewCell.Type {
return TextFieldTableViewCell.self
}

var placeholder: String {
"Enter text"
}

var keyboardType: UIKeyboardType {
.default
}

var initialValue: String? {
nil
}
}

0 comments on commit 41d8de9

Please sign in to comment.