Merge branch 'feature/textLink' into 'develop'

added textField addition

See merge request BPHV_MIPS/vds_ios_sample!9
This commit is contained in:
Bruce, Matt R 2022-11-21 21:05:44 +00:00
commit 76260ad24e
18 changed files with 145 additions and 50 deletions

View File

@ -571,7 +571,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = FCMA4QKS77;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = VDSSample/Info.plist;
@ -601,7 +601,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = FCMA4QKS77;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = VDSSample/Info.plist;

View File

@ -7,6 +7,7 @@
import Foundation
import UIKit
import VDS
class TextField: UITextField {
var textPadding = UIEdgeInsets(
@ -16,6 +17,15 @@ class TextField: UITextField {
right: 10
)
override init(frame: CGRect) {
super.init(frame: frame)
font = TypographicalStyle.BodyLarge.font
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func textRect(forBounds bounds: CGRect) -> CGRect {
layer.borderColor = UIColor.black.cgColor
layer.borderWidth = 1

View File

@ -36,7 +36,10 @@ public class PickerSelectorView<EnumType: RawRepresentable>: UIStackView, Picker
private weak var picker: UIPickerView?
fileprivate var selectedIndex = 0
private var subscribers = Set<AnyCancellable>()
private var label = UILabel()
private var label = Label().with {
$0.typograpicalStyle = .BodyLarge
}
private var button = Button().with { instance in
instance.size = .small
instance.use = .secondary
@ -88,11 +91,6 @@ public class PickerSelectorView<EnumType: RawRepresentable>: UIStackView, Picker
items.count + 1
}
public func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int ) -> String? {
guard row > 0, let item = items[row-1].rawValue as? String else { return "" }
return item
}
public func pickerView( _ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
guard row - 1 >= 0 else { return }
selectedIndex = row
@ -100,6 +98,21 @@ public class PickerSelectorView<EnumType: RawRepresentable>: UIStackView, Picker
text = "\(items[row-1].rawValue)"
pickerView.isHidden = true
}
public func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {
var label = UILabel()
if let v = view as? UILabel { label = v }
label.font = TypographicalStyle.TitleMedium.font
label.text = title(for: row)
label.textAlignment = .center
return label
}
private func title(for row: Int) -> String {
guard row > 0, let item = items[row-1].rawValue as? String else { return "" }
return item
}
}
public class SurfacePickerSelectorView: PickerSelectorView<Surface>{

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="IOo-c1-iSM">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="IOo-c1-iSM">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -13,7 +14,7 @@
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="IOo-c1-iSM" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="PHn-rK-60b">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<rect key="frame" x="0.0" y="48" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
@ -33,25 +34,6 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="cell" textLabel="IUG-CW-6ON" style="IBUITableViewCellStyleDefault" id="1RT-mx-PaP">
<rect key="frame" x="0.0" y="44.5" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="1RT-mx-PaP" id="jMm-oH-21o">
<rect key="frame" x="0.0" y="0.0" width="385.5" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="IUG-CW-6ON">
<rect key="frame" x="20" y="0.0" width="357.5" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="0.0"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="COS-ke-xox" id="uRU-Qn-p3g"/>
<outlet property="delegate" destination="COS-ke-xox" id="Hfp-uJ-fdZ"/>

View File

@ -53,6 +53,8 @@ class BadgeViewController: BaseViewController {
var maxWidthTextField = TextField()
var badge = Badge()
override func allTextFields() -> [UITextField]? { [textField, maxWidthTextField] }
override func viewDidLoad() {
super.viewDidLoad()
@ -68,7 +70,7 @@ class BadgeViewController: BaseViewController {
addFormRow(label: "Text", view: textField)
addFormRow(label: "Max Width", view: maxWidthTextField)
addFormRow(label: "Number of Lines", view: numberOfLinesPickerSelectorView)
textField
.textPublisher
.sink { [weak self] text in

View File

@ -168,8 +168,9 @@ public class BaseViewController: UIViewController, Initable {
$0.spacing = 5
}
let label = UILabel().with {
let label = Label().with {
$0.text = label
$0.typograpicalStyle = .BodyLarge
}
formRow.addArrangedSubview(label)
@ -186,10 +187,23 @@ public class BaseViewController: UIViewController, Initable {
}
}
open func setup() {}
open func setup() {
if let textFields = allTextFields() {
for textField in textFields {
textField.returnKeyType = .done
textField
.publisher(for: .editingDidEndOnExit)
.sink { textField in
textField.resignFirstResponder()
}
.store(in: &subscribers)
}
}
}
open func updateView() {
print("\(Self.self) updateView()")
}
open func allTextFields() -> [UITextField]? { nil }
}

View File

@ -40,6 +40,8 @@ class ButtonGroupViewController: BaseViewController {
setupModel()
}
override func allTextFields() -> [UITextField]? { [widthTextField] }
func setupForm(){
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch))

View File

@ -40,6 +40,8 @@ class ButtonViewController: BaseViewController {
setupModel()
}
override func allTextFields() -> [UITextField]? { [textField, widthTextField] }
func setupForm(){
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Use", view: usePickerSelectorView)

View File

@ -29,6 +29,8 @@ class CheckboxGroupViewController: BaseViewController {
setupModel()
}
override func allTextFields() -> [UITextField]? { [labelTextField, childTextField] }
func setupForm() {
addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch))
addFormRow(label: "Surface", view: surfacePickerSelectorView)

View File

@ -30,6 +30,8 @@ class CheckboxViewController: BaseViewController {
setupModel()
}
override func allTextFields() -> [UITextField]? { [labelTextField, childTextField, errorTextField] }
func setupForm(){
addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch))
addFormRow(label: "Surface", view: surfacePickerSelectorView)

View File

@ -38,6 +38,8 @@ class LabelViewController: BaseViewController {
setupModel()
}
override func allTextFields() -> [UITextField]? { [textField] }
func setupForm(){
addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch))
addFormRow(label: "Bold", view: .makeWrapper(for: boldSwitch))

View File

@ -7,9 +7,12 @@
import Foundation
import UIKit
import VDS
import VDSColorTokens
struct MenuComponent {
var title: String
var completed: Bool
var viewController: UIViewController.Type
}
@ -17,26 +20,70 @@ protocol Initable {
init()
}
class MenuCell: UITableViewCell {
var completed: Bool = true {
didSet {
if completed {
statusImage.image = UIImage(systemName: "checkmark.circle")
statusImage.tintColor = VDSColor.paletteGreen26
} else {
statusImage.image = UIImage(systemName: "xmark.circle")
statusImage.tintColor = VDSColor.paletteRed
}
}
}
var statusImage = UIImageView().with {
$0.translatesAutoresizingMaskIntoConstraints = false
}
var label = Label().with {
$0.typograpicalStyle = .BodyLarge
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setup()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setup(){
addSubview(statusImage)
addSubview(label)
statusImage.pinLeading(16)
label.pinLeading(statusImage.trailingAnchor, 10)
label.pinTop()
label.pinBottom()
label.pinTrailing()
statusImage.width(20)
statusImage.height(20)
statusImage.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
}
}
class MenuViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
overrideUserInterfaceStyle = .light
tableView.register(MenuCell.self, forCellReuseIdentifier: "cell")
}
let items: [MenuComponent] = [
MenuComponent(title: "Badge", viewController: BadgeViewController.self),
MenuComponent(title: "Button", viewController: ButtonViewController.self),
MenuComponent(title: "ButtonGroup", viewController: ButtonGroupViewController.self),
MenuComponent(title: "Checkbox", viewController: CheckboxViewController.self),
MenuComponent(title: "CheckboxGroup", viewController: CheckboxGroupViewController.self),
MenuComponent(title: "Label", viewController: LabelViewController.self),
MenuComponent(title: "RadioBoxGroup", viewController: RadioBoxGroupViewController.self),
MenuComponent(title: "RadioButtonGroup", viewController: RadioButtonViewController.self),
MenuComponent(title: "RadioSwatchGroup", viewController: RadioSwatchGroupViewController.self),
MenuComponent(title: "TextEntryField", viewController: TextEntryFieldViewController.self),
MenuComponent(title: "TextLink", viewController: TextLinkViewController.self),
MenuComponent(title: "TextLinkCaret", viewController: TextLinkCaretViewController.self),
MenuComponent(title: "Toggle", viewController: ToggleViewController.self)
MenuComponent(title: "Badge", completed: true, viewController: BadgeViewController.self),
MenuComponent(title: "Button", completed: true, viewController: ButtonViewController.self),
MenuComponent(title: "ButtonGroup", completed: false, viewController: ButtonGroupViewController.self),
MenuComponent(title: "Checkbox", completed: true, viewController: CheckboxViewController.self),
MenuComponent(title: "CheckboxGroup", completed: true, viewController: CheckboxGroupViewController.self),
MenuComponent(title: "Label", completed: true, viewController: LabelViewController.self),
MenuComponent(title: "RadioBoxGroup", completed: true, viewController: RadioBoxGroupViewController.self),
MenuComponent(title: "RadioButtonGroup", completed: true, viewController: RadioButtonViewController.self),
MenuComponent(title: "RadioSwatchGroup", completed: true, viewController: RadioSwatchGroupViewController.self),
MenuComponent(title: "TextEntryField", completed: false, viewController: TextEntryFieldViewController.self),
MenuComponent(title: "TextLink", completed: true, viewController: TextLinkViewController.self),
MenuComponent(title: "TextLinkCaret", completed: true, viewController: TextLinkCaretViewController.self),
MenuComponent(title: "Toggle", completed: true, viewController: ToggleViewController.self)
]
override func numberOfSections(in tableView: UITableView) -> Int {
@ -47,14 +94,19 @@ class MenuViewController: UITableViewController {
items.count
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
50.0
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
guard items.count > indexPath.row,
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? MenuCell
else { return UITableViewCell() }
guard items.count > indexPath.row else { return UITableViewCell() }
let item = items[indexPath.row]
cell.textLabel?.text = item.title
cell.label.text = item.title
cell.completed = item.completed
cell.accessoryType = .disclosureIndicator
return cell
}

View File

@ -31,6 +31,8 @@ class RadioBoxGroupViewController: BaseViewController {
setupModel()
}
override func allTextFields() -> [UITextField]? { [textField, subTextField, subTextRightField] }
func setupForm() {
addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch))
addFormRow(label: "Surface", view: surfacePickerSelectorView)

View File

@ -29,6 +29,8 @@ class RadioButtonViewController: BaseViewController {
setupModel()
}
override func allTextFields() -> [UITextField]? { [labelTextField, childTextField] }
func setupForm() {
addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch))
addFormRow(label: "Surface", view: surfacePickerSelectorView)

View File

@ -41,6 +41,8 @@ class TextEntryFieldViewController: BaseViewController {
setupModel()
}
override func allTextFields() -> [UITextField]? { [labelTextField, errorTextField, successTextField, helperTextField, widthTextField, tooltipTitleTextField, tooltipContentTextField] }
func setupForm(){
addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch))
addFormRow(label: "Required", view: .makeWrapper(for: requiredSwitch))

View File

@ -33,6 +33,8 @@ class TextLinkCaretViewController: BaseViewController {
setupModel()
}
override func allTextFields() -> [UITextField]? { [textField] }
func setupForm(){
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch))

View File

@ -34,6 +34,8 @@ class TextLinkViewController: BaseViewController {
setupModel()
}
override func allTextFields() -> [UITextField]? { [textField] }
func setupForm(){
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch))

View File

@ -52,6 +52,8 @@ class ToggleViewController: BaseViewController {
setupPicker()
}
override func allTextFields() -> [UITextField]? { [onTextField, offTextField] }
func setupForm() {
addFormRow(label: "Show Text", view: .makeWrapper(for: showTextSwitch))