예제 #1
0
 public void UpdateContent(User participant)
 {
     ParticipantName.Text      = participant.Name;
     ParticipantName.TextColor = participant.Selected ? UIColor.White : UIColor.Black;
     BackgroundColor           = participant.Selected ? UIColor.FromCGColor(Application.MainColour) : UIColor.White;
     Layer.BorderColor         = Application.MainColour;
 }
        public void UpdateContent(Topic topic)
        {
            ProjectTopic.Text = topic.Text;

            var topCorrect = (ProjectTopic.Bounds.Size.Height - ProjectTopic.ContentSize.Height * ProjectTopic.ZoomScale) / 2.0;

            topCorrect = (topCorrect < 0.0 ? 0.0 : topCorrect);
            ProjectTopic.ContentInset = new UIEdgeInsets((nfloat)topCorrect, 0, 0, 0);

            ProjectTopic.TextColor = UIColor.Black;
            Layer.BorderColor      = Application.MainColour;

            if (topic.SelectionState == Topic.SelectedState.current)
            {
                ProjectTopic.TextColor       = UIColor.White;
                ProjectTopic.BackgroundColor = UIColor.FromCGColor(Application.MainColour);
                Layer.BorderColor            = Application.MainColour;
            }
            else if (topic.SelectionState == Topic.SelectedState.previous)
            {
                ProjectTopic.BackgroundColor = UIColor.FromRGB(232, 206, 206);
            }
            else
            {
                ProjectTopic.BackgroundColor = UIColor.White;
            }
        }
예제 #3
0
        // TODO: This is On Element Change event
        protected override void OnElementChanged(ElementChangedEventArgs <Editor> e)
        {
            base.OnElementChanged(e);
            var element = this.Element as CustomEditor;

            if (Control != null && element != null)
            {
                Placeholder             = element.Placeholder;
                Control.TextColor       = UIColor.DarkGray;
                Control.Text            = Placeholder;
                Control.BackgroundColor = UIColor.FromCGColor(Color.FromHex("#F8F8F8").ToCGColor());

                Control.ShouldBeginEditing += (UITextView textView) => {
                    if (textView.Text == Placeholder)
                    {
                        textView.Text      = "";
                        textView.TextColor = UIColor.Black; // Text Color
                    }

                    return(true);
                };

                Control.ShouldEndEditing += (UITextView textView) => {
                    if (textView.Text == "")
                    {
                        textView.Text = Placeholder;
                        // textView.TextColor = UIColor.DarkGray; // Placeholder Color
                        textView.TextColor = UIColor.FromRGB(166, 166, 166);
                    }

                    return(true);
                };
            }
        }
예제 #4
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            var pageControl = UIPageControl.Appearance;

            pageControl.PageIndicatorTintColor        = UIColor.LightGray;
            pageControl.CurrentPageIndicatorTintColor = UIColor.FromCGColor(Application.MainColour);
            pageControl.BackgroundColor = UIColor.White;
        }
예제 #5
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            customizedTab = new CurvedBottomNavigationView();
            element       = Element as CurvedBottomTabbedPage;

            customizedTab.Frame                   = this.TabBar.Frame;
            customizedTab.Items                   = this.TabBar.Items;
            customizedTab.SelectedItem            = this.TabBar.SelectedItem;
            customizedTab.TintColor               = this.TabBar.TintColor;
            customizedTab.UnselectedItemTintColor = this.TabBar.UnselectedItemTintColor;
            customizedTab.BarBackgroundColor      = this.TabBar.BarTintColor;
            customizedTab.BackgroundColor         = Xamarin.Forms.Color.Transparent.ToUIColor();
            customizedTab.ItemSpacing             = 4f;
            customizedTab.ClipsToBounds           = true;
            this.TabBar.RemoveFromSuperview();

            SetMenuItems();

            // Creates a Button
            var appButton = new UIButton(UIButtonType.Custom);

            UIImage imageAppButtonButton = UIImage.FromBundle(element.FabIcon);

            if (imageAppButtonButton != null)
            {
                appButton.SetImage(imageAppButtonButton, UIControlState.Normal);
            }

            // Sets width and height to the Button
            appButton.Frame = new CGRect(0.0f, 0.0f, 48, 48);

            //appButton.SetBackgroundImage(imageAppButtonButton, UIControlState.Normal);
            appButton.BackgroundColor = UIColor.FromCGColor(element.FabBackgroundColor.ToCGColor());

            CGPoint centers = TabBar.Center;

            centers.Y        = this.customizedTab.Frame.Y;
            appButton.Center = centers;

            var eventHandler = new EventHandler(ButtonClick);

            appButton.AddTarget(eventHandler, events: UIControlEvent.TouchUpInside);

            //Create shadow effect
            appButton.Layer.ShadowColor   = UIColor.Black.CGColor;
            appButton.Layer.ShadowOffset  = new CGSize(width: 0.0, height: 5.0);
            appButton.Layer.ShadowOpacity = 0.5f;
            appButton.Layer.ShadowRadius  = 2.0f;
            appButton.Layer.MasksToBounds = false;
            appButton.Layer.CornerRadius  = 24;

            // Adds the Button to the view
            View.Add(customizedTab);
            View.AddSubview(appButton);
        }
예제 #6
0
        public static Color ToColor(this CGColor cgcolor)
        {
            if (cgcolor == null)
            {
                return(new Color());
            }

            nfloat a, r, g, b;

            UIColor.FromCGColor(cgcolor).GetRGBA(out r, out g, out b, out a);

            return(new Color((byte)(a * 255), (byte)(r * 255), (byte)(g * 255), (byte)(b * 255)));
        }
예제 #7
0
        private static UIView AddBorder(UIView view, CGColor borderColor, UIViewAutoresizing autoresizingMask, CGRect frame)
        {
            var border = new UIView
            {
                BackgroundColor  = UIColor.FromCGColor(borderColor),
                AutoresizingMask = autoresizingMask,
                Frame            = frame
            };

            view.AddSubview(border);

            return(view);
        }
        /// <summary>
        ///     The on element changed callback.
        /// </summary>
        /// <param name="e">The event arguments.</param>
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            var textField = Control;

            //Entry Styling

            //Padding
            textField.BorderStyle = UITextBorderStyle.Line;
            var paddingView = new UIView(new RectangleF(0, 0, 7, 20));

            textField.LeftView     = paddingView;
            textField.LeftViewMode = UITextFieldViewMode.Always;

            //Border
            textField.Layer.BorderWidth  = 1;
            textField.Layer.CornerRadius = 4;
            textField.Layer.BorderColor  = UIColor.FromRGB(202, 223, 233).CGColor;

            //Colors
            textField.Layer.BackgroundColor = UIColor.FromRGBA(255, 255, 255, 20).CGColor;
            textField.TintColor             = UIColor.FromCGColor(Color.Transparent.ToCGColor());

            //Font size
            var fontSize = UIScreen.MainScreen.Bounds.Width > 500.0 ? 35 : 24;

            textField.Font = UIFont.FromName("Arial", fontSize);

            if (string.IsNullOrEmpty(textField.Placeholder) == false)
            {
                var placeholderString = new NSAttributedString(textField.Placeholder,
                                                               new UIStringAttributes {
                    ForegroundColor = UIColor.FromRGBA(255, 255, 255, 150)
                });
                textField.AttributedPlaceholder = placeholderString;
            }

            //Show Done button if entry is last item in the form otherwise shows Next button
            //if (this.Element != null &&(this.Element as HACCPTemperatureEntry).IsLastItem)
            textField.ReturnKeyType = UIReturnKeyType.Done;
            //else
            //	textField.ReturnKeyType = UIReturnKeyType.Next;

            //Show done button if keyboard is numeric
            if (Element != null && Element.Keyboard == Keyboard.Numeric)
            {
                AddDoneButton();
            }
        }
예제 #9
0
        private void OnSocialButtonSelected(UIButton button, bool selected)
        {
            button.Selected = !button.Selected;

            if (button.Selected)
            {
                button.BackgroundColor      = UIColor.FromCGColor(button.Layer.BorderColor);
                button.TitleLabel.TextColor = UIColor.White;
            }
            else
            {
                button.BackgroundColor      = UIColor.Clear;
                button.TitleLabel.TextColor = UIColor.FromCGColor(button.Layer.BorderColor);
            }
            button.TitleLabel.BackgroundColor = UIColor.Clear;
        }
예제 #10
0
 public void DrawBitmap()
 {
     isCleared = false;
     UIGraphics.BeginImageContextWithOptions(this.Bounds.Size, false, 0.0f);
     if (canvas != null)
     {
         CGContext context = UIGraphics.GetCurrentContext();
         context.TranslateCTM(0f, this.Bounds.Size.Height);
         context.ScaleCTM(1.0f, -1.0f);
         context.DrawImage(this.Bounds, canvas.CGImage);
         context.ScaleCTM(1.0f, -1.0f);
         context.TranslateCTM(0f, -this.Bounds.Size.Height);
     }
     if (incrementalImage != null)
     {
         incrementalImage.Draw(CGPoint.Empty);
     }
     UIColor.FromCGColor(strokeColor).SetStroke();
     path.Stroke();
     incrementalImage = UIGraphics.GetImageFromCurrentImageContext();
     UIGraphics.EndImageContext();
 }
예제 #11
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            var cell = tableView.DequeueReusableCell("SettingsCell");
            var isLogoutOrAboutCells = (indexPath.Row == Options.Count - 1) || indexPath.Row == 0;

            var type = isLogoutOrAboutCells ? UITableViewCellStyle.Default : UITableViewCellStyle.Subtitle;

            cell = new UITableViewCell(type, "SettingsCell")
            {
                SelectionStyle = UITableViewCellSelectionStyle.None
            };

            cell.TextLabel.Text = Options[indexPath.Row].Title;

            if (!isLogoutOrAboutCells)
            {
                cell.DetailTextLabel.Text      = Options[indexPath.Row].Subtitle;
                cell.DetailTextLabel.TextColor = UIColor.FromCGColor(Application.MainColour);
            }

            return(cell);
        }
예제 #12
0
        public override void Draw(CGRect rect)
        {
            if (drawBitmap)
            {
                DrawBitmap();
            }

            if (incrementalImage == null)
            {
                incrementalImage = new UIImage();
            }

            incrementalImage.Draw(rect);
            UIColor.FromCGColor(strokeColor).SetStroke();
            path.Stroke();

            if (drawBitmap)
            {
                path.RemoveAllPoints();
                center     = 0;
                drawBitmap = false;
            }
        }
예제 #13
0
        void ShowView(string type)
        {
            UIViewController controller = null;
            var isLogin = type == "login";

            if (isLogin)
            {
                controller = Storyboard.InstantiateViewController("LoginViewController") as LoginViewController;
            }
            else
            {
                controller = Storyboard.InstantiateViewController("RegisterViewController") as RegisterViewController;
            }
            controller.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(
                UIImage.FromBundle("BackButton"),
                UIBarButtonItemStyle.Plain,
                delegate { DismissViewController(true, null); });
            controller.NavigationItem.LeftBarButtonItem.TintColor = UIColor.FromCGColor(Application.MainColour);
            controller.NavigationItem.Title = isLogin ? StringResources.login_ui_title : StringResources.register_ui_title;
            var navBar = new UINavigationController(controller);

            PresentViewController(navBar, true, null);
        }
예제 #14
0
        /// <summary>
        /// Updates the current state and recolors.
        /// </summary>
        /// <param name="state">The new validation state</param>
        /// <param name="message">The validation message (can be null)</param>
        private void Update(ValidationState state, string message)
        {
            _state             = state;
            _errorLabel.Text   = message;
            _errorLabel.Hidden = string.IsNullOrWhiteSpace(message);
            switch (state)
            {
            case ValidationState.Valid:
                _textField.BorderColor = ValidStateColor;
                break;

            case ValidationState.Error:
                _textField.BorderColor = ErrorStateColor;
                break;

            default:
            case ValidationState.Neutral:
                _textField.BorderColor = NeutralStateColor;
                break;
            }

            _errorLabel.TextColor = UIColor.FromCGColor(_textField.BorderColor);
            _textField.TextField.Superview.InvokeOnMainThread(() => _textField.Color());
        }
예제 #15
0
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var SupportedLanguages = (await LanguageChoiceManager.GetLanguageChoices()).OrderBy((lang) => lang.Code).ToList();

            TableView.RegisterNibForCellReuse(ProjectTableViewHeader.Nib, ProjectTableViewHeader.CellID);
            TableView.RowHeight          = UITableView.AutomaticDimension;
            TableView.EstimatedRowHeight = 250;

            if (Session.ActiveUser == null)
            {
                var email   = NSUserDefaults.StandardUserDefaults.StringForKey("username");
                var user    = Queries.UserByEmail(email);
                var _tokens = NSUserDefaults.StandardUserDefaults.StringForKey("tokens");
                var tokens  = JsonConvert.DeserializeObject <JWToken>(_tokens);
                Queries.SetActiveUser(new DataUserTokens {
                    User = user, Tokens = tokens
                });
                Firebase.Analytics.Analytics.SetUserId(Session.ActiveUser.Id.ToString());
                // If the user has set the preference or is was determined below, we want to apply it
                Session.ActiveUser.AppLang = user.AppLang;
            }

            var currentMobileLang = Localize.GetCurrentCultureInfo().TwoLetterISOLanguageName;
            var isSupportedLang   = SupportedLanguages.FindIndex((lang) => lang.Code == currentMobileLang);

            // If the user has logged in for the first time, then
            // and their mobile language is one we support, then we must choose that.
            if (isSupportedLang != -1 && Session.ActiveUser.AppLang == 0)
            {
                Session.ActiveUser.AppLang = SupportedLanguages.First((lang) => lang.Code == currentMobileLang).Id;
            }
            // Otherwise, the user who logged in, may not have their phone in a lang we do not support
            else if (isSupportedLang == -1 && Session.ActiveUser.AppLang == 0)
            {
                Session.ActiveUser.AppLang = 1;
            }
            Queries.SaveActiveUser();

            var languages = SupportedLanguages.FirstOrDefault((lang) => lang.Id == Session.ActiveUser.AppLang);

            StringResources.Culture = new CultureInfo(languages.Code);
            Localize.SetLayoutDirectionByPreference();

            SetStringResources();

            projects = Queries.AllProjects();

            refreshControl = new UIRefreshControl
            {
                AttributedTitle = new NSAttributedString(StringResources.projects_ui_fetching),
                TintColor       = UIColor.FromCGColor(Application.MainColour)
            };

            refreshControl.AddTarget(delegate
            {
                Logger.LOG_EVENT_WITH_ACTION("SWIPE_REFRESH", projects.Count.ToString(), "PROJECT_COUNT");
                var suppress = RefreshData();
            }, UIControlEvent.AllEvents);

            ProjectsTableViewSource source = new ProjectsTableViewSource(projects, LaunchProject, HandleExpansion);

            TableView.Source         = source;
            TableView.RefreshControl = refreshControl;
            TableView.ReloadData();

            var suppressAsync = RefreshData();

            SendFCMToken();
        }
        private void CreatingTabBar()
        {
            element = Element as CurvedBottomTabbedPage;
            this.RemoveFromParentViewController();

            if (customizedTab != null)
            {
                this.customizedTab.RemoveFromSuperview();
                View.WillRemoveSubview(this.customizedTab);
            }

            if (appButton != null)
            {
                this.appButton.RemoveFromSuperview();
                View.WillRemoveSubview(this.appButton);
            }

            this.TabBar.RemoveFromSuperview();
            View.WillRemoveSubview(this.TabBar);

            customizedTab.Frame                   = this.TabBar.Frame;
            customizedTab.Items                   = this.TabBar.Items;
            customizedTab.SelectedItem            = this.TabBar.SelectedItem;
            customizedTab.TintColor               = this.TabBar.TintColor;
            customizedTab.UnselectedItemTintColor = this.TabBar.UnselectedItemTintColor;
            customizedTab.BarBackgroundColor      = this.TabBar.BarTintColor;
            customizedTab.BackgroundColor         = Xamarin.Forms.Color.Transparent.ToUIColor();
            customizedTab.ItemSpacing             = 4f;
            customizedTab.ClipsToBounds           = true;

            // Creates a Button
            appButton = new UIButton(UIButtonType.Custom);

            UIImage imageAppButtonButton = UIImage.FromBundle(element.FabIcon);

            if (imageAppButtonButton != null)
            {
                appButton.SetImage(imageAppButtonButton, UIControlState.Normal);
            }

            // Sets width and height to the Button
            appButton.Frame = new CGRect(0.0f, 0.0f, 48, 48);

            //appButton.SetBackgroundImage(imageAppButtonButton, UIControlState.Normal);
            appButton.BackgroundColor = UIColor.FromCGColor(element.FabBackgroundColor.ToCGColor());

            CGPoint centers = TabBar.Center;

            centers.Y        = this.customizedTab.Frame.Y;
            appButton.Center = centers;

            var eventHandler = new EventHandler(ButtonClick);

            appButton.AddTarget(eventHandler, events: UIControlEvent.TouchUpInside);

            //Create shadow effect
            appButton.Layer.ShadowColor   = UIColor.Black.CGColor;
            appButton.Layer.ShadowOffset  = new CGSize(width: 0.0, height: 5.0);
            appButton.Layer.ShadowOpacity = 0.5f;
            appButton.Layer.ShadowRadius  = 2.0f;
            appButton.Layer.MasksToBounds = false;
            appButton.Layer.CornerRadius  = 24;

            if (Device.Idiom == TargetIdiom.Phone)
            {
                SetMenuItemsForPhone();
            }
            else
            {
                SetMenuItemsForTablet();
            }

            //Adds the Button to the view
            if (View.Subviews.Length == 1)
            {
                View.Add(customizedTab);
                View.Add(appButton);
            }
        }
예제 #17
0
        public override void ViewDidLoad()
        {
            Title = StringResources.recording_ui_title;
            TopicsInstructions.Text = StringResources.recording_ui_instructions_header;

            var es = new CoreGraphics.CGSize(UIScreen.MainScreen.Bounds.Width - 36, 70);

            (TopicsCollectionView.CollectionViewLayout as UICollectionViewFlowLayout).EstimatedItemSize = es;

            RequestAudioRecordPermission();
            if (CheckAccess().Contains("denied"))
            {
                ConfigureMicrophoneAccessDialog();
                return;
            }

            NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIImage.FromBundle("BackButton"), UIBarButtonItemStyle.Plain, (sender, args) =>
            {
                if (AudioRecorder.IsRecording())
                {
                    var doDeleteRecording = UIAlertController.Create(
                        StringResources.recording_ui_dialog_back_title,
                        StringResources.recording_ui_dialog_back_body,
                        UIAlertControllerStyle.Alert);

                    doDeleteRecording.AddAction(
                        UIAlertAction.Create(
                            StringResources.recording_ui_dialog_back_negative,
                            UIAlertActionStyle.Cancel,
                            (_) => { }
                            )
                        );
                    doDeleteRecording.AddAction(
                        UIAlertAction.Create(
                            StringResources.recording_ui_dialog_back_positive,
                            UIAlertActionStyle.Default, (_) =>
                    {
                        NavigationController.PopViewController(false);
                    }));
                    PresentViewController(doDeleteRecording, true, null);
                }
                NavigationController.PopViewController(false);
            })
            {
                TintColor = UIColor.FromCGColor(Application.MainColour)
            };

            // As we can record, enable it all.
            AudioRecorder      = new AudioRecorder();
            InterviewSessionID = Guid.NewGuid().ToString();

            SelectedProjectID = Convert.ToInt32(NSUserDefaults.StandardUserDefaults.IntForKey("SelectedProjectID"));
            var lang            = Convert.ToInt32(NSUserDefaults.StandardUserDefaults.IntForKey("SESSION_LANG"));
            var SelectedProject = LanguageChoiceManager.ContentByLanguage(Queries.ProjectById(SelectedProjectID), lang);

            var activeTopics = SelectedProject.Topics.Where((t) => t.IsActive).ToList();

            ThemeTitleLabel.Text = SelectedProject.Title;

            Topics = activeTopics;
            TopicsCollectionView.Source = new TopicsCollectionViewSource
            {
                Rows          = Topics,
                AddAnnotation = AddAnnotation
            };
        }
예제 #18
0
 private void InitializeFields()
 {
     BorderColor = UIColor.Clear;
     ShadowColor = UIColor.FromCGColor(Layer.ShadowColor);
     BorderWidth = Layer.BorderWidth;
 }