private CGSize showStopResponse(StopTimerIntentResponse response)
        {
            entryInfoView.TimeLabel.Text = secondsToString(response.EntryDuration.DoubleValue);

            var attributedString = new NSMutableAttributedString(response.EntryDescription ?? string.Empty, boldAttributes);

            var startTime       = DateTimeOffset.FromUnixTimeSeconds(response.EntryStart.LongValue).ToLocalTime();
            var endTime         = DateTimeOffset.FromUnixTimeSeconds(response.EntryStart.LongValue + response.EntryDuration.LongValue).ToLocalTime();
            var fromTime        = startTime.ToString("HH:mm", CultureInfo.InvariantCulture);
            var toTime          = endTime.ToString("HH:mm", CultureInfo.InvariantCulture);
            var timeFrameString = new NSAttributedString($"\n{fromTime} - {toTime}", regularAttributes);

            attributedString.Append(timeFrameString);
            entryInfoView.DescriptionLabel.AttributedText = attributedString;

            var width        = ExtensionContext?.GetHostedViewMaximumAllowedSize().Width ?? 320;
            var boundingRect = attributedString.GetBoundingRect(new CGSize(width - 135 - 16 * 2, nfloat.MaxValue), NSStringDrawingOptions.UsesLineFragmentOrigin | NSStringDrawingOptions.UsesFontLeading, null);

            View.AddSubview(entryInfoView);
            var frame = new CGRect(0, 0, width, boundingRect.Height + 12 * 2);

            entryInfoView.Frame = frame;

            return(frame.Size);
        }
        private CGSize showStartTimerSuccess(string description)
        {
            entryInfoView.DescriptionLabel.Text = string.Empty;
            entryInfoView.TimeLabel.Text        = string.Empty;

            var attributedString = new NSMutableAttributedString(string.IsNullOrEmpty(description) ? Resources.NoDescription : description);

            entryInfoView.DescriptionLabel.AttributedText = attributedString;

            var start       = DateTimeOffset.Now;
            var displayLink = CADisplayLink.Create(() =>
            {
                var passed = DateTimeOffset.Now - start;
                entryInfoView.TimeLabel.Text = secondsToString(passed.Seconds);
            });

            displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Default);

            View.AddSubview(entryInfoView);
            var width = ExtensionContext?.GetHostedViewMaximumAllowedSize().Width ?? 320;
            var frame = new CGRect(0, 0, width, 60);

            entryInfoView.Frame = frame;

            return(frame.Size);
        }
        private CGSize showMessage(string confirmationText)
        {
            confirmationView.ConfirmationLabel.Text = string.Empty;

            var attributedString = new NSMutableAttributedString(confirmationText, boldAttributes);

            var width        = ExtensionContext?.GetHostedViewMaximumAllowedSize().Width ?? 320;
            var boundingRect = attributedString.GetBoundingRect(new CGSize(width - 16 * 2, nfloat.MaxValue),
                                                                NSStringDrawingOptions.UsesLineFragmentOrigin | NSStringDrawingOptions.UsesFontLeading, null);

            var frame = new CGRect(0, 0, width, boundingRect.Height + 12 * 2);

            View.AddSubview(confirmationView);

            confirmationView.ConfirmationLabel.AttributedText = attributedString;
            confirmationView.Frame = frame;

            return(frame.Size);
        }
Esempio n. 4
0
 CGSize DesiredSize()
 {
     return(ExtensionContext.GetHostedViewMaximumAllowedSize());
 }