<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoreGraphics;
using Foundation;
using Praeclarum.UI;
using UIKit;

namespace MobileCalc.iOS.Views
{
    public class MainViewController : UIViewController
    {
        private UIButton _plusMinusButton;
        private UILabel _mainLabel;
        private UIButton _zeroButton;
        private UIButton _dotButton;
        private UIButton _equalsButton;
        private UIButton _button1;
        private UIButton _button2;
        private UIButton _button3;
        private UIButton _buttonPlus;
        private UIButton _button4;
        private UIButton _button5;
        private UIButton _button6;
        private UIButton _buttonMinus;
        private UIButton _button7;
        private UIButton _button8;
        private UIButton _button9;
        private UIButton _buttonTimes;
        private UIButton _buttonCe;
        private UIButton _buttonC;
        private UIButton _buttonBackspace;
        private UIButton _buttonDivide;

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = UIColor.FromRGBA(236, 236, 236, 255);
            AddViews();
            AddConstraints();
        }

        private void AddConstraints()
        {
            View.ConstrainLayout(() => 
                _mainLabel.Frame.Top == View.Frame.Top + 40
                && _mainLabel.Frame.Left == View.Frame.Left + 50
                && _mainLabel.Frame.Right == View.Frame.Right - 15
                && _mainLabel.Frame.Height == View.Frame.Height * .167f

                && _plusMinusButton.Frame.Bottom == View.Frame.Bottom
                && _plusMinusButton.Frame.Left == View.Frame.Left
                && _plusMinusButton.Frame.Width == View.Frame.Width * .25f - 4
                && _plusMinusButton.Frame.Height == View.Frame.Height * .167f - 4
                
                && _zeroButton.Frame.Bottom == View.Frame.Bottom
                && _zeroButton.Frame.Left == _plusMinusButton.Frame.Right + 4
                && _zeroButton.Frame.Width == _plusMinusButton.Frame.Width
                && _zeroButton.Frame.Height == _plusMinusButton.Frame.Height
                
                && _dotButton.Frame.Bottom == View.Frame.Bottom
                && _dotButton.Frame.Left == _zeroButton.Frame.Right + 4
                && _dotButton.Frame.Width == _plusMinusButton.Frame.Width
                && _dotButton.Frame.Height == _plusMinusButton.Frame.Height
                
                && _equalsButton.Frame.Bottom == View.Frame.Bottom
                && _equalsButton.Frame.Left == _dotButton.Frame.Right + 4
                && _equalsButton.Frame.Width == _plusMinusButton.Frame.Width
                && _equalsButton.Frame.Height == _plusMinusButton.Frame.Height

                && _button1.Frame.Bottom == _plusMinusButton.Frame.Top - 4
                && _button1.Frame.Left == View.Frame.Left
                && _button1.Frame.Width == _plusMinusButton.Frame.Width
                && _button1.Frame.Height == _plusMinusButton.Frame.Height

                && _button2.Frame.Bottom == _button1.Frame.Bottom
                && _button2.Frame.Left == _button1.Frame.Right + 4
                && _button2.Frame.Width == _plusMinusButton.Frame.Width
                && _button2.Frame.Height == _plusMinusButton.Frame.Height

                && _button3.Frame.Bottom == _button1.Frame.Bottom
                && _button3.Frame.Left == _button2.Frame.Right + 4
                && _button3.Frame.Width == _plusMinusButton.Frame.Width
                && _button3.Frame.Height == _plusMinusButton.Frame.Height

                && _buttonPlus.Frame.Bottom == _button1.Frame.Bottom
                && _buttonPlus.Frame.Left == _button3.Frame.Right + 4
                && _buttonPlus.Frame.Width == _plusMinusButton.Frame.Width
                && _buttonPlus.Frame.Height == _plusMinusButton.Frame.Height

                && _button4.Frame.Bottom == _button1.Frame.Top - 4
                && _button4.Frame.Left == View.Frame.Left
                && _button4.Frame.Width == _plusMinusButton.Frame.Width
                && _button4.Frame.Height == _plusMinusButton.Frame.Height
                
                && _button5.Frame.Bottom == _button4.Frame.Bottom
                && _button5.Frame.Left == _button4.Frame.Right + 4
                && _button5.Frame.Width == _plusMinusButton.Frame.Width
                && _button5.Frame.Height == _plusMinusButton.Frame.Height
                
                && _button6.Frame.Bottom == _button4.Frame.Bottom
                && _button6.Frame.Left == _button5.Frame.Right + 4
                && _button6.Frame.Width == _plusMinusButton.Frame.Width
                && _button6.Frame.Height == _plusMinusButton.Frame.Height
                
                && _buttonMinus.Frame.Bottom == _button4.Frame.Bottom
                && _buttonMinus.Frame.Left == _button6.Frame.Right + 4
                && _buttonMinus.Frame.Width == _plusMinusButton.Frame.Width
                && _buttonMinus.Frame.Height == _plusMinusButton.Frame.Height

                && _button7.Frame.Bottom == _button4.Frame.Top - 4
                && _button7.Frame.Left == View.Frame.Left
                && _button7.Frame.Width == _plusMinusButton.Frame.Width
                && _button7.Frame.Height == _plusMinusButton.Frame.Height
                
                && _button8.Frame.Bottom == _button7.Frame.Bottom
                && _button8.Frame.Left == _button7.Frame.Right + 4
                && _button8.Frame.Width == _plusMinusButton.Frame.Width
                && _button8.Frame.Height == _plusMinusButton.Frame.Height
                
                && _button9.Frame.Bottom == _button7.Frame.Bottom
                && _button9.Frame.Left == _button8.Frame.Right + 4
                && _button9.Frame.Width == _plusMinusButton.Frame.Width
                && _button9.Frame.Height == _plusMinusButton.Frame.Height

                && _buttonTimes.Frame.Bottom == _button7.Frame.Bottom
                && _buttonTimes.Frame.Left == _button9.Frame.Right + 4
                && _buttonTimes.Frame.Width == _plusMinusButton.Frame.Width
                && _buttonTimes.Frame.Height == _plusMinusButton.Frame.Height

                && _buttonCe.Frame.Bottom == _button7.Frame.Top - 4
                && _buttonCe.Frame.Left == View.Frame.Left
                && _buttonCe.Frame.Width == _plusMinusButton.Frame.Width
                && _buttonCe.Frame.Height == _plusMinusButton.Frame.Height

                && _buttonC.Frame.Bottom == _buttonCe.Frame.Bottom
                && _buttonC.Frame.Left == _buttonCe.Frame.Right + 4
                && _buttonC.Frame.Width == _plusMinusButton.Frame.Width
                && _buttonC.Frame.Height == _plusMinusButton.Frame.Height

                && _buttonBackspace.Frame.Bottom == _buttonCe.Frame.Bottom
                && _buttonBackspace.Frame.Left == _buttonC.Frame.Right + 4
                && _buttonBackspace.Frame.Width == _plusMinusButton.Frame.Width
                && _buttonBackspace.Frame.Height == _plusMinusButton.Frame.Height

                && _buttonDivide.Frame.Bottom == _buttonCe.Frame.Bottom
                && _buttonDivide.Frame.Left == _buttonBackspace.Frame.Right + 4
                && _buttonDivide.Frame.Width == _plusMinusButton.Frame.Width
                && _buttonDivide.Frame.Height == _plusMinusButton.Frame.Height

            );

        }

        private void AddViews()
        {
            _mainLabel = AddLabel(View, "0");

            _plusMinusButton = AddButton(View, "+=");
            _zeroButton = AddButton(View, "0");
            _dotButton = AddButton(View, ".");
            _equalsButton = AddButton(View, "=");

            _button1 = AddButton(View, "1");
            _button2 = AddButton(View, "2");
            _button3 = AddButton(View, "3");
            _buttonPlus = AddButton(View, "+");

            _button4 = AddButton(View, "4");
            _button5 = AddButton(View, "5");
            _button6 = AddButton(View, "6");
            _buttonMinus = AddButton(View, "-");

            _button7 = AddButton(View, "7");
            _button8 = AddButton(View, "8");
            _button9 = AddButton(View, "9");
            _buttonTimes = AddButton(View, "X");

            _buttonCe = AddButton(View, "CE");
            _buttonC = AddButton(View, "C");
            _buttonBackspace = AddButton(View, "<-");
            _buttonDivide = AddButton(View, "%");
        }

        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);
            _equalsButton.TouchUpInside += EqualsButtonOnTouchUpInside;
        }

        public override void ViewDidDisappear(bool animated)
        {
            base.ViewDidDisappear(animated);
            _equalsButton.TouchUpInside -= EqualsButtonOnTouchUpInside;
        }

        private int counter = 0;

        private void EqualsButtonOnTouchUpInside(object sender, EventArgs eventArgs)
        {
            counter++;
            _mainLabel.Text = counter.ToString();
        }

        private static UILabel AddLabel(UIView parent, string text)
        {
            var label = new UILabel();
            parent.AddSubview(label);
            label.Text = text;
            label.Font = UIFont.FromName(label.Font.Name, 40);
            label.TextAlignment = UITextAlignment.Right;
            label.BackgroundColor = UIColor.FromRGBA(237, 237, 237, 255);
            return label;
        }


        private static UIButton AddButton(UIView parent, string title)
        {
            var button = new UIButton();
            button.BackgroundColor = UIColor.FromRGBA(251, 251, 251, 255);
            button.SetTitleColor(UIColor.Black, UIControlState.Normal);
            button.SetTitle(title, UIControlState.Normal);
            parent.AddSubview(button);
            return button;
        }

    }
}<commit_msg>Fixes the top label's margin to account for the status bar<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoreGraphics;
using Foundation;
using Praeclarum.UI;
using UIKit;

namespace MobileCalc.iOS.Views
{
    public class MainViewController : UIViewController
    {
        private UIButton _plusMinusButton;
        private UILabel _mainLabel;
        private UIButton _zeroButton;
        private UIButton _dotButton;
        private UIButton _equalsButton;
        private UIButton _button1;
        private UIButton _button2;
        private UIButton _button3;
        private UIButton _buttonPlus;
        private UIButton _button4;
        private UIButton _button5;
        private UIButton _button6;
        private UIButton _buttonMinus;
        private UIButton _button7;
        private UIButton _button8;
        private UIButton _button9;
        private UIButton _buttonTimes;
        private UIButton _buttonCe;
        private UIButton _buttonC;
        private UIButton _buttonBackspace;
        private UIButton _buttonDivide;

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = UIColor.FromRGBA(236, 236, 236, 255);
            AddViews();
            AddConstraints();
        }

        private void AddConstraints()
        {
            View.ConstrainLayout(() => 
                _mainLabel.Frame.Top == View.Frame.Top + 40
                && _mainLabel.Frame.Left == View.Frame.Left + 50
                && _mainLabel.Frame.Right == View.Frame.Right - 15
                && _mainLabel.Frame.Height == View.Frame.Height * .167f - 44

                && _plusMinusButton.Frame.Bottom == View.Frame.Bottom
                && _plusMinusButton.Frame.Left == View.Frame.Left
                && _plusMinusButton.Frame.Width == View.Frame.Width * .25f - 4
                && _plusMinusButton.Frame.Height == View.Frame.Height * .167f - 4
                
                && _zeroButton.Frame.Bottom == View.Frame.Bottom
                && _zeroButton.Frame.Left == _plusMinusButton.Frame.Right + 4
                && _zeroButton.Frame.Width == _plusMinusButton.Frame.Width
                && _zeroButton.Frame.Height == _plusMinusButton.Frame.Height
                
                && _dotButton.Frame.Bottom == View.Frame.Bottom
                && _dotButton.Frame.Left == _zeroButton.Frame.Right + 4
                && _dotButton.Frame.Width == _plusMinusButton.Frame.Width
                && _dotButton.Frame.Height == _plusMinusButton.Frame.Height
                
                && _equalsButton.Frame.Bottom == View.Frame.Bottom
                && _equalsButton.Frame.Left == _dotButton.Frame.Right + 4
                && _equalsButton.Frame.Width == _plusMinusButton.Frame.Width
                && _equalsButton.Frame.Height == _plusMinusButton.Frame.Height

                && _button1.Frame.Bottom == _plusMinusButton.Frame.Top - 4
                && _button1.Frame.Left == View.Frame.Left
                && _button1.Frame.Width == _plusMinusButton.Frame.Width
                && _button1.Frame.Height == _plusMinusButton.Frame.Height

                && _button2.Frame.Bottom == _button1.Frame.Bottom
                && _button2.Frame.Left == _button1.Frame.Right + 4
                && _button2.Frame.Width == _plusMinusButton.Frame.Width
                && _button2.Frame.Height == _plusMinusButton.Frame.Height

                && _button3.Frame.Bottom == _button1.Frame.Bottom
                && _button3.Frame.Left == _button2.Frame.Right + 4
                && _button3.Frame.Width == _plusMinusButton.Frame.Width
                && _button3.Frame.Height == _plusMinusButton.Frame.Height

                && _buttonPlus.Frame.Bottom == _button1.Frame.Bottom
                && _buttonPlus.Frame.Left == _button3.Frame.Right + 4
                && _buttonPlus.Frame.Width == _plusMinusButton.Frame.Width
                && _buttonPlus.Frame.Height == _plusMinusButton.Frame.Height

                && _button4.Frame.Bottom == _button1.Frame.Top - 4
                && _button4.Frame.Left == View.Frame.Left
                && _button4.Frame.Width == _plusMinusButton.Frame.Width
                && _button4.Frame.Height == _plusMinusButton.Frame.Height
                
                && _button5.Frame.Bottom == _button4.Frame.Bottom
                && _button5.Frame.Left == _button4.Frame.Right + 4
                && _button5.Frame.Width == _plusMinusButton.Frame.Width
                && _button5.Frame.Height == _plusMinusButton.Frame.Height
                
                && _button6.Frame.Bottom == _button4.Frame.Bottom
                && _button6.Frame.Left == _button5.Frame.Right + 4
                && _button6.Frame.Width == _plusMinusButton.Frame.Width
                && _button6.Frame.Height == _plusMinusButton.Frame.Height
                
                && _buttonMinus.Frame.Bottom == _button4.Frame.Bottom
                && _buttonMinus.Frame.Left == _button6.Frame.Right + 4
                && _buttonMinus.Frame.Width == _plusMinusButton.Frame.Width
                && _buttonMinus.Frame.Height == _plusMinusButton.Frame.Height

                && _button7.Frame.Bottom == _button4.Frame.Top - 4
                && _button7.Frame.Left == View.Frame.Left
                && _button7.Frame.Width == _plusMinusButton.Frame.Width
                && _button7.Frame.Height == _plusMinusButton.Frame.Height
                
                && _button8.Frame.Bottom == _button7.Frame.Bottom
                && _button8.Frame.Left == _button7.Frame.Right + 4
                && _button8.Frame.Width == _plusMinusButton.Frame.Width
                && _button8.Frame.Height == _plusMinusButton.Frame.Height
                
                && _button9.Frame.Bottom == _button7.Frame.Bottom
                && _button9.Frame.Left == _button8.Frame.Right + 4
                && _button9.Frame.Width == _plusMinusButton.Frame.Width
                && _button9.Frame.Height == _plusMinusButton.Frame.Height

                && _buttonTimes.Frame.Bottom == _button7.Frame.Bottom
                && _buttonTimes.Frame.Left == _button9.Frame.Right + 4
                && _buttonTimes.Frame.Width == _plusMinusButton.Frame.Width
                && _buttonTimes.Frame.Height == _plusMinusButton.Frame.Height

                && _buttonCe.Frame.Bottom == _button7.Frame.Top - 4
                && _buttonCe.Frame.Left == View.Frame.Left
                && _buttonCe.Frame.Width == _plusMinusButton.Frame.Width
                && _buttonCe.Frame.Height == _plusMinusButton.Frame.Height

                && _buttonC.Frame.Bottom == _buttonCe.Frame.Bottom
                && _buttonC.Frame.Left == _buttonCe.Frame.Right + 4
                && _buttonC.Frame.Width == _plusMinusButton.Frame.Width
                && _buttonC.Frame.Height == _plusMinusButton.Frame.Height

                && _buttonBackspace.Frame.Bottom == _buttonCe.Frame.Bottom
                && _buttonBackspace.Frame.Left == _buttonC.Frame.Right + 4
                && _buttonBackspace.Frame.Width == _plusMinusButton.Frame.Width
                && _buttonBackspace.Frame.Height == _plusMinusButton.Frame.Height

                && _buttonDivide.Frame.Bottom == _buttonCe.Frame.Bottom
                && _buttonDivide.Frame.Left == _buttonBackspace.Frame.Right + 4
                && _buttonDivide.Frame.Width == _plusMinusButton.Frame.Width
                && _buttonDivide.Frame.Height == _plusMinusButton.Frame.Height

            );

        }

        private void AddViews()
        {
            _mainLabel = AddLabel(View, "0");

            _plusMinusButton = AddButton(View, "+=");
            _zeroButton = AddButton(View, "0");
            _dotButton = AddButton(View, ".");
            _equalsButton = AddButton(View, "=");

            _button1 = AddButton(View, "1");
            _button2 = AddButton(View, "2");
            _button3 = AddButton(View, "3");
            _buttonPlus = AddButton(View, "+");

            _button4 = AddButton(View, "4");
            _button5 = AddButton(View, "5");
            _button6 = AddButton(View, "6");
            _buttonMinus = AddButton(View, "-");

            _button7 = AddButton(View, "7");
            _button8 = AddButton(View, "8");
            _button9 = AddButton(View, "9");
            _buttonTimes = AddButton(View, "X");

            _buttonCe = AddButton(View, "CE");
            _buttonC = AddButton(View, "C");
            _buttonBackspace = AddButton(View, "<-");
            _buttonDivide = AddButton(View, "%");
        }

        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);
            _equalsButton.TouchUpInside += EqualsButtonOnTouchUpInside;
        }

        public override void ViewDidDisappear(bool animated)
        {
            base.ViewDidDisappear(animated);
            _equalsButton.TouchUpInside -= EqualsButtonOnTouchUpInside;
        }

        private int counter = 0;

        private void EqualsButtonOnTouchUpInside(object sender, EventArgs eventArgs)
        {
            counter++;
            _mainLabel.Text = counter.ToString();
        }

        private static UILabel AddLabel(UIView parent, string text)
        {
            var label = new UILabel();
            parent.AddSubview(label);
            label.Text = text;
            label.Font = UIFont.FromName(label.Font.Name, 40);
            label.TextAlignment = UITextAlignment.Right;
            label.BackgroundColor = UIColor.FromRGBA(237, 237, 237, 255);
            return label;
        }


        private static UIButton AddButton(UIView parent, string title)
        {
            var button = new UIButton();
            button.BackgroundColor = UIColor.FromRGBA(251, 251, 251, 255);
            button.SetTitleColor(UIColor.Black, UIControlState.Normal);
            button.SetTitle(title, UIControlState.Normal);
            parent.AddSubview(button);
            return button;
        }

    }
}
{'fraction_non_alphanumeric': 0.10507462686567164, 'fraction_numerical': 0.016019900497512438, 'mean_word_length': 1.8503970504821328, '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': '3834316', 'n_tokens_mistral': 5806, 'n_tokens_neox': 5389, 'n_words': 877}