Compare commits
6 Commits
255f171aa8
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a525c763e | |||
| a0dffdc715 | |||
| 4765d48021 | |||
| f888e28d15 | |||
| c934dbad84 | |||
| 4088db8ec0 |
@@ -184,6 +184,7 @@
|
|||||||
knownRegions = (
|
knownRegions = (
|
||||||
en,
|
en,
|
||||||
Base,
|
Base,
|
||||||
|
"zh-Hans",
|
||||||
);
|
);
|
||||||
mainGroup = CFD40B073003C283009C9F2A;
|
mainGroup = CFD40B073003C283009C9F2A;
|
||||||
minimizedProjectReferenceProxies = 1;
|
minimizedProjectReferenceProxies = 1;
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import UIKit
|
|||||||
class ClipEditViewController: UIViewController {
|
class ClipEditViewController: UIViewController {
|
||||||
|
|
||||||
private var textView: UITextView!
|
private var textView: UITextView!
|
||||||
|
private var floatingDoneButton: UIButton!
|
||||||
|
private var floatingDoneButtonBottomConstraint: NSLayoutConstraint!
|
||||||
private var clip: Clip
|
private var clip: Clip
|
||||||
|
|
||||||
init(clip: Clip) {
|
init(clip: Clip) {
|
||||||
@@ -52,6 +54,8 @@ class ClipEditViewController: UIViewController {
|
|||||||
UIView.animate(withDuration: duration, delay: 0, options: .beginFromCurrentState) {
|
UIView.animate(withDuration: duration, delay: 0, options: .beginFromCurrentState) {
|
||||||
self.textView.contentInset.bottom = keyboardHeight
|
self.textView.contentInset.bottom = keyboardHeight
|
||||||
self.textView.verticalScrollIndicatorInsets.bottom = keyboardHeight
|
self.textView.verticalScrollIndicatorInsets.bottom = keyboardHeight
|
||||||
|
self.floatingDoneButtonBottomConstraint.constant = -(keyboardHeight + 8)
|
||||||
|
self.floatingDoneButton.alpha = 1
|
||||||
self.view.layoutIfNeeded()
|
self.view.layoutIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,6 +66,8 @@ class ClipEditViewController: UIViewController {
|
|||||||
UIView.animate(withDuration: duration, delay: 0, options: .beginFromCurrentState) {
|
UIView.animate(withDuration: duration, delay: 0, options: .beginFromCurrentState) {
|
||||||
self.textView.contentInset.bottom = 0
|
self.textView.contentInset.bottom = 0
|
||||||
self.textView.verticalScrollIndicatorInsets.bottom = 0
|
self.textView.verticalScrollIndicatorInsets.bottom = 0
|
||||||
|
self.floatingDoneButtonBottomConstraint.constant = -16
|
||||||
|
self.floatingDoneButton.alpha = 0
|
||||||
self.view.layoutIfNeeded()
|
self.view.layoutIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,31 +100,39 @@ class ClipEditViewController: UIViewController {
|
|||||||
textView.font = UIFont.preferredFont(forTextStyle: .body)
|
textView.font = UIFont.preferredFont(forTextStyle: .body)
|
||||||
textView.textContainerInset = UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12)
|
textView.textContainerInset = UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12)
|
||||||
textView.text = clip.text
|
textView.text = clip.text
|
||||||
textView.inputAccessoryView = createInputAccessoryView()
|
|
||||||
view.addSubview(textView)
|
view.addSubview(textView)
|
||||||
|
|
||||||
|
var doneConfig = UIButton.Configuration.glass()
|
||||||
|
doneConfig.title = "完成"
|
||||||
|
doneConfig.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
|
||||||
|
var outgoing = incoming
|
||||||
|
outgoing.font = UIFont.systemFont(ofSize: 17, weight: .semibold)
|
||||||
|
return outgoing
|
||||||
|
}
|
||||||
|
doneConfig.baseForegroundColor = .label
|
||||||
|
doneConfig.cornerStyle = .capsule
|
||||||
|
doneConfig.contentInsets = NSDirectionalEdgeInsets(top: 15, leading: 22, bottom: 15, trailing: 22)
|
||||||
|
floatingDoneButton = UIButton(configuration: doneConfig)
|
||||||
|
floatingDoneButton.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
floatingDoneButton.alpha = 0
|
||||||
|
floatingDoneButton.addTarget(self, action: #selector(didTapFloatingDoneButton), for: .touchUpInside)
|
||||||
|
view.addSubview(floatingDoneButton)
|
||||||
|
|
||||||
let safeArea = view.safeAreaLayoutGuide
|
let safeArea = view.safeAreaLayoutGuide
|
||||||
|
floatingDoneButtonBottomConstraint = floatingDoneButton.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -16)
|
||||||
|
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
textView.topAnchor.constraint(equalTo: safeArea.topAnchor, constant: 16),
|
textView.topAnchor.constraint(equalTo: safeArea.topAnchor, constant: 16),
|
||||||
textView.leadingAnchor.constraint(equalTo: safeArea.leadingAnchor, constant: 16),
|
textView.leadingAnchor.constraint(equalTo: safeArea.leadingAnchor, constant: 16),
|
||||||
textView.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor, constant: -16),
|
textView.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor, constant: -16),
|
||||||
textView.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor, constant: -16)
|
textView.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor, constant: -16),
|
||||||
|
|
||||||
|
floatingDoneButton.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor, constant: -16),
|
||||||
|
floatingDoneButtonBottomConstraint
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
private func createInputAccessoryView() -> UIToolbar {
|
@objc private func didTapFloatingDoneButton() {
|
||||||
let toolbar = UIToolbar(frame: CGRect(x: 0, y: 0, width: view.bounds.width, height: 44))
|
|
||||||
toolbar.barStyle = .default
|
|
||||||
toolbar.isTranslucent = true
|
|
||||||
|
|
||||||
let flexSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
|
|
||||||
let doneButton = UIBarButtonItem(title: "完成", style: .done, target: self, action: #selector(didTapKeyboardDoneButton))
|
|
||||||
toolbar.items = [flexSpace, doneButton]
|
|
||||||
toolbar.sizeToFit()
|
|
||||||
return toolbar
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc private func didTapKeyboardDoneButton() {
|
|
||||||
textView.resignFirstResponder()
|
textView.resignFirstResponder()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -246,8 +246,10 @@ extension ClipInboxViewController: UITableViewDataSource {
|
|||||||
|
|
||||||
var config = cell.defaultContentConfiguration()
|
var config = cell.defaultContentConfiguration()
|
||||||
config.text = previewText(for: clip.text)
|
config.text = previewText(for: clip.text)
|
||||||
|
config.textProperties.numberOfLines = 0
|
||||||
config.secondaryText = formattedDate(clip.createdAt)
|
config.secondaryText = formattedDate(clip.createdAt)
|
||||||
config.secondaryTextProperties.color = .secondaryLabel
|
config.secondaryTextProperties.color = .secondaryLabel
|
||||||
|
config.textToSecondaryTextVerticalPadding = 12
|
||||||
cell.contentConfiguration = config
|
cell.contentConfiguration = config
|
||||||
cell.accessoryType = .disclosureIndicator
|
cell.accessoryType = .disclosureIndicator
|
||||||
|
|
||||||
@@ -255,9 +257,7 @@ extension ClipInboxViewController: UITableViewDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func previewText(for text: String) -> String {
|
private func previewText(for text: String) -> String {
|
||||||
let lines = text.components(separatedBy: .newlines)
|
let preview = text.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
let firstTwoLines = Array(lines.prefix(2))
|
|
||||||
let preview = firstTwoLines.joined(separator: " ").trimmingCharacters(in: .whitespaces)
|
|
||||||
if preview.isEmpty {
|
if preview.isEmpty {
|
||||||
return "(无内容)"
|
return "(无内容)"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,10 +35,6 @@ class FormatNoteViewController: UIViewController {
|
|||||||
setupUI()
|
setupUI()
|
||||||
if let initialText = initialText {
|
if let initialText = initialText {
|
||||||
textView.text = initialText
|
textView.text = initialText
|
||||||
isNoteFormatted = true
|
|
||||||
noteButton.setTitle("复制并打开备忘录", for: .normal)
|
|
||||||
rightBarButtonMode = .reset
|
|
||||||
updateRightBarButtonItem()
|
|
||||||
}
|
}
|
||||||
setupKeyboardObservers()
|
setupKeyboardObservers()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
/* Simplified Chinese localization */
|
||||||
Reference in New Issue
Block a user