Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into release/1.66
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-magda committed Jul 26, 2024
2 parents 19fdf09 + 1b9e0c4 commit 52bab25
Show file tree
Hide file tree
Showing 14 changed files with 1,011 additions and 221 deletions.
1 change: 1 addition & 0 deletions iosHyperskillApp/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ target "iosHyperskillApp" do
pod "SVProgressHUD", "2.3.1"
pod "SkeletonUI", "1.0.11"
pod "lottie-ios", "4.4.3"
pod "BEMCheckBox", "1.4.1"

pod "PanModal", :git => "https://github.com/ivan-magda/PanModal.git", :branch => "remove-presenting-appearance-transitions"
pod "CombineSchedulers", :git => "https://github.com/ivan-magda/combine-schedulers.git", :branch => "main"
Expand Down
6 changes: 5 additions & 1 deletion iosHyperskillApp/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ PODS:
- AppsFlyerFramework/Main (= 6.14.2)
- AppsFlyerFramework/Main (6.14.2)
- Atributika (4.10.1)
- BEMCheckBox (1.4.1)
- CocoaLumberjack (3.8.2):
- CocoaLumberjack/Core (= 3.8.2)
- CocoaLumberjack/Core (3.8.2)
Expand Down Expand Up @@ -116,6 +117,7 @@ DEPENDENCIES:
- AmplitudeSwift (= 1.4.5)
- AppsFlyerFramework (= 6.14.2)
- Atributika (= 4.10.1)
- BEMCheckBox (= 1.4.1)
- CombineSchedulers (from `https://github.com/ivan-magda/combine-schedulers.git`, branch `main`)
- Firebase/CoreOnly (= 10.24.0)
- Firebase/Messaging (= 10.24.0)
Expand Down Expand Up @@ -143,6 +145,7 @@ SPEC REPOS:
- AppAuth
- AppsFlyerFramework
- Atributika
- BEMCheckBox
- CocoaLumberjack
- Firebase
- FirebaseCore
Expand Down Expand Up @@ -212,6 +215,7 @@ SPEC CHECKSUMS:
AppAuth: 501c04eda8a8d11f179dbe8637b7a91bb7e5d2fa
AppsFlyerFramework: b3de9a49c6af8a8e38c44603e468b5e207f22466
Atributika: 47e778507cfb3cd2c996278b0285221a62e97d71
BEMCheckBox: 5ba6e37ade3d3657b36caecc35c8b75c6c2b1a4e
CocoaLumberjack: f8d89a516e7710fdb2e9b8f1560b16ec6040eef0
CombineSchedulers: 80f670c732b4754eb011cd1147d9a08654b1c463
Firebase: 91fefd38712feb9186ea8996af6cbdef41473442
Expand Down Expand Up @@ -245,6 +249,6 @@ SPEC CHECKSUMS:
SVProgressHUD: 4837c74bdfe2e51e8821c397825996a8d7de6e22
SwiftLint: c1de071d9d08c8aba837545f6254315bc900e211

PODFILE CHECKSUM: 9392d71b37a5fe79e30faedcb4e232aa00f3bc67
PODFILE CHECKSUM: 1177593fe82412f60dfb7e58578b56066fe42f4f

COCOAPODS: 1.15.2
52 changes: 32 additions & 20 deletions iosHyperskillApp/iosHyperskillApp.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import UIKit

extension UIStackView {
func removeAllArrangedSubviews() {
for subview in arrangedSubviews {
removeArrangedSubview(subview)
subview.removeFromSuperview()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct StepQuizTableViewData {
}
}

struct Column: Identifiable {
struct Column: Identifiable, Equatable {
let id: Int
let text: String

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
import BEMCheckBox
import SnapKit
import UIKit

extension StepQuizTableSelectColumnsColumnView {
struct Appearance {
var checkBoxBoxType: BEMBoxType = .circle
let checkBoxLineWidth: CGFloat = 2
let checkBoxAnimationDuration: CGFloat = 0.5
let checkBoxTintColor = ColorPalette.primary
let checkBoxOnCheckColor = UIColor.white
let checkBoxOnFillColor = ColorPalette.primary
let checkBoxOnTintColor = ColorPalette.primary
let checkBoxWidthHeight: CGFloat = 20
let checkBoxInsets = LayoutInsets(leading: 16)

let titleFont = UIFont.preferredFont(forTextStyle: .body)
let titleTextColor = UIColor.primaryText
let titleInsets = LayoutInsets.default

let contentViewMinHeight: CGFloat = 44

let backgroundColor = UIColor.clear
}
}

final class StepQuizTableSelectColumnsColumnView: UIControl {
let appearance: Appearance

private lazy var checkBox: BEMCheckBox = {
let checkBox = BEMCheckBox()
checkBox.lineWidth = appearance.checkBoxLineWidth
checkBox.hideBox = false
checkBox.boxType = appearance.checkBoxBoxType
checkBox.tintColor = appearance.checkBoxTintColor
checkBox.onCheckColor = appearance.checkBoxOnCheckColor
checkBox.onFillColor = appearance.checkBoxOnFillColor
checkBox.onTintColor = appearance.checkBoxOnTintColor
checkBox.animationDuration = appearance.checkBoxAnimationDuration
checkBox.onAnimationType = .fill
checkBox.offAnimationType = .fill
return checkBox
}()

private lazy var titleProcessedContentView: ProcessedContentView = {
let processedContentViewAppearance = ProcessedContentView.Appearance(
labelFont: appearance.titleFont,
labelTextColor: appearance.titleTextColor,
backgroundColor: .clear
)

let contentProcessor = ContentProcessor(
injections: ContentProcessor.defaultInjections + [
FontInjection(font: appearance.titleFont),
TextColorInjection(dynamicColor: appearance.titleTextColor)
]
)

let processedContentView = ProcessedContentView(
frame: .zero,
appearance: processedContentViewAppearance,
contentProcessor: contentProcessor,
htmlToAttributedStringConverter: HTMLToAttributedStringConverter(font: appearance.titleFont)
)
processedContentView.delegate = self

return processedContentView
}()

private lazy var contentView = UIView()

private lazy var tapProxyView = UIKitTapProxyView(targetView: self)

var isOn: Bool { checkBox.on }

var onValueChanged: ((Bool) -> Void)?

var onContentLoad: (() -> Void)?

override var isHighlighted: Bool {
didSet {
titleProcessedContentView.alpha = isHighlighted ? 0.5 : 1.0
}
}

override var intrinsicContentSize: CGSize {
let titleProcessedContentViewIntrinsicContentSize = titleProcessedContentView.intrinsicContentSize
let titleProcessedContentViewHeightWithInsets = titleProcessedContentViewIntrinsicContentSize.height
+ appearance.titleInsets.top
+ appearance.titleInsets.bottom

let height = max(appearance.contentViewMinHeight, titleProcessedContentViewHeightWithInsets)

return CGSize(width: UIView.noIntrinsicMetric, height: height)
}

init(
frame: CGRect = .zero,
appearance: Appearance = Appearance()
) {
self.appearance = appearance
super.init(frame: frame)

self.setupView()
self.addSubviews()
self.makeConstraints()
}

@available(*, unavailable)
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func layoutSubviews() {
super.layoutSubviews()
invalidateIntrinsicContentSize()
}

func setOn(_ isOn: Bool, animated: Bool) {
checkBox.setOn(isOn, animated: animated)
}

func setTitle(_ title: String) {
titleProcessedContentView.setText(title)
}

@objc
private func clicked() {
let newValue = !checkBox.on
onValueChanged?(newValue)
}
}

extension StepQuizTableSelectColumnsColumnView: ProgrammaticallyInitializableViewProtocol {
func setupView() {
backgroundColor = appearance.backgroundColor
contentView.backgroundColor = appearance.backgroundColor

addTarget(self, action: #selector(clicked), for: .touchUpInside)
}

func addSubviews() {
addSubview(contentView)
contentView.addSubview(checkBox)
contentView.addSubview(titleProcessedContentView)

addSubview(tapProxyView)
}

func makeConstraints() {
contentView.translatesAutoresizingMaskIntoConstraints = false
contentView.snp.makeConstraints { make in
make.edges.equalToSuperview()
make.height.greaterThanOrEqualTo(appearance.contentViewMinHeight)
}

checkBox.translatesAutoresizingMaskIntoConstraints = false
checkBox.snp.makeConstraints { make in
make.leading.equalToSuperview().offset(appearance.checkBoxInsets.leading)
make.centerY.equalToSuperview()
make.width.height.equalTo(appearance.checkBoxWidthHeight)
}

titleProcessedContentView.translatesAutoresizingMaskIntoConstraints = false
titleProcessedContentView.snp.makeConstraints { make in
make.top.greaterThanOrEqualToSuperview().offset(appearance.titleInsets.top)
make.leading.equalTo(checkBox.snp.trailing).offset(appearance.titleInsets.leading)
make.bottom.lessThanOrEqualToSuperview().offset(-appearance.titleInsets.bottom)
make.trailing.equalToSuperview().offset(-appearance.titleInsets.trailing)
make.centerY.equalToSuperview()
}

tapProxyView.translatesAutoresizingMaskIntoConstraints = false
tapProxyView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}
}

extension StepQuizTableSelectColumnsColumnView: ProcessedContentViewDelegate {
func processedContentViewDidLoadContent(_ view: ProcessedContentView) {
invalidateIntrinsicContentSize()
onContentLoad?()
}

func processedContentView(_ view: ProcessedContentView, didReportNewHeight height: Int) {
invalidateIntrinsicContentSize()
}

func processedContentView(_ view: ProcessedContentView, didOpenImageURL url: URL) {}

func processedContentView(_ view: ProcessedContentView, didOpenLink url: URL) {}
}

#if DEBUG
@available(iOS 17.0, *)
#Preview {
let view = StepQuizTableSelectColumnsColumnView()
view.setTitle("test")

DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
view.setOn(true, animated: true)
}

return view
}
#endif
Loading

0 comments on commit 52bab25

Please sign in to comment.