<commit_before>import UIKit
import Cartography
import RxSwift
import RxCocoa

final class PoliticiansView: UIView {
    let tableView: UITableView = {
        let tableView = UITableView()
        tableView.register(PoliticianTableViewCell.self)
        tableView.rowHeight = PoliticianTableViewCell.preferredHeight
        tableView.tableFooterView = UIView()
        return tableView
    }()

    fileprivate let noDataView = EmptyStateView(icon: Asset.warningIcon.image, message: L10n.noDataToShow.string)
    fileprivate let errorView = EmptyStateView(icon: Asset.errorIcon.image, message: L10n.somethingIsWrong.string)

    override init(frame: CGRect) {
        super.init(frame: frame)
        setUp()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    private func setUp() {
        addSubview(tableView)
        createConstraints()
    }

    private func createConstraints() {
        constrainTableView()
    }

    private func constrainTableView() {
        constrain(tableView) { tableView in
            tableView.edges == tableView.superview!.edges
        }
    }
}

extension Reactive where Base: PoliticiansView {
    var state: UIBindingObserver<PoliticiansView, PoliticiansViewState> {
        return UIBindingObserver(UIElement: base) { view, state in
            view.render(state: state)
        }
    }
}

private extension PoliticiansView {
    func render(state: PoliticiansViewState) {
        switch state {
        case .empty:
            renderWhenEmpty()
        case .failed:
            renderWhenFailed()
        case .loading:
            renderWhenLoading()
        case .loaded:
            renderWhenLoaded()
        }
    }

    private func renderWhenEmpty() {
        tableView.backgroundView = noDataView
    }

    private func renderWhenFailed() {
        tableView.backgroundView = errorView
    }

    private func renderWhenLoading() {
        tableView.backgroundView = nil
    }

    private func renderWhenLoaded() {
        tableView.backgroundView = nil
    }
}
<commit_msg>Present activity indicator when loading politicians<commit_after>import UIKit
import Cartography
import RxSwift
import RxCocoa

final class PoliticiansView: UIView {
    let tableView: UITableView = {
        let tableView = UITableView()
        tableView.register(PoliticianTableViewCell.self)
        tableView.rowHeight = PoliticianTableViewCell.preferredHeight
        tableView.tableFooterView = UIView()
        return tableView
    }()

    fileprivate let activityIndicator: UIActivityIndicatorView = {
        let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge)
        activityIndicator.color = Style.Colors.activityIndicator
        activityIndicator.startAnimating()
        return activityIndicator
    }()

    fileprivate let noDataView = EmptyStateView(icon: Asset.warningIcon.image, message: L10n.noDataToShow.string)
    fileprivate let errorView = EmptyStateView(icon: Asset.errorIcon.image, message: L10n.somethingIsWrong.string)

    override init(frame: CGRect) {
        super.init(frame: frame)
        setUp()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    private func setUp() {
        addSubview(tableView)
        createConstraints()
    }

    private func createConstraints() {
        constrainTableView()
    }

    private func constrainTableView() {
        constrain(tableView) { tableView in
            tableView.edges == tableView.superview!.edges
        }
    }
}

extension Reactive where Base: PoliticiansView {
    var state: UIBindingObserver<PoliticiansView, PoliticiansViewState> {
        return UIBindingObserver(UIElement: base) { view, state in
            view.render(state: state)
        }
    }
}

private extension PoliticiansView {
    func render(state: PoliticiansViewState) {
        switch state {
        case .empty:
            renderWhenEmpty()
        case .failed:
            renderWhenFailed()
        case .loading:
            renderWhenLoading()
        case .loaded:
            renderWhenLoaded()
        }
    }

    private func renderWhenEmpty() {
        tableView.backgroundView = noDataView
    }

    private func renderWhenFailed() {
        tableView.backgroundView = errorView
    }

    private func renderWhenLoading() {
        tableView.backgroundView = activityIndicator
    }

    private func renderWhenLoaded() {
        tableView.backgroundView = nil
    }
}

private struct Style {
    struct Colors {
        static let activityIndicator = UIColor(white: 140.0/255.0, alpha: 1)
    }
}

{'fraction_non_alphanumeric': 0.0773492435542297, 'fraction_numerical': 0.0036224163647986364, 'mean_word_length': 2.647241647241647, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1201685', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1258, 'n_words': 286}