<commit_before>﻿using System;
using System.Drawing;
using Cirrious.FluentLayouts.Touch;
using MonoTouch.CoreAnimation;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Toggl.Phoebe.Data.Models;
using Toggl.Ross.Theme;

namespace Toggl.Ross.ViewControllers
{
    public class EditTimeEntryViewController : UIViewController
    {
        private StartStopView startStopView;
        private UIDatePicker datePicker;
        private ProjectClientTaskButton projectButton;
        private UITextField descriptionTextField;
        private UIButton tagsButton;
        private UIView billableView;
        private UILabel billableLabel;
        private UISwitch billableSwitch;
        private UIButton deleteButton;

        public EditTimeEntryViewController (TimeEntryModel model)
        {
        }

        public override void LoadView ()
        {
            var scrollView = new UIScrollView ().ApplyStyle (Style.Screen);

            scrollView.Add (startStopView = new StartStopView () {
                TranslatesAutoresizingMaskIntoConstraints = false,
            });

            scrollView.Add (projectButton = new ProjectClientTaskButton () {
                TranslatesAutoresizingMaskIntoConstraints = false,
            });

            scrollView.AddConstraints (
                startStopView.AtTopOf (scrollView),
                startStopView.WithSameWidth (scrollView),
                startStopView.AtLeftOf (scrollView),
                startStopView.AtRightOf (scrollView),

                projectButton.Below (startStopView, 5f),
                projectButton.WithSameWidth (scrollView),
                projectButton.Height ().GreaterThanOrEqualTo (60f),
                projectButton.AtLeftOf (scrollView),
                projectButton.AtRightOf (scrollView),

                projectButton.AtBottomOf (scrollView, 1000f),
                null
            );

            View = scrollView;<commit_msg>Use generic auto layout function for edit view.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Drawing;
using Cirrious.FluentLayouts.Touch;
using MonoTouch.CoreAnimation;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Toggl.Phoebe.Data.Models;
using Toggl.Ross.Theme;

namespace Toggl.Ross.ViewControllers
{
    public class EditTimeEntryViewController : UIViewController
    {
        private StartStopView startStopView;
        private UIDatePicker datePicker;
        private ProjectClientTaskButton projectButton;
        private UITextField descriptionTextField;
        private UIButton tagsButton;
        private UIView billableView;
        private UILabel billableLabel;
        private UISwitch billableSwitch;
        private UIButton deleteButton;

        public EditTimeEntryViewController (TimeEntryModel model)
        {
        }

        public override void LoadView ()
        {
            var scrollView = new UIScrollView ().ApplyStyle (Style.Screen);

            scrollView.Add (startStopView = new StartStopView () {
                TranslatesAutoresizingMaskIntoConstraints = false,
            });
            scrollView.Add (projectButton = new ProjectClientTaskButton () {
                TranslatesAutoresizingMaskIntoConstraints = false,
            });

            scrollView.AddConstraints (VerticalLinearLayout (scrollView));

            View = scrollView;
        }

        private IEnumerable<FluentLayout> VerticalLinearLayout (UIView container)
        {
            UIView prev = null;

            foreach (var v in container.Subviews) {
                if (v.Hidden)
                    continue;

                if (prev == null) {
                    yield return v.AtTopOf (container);
                } else {
                    yield return v.Below (prev, 5f);
                }
                yield return v.WithSameWidth (container);
                yield return v.Height ().GreaterThanOrEqualTo (60f);
                yield return v.AtLeftOf (container);
                yield return v.AtRightOf (container);

                prev = v;
            }

            if (prev != null) {
                yield return prev.AtBottomOf (container, 1000f);
            }
{'fraction_non_alphanumeric': 0.06603098927294399, 'fraction_numerical': 0.0033373063170441, 'mean_word_length': 2.1220238095238093, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '7144668', 'n_tokens_mistral': 1077, 'n_tokens_neox': 994, 'n_words': 246}