<commit_before>////
///  CategoryDetailScreen.swift
//

import SnapKit


class CategoryDetailScreen: Screen {
    struct Size {
        static let defaultMargin: CGFloat = 10
        static let closeButtonMargin: CGFloat = calculateButtonMargin()
        static let lineMargin: CGFloat = 10
        static let closeSize: CGFloat = 30
        static let textSideMargin: CGFloat = 15
        static let sectionSpacing: CGFloat = 35
        static let lineHeight: CGFloat = 1

        static func calculateButtonMargin() -> CGFloat {
            return Globals.isIphoneX ? 20 : 10
        }
    }

    struct Config {
        let title: String
        let description: String
        let imageURL: URL?
        let user: User?
        let isSubscribed: Bool

        init(title: String = "", description: String = "", imageURL: URL? = nil, user: User? = nil, isSubscribed: Bool = false) {
            self.title = title
            self.description = description
            self.imageURL = imageURL
            self.user = user
            self.isSubscribed = isSubscribed
        }
    }

    weak var delegate: CategoryDetailDelegate?
    var headerView: UIView { return categoryHeaderView }

    private let closeButton = UIButton()
    private let scrollView = UIScrollView()
    private var scrollViewWidthConstraint: Constraint!
    private let categoryHeaderView = CategoryDetailHeaderView()
    private let aboutLabel = StyledLabel(style: .bold)

    private let moderatorsContainer = UIView()
    private let moderatorsLabel = StyledLabel(style: .largeBoldGray)
    private var moderatorViews: [UIView] = []
    private var moderatorsContainerCollapsed: Constraint!

    private let curatorsContainer = UIView()
    private let curatorsLabel = StyledLabel(style: .largeBoldGray)
    private var curatorViews: [UIView] = []
    private var curatorsContainerSpacing: Constraint!
    private var curatorsContainerCollapsed: Constraint!

    var config: Config = Config() {
        didSet {
            updateConfig()
            categoryHeaderView.config = CategoryDetailHeaderView.Config(
                title: config.title,
                imageURL: config.imageURL,
                user: config.user,
                isSubscribed: config.isSubscribed
                )
        }
    }

    override func updateConstraints() {
        super.updateConstraints()
        scrollViewWidthConstraint.update(offset: frame.size.width)
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        scrollViewWidthConstraint.update(offset: frame.size.width)
    }

    override func setText() {
        moderatorsLabel.text = InterfaceString.Category.Moderators
        curatorsLabel.text = InterfaceString.Category.Curators
    }

    override func style() {
        backgroundColor = .white

        closeButton.setImage(.x, imageStyle: .white, for: .normal)
        closeButton.layer.masksToBounds = true
        closeButton.layer.cornerRadius = Size.closeSize / 2
        closeButton.backgroundColor = .dimmedBlackBackground

        aboutLabel.isMultiline = true
    }

    override func bindActions() {
        closeButton.addTarget(self, action: #selector(closeButtonTapped), for: .touchUpInside)
    }

    override func arrange() {
        addSubview(scrollView)
        addSubview(closeButton)

        scrollView.addSubview(categoryHeaderView)
        scrollView.addSubview(aboutLabel)

        let moderatorsLine = generateSectionLine()
        scrollView.addSubview(moderatorsContainer)
        moderatorsContainer.addSubview(moderatorsLabel)
        moderatorsContainer.addSubview(moderatorsLine)

        let curatorsLine = generateSectionLine()<commit_msg>turn of contentInsetAdjustmentBehavior on category detail scrollview<commit_after>////
///  CategoryDetailScreen.swift
//

import SnapKit


class CategoryDetailScreen: Screen {
    struct Size {
        static let defaultMargin: CGFloat = 10
        static let closeButtonMargin: CGFloat = calculateButtonMargin()
        static let lineMargin: CGFloat = 10
        static let closeSize: CGFloat = 30
        static let textSideMargin: CGFloat = 15
        static let sectionSpacing: CGFloat = 35
        static let lineHeight: CGFloat = 1

        static func calculateButtonMargin() -> CGFloat {
            return Globals.isIphoneX ? 20 : 10
        }
    }

    struct Config {
        let title: String
        let description: String
        let imageURL: URL?
        let user: User?
        let isSubscribed: Bool

        init(title: String = "", description: String = "", imageURL: URL? = nil, user: User? = nil, isSubscribed: Bool = false) {
            self.title = title
            self.description = description
            self.imageURL = imageURL
            self.user = user
            self.isSubscribed = isSubscribed
        }
    }

    weak var delegate: CategoryDetailDelegate?
    var headerView: UIView { return categoryHeaderView }

    private let closeButton = UIButton()
    private let scrollView = UIScrollView()
    private var scrollViewWidthConstraint: Constraint!
    private let categoryHeaderView = CategoryDetailHeaderView()
    private let aboutLabel = StyledLabel(style: .bold)

    private let moderatorsContainer = UIView()
    private let moderatorsLabel = StyledLabel(style: .largeBoldGray)
    private var moderatorViews: [UIView] = []
    private var moderatorsContainerCollapsed: Constraint!

    private let curatorsContainer = UIView()
    private let curatorsLabel = StyledLabel(style: .largeBoldGray)
    private var curatorViews: [UIView] = []
    private var curatorsContainerSpacing: Constraint!
    private var curatorsContainerCollapsed: Constraint!

    var config: Config = Config() {
        didSet {
            updateConfig()
            categoryHeaderView.config = CategoryDetailHeaderView.Config(
                title: config.title,
                imageURL: config.imageURL,
                user: config.user,
                isSubscribed: config.isSubscribed
                )
        }
    }

    override func updateConstraints() {
        super.updateConstraints()
        scrollViewWidthConstraint.update(offset: frame.size.width)
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        scrollViewWidthConstraint.update(offset: frame.size.width)
    }

    override func setText() {
        moderatorsLabel.text = InterfaceString.Category.Moderators
        curatorsLabel.text = InterfaceString.Category.Curators
    }

    override func style() {
        if #available(iOS 11.0, *) {
            scrollView.contentInsetAdjustmentBehavior = .never
        }
        backgroundColor = .white

        closeButton.setImage(.x, imageStyle: .white, for: .normal)
        closeButton.layer.masksToBounds = true
        closeButton.layer.cornerRadius = Size.closeSize / 2
        closeButton.backgroundColor = .dimmedBlackBackground

        aboutLabel.isMultiline = true
    }

    override func bindActions() {
        closeButton.addTarget(self, action: #selector(closeButtonTapped), for: .touchUpInside)
    }

    override func arrange() {
        addSubview(scrollView)
        addSubview(closeButton)

        scrollView.addSubview(categoryHeaderView)
        scrollView.addSubview(aboutLabel)

        let moderatorsLine = generateSectionLine()
        scrollView.addSubview(moderatorsContainer)
        moderatorsContainer.addSubview(moderatorsLabel)
        moderatorsContainer.addSubview(moderatorsLine)

        let curatorsLine = generateSectionLine()
{'fraction_non_alphanumeric': 0.07459917848151583, 'fraction_numerical': 0.004637604346097788, 'mean_word_length': 2.6028639618138425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6644171', 'n_tokens_mistral': 2044, 'n_tokens_neox': 1944, 'n_words': 486}