Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added RichTextViewController with RichTextView and ToolBar. #7

Open
wants to merge 1 commit into
base: feature/rich_text
Choose a base branch
from

Conversation

RomanKozlovskiy
Copy link
Owner

added toolbar, text styling using toolbar buttons and text formatting within a specific range

added text formatting using toolbar buttons and text formatting in a specific range

import UIKit
import RichTextKit
import SnapKit
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

получится без снапкита сделать?

import RichTextKit
import SnapKit

final class RichTextViewController: UIViewController {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

получится переделать с UIViewController на UIView?

barButton.isSelected.toggle()

if barButton.isSelected == true {
richTextView.setRichTextStyle(style, to: barButton.isSelected)
Copy link
Collaborator

@IslamRustamov98 IslamRustamov98 May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вот это можно вынести из if/else и написать лишь один раз

barButton.tintColor = .systemBlue
} else {
richTextView.setRichTextStyle(style, to: barButton.isSelected)
barButton.tintColor = .none
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вот это можно переписать на barButton.tintColor = barButton.isSelected ? .systemBlue : .none

guard let barButton else { return }
barButton.isSelected.toggle()

if barButton.isSelected == true {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в таких случаях просто пиши if barButton.isSelected

Comment on lines +108 to +111
boldButton?.isSelected = richTextView.richTextStyles.contains(.bold) ? true : false
italicButton?.isSelected = richTextView.richTextStyles.contains(.italic) ? true : false
strikethroughButton?.isSelected = richTextView.richTextStyles.contains(.strikethrough) ? true : false
underlinedButton?.isSelected = richTextView.richTextStyles.contains(.underlined) ? true : false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вот это все можно переписать так:
boldButton?.isSelected = richTextView.richTextStyles.contains(.bold)
(и для других кнопок также)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants