示例#1
0
        public PersonListPage()
        {
            _addButtonToolBarItem = new ToolbarItem
            {
                Icon         = "Add",
                AutomationId = AutomationIdConstants.PersonListPage_AddButton
            };
            ToolbarItems.Add(_addButtonToolBarItem);

            _personList = new ListView(ListViewCachingStrategy.RecycleElement)
            {
                ItemTemplate           = new DataTemplate(typeof(PersonListViewCell)),
                IsPullToRefreshEnabled = true,
                BackgroundColor        = ColorConstants.PageBackgroundColor,
                HasUnevenRows          = true,
                AutomationId           = AutomationIdConstants.PersonListPage_PersonList
            };
            _personList.SetBinding(ListView.IsRefreshingProperty, nameof(ViewModel.IsRefreshing));
            _personList.SetBinding(ListView.ItemsSourceProperty, nameof(ViewModel.PersonList));
            _personList.SetBinding(ListView.RefreshCommandProperty, nameof(ViewModel.PullToRefreshCommand));

            var activityIndicator = new ActivityIndicator {
                AutomationId = AutomationIdConstants.PersonListPage_ActivityIndicator
            };

            activityIndicator.SetBinding(IsVisibleProperty, nameof(ViewModel.IsDeletingPerson));
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ViewModel.IsDeletingPerson));

            var whiteOverlayBoxView = new BoxView {
                BackgroundColor = new Color(1, 1, 1, 0.75)
            };

            whiteOverlayBoxView.SetBinding(IsVisibleProperty, nameof(ViewModel.IsDeletingPerson));

            var relativeLayout = new RelativeLayout();

            Func <RelativeLayout, double> getActivityIndicatorWidth  = (p) => activityIndicator.Measure(p.Width, p.Height).Request.Width;
            Func <RelativeLayout, double> getActivityIndicatorHeight = (p) => activityIndicator.Measure(p.Width, p.Height).Request.Height;

            relativeLayout.Children.Add(_personList,
                                        Constraint.Constant(0),
                                        Constraint.Constant(0));

            relativeLayout.Children.Add(whiteOverlayBoxView,
                                        Constraint.Constant(0),
                                        Constraint.Constant(0),
                                        Constraint.RelativeToParent(parent => parent.Width),
                                        Constraint.RelativeToParent(parent => parent.Height));

            relativeLayout.Children.Add(activityIndicator,
                                        Constraint.RelativeToParent(parent => parent.Width / 2 - getActivityIndicatorWidth(parent) / 2),
                                        Constraint.RelativeToParent(parent => parent.Height / 2 - getActivityIndicatorHeight(parent) / 2));

            Content = relativeLayout;

            Title = PageTitles.PersonListPage;
        }
        public override View Run()
        {
            var view = new View
            {
                Layout = new LinearLayout
                {
                    LinearAlignment   = LinearLayout.Alignment.Center,
                    LinearOrientation = LinearLayout.Orientation.Vertical,
                }
            };
            var ai = new ActivityIndicator();

            ai.SizeHeight = (float)ai.Measure(300, 300).Height;
            ai.SizeWidth  = (float)ai.Measure(300, 300).Width;
            view.Add(ai);

            var ai2 = new ActivityIndicator
            {
                Color = Color.Red,
            };

            ai2.SizeHeight = (float)ai2.Measure(300, 300).Height;
            ai2.SizeWidth  = (float)ai2.Measure(300, 300).Width;
            view.Add(ai2);

            var start = new Tizen.UIExtensions.NUI.Button()
            {
                Text = "start"
            };

            view.Add(start);
            start.Clicked += (s, e) =>
            {
                ai.IsRunning  = true;
                ai2.IsRunning = true;
            };

            var stop = new Tizen.UIExtensions.NUI.Button()
            {
                Text = "stop"
            };

            view.Add(stop);
            stop.Clicked += (s, e) =>
            {
                ai.IsRunning  = false;
                ai2.IsRunning = false;
            };

            return(view);
        }
        void AddSpinner()
        {
            var spinner = new ActivityIndicator()
            {
                Color     = Color.White,
                IsRunning = true,
                IsVisible = true,
                Scale     = 1.5
            };
            Func <RelativeLayout, double> getSpinnerWidth  = (p) => spinner.Measure(defaultLayout.Width, defaultLayout.Height).Request.Width;
            Func <RelativeLayout, double> getSpinnerHeight = (p) => spinner.Measure(defaultLayout.Width, defaultLayout.Height).Request.Height;

            defaultLayout.Children.Add(spinner,
                                       Constraint.RelativeToParent((parent) => parent.Width / 2 - getSpinnerWidth(parent) / 2),
                                       Constraint.RelativeToParent((parent) => parent.Height / 2 - getSpinnerHeight(parent) / 2)
                                       );
        }
        public ListViewContentPage()
        {
            var viewModel = new ListViewViewModel();

            BindingContext = viewModel;

            var activityIndicator = new ActivityIndicator();

            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(viewModel.IsBusy));
            activityIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, nameof(viewModel.IsBusy));

            var listView = new ListView(ListViewCachingStrategy.RecycleElement)
            {
                BackgroundColor = Color.White,
                RowHeight       = 200,
                ItemTemplate    = new DataTemplate(typeof(PuzzleCellCardView)),
                SeparatorColor  = Color.Transparent
            };

            listView.SetBinding(ListView.ItemsSourceProperty, nameof(viewModel.AzurePunModelList));

            var relativeLayout = new RelativeLayout();

            Func <RelativeLayout, double> getActivityIndicatorHeight = (p) => activityIndicator.Measure(relativeLayout.Width, relativeLayout.Height).Request.Height;
            Func <RelativeLayout, double> getActivityIndicatorWidth  = (p) => activityIndicator.Measure(relativeLayout.Width, relativeLayout.Height).Request.Width;

            relativeLayout.Children.Add(listView,
                                        Constraint.Constant(0),
                                        Constraint.Constant(0),
                                        Constraint.RelativeToParent(parent => parent.Width),
                                        Constraint.RelativeToParent(parent => parent.Height));
            relativeLayout.Children.Add(activityIndicator,
                                        Constraint.RelativeToParent(parent => parent.Width / 2 - getActivityIndicatorWidth(parent) / 2),
                                        Constraint.RelativeToParent(parent => parent.Height / 2 - getActivityIndicatorHeight(parent) / 2));

            Content = relativeLayout;
        }
        public LoginPage()
        {
            NavigationPage.SetHasBackButton(this, false);

            ViewModel.LoginSuccess += LoginSuccess;
            ViewModel.LoginFailed  += LoginFailed;

            var mainRelativeLayout = new RelativeLayout
            {
                WidthRequest  = App.ScreenWidth,
                HeightRequest = App.ScreenHeight
            };


            var userName = new Entry
            {
                Placeholder  = "Username",
                WidthRequest = 200
            };

            userName.SetBinding(Entry.TextProperty, nameof(ViewModel.Name));
            Func <RelativeLayout, double> userNameWidth = (parent) => userName.Measure(mainRelativeLayout.Width, mainRelativeLayout.Height).Request.Width;

            var passWord = new Entry
            {
                Placeholder = "Password",
                IsPassword  = true
            };

            passWord.SetBinding(Entry.TextProperty, nameof(ViewModel.Password));
            Func <RelativeLayout, double> passwordWidth = (parent) => passWord.Measure(mainRelativeLayout.Width, mainRelativeLayout.Height).Request.Width;


            var registerButton = new Button
            {
                Text = "Register",
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                BackgroundColor   = Color.Transparent,
                TextColor         = Color.FromRgb(7, 62, 164),
                FontSize          = 18,
                BorderRadius      = 5,
                BorderWidth       = 2,
                BorderColor       = Color.FromRgb(7, 62, 164),
                WidthRequest      = 140,
                AutomationId      = "loginButton",
                Command           = ViewModel.CustomLoginCommand
            };
            Func <RelativeLayout, double> registerBtnWidth = (parent) => registerButton.Measure(mainRelativeLayout.Width, mainRelativeLayout.Height).Request.Width;


            var activity = new ActivityIndicator
            {
                HeightRequest = 80,
                WidthRequest  = 80,
                Color         = Color.Blue,
            };

            activity.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ViewModel.IsBusy));
            activity.SetBinding(IsEnabledProperty, nameof(ViewModel.IsBusy));

            Func <RelativeLayout, double> activityWidth = (parent) => activity.Measure(mainRelativeLayout.Width, mainRelativeLayout.Height).Request.Width;


            /* ADD CONTROLS TO MAIN LAYOUT */
            var loginLayout = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Children        =
                {
                    userName,
                    passWord,
                    registerButton
                },
                Padding = 40
            };

            mainRelativeLayout.Children.Add(loginLayout,
                                            Constraint.RelativeToParent((parent) =>
            {
                return(parent.X);
            }),
                                            Constraint.RelativeToParent((parent) =>
            {
                return(parent.Y);
            }),
                                            Constraint.Constant(App.ScreenWidth),
                                            Constraint.Constant(App.ScreenHeight * .8)
                                            );

            /* LAY THE ACTIVITY INDICATOR OVER THE REST OF THE LOGIN SCREEN*/
            mainRelativeLayout.Children.Add(activity,
                                            Constraint.RelativeToParent((parent) =>
            {
                return(parent.Bounds.Width / 2 - activityWidth(parent) / 2);
            }),
                                            Constraint.RelativeToParent((parent) =>
            {
                return(loginLayout.Bounds.Center.Y);
            }));

            Content = mainRelativeLayout;
        }
示例#6
0
        public FirstPage() : base(PageTitleConstants.FirstPage)
        {
            const string entryTextPaceHolder = "Enter text and click 'Go'";

            _goButton = new StyledButton(Borders.Thin, 1)
            {
                Text         = "Go",
                AutomationId = AutomationIdConstants.GoButton, // This provides an ID that can be referenced in UITests
            };
            _goButton.SetBinding(Button.CommandProperty, nameof(ViewModel.GoButtonCommand));

            var textEntry = new StyledEntry(1)
            {
                Placeholder             = entryTextPaceHolder,
                AutomationId            = AutomationIdConstants.TextEntry, // This provides an ID that can be referenced in UITests
                PlaceholderColor        = Color.FromHex("749FA8"),
                HorizontalTextAlignment = TextAlignment.Center
            };

            CustomReturnEffect.SetReturnType(textEntry, ReturnType.Go);
            textEntry.SetBinding(CustomReturnEffect.ReturnCommandProperty, nameof(ViewModel.GoButtonCommand));
            textEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.EntryText));

            var textLabel = new StyledLabel
            {
                AutomationId      = AutomationIdConstants.TextLabel, // This provides an ID that can be referenced in UITests
                HorizontalOptions = LayoutOptions.Center
            };

            textLabel.SetBinding(Label.TextProperty, nameof(ViewModel.LabelText));

            _listPageButton = new StyledButton(Borders.Thin, 1)
            {
                Text         = "Go to List Page",
                AutomationId = AutomationIdConstants.ListViewButton // This provides an ID that can be referenced in UITests
            };

            var activityIndicator = new ActivityIndicator
            {
                AutomationId = AutomationIdConstants.BusyActivityIndicator, // This provides an ID that can be referenced in UITests
                Color        = Color.White
            };

            activityIndicator.SetBinding(IsVisibleProperty, nameof(ViewModel.IsActiityIndicatorRunning));
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ViewModel.IsActiityIndicatorRunning));

            Func <RelativeLayout, double> getTextEntryWidth         = (p) => textEntry.Measure(p.Width, p.Height).Request.Width;
            Func <RelativeLayout, double> getGoButtonWidth          = (p) => _goButton.Measure(p.Width, p.Height).Request.Width;
            Func <RelativeLayout, double> getActivityIndicatorWidth = (p) => activityIndicator.Measure(p.Width, p.Height).Request.Width;
            Func <RelativeLayout, double> getTextLabelWidth         = (p) => textLabel.Measure(p.Width, p.Height).Request.Width;

            var relativeLayout = new RelativeLayout();

            relativeLayout.Children.Add(textEntry,
                                        Constraint.RelativeToParent((parent) => parent.X),
                                        Constraint.RelativeToParent((parent) => parent.Y),
                                        Constraint.RelativeToParent((parent) => parent.Width - 20));
            relativeLayout.Children.Add(_goButton,
                                        Constraint.RelativeToParent((parent) => parent.X),
                                        Constraint.RelativeToView(textEntry, (parent, view) => view.Y + view.Height + _relativeLayoutPadding),
                                        Constraint.RelativeToParent((parent) => parent.Width - 20));
            relativeLayout.Children.Add(activityIndicator,
                                        Constraint.RelativeToParent((parent) => parent.Width / 2 - getActivityIndicatorWidth(parent) / 2),
                                        Constraint.RelativeToView(_goButton, (parent, view) => view.Y + view.Height + _relativeLayoutPadding));
            relativeLayout.Children.Add(textLabel,
                                        Constraint.RelativeToParent((parent) => parent.Width / 2 - getTextLabelWidth(parent) / 2),
                                        Constraint.RelativeToView(_goButton, (parent, view) => view.Y + view.Height + _relativeLayoutPadding));
            relativeLayout.Children.Add(_listPageButton,
                                        Constraint.RelativeToParent((parent) => parent.X),
                                        Constraint.RelativeToView(_goButton, (parent, view) => view.Y + view.Height + _relativeLayoutPadding * 15),
                                        Constraint.RelativeToParent((parent) => parent.Width - 20));

            Padding = GetPagePadding();
            Content = relativeLayout;
        }
        public override View Run()
        {
            var scrollview = new Tizen.UIExtensions.NUI.ScrollView();

            scrollview.ContentContainer.Layout = new LinearLayout
            {
                LinearAlignment   = LinearLayout.Alignment.Center,
                LinearOrientation = LinearLayout.Orientation.Vertical,
            };

            var view = scrollview.ContentContainer;


            view.Add(new Label
            {
                Text                  = "Graphics View",
                TextColor             = Color.White,
                FontSize              = 9,
                FontAttributes        = Tizen.UIExtensions.Common.FontAttributes.Bold,
                VerticalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Center,
                WidthSpecification    = LayoutParamPolicies.MatchParent,
                SizeHeight            = 100,
                Padding               = new Extents(20, 10, 10, 10),
                BackgroundColor       = Color.FromHex("#2196f3").ToNative(),
                BoxShadow             = new Shadow(5, Color.FromHex("#bbbbbb").ToNative(), new Vector2(0, 5))
            });

            view.Add(new View
            {
                SizeHeight = 20,
            });

            view.Add(new Label
            {
                Padding  = new Extents(10, 0, 0, 0),
                Text     = "ActivityIndicator",
                FontSize = 7,
                HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HeightSpecification     = LayoutParamPolicies.WrapContent,
            });

            var hlayout = new View
            {
                Layout = new LinearLayout
                {
                    LinearOrientation = LinearLayout.Orientation.Horizontal,
                },
                Padding = 10,
            };

            {
                var ai = new ActivityIndicator
                {
                    IsRunning = true,
                    Margin    = 5,
                };
                ai.SizeHeight = (float)ai.Measure(300, 300).Height;
                ai.SizeWidth  = (float)ai.Measure(300, 300).Width;
                view.Add(ai);
                hlayout.Add(ai);
                var timer = ElmSharp.EcoreMainloop.AddTimer(3, () =>
                {
                    ai.IsRunning = !ai.IsRunning;
                    return(true);
                });
                ai.RemovedFromWindow += (s, e) =>
                {
                    ElmSharp.EcoreMainloop.RemoveTimer(timer);
                    (s as View).Dispose();
                };
            }

            {
                var ai = new ActivityIndicator
                {
                    Color     = Color.FromHex("#ff9800"),
                    IsRunning = true,
                    Margin    = 5
                };
                ai.SizeHeight = (float)ai.Measure(300, 300).Height;
                ai.SizeWidth  = (float)ai.Measure(300, 300).Width;
                view.Add(ai);
                hlayout.Add(ai);
                var timer = ElmSharp.EcoreMainloop.AddTimer(3.3, () =>
                {
                    ai.IsRunning = !ai.IsRunning;
                    return(true);
                });
                ai.RemovedFromWindow += (s, e) =>
                {
                    ElmSharp.EcoreMainloop.RemoveTimer(timer);
                    (s as View).Dispose();
                };
            }

            {
                var ai = new ActivityIndicator
                {
                    Color     = Color.FromHex("#ffeb3b"),
                    IsRunning = true,
                    Margin    = 5
                };
                ai.SizeHeight = (float)ai.Measure(300, 300).Height;
                ai.SizeWidth  = (float)ai.Measure(300, 300).Width;
                view.Add(ai);
                hlayout.Add(ai);
                var timer = ElmSharp.EcoreMainloop.AddTimer(4, () =>
                {
                    ai.IsRunning = !ai.IsRunning;
                    return(true);
                });
                ai.RemovedFromWindow += (s, e) =>
                {
                    ElmSharp.EcoreMainloop.RemoveTimer(timer);
                    (s as View).Dispose();
                };
            }

            view.Add(hlayout);

            view.Add(new Label
            {
                Padding  = new Extents(10, 0, 0, 0),
                Text     = "ProgressBar",
                FontSize = 7,
                HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HeightSpecification     = LayoutParamPolicies.WrapContent,
            });

            {
                var progressBar2 = new ProgressBar
                {
                    Margin             = 10,
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                    ProgressColor      = Color.GreenYellow,
                };
                progressBar2.SizeHeight = (float)progressBar2.Measure(300, 300).Height;

                view.Add(progressBar2);
                var timer = ElmSharp.EcoreMainloop.AddTimer(1, () =>
                {
                    if (progressBar2.Progress >= 1.0)
                    {
                        progressBar2.Progress = 0;
                    }

                    progressBar2.ProgressTo(progressBar2.Progress + 0.2);
                    return(true);
                });
                progressBar2.RemovedFromWindow += (s, e) => ElmSharp.EcoreMainloop.RemoveTimer(timer);
            }


            var progressBar1 = new ProgressBar
            {
                Margin             = 10,
                WidthSpecification = LayoutParamPolicies.MatchParent,
            };

            progressBar1.SizeHeight = (float)progressBar1.Measure(300, 300).Height;

            view.Add(progressBar1);

            view.Add(new View
            {
                SizeHeight         = 10,
                WidthSpecification = LayoutParamPolicies.MatchParent,
            });

            view.Add(new Label
            {
                Padding  = new Extents(10, 0, 10, 0),
                Text     = "Slider",
                FontSize = 7,
                HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HeightSpecification     = LayoutParamPolicies.WrapContent,
            });

            {
                var slider1 = new Slider
                {
                    IsEnabled          = false,
                    Margin             = 5,
                    Value              = 0,
                    Minimum            = 0,
                    Maximum            = 1,
                    SizeHeight         = 50,
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                };
                slider1.ValueChanged += (s, e) =>
                {
                    progressBar1.Progress = slider1.Value;
                };
                view.Add(slider1);
            }

            {
                var slider1 = new Slider
                {
                    Margin             = 5,
                    Value              = 0,
                    Minimum            = 0,
                    Maximum            = 1,
                    SizeHeight         = 50,
                    MaximumTrackColor  = Color.Red,
                    MinimumTrackColor  = Color.Green,
                    ThumbColor         = Color.Yellow,
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                };
                view.Add(slider1);
            }

            {
                var slider1 = new Slider
                {
                    Margin             = 5,
                    Value              = 0,
                    Minimum            = -20,
                    Maximum            = 10,
                    SizeHeight         = 50,
                    MaximumTrackColor  = Color.Red,
                    MinimumTrackColor  = Color.Green,
                    ThumbColor         = Color.Yellow,
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                };
                view.Add(slider1);
            }

            view.Add(new Label
            {
                Padding  = new Extents(10, 0, 10, 0),
                Text     = "Button",
                FontSize = 7,
                HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HeightSpecification     = LayoutParamPolicies.WrapContent,
            });

            {
                var button = new Tizen.UIExtensions.NUI.GraphicsView.Button
                {
                    IsEnabled    = false,
                    Margin       = 5,
                    Text         = "Clicked 0",
                    CornerRadius = 10,
                };

                button.SizeHeight = (float)button.Measure(300, 300).Height;
                button.SizeWidth  = (float)button.Measure(300, 300).Width;
                int count = 1;
                button.Clicked += (s, e) =>
                {
                    button.Text = $"Clicked {count++}";
                };
                view.Add(button);
            }

            {
                var button = new Tizen.UIExtensions.NUI.GraphicsView.Button
                {
                    Margin          = 5,
                    BackgroundColor = Color.Green,
                    Text            = "BUTTON",
                };

                button.SizeHeight = (float)button.Measure(300, 300).Height;
                button.SizeWidth  = (float)button.Measure(300, 300).Width;
                view.Add(button);
            }

            {
                var button = new Tizen.UIExtensions.NUI.GraphicsView.Button
                {
                    Margin          = 5,
                    BackgroundColor = Color.Red,
                    Text            = "BUTTON",
                };

                button.SizeHeight = (float)button.Measure(300, 300).Height;
                button.SizeWidth  = (float)button.Measure(300, 300).Width + 100;
                view.Add(button);
            }

            view.Add(new Label
            {
                Padding  = new Extents(10, 0, 10, 0),
                Text     = "CheckBox",
                FontSize = 7,
                HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HeightSpecification     = LayoutParamPolicies.WrapContent,
            });

            {
                var checkbox1 = new CheckBox
                {
                    Margin = 5,
                    Text   = "CheckBox1",
                };
                checkbox1.SizeHeight = (float)checkbox1.Measure(300, 300).Height;
                checkbox1.SizeWidth  = (float)checkbox1.Measure(300, 300).Width;
                view.Add(checkbox1);
            }
            {
                var checkbox1 = new CheckBox
                {
                    IsEnabled = false,
                    Margin    = 5,
                    Text      = "CheckBox1",
                };
                checkbox1.SizeHeight = (float)checkbox1.Measure(300, 300).Height;
                checkbox1.SizeWidth  = (float)checkbox1.Measure(300, 300).Width;
                view.Add(checkbox1);
            }
            {
                var checkbox1 = new CheckBox
                {
                    IsEnabled = false,
                    IsChecked = true,
                    Margin    = 5,
                    Text      = "CheckBox1",
                };
                checkbox1.SizeHeight = (float)checkbox1.Measure(300, 300).Height;
                checkbox1.SizeWidth  = (float)checkbox1.Measure(300, 300).Width;
                view.Add(checkbox1);
            }
            {
                var checkbox1 = new CheckBox
                {
                    Margin = 5,
                    Color  = Color.Red,
                    Text   = "Red",
                };
                checkbox1.SizeHeight = (float)checkbox1.Measure(300, 300).Height;
                checkbox1.SizeWidth  = (float)checkbox1.Measure(300, 300).Width;
                view.Add(checkbox1);
            }
            {
                var checkbox1 = new CheckBox
                {
                    Margin = 5,
                    Color  = Color.Blue,
                    Text   = "Blue",
                };
                checkbox1.SizeHeight = (float)checkbox1.Measure(300, 300).Height;
                checkbox1.SizeWidth  = (float)checkbox1.Measure(300, 300).Width;
                view.Add(checkbox1);
            }

            view.Add(new Label
            {
                Padding  = new Extents(10, 0, 10, 0),
                Text     = "Switch",
                FontSize = 7,
                HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HeightSpecification     = LayoutParamPolicies.WrapContent,
            });

            hlayout = new View
            {
                Layout = new LinearLayout
                {
                    LinearOrientation = LinearLayout.Orientation.Horizontal,
                },
                Padding = 10,
            };

            {
                var switch1 = new Switch
                {
                    Margin = 5,
                };
                switch1.SizeHeight = (float)switch1.Measure(300, 300).Height;
                switch1.SizeWidth  = (float)switch1.Measure(300, 300).Width;
                hlayout.Add(switch1);
            }
            {
                var switch1 = new Switch
                {
                    IsEnabled  = false,
                    Margin     = 5,
                    ThumbColor = Color.Red,
                    OnColor    = Color.Yellow
                };
                switch1.SizeHeight = (float)switch1.Measure(300, 300).Height;
                switch1.SizeWidth  = (float)switch1.Measure(300, 300).Width;
                hlayout.Add(switch1);
            }
            {
                var switch1 = new Switch
                {
                    Margin     = 5,
                    ThumbColor = Color.BlueViolet,
                    OnColor    = Color.Red,
                    IsToggled  = true,
                };
                switch1.SizeHeight = (float)switch1.Measure(300, 300).Height;
                switch1.SizeWidth  = (float)switch1.Measure(300, 300).Width;
                hlayout.Add(switch1);
            }
            view.Add(hlayout);

            view.Add(new Label
            {
                Padding  = new Extents(10, 0, 10, 0),
                Text     = "Stepper",
                FontSize = 7,
                HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HeightSpecification     = LayoutParamPolicies.WrapContent,
            });

            var stepper = new Stepper();

            stepper.SizeHeight = (float)stepper.Measure(300, 300).Height;
            stepper.SizeWidth  = (float)stepper.Measure(300, 300).Width;
            view.Add(stepper);

            var stepperLabel = new Label
            {
                Text = "0",
            };

            view.Add(stepperLabel);

            stepper.ValueChanged += (s, e) => stepperLabel.Text = $"{stepper.Value}";


            view.Add(new Label
            {
                Padding  = 10,
                Text     = "Entry",
                FontSize = 7,
                HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HeightSpecification     = LayoutParamPolicies.WrapContent,
            });

            var gEntry = new Tizen.UIExtensions.NUI.GraphicsView.Entry
            {
                Placeholder = "Entry",
            };


            gEntry.SizeHeight = (float)gEntry.Measure(600, 300).Height;
            gEntry.SizeWidth  = (float)gEntry.Measure(600, 300).Width;

            view.Add(gEntry);

            view.Add(new View
            {
                SizeHeight = 20
            });

            var gEntry2 = new Tizen.UIExtensions.NUI.GraphicsView.Entry
            {
                Placeholder      = "Entry2",
                PlaceholderColor = Color.Red,
            };

            gEntry2.SizeHeight = (float)gEntry2.Measure(600, 300).Height;
            gEntry2.SizeWidth  = (float)gEntry2.Measure(600, 300).Width;

            view.Add(gEntry2);

            view.Add(new View
            {
                SizeHeight = 60
            });


            var editor = new Tizen.UIExtensions.NUI.GraphicsView.Editor
            {
                Placeholder = "Editor"
            };

            editor.SizeHeight = 500;
            editor.SizeWidth  = (float)editor.Measure(600, 300).Width;

            view.Add(editor);


            view.Add(new View
            {
                SizeHeight = 600
            });

            return(scrollview);
        }
示例#8
0
        public LoginPage()
        {
            ViewModel.LoginFailed   += HandleLoginFailed;
            ViewModel.LoginApproved += HandleLoginApproved;

            BackgroundColor = Color.FromHex("#3498db");
            Padding         = GetPagePadding();

            _logo = new Image {
                Source = "xamarin_logo"
            };

            _logoSlogan = new StyledLabel
            {
                Opacity = 0,
                Text    = "Login to your account with facial recognition.",
            };
            _usernameEntry = new StyledEntry
            {
                Placeholder   = "Username",
                ReturnType    = ReturnType.Next,
                ReturnCommand = new Command(() => _passwordEntry.Focus())
            };
            _usernameEntry.SetBinding(Xamarin.Forms.Entry.TextProperty, nameof(ViewModel.UsernameEntryText));

            _passwordEntry = new StyledEntry
            {
                Placeholder = "Password",
                IsPassword  = true,
                ReturnType  = ReturnType.Done
            };
            _passwordEntry.SetBinding(Xamarin.Forms.Entry.TextProperty, nameof(ViewModel.PasswordEntryText));
            _passwordEntry.SetBinding(Xamarin.Forms.Entry.ReturnCommandProperty, nameof(ViewModel.LoginButtonTappedCommand));

            _loginButton = new StyledButton(Borders.Thin)
            {
                Text = "Login"
            };
            _loginButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsInternetConnectionInactive));
            _loginButton.SetBinding(Button.CommandProperty, nameof(ViewModel.LoginButtonTappedCommand));

            _newUserSignUpButton = new StyledButton(Borders.None)
            {
                Text = "Sign-up"
            };
            _newUserSignUpButton.Clicked += HandleNewUserSignUpButtonClicked;
            _newUserSignUpButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsInternetConnectionInactive));

            var activityIndicator = new ActivityIndicator {
                Color = Color.White
            };

            activityIndicator.SetBinding(IsVisibleProperty, nameof(ViewModel.IsInternetConnectionActive));
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ViewModel.IsInternetConnectionActive));

            On <Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true);

            Func <RelativeLayout, double> getNewUserButtonWidth      = (p) => _newUserSignUpButton.Measure(p.Width, p.Height).Request.Width;
            Func <RelativeLayout, double> getLogoSloganWidth         = (p) => _logoSlogan.Measure(p.Width, p.Height).Request.Width;
            Func <RelativeLayout, double> getActivityIndicatorHeight = (p) => activityIndicator.Measure(p.Width, p.Height).Request.Height;
            Func <RelativeLayout, double> getActivityIndicatorWidth  = (p) => activityIndicator.Measure(p.Width, p.Height).Request.Width;

            _relativeLayout = new RelativeLayout();
            _relativeLayout.Children.Add(
                _logo,
                xConstraint: Constraint.Constant(100),
                yConstraint: Constraint.Constant(250),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - 200)
                );

            _relativeLayout.Children.Add(
                _logoSlogan,
                xConstraint: Constraint.RelativeToParent(p => (p.Width / 2) - (getLogoSloganWidth(p) / 2)),
                yConstraint: Constraint.Constant(125)
                );

            _relativeLayout.Children.Add(
                _usernameEntry,
                xConstraint: Constraint.Constant(40),
                yConstraint: Constraint.RelativeToView(_logoSlogan, (p, v) => v.Y + v.Height + _relativeLayoutPadding),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - 80)
                );
            _relativeLayout.Children.Add(
                _passwordEntry,
                xConstraint: Constraint.Constant(40),
                yConstraint: Constraint.RelativeToView(_usernameEntry, (p, v) => v.Y + v.Height + _relativeLayoutPadding),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - 80)
                );

            _relativeLayout.Children.Add(
                _loginButton,
                xConstraint: Constraint.Constant(40),
                yConstraint: Constraint.RelativeToView(_passwordEntry, (p, v) => v.Y + v.Height + _relativeLayoutPadding),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - 80)
                );
            _relativeLayout.Children.Add(
                _newUserSignUpButton,
                xConstraint: Constraint.RelativeToParent(p => (p.Width / 2) - (getNewUserButtonWidth(p) / 2)),
                yConstraint: Constraint.RelativeToView(_loginButton, (p, v) => v.Y + _loginButton.Height + 15)
                );

            _relativeLayout.Children.Add(activityIndicator,
                                         xConstraint: Constraint.RelativeToParent(parent => parent.Width / 2 - getActivityIndicatorWidth(parent) / 2),
                                         yConstraint: Constraint.RelativeToParent(parent => parent.Height / 2 - getActivityIndicatorHeight(parent) / 2));

            Content = new Xamarin.Forms.ScrollView {
                Content = _relativeLayout
            };
        }
示例#9
0
        public DetailsPage(string groupIdApiUrl)
        {
            var isRetrievingDataActivityIndicator = new ActivityIndicator();

            isRetrievingDataActivityIndicator.SetBinding(IsEnabledProperty, nameof(ViewModel.IsRetrievingData));
            isRetrievingDataActivityIndicator.SetBinding(IsVisibleProperty, nameof(ViewModel.IsRetrievingData));

            var getChartButton = new Button
            {
                Text             = "Get Chart",
                CommandParameter = groupIdApiUrl
            };

            getChartButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsRetrievingData));
            getChartButton.SetBinding(IsVisibleProperty, nameof(ViewModel.IsGetChartButtonVisible));
            getChartButton.SetBinding(Button.CommandProperty, nameof(ViewModel.GetChartButtonCommand));

            var iframeSource = new HtmlWebViewSource();

            iframeSource.SetBinding(HtmlWebViewSource.HtmlProperty, nameof(ViewModel.IFrameHtml));

            var embededDashboardWebView = new WebView
            {
                Source = iframeSource
            };

            var relativeLayout = new RelativeLayout();

            Func <RelativeLayout, double> getDetailsButtonWidth  = (p) => getChartButton.Measure(p.Width, p.Height).Request.Width;
            Func <RelativeLayout, double> getDetailsButtonHeight = (p) => getChartButton.Measure(p.Width, p.Height).Request.Height;

            Func <RelativeLayout, double> getIsRetrievingDataActivityIndicatorWidth  = (p) => isRetrievingDataActivityIndicator.Measure(p.Width, p.Height).Request.Width;
            Func <RelativeLayout, double> getIsRetrievingDataActivityIndicatorHeight = (p) => isRetrievingDataActivityIndicator.Measure(p.Width, p.Height).Request.Height;

            relativeLayout.Children.Add(embededDashboardWebView,
                                        Constraint.Constant(0),
                                        Constraint.Constant(0),
                                        Constraint.RelativeToParent(parent => parent.Width),
                                        Constraint.RelativeToParent(parent => parent.Height)
                                        );

            relativeLayout.Children.Add(getChartButton,
                                        Constraint.RelativeToParent(parent => parent.Width / 2 - getDetailsButtonWidth(parent) / 2),
                                        Constraint.Constant(0)
                                        );

            relativeLayout.Children.Add(isRetrievingDataActivityIndicator,
                                        Constraint.RelativeToParent(parent => parent.Width / 2 - getIsRetrievingDataActivityIndicatorWidth(parent) / 2),
                                        Constraint.RelativeToParent(parent => parent.Height / 2 - getIsRetrievingDataActivityIndicatorHeight(parent) / 2)
                                        );

            Content = relativeLayout;
        }
示例#10
0
        public LoginPage()
        {
            BackgroundColor = Color.FromHex("#3498db");
            Padding         = GetPagePadding();

            _logo = new Image {
                Source = "xamarin_logo"
            };

            _logoSlogan = new StyledLabel
            {
                Opacity = 0,
                Text    = "Delighting Developers."
            };
            _usernameEntry = new StyledEntry {
                Placeholder = "Username"
            };
            _usernameEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.UsernameEntryText));
            CustomReturnEffect.SetReturnType(_usernameEntry, ReturnType.Next);
            CustomReturnEffect.SetReturnCommand(_usernameEntry, new Command(() => _passwordEntry.Focus()));

            _passwordEntry = new StyledEntry
            {
                Placeholder = "Password",
                IsPassword  = true,
            };
            _passwordEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.PasswordEntryText));
            _passwordEntry.SetBinding(CustomReturnEffect.ReturnCommandProperty, nameof(ViewModel.LoginButtonTappedCommand));
            CustomReturnEffect.SetReturnType(_passwordEntry, ReturnType.Done);

            _loginButton = new StyledButton(Borders.Thin)
            {
                Text = "Login"
            };
            _loginButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsInternetConnectionInactive));
            _loginButton.SetBinding(Button.CommandProperty, nameof(ViewModel.LoginButtonTappedCommand));

            _newUserSignUpButton = new StyledButton(Borders.None)
            {
                Text = "Sign-up"
            };
            _newUserSignUpButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsInternetConnectionInactive));

            var activityIndicator = new ActivityIndicator {
                Color = Color.White
            };

            activityIndicator.SetBinding(IsVisibleProperty, nameof(ViewModel.IsInternetConnectionActive));
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ViewModel.IsInternetConnectionActive));

            Func <RelativeLayout, double> getNewUserButtonWidth      = (p) => _newUserSignUpButton.Measure(p.Width, p.Height).Request.Width;
            Func <RelativeLayout, double> getLogoSloganWidth         = (p) => _logoSlogan.Measure(p.Width, p.Height).Request.Width;
            Func <RelativeLayout, double> getActivityIndicatorHeight = (p) => activityIndicator.Measure(p.Width, p.Height).Request.Height;
            Func <RelativeLayout, double> getActivityIndicatorWidth  = (p) => activityIndicator.Measure(p.Width, p.Height).Request.Width;

            _relativeLayout = new RelativeLayout();
            _relativeLayout.Children.Add(
                _logo,
                xConstraint: Constraint.Constant(100),
                yConstraint: Constraint.Constant(250),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - 200)
                );

            _relativeLayout.Children.Add(
                _logoSlogan,
                xConstraint: Constraint.RelativeToParent(p => (p.Width / 2) - (getLogoSloganWidth(p) / 2)),
                yConstraint: Constraint.Constant(125)
                );

            _relativeLayout.Children.Add(
                _usernameEntry,
                xConstraint: Constraint.Constant(40),
                yConstraint: Constraint.RelativeToView(_logoSlogan, (p, v) => v.Y + v.Height + _relativeLayoutPadding),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - 80)
                );
            _relativeLayout.Children.Add(
                _passwordEntry,
                xConstraint: Constraint.Constant(40),
                yConstraint: Constraint.RelativeToView(_usernameEntry, (p, v) => v.Y + v.Height + _relativeLayoutPadding),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - 80)
                );

            _relativeLayout.Children.Add(
                _loginButton,
                xConstraint: Constraint.Constant(40),
                yConstraint: Constraint.RelativeToView(_passwordEntry, (p, v) => v.Y + v.Height + _relativeLayoutPadding),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - 80)
                );
            _relativeLayout.Children.Add(
                _newUserSignUpButton,
                xConstraint: Constraint.RelativeToParent(p => (p.Width / 2) - (getNewUserButtonWidth(p) / 2)),
                yConstraint: Constraint.RelativeToView(_loginButton, (p, v) => v.Y + _loginButton.Height + 15)
                );

            _relativeLayout.Children.Add(activityIndicator,
                                         xConstraint: Constraint.RelativeToParent(parent => parent.Width / 2 - getActivityIndicatorWidth(parent) / 2),
                                         yConstraint: Constraint.RelativeToParent(parent => parent.Height / 2 - getActivityIndicatorHeight(parent) / 2));

            Content = new ScrollView {
                Content = _relativeLayout
            };
        }
示例#11
0
        public ListPage()
        {
            _viewModel     = new ListViewModel();
            BindingContext = _viewModel;

            var loadingAzureDataActivityIndicator = new ActivityIndicator
            {
                AutomationId = AutomationIdConstants.LoadingDataFromBackendActivityIndicator,
                Color        = Color.White
            };

            loadingAzureDataActivityIndicator.SetBinding <ListViewModel>(IsVisibleProperty, vm => vm.IsDataLoading);
            loadingAzureDataActivityIndicator.SetBinding <ListViewModel>(ActivityIndicator.IsRunningProperty, vm => vm.IsDataLoading);

            _listView = new ListView(ListViewCachingStrategy.RetainElement)
            {
                //ToDo Change to ListViewCachingStrategy.RecycleElement once this bug has been fixed https://bugzilla.xamarin.com/show_bug.cgi?id=42678
                ItemTemplate           = new DataTemplate(typeof(WhiteTextImageCell)),
                BackgroundColor        = Color.FromHex("#2980b9"),
                IsPullToRefreshEnabled = true
            };
            _listView.SetBinding <ListViewModel>(ListView.ItemsSourceProperty, vm => vm.DataList);
            _listView.SetBinding <ListViewModel>(ListView.RefreshCommandProperty, vm => vm.PullToRefreshCommand);

            Title = "List Page";

            var relativeLayout = new RelativeLayout();

            Func <RelativeLayout, double> getloadingAzureDataActivityIndicatorWidth  = (p) => loadingAzureDataActivityIndicator.Measure(relativeLayout.Width, relativeLayout.Height).Request.Width;
            Func <RelativeLayout, double> getloadingAzureDataActivityIndicatorHeight = (p) => loadingAzureDataActivityIndicator.Measure(relativeLayout.Width, relativeLayout.Height).Request.Height;

            relativeLayout.Children.Add(_listView,
                                        Constraint.Constant(0),
                                        Constraint.Constant(0),
                                        Constraint.RelativeToParent(parent => parent.Width),
                                        Constraint.RelativeToParent(parent => parent.Height)
                                        );
            relativeLayout.Children.Add(loadingAzureDataActivityIndicator,
                                        Constraint.RelativeToParent((parent) => parent.Width / 2 - getloadingAzureDataActivityIndicatorWidth(parent) / 2),
                                        Constraint.RelativeToParent((parent) => parent.Height / 2 - getloadingAzureDataActivityIndicatorHeight(parent) / 2)
                                        );
            Content = relativeLayout;
        }
示例#12
0
        public PushNotificationPage()
        {
            var currentUser = Settings.CurrentUser;

            var mainRelativeLayout = new RelativeLayout
            {
                WidthRequest  = App.ScreenWidth,
                HeightRequest = App.ScreenHeight
            };

            var Name = new Label
            {
                HorizontalOptions = LayoutOptions.Center
            };

            Name.SetBinding(Label.TextProperty, nameof(ViewModel.Name), BindingMode.Default, null,
                            "Name: {0}");

            var Email = new Label
            {
                HorizontalOptions = LayoutOptions.Center
            };

            Email.SetBinding(Label.TextProperty, nameof(ViewModel.Email), BindingMode.Default, null,
                             "Email: {0}");

            var registerForPushNotificationsButton = new Button
            {
                Command = ViewModel.RegisterForPushNotificationCommand
            };

            registerForPushNotificationsButton.SetBinding(Button.TextProperty, nameof(ViewModel.RegisterForPushNotificationButtonLabel));

            var requestPushNotificationButton = new Button
            {
                Text    = "Request Push Notification",
                Command = ViewModel.RequestPushNotificationCommand
            };

            requestPushNotificationButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsRegisteredForPushNotifications));


            var logOutButton = new Button
            {
                Text    = "Logout",
                Command = ViewModel.LogoutCommand,
                Margin  = 100
            };

            var activity = new ActivityIndicator
            {
                HeightRequest = 80,
                WidthRequest  = 80,
                Color         = Color.Blue,
            };

            activity.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ViewModel.IsBusy));
            activity.SetBinding(IsEnabledProperty, nameof(ViewModel.IsBusy));
            Func <RelativeLayout, double> activityWidth = (parent) => activity.Measure(mainRelativeLayout.Width, mainRelativeLayout.Height).Request.Width;


            var pushLayout = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Children        =
                {
                    Name,
                    Email,
                    registerForPushNotificationsButton,
                    requestPushNotificationButton,
                    logOutButton
                },
                Padding = 30
            };


            mainRelativeLayout.Children.Add(pushLayout,
                                            Constraint.RelativeToParent((parent) =>
            {
                return(parent.X);
            }),
                                            Constraint.RelativeToParent((parent) =>
            {
                return(parent.Y);
            }),
                                            Constraint.Constant(App.ScreenWidth),
                                            Constraint.Constant(App.ScreenHeight * .8)
                                            );

            /* LAY THE ACTIVITY INDICATOR OVER THE REST OF THE LOGIN SCREEN*/
            mainRelativeLayout.Children.Add(activity,
                                            Constraint.RelativeToParent((parent) =>
            {
                return(parent.Bounds.Width / 2 - activityWidth(parent) / 2);
            }),
                                            Constraint.RelativeToParent((parent) =>
            {
                return(pushLayout.Bounds.Center.Y);
            }));

            Content = mainRelativeLayout;
        }