Пример #1
0
        protected static HtmlTag TimeInputRender(TypedElement element, RenderContext context)
        {
            TimeInput input       = (TimeInput)element;
            var       uiTimeInput = new HtmlTag("input")
                                    .Attr("type", "time")
                                    .Attr("name", input.Id)
                                    .AddClass("ac-input")
                                    .AddClass("ac-timeInput")
                                    .Style("width", "100%");

            if (!string.IsNullOrEmpty(input.Value))
            {
                uiTimeInput.Attr("value", input.Value);
            }

            if (!string.IsNullOrEmpty(input.Min))
            {
                uiTimeInput.Attr("min", input.Min);
            }

            if (!string.IsNullOrEmpty(input.Max))
            {
                uiTimeInput.Attr("max", input.Max);
            }

            return(uiTimeInput);
        }
Пример #2
0
        public static FrameworkElement Render(TypedElement element, RenderContext context)
        {
            TimeInput input = (TimeInput)element;

            if (context.Config.SupportsInteractivity)
            {
                var      timePicker = new TimePicker();
                DateTime value;
                if (DateTime.TryParse(input.Value, out value))
                {
                    timePicker.Value = value;
                }
                TimeSpan minValue;
                if (TimeSpan.TryParse(input.Min, out minValue))
                {
                    timePicker.EndTime = minValue;
                }
                TimeSpan maxValue;
                if (TimeSpan.TryParse(input.Max, out maxValue))
                {
                    timePicker.EndTime = maxValue;
                }
                timePicker.Watermark   = input.Placeholder;
                timePicker.Style       = context.GetStyle("Adaptive.Input.Time");
                timePicker.DataContext = input;
                context.InputBindings.Add(input.Id, () => timePicker.Text);
                return(timePicker);
            }
            else
            {
                var textBlock = TypedElementConverter.CreateElement <TextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
                return(context.Render(textBlock));
            }
        }
Пример #3
0
    public void Write(Input input)
    {
        TimeInput timeInput = new TimeInput(input);

        buffer[writePos] = timeInput;
        writePos         = (writePos + 1) % buffer.Length;
    }
Пример #4
0
        public static FrameworkElement Render(TypedElement element, RenderContext context)
        {
            TimeInput input = (TimeInput)element;

            if (context.Config.SupportsInteractivity)
            {
                var textBox = new TextBox()
                {
                    Text = input.Value
                };
                textBox.SetPlaceholder(input.Placeholder);
                textBox.Style = context.GetStyle($"Adaptive.Input.Text.Time");
                textBox.SetContext(input);
                context.InputBindings.Add(input.Id, () => textBox.Text);
                return(textBox);
            }
            else
            {
                Container container = TypedElementConverter.CreateElement <Container>();
                container.Separation = input.Separation;
                TextBlock textBlock = TypedElementConverter.CreateElement <TextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
                container.Items.Add(textBlock);
                if (input.Value != null)
                {
                    textBlock       = TypedElementConverter.CreateElement <TextBlock>();
                    textBlock.Text  = input.Value;
                    textBlock.Color = TextColor.Accent;
                    textBlock.Wrap  = true;
                    container.Items.Add(textBlock);
                }
                return(context.Render(container));
            }
        }
    public void NewInput(float newTime, bool canPause, float priority)
    {
        TimeInput toAdd = new TimeInput();

        toAdd.canPause = canPause;
        toAdd.newTime  = newTime;
        toAdd.priority = priority;
        input.Add(toAdd);
    }
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            base.TouchesBegan(touches, evt);

            if (TimeInput.IsEditing)
            {
                TimeInput.EndEditing(true);
                DescriptionTextView.BecomeFirstResponder();
            }
        }
        private void prepareTimeViews()
        {
            var tapRecognizer = new UITapGestureRecognizer(() =>
            {
                switchTimeLabelAndInput();

                if (!TimeInput.Hidden)
                {
                    TimeInput.FormattedDuration = TimeLabel.Text;
                    TimeInput.BecomeFirstResponder();
                }
            });

            TimeLabel.UserInteractionEnabled = true;
            TimeLabel.AddGestureRecognizer(tapRecognizer);

            TimeInput.LostFocus += onTimeInputLostFocus;
        }
    public void NewInput(float newTime, float priority, float timeUnscaled, bool canPause)
    {
        TimeInput toAdd = new TimeInput();

        toAdd.canPause = canPause;
        toAdd.newTime  = newTime;
        toAdd.priority = priority;
        toAdd.id       = Random.Range(0, 6666666);
        for (int i = 0; i < input.Count - 1; i++)
        {
            if (input[i].id == toAdd.id)
            {
                i = 0;
                toAdd.id++;
            }
        }
        input.Add(toAdd);
        StartCoroutine(TimeBackUnscaled(timeUnscaled, toAdd.id));
    }
Пример #9
0
        public void RenderTest()
        {
            var dt = new System.DateTime(2008, 11, 15, 10, 2, 45, 234);

            TimeInput target = new TimeInput();

            Assert.AreEqual("<input type=\"text\" name=\"test\" />",
                            target.Render("test", null));
            Assert.AreEqual("<input type=\"text\" name=\"test\" value=\"10:02:45\" />",
                            target.Render("test", dt));
            Assert.AreEqual("<input type=\"text\" name=\"test\" />",
                            target.Render("test", 123));

            target.Format = "HH:mm:ss.fff";
            Assert.AreEqual("<input type=\"text\" name=\"test\" />",
                            target.Render("test", null));
            Assert.AreEqual("<input type=\"text\" name=\"test\" value=\"10:02:45.234\" />",
                            target.Render("test", dt));
        }
Пример #10
0
        protected static HtmlTag TimeInputRender(TypedElement element, RenderContext context)
        {
            TimeInput input     = (TimeInput)element;
            var       container = new Container {
                Separation = input.Separation
            };

            container.Items.Add(new TextBlock {
                Text = GetFallbackText(input) ?? input.Placeholder
            });
            if (input.Value != null)
            {
                container.Items.Add(new TextBlock
                {
                    Text  = input.Value,
                    Color = TextColor.Accent,
                    Wrap  = true
                });
            }
            return(context.Render(container));
        }
        void ReleaseDesignerOutlets()
        {
            if (AddProjectOnboardingBubble != null)
            {
                AddProjectOnboardingBubble.Dispose();
                AddProjectOnboardingBubble = null;
            }

            if (DescriptionRemainingLengthLabel != null)
            {
                DescriptionRemainingLengthLabel.Dispose();
                DescriptionRemainingLengthLabel = null;
            }

            if (Placeholder != null)
            {
                Placeholder.Dispose();
                Placeholder = null;
            }

            if (StartDateButton != null)
            {
                StartDateButton.Dispose();
                StartDateButton = null;
            }

            if (TimeInput != null)
            {
                TimeInput.Dispose();
                TimeInput = null;
            }

            if (TimeInputTrailingConstraint != null)
            {
                TimeInputTrailingConstraint.Dispose();
                TimeInputTrailingConstraint = null;
            }

            if (TimeLabel != null)
            {
                TimeLabel.Dispose();
                TimeLabel = null;
            }

            if (TimeLabelTrailingConstraint != null)
            {
                TimeLabelTrailingConstraint.Dispose();
                TimeLabelTrailingConstraint = null;
            }

            if (BillableButton != null)
            {
                BillableButton.Dispose();
                BillableButton = null;
            }

            if (BillableButtonWidthConstraint != null)
            {
                BillableButtonWidthConstraint.Dispose();
                BillableButtonWidthConstraint = null;
            }

            if (BottomDistanceConstraint != null)
            {
                BottomDistanceConstraint.Dispose();
                BottomDistanceConstraint = null;
            }

            if (BottomOptionsSheet != null)
            {
                BottomOptionsSheet.Dispose();
                BottomOptionsSheet = null;
            }

            if (CloseButton != null)
            {
                CloseButton.Dispose();
                CloseButton = null;
            }

            if (DateTimeButton != null)
            {
                DateTimeButton.Dispose();
                DateTimeButton = null;
            }

            if (DescriptionTextView != null)
            {
                DescriptionTextView.Dispose();
                DescriptionTextView = null;
            }

            if (DoneButton != null)
            {
                DoneButton.Dispose();
                DoneButton = null;
            }

            if (ProjectsButton != null)
            {
                ProjectsButton.Dispose();
                ProjectsButton = null;
            }

            if (SuggestionsTableView != null)
            {
                SuggestionsTableView.Dispose();
                SuggestionsTableView = null;
            }

            if (TagsButton != null)
            {
                TagsButton.Dispose();
                TagsButton = null;
            }

            if (AddProjectBubbleLabel != null)
            {
                AddProjectBubbleLabel.Dispose();
                AddProjectBubbleLabel = null;
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            AddProjectBubbleLabel.Text = Resources.AddProjectBubbleText;

            prepareViews();
            prepareOnboarding();

            var source = new StartTimeEntryTableViewSource(SuggestionsTableView);

            SuggestionsTableView.Source = source;

            source.Rx().ModelSelected()
            .Subscribe(ViewModel.SelectSuggestion.Inputs)
            .DisposedBy(DisposeBag);

            ViewModel.Suggestions
            .Subscribe(SuggestionsTableView.Rx().ReloadSections(source))
            .DisposedBy(DisposeBag);

            source.ToggleTasks
            .Subscribe(ViewModel.ToggleTasks.Inputs)
            .DisposedBy(DisposeBag);

            TimeInput.Rx().Duration()
            .Subscribe(ViewModel.SetRunningTime.Inputs)
            .DisposedBy(DisposeBag);

            //Text

            ViewModel.DisplayedTime
            .Subscribe(TimeLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            Placeholder.Text = ViewModel.PlaceholderText;

            // Buttons
            UIColor booleanToColor(bool b) => b
                ? Colors.StartTimeEntry.ActiveButton.ToNativeColor()
                : Colors.StartTimeEntry.InactiveButton.ToNativeColor();

            ViewModel.IsBillable
            .Select(booleanToColor)
            .Subscribe(BillableButton.Rx().TintColor())
            .DisposedBy(DisposeBag);

            ViewModel.IsSuggestingTags
            .Select(booleanToColor)
            .Subscribe(TagsButton.Rx().TintColor())
            .DisposedBy(DisposeBag);

            ViewModel.IsSuggestingProjects
            .Select(booleanToColor)
            .Subscribe(ProjectsButton.Rx().TintColor())
            .DisposedBy(DisposeBag);

            //Visibility
            ViewModel.IsBillableAvailable
            .Select(b => b ? (nfloat)42 : 0)
            .Subscribe(BillableButtonWidthConstraint.Rx().Constant())
            .DisposedBy(DisposeBag);

            // Actions
            CloseButton.Rx().Tap()
            .Subscribe(ViewModel.CloseWithDefaultResult)
            .DisposedBy(DisposeBag);

            DoneButton.Rx()
            .BindAction(ViewModel.Done)
            .DisposedBy(DisposeBag);

            ViewModel.Done.Elements
            .Subscribe(IosDependencyContainer.Instance.IntentDonationService.DonateStartTimeEntry)
            .DisposedBy(DisposeBag);

            BillableButton.Rx()
            .BindAction(ViewModel.ToggleBillable)
            .DisposedBy(DisposeBag);

            StartDateButton.Rx()
            .BindAction(ViewModel.SetStartDate)
            .DisposedBy(DisposeBag);

            DateTimeButton.Rx()
            .BindAction(ViewModel.ChangeTime)
            .DisposedBy(DisposeBag);

            TagsButton.Rx()
            .BindAction(ViewModel.ToggleTagSuggestions)
            .DisposedBy(DisposeBag);

            ProjectsButton.Rx()
            .BindAction(ViewModel.ToggleProjectSuggestions)
            .DisposedBy(DisposeBag);

            // Reactive
            ViewModel.TextFieldInfo
            .DistinctUntilChanged()
            .Subscribe(onTextFieldInfo)
            .DisposedBy(DisposeBag);

            DescriptionTextView.Rx().AttributedText()
            .Select(attributedString => attributedString.Length == 0)
            .Subscribe(isDescriptionEmptySubject)
            .DisposedBy(DisposeBag);

            Observable.CombineLatest(
                DescriptionTextView.Rx().AttributedText().SelectUnit(),
                DescriptionTextView.Rx().CursorPosition().SelectUnit()
                )
            .Select(_ => DescriptionTextView.AttributedText)     // Programatically changing the text doesn't send an event, that's why we do this, to get the last version of the text
            .Do(updatePlaceholder)
            .Select(text => text.AsSpans((int)DescriptionTextView.SelectedRange.Location).ToIImmutableList())
            .Subscribe(ViewModel.SetTextSpans.Inputs)
            .DisposedBy(DisposeBag);
        }
Пример #13
0
 public virtual void Visit(TimeInput inputTime)
 {
 }
Пример #14
0
 public void Write(TimeInput input)
 {
     buffer[writePos] = input;
     writePos         = (writePos + 1) % buffer.Length;
 }
Пример #15
0
 public void WriteInInputBuffer(TimeInput input)
 {
     inputBuffer.Write(input);
 }
Пример #16
0
 public void TimeInputConstructorTest()
 {
     TimeInput target = new TimeInput();
 }