示例#1
0
        private void InitializeWithImagePath(UITextView textView, ARNotificationType alertType, Image image)
        {
            BackgroundColor = alertType == ARNotificationType.Error ? Theme.ControlPalette.Notifications.Error.Background.ToUIColor() : Theme.ControlPalette.Notifications.Alert.Background.ToUIColor();

            var imageView = new UIImageView();

            imageView.SetupStyle(image);

            textView.Frame = imageView.Image.Size == CGSize.Empty ?
                             new CGRect(16, TEXT_VIEW_OFFSET, Frame.Width - 32, TEXT_VIEW_HEIGHT) :
                             new CGRect(16 + imageView.Image.Size.Width + 10, TEXT_VIEW_OFFSET, Frame.Width - 86, TEXT_VIEW_HEIGHT);

            AddSubviews(
                imageView
                .WithFrame(16, (TEXT_VIEW_OFFSET / 2) + ((Frame.Height - imageView.Image.Size.Height) / 2), imageView.Image.Size.Width, imageView.Image.Size.Height)
                .WithTune(tune => tune.ActionOnTap(() =>
            {
                _hintTimer?.Stop();
                _hiddenTimer?.Stop();

                Hide();
            })),
                textView
                );
        }
示例#2
0
        private UIColor GetTexViewTextColor(ARNotificationType alertType)
        {
            switch (alertType)
            {
            case ARNotificationType.Error:
                return((UIColor)Theme.ControlPalette.Notifications.Error.Text.TextColor);

            case ARNotificationType.Confirm:
                return((UIColor)Theme.ControlPalette.Notifications.Confirm.Text.TextColor);

            default:
                return((UIColor)Theme.ControlPalette.Notifications.Alert.Text.TextColor);
            }
        }
示例#3
0
        private void InitializeSubviews(string message, ARNotificationType alertType, string buttonTitle)
        {
            _textView = new UITextView(new CGRect(0, TEXT_VIEW_OFFSET, Frame.Width - 86, 0))
            {
                Editable          = false,
                ScrollEnabled     = false,
                IndicatorStyle    = UIScrollViewIndicatorStyle.Black,
                DataDetectorTypes = UIDataDetectorType.None,
                Text                   = message,
                TextColor              = GetTexViewTextColor(alertType),
                Font                   = GetTexViewFont(alertType),
                BackgroundColor        = UIColor.Clear,
                Opaque                 = true,
                UserInteractionEnabled = false
            };

            if (alertType == ARNotificationType.Error)
            {
                _textView.DraggingStarted   += OnDraggingStarted;
                _textView.DraggingEnded     += OnDraggingEnded;
                _textView.DecelerationEnded += OnDecelerationEnded;
                _textView.SelectionChanged  += OnSelectionChanged;
            }

            _textView.TextContainer.LineBreakMode = UILineBreakMode.TailTruncation;

            _textView.SizeToFit();

            _realTextSize = new CGSize(_textView.Frame.Size);

            switch (alertType)
            {
            case ARNotificationType.Alert:
                InitializeWithImagePath(_textView, alertType, Theme.ControlPalette.Notifications.Alert.Icon);
                break;

            case ARNotificationType.Confirm:
                InitializeWithButtonTitle(_textView, buttonTitle);
                break;

            case ARNotificationType.Error:
                InitializeWithImagePath(_textView, alertType, Theme.ControlPalette.Notifications.Error.Icon);
                break;
            }
        }
示例#4
0
        public ARNotificationView(string message, ARNotificationType alertType, string buttonTitle = null, bool autoHide = false)
        {
            _message  = message;
            _autoHide = autoHide;

            _alertType = alertType;

            HEIGHT           = 68.If_iPhoneX(88);
            TEXT_VIEW_OFFSET = 0.If_iPhoneX(23);

            TEXT_VIEW_HEIGHT = HEIGHT - TEXT_VIEW_OFFSET;

            Frame = new CGRect(0, -HEIGHT, DeviceInfo.ScreenWidth, HEIGHT);
            Tag   = TAG;
            UserInteractionEnabled = true;

            InitializeSubviews(message, alertType, buttonTitle);
        }