-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:weiran/Hackers into text
# Conflicts: # App/Main.storyboard
- Loading branch information
Showing
7 changed files
with
187 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// TextSelectionViewController.swift | ||
// Hackers | ||
// | ||
// Created by Peter Ajayi on 08/07/2023. | ||
// Copyright © 2023 Glass Umbrella. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
final class TextSelectionViewController: UIViewController { | ||
|
||
var comment: String? | ||
|
||
@IBOutlet private var commentTextView: UITextView! | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
setup() | ||
} | ||
|
||
private func setup() { | ||
view.backgroundColor = AppTheme.default.backgroundColor | ||
setupCommentTextView() | ||
} | ||
|
||
private func setupCommentTextView() { | ||
commentTextView.attributedText = attributedComment() | ||
commentTextView.textContainerInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10) | ||
commentTextView.textColor = AppTheme.default.textColor | ||
commentTextView.selectAll(nil) | ||
} | ||
|
||
private func attributedComment() -> NSAttributedString? { | ||
guard let comment = comment else { return nil } | ||
|
||
let attributedString = comment.parseToAttributedString() | ||
|
||
let commentRange = NSRange(location: 0, length: attributedString.length) | ||
let commentFont = UIFont.preferredFont(forTextStyle: .subheadline) | ||
|
||
attributedString.addAttribute(NSAttributedString.Key.font, | ||
value: commentFont, | ||
range: commentRange) | ||
|
||
attributedString.addAttribute(NSAttributedString.Key.foregroundColor, | ||
value: AppTheme.default.textColor, | ||
range: commentRange) | ||
|
||
return attributedString | ||
} | ||
|
||
@IBAction private func didPressDone(_ sender: Any) { | ||
dismiss(animated: true) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters