deep-linking-sample/Apps/Wikipedia/Wikipedia/Code/InsertMediaSettingsTextTableViewCell.swift
Javier Cicchelli 9bcdaa697b [Setup] Basic project structure (#1)
This PR contains all the work related to setting up this project as required to implement the [Assignment](https://repo.rock-n-code.com/rock-n-code/deep-linking-assignment/wiki/Assignment) on top, as intended.

To summarise this work:
- [x] created a new **Xcode** project;
- [x] cloned the `Wikipedia` app and inserted it into the **Xcode** project;
- [x] created the `Locations` app and also, its `Libraries` package;
- [x] created the `Shared` package to share dependencies between the apps;
- [x] added a `Makefile` file and implemented some **environment** and **help** commands.

Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Reviewed-on: rock-n-code/deep-linking-assignment#1
2023-04-08 18:37:13 +00:00

60 lines
2.1 KiB
Swift

import UIKit
class InsertMediaSettingsTextTableViewCell: UITableViewCell {
@IBOutlet private weak var headerLabel: UILabel!
@IBOutlet private weak var footerLabel: UILabel!
@IBOutlet private weak var textView: ThemeableTextView!
var headerText: String? {
didSet {
headerLabel.text = headerText
}
}
var footerText: String? {
didSet {
footerLabel.text = footerText
}
}
func textViewConfigured(with delegate: UITextViewDelegate, placeholder: String?, placeholderDelegate: ThemeableTextViewPlaceholderDelegate, clearDelegate: ThemeableTextViewClearDelegate, tag: Int) -> UITextView {
textView._delegate = delegate
textView.placeholderDelegate = placeholderDelegate
textView.clearDelegate = clearDelegate
textView.showsClearButton = true
textView.placeholder = placeholder
textView.textContainer.lineFragmentPadding = 0
textView.tag = tag
accessibilityElements = [headerLabel as Any, textView as Any, textView.clearButton as Any, footerLabel as Any]
updateFonts()
return textView
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
updateFonts()
}
private func updateFonts() {
headerLabel.font = UIFont.wmf_font(.subheadline, compatibleWithTraitCollection: traitCollection)
footerLabel.font = UIFont.wmf_font(.footnote, compatibleWithTraitCollection: traitCollection)
textView.font = UIFont.wmf_font(.body, compatibleWithTraitCollection: traitCollection)
}
override func prepareForReuse() {
super.prepareForReuse()
headerLabel.text = nil
footerLabel.text = nil
textView.reset()
}
}
extension InsertMediaSettingsTextTableViewCell: Themeable {
func apply(theme: Theme) {
backgroundColor = theme.colors.paperBackground
headerLabel.textColor = theme.colors.secondaryText
footerLabel.textColor = theme.colors.secondaryText
textView.apply(theme: theme)
}
}