Example #1
0
        public void ActivateChosen(object sender)
        {
            StyledButton s = (StyledButton)sender;

            s.BackgroundColor = Color.Red;
            if (s.Equals(Hours))
            {
                HourStack.IsVisible = true;
                Mode = 0;
            }
            else if (s.Equals(Live))
            {
                LiveStack.IsVisible = true;
                Mode = 1;
            }
            else if (s.Equals(Approve))
            {
                ApproveStack.IsVisible = true;
                Mode = 2;
            }
            else if (s.Equals(Tardy))
            {
                TardStack.IsVisible = true;
                Mode = 3;
            }
        }
        public SuccessPage()
        {
            BackgroundColor = Color.FromHex("#2980b9");

            Padding = GetPagePadding();
            Title   = "Success";

            var successLabel = new Label
            {
                TextColor = Color.White,
                Text      = "Login Successful"
            };

            var logoutButton = new StyledButton(Borders.Thin, 1)
            {
                Text = "Logout"
            };

            logoutButton.Clicked += HandleLogoutButtonClicked;

            Content = new StackLayout
            {
                Spacing           = 35,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
                Children          =
                {
                    successLabel,
                    logoutButton
                }
            };
        }
Example #3
0
        public void onClickStateless(object sender, RoutedEventArgs e)
        {
            StyledButton x = (StyledButton)sender;

            x.Background   = new SolidColorBrush(Colors.SlateGray);
            statelessPunch = true;
            getCurrentPunchState(true);
        }
Example #4
0
        public void onclick(object sender, RoutedEventArgs e)
        {
            StyledButton x = (StyledButton)sender;

            x.Background        = new SolidColorBrush(Colors.SlateGray);
            createPunchOnResult = true;
            getCurrentPunchState(true);
        }
        void ConstructUI()
        {
            _layout = new StackLayout
            {
                Padding         = new Thickness(20, 50, 20, 20),
                VerticalOptions = LayoutOptions.FillAndExpand,
            };

            _usernameEntry = new StyledEntry(1)
            {
                Style                   = StyleConstants.UnderlinedEntry,
                AutomationId            = AutomationIdConstants.NewUserSignUpPage_NewUserNameEntry,
                Placeholder             = "Username",
                HorizontalOptions       = LayoutOptions.Fill,
                HorizontalTextAlignment = TextAlignment.End,
                PlaceholderColor        = Color.FromHex("749FA8"),
                ReturnType              = ReturnType.Next,
                ReturnCommand           = new Command(() => _passwordEntry.Focus())
            };

            _passwordEntry = new StyledEntry(1)
            {
                Style                   = StyleConstants.UnderlinedEntry,
                AutomationId            = AutomationIdConstants.NewUserSignUpPage_NewPasswordEntry,
                Placeholder             = "Password",
                IsPassword              = true,
                HorizontalOptions       = LayoutOptions.Fill,
                HorizontalTextAlignment = TextAlignment.End,
                VerticalOptions         = LayoutOptions.Fill,
                PlaceholderColor        = Color.FromHex("749FA8"),
                ReturnType              = ReturnType.Go,
                ReturnCommand           = new Command(() => HandleSaveUsernameButtonClicked(_saveUsernameButton, EventArgs.Empty))
            };

            _saveUsernameButton = new StyledButton(Borders.Thin, 1)
            {
                Style             = StyleConstants.BorderedButton,
                AutomationId      = AutomationIdConstants.NewUserSignUpPage_SaveUsernameButton,
                Text              = "Save Username",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.EndAndExpand
            };
            _saveUsernameButton.Clicked += HandleSaveUsernameButtonClicked;

            _cancelButton = new StyledButton(Borders.Thin, 1)
            {
                Style             = StyleConstants.BorderedButton,
                AutomationId      = AutomationIdConstants.NewUserSignUpPage_CancelButton,
                Text              = "Cancel",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.End
            };

            _cancelButton.Clicked += (object sender, EventArgs e) =>
            {
                Navigation.PopModalAsync();
            };
        }
Example #6
0
        public NewUserSignUpPage()
        {
            On <iOS>().SetUseSafeArea(true);

            BackgroundColor = Color.FromHex("#2980b9");

            _usernameEntry = new UnderlinedEntry("Username", AutomationIdConstants.NewUserSignUpPage_NewUserNameEntry)
            {
                ReturnType = ReturnType.Next
            };

            _passwordEntry = new UnderlinedEntry("Password", AutomationIdConstants.NewUserSignUpPage_NewPasswordEntry)
            {
                IsPassword    = true,
                ReturnType    = ReturnType.Go,
                ReturnCommand = new Command(() => HandleSaveUsernameButtonClicked(_saveUsernameButton, EventArgs.Empty))
            };

            _saveUsernameButton = new BorderedButton("Save Username", AutomationIdConstants.NewUserSignUpPage_SaveUsernameButton)
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.EndAndExpand
            };
            _saveUsernameButton.Clicked += HandleSaveUsernameButtonClicked;

            _cancelButton = new BorderedButton("Cancel", AutomationIdConstants.NewUserSignUpPage_CancelButton)
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.End
            };

            _cancelButton.Clicked += (object sender, EventArgs e) =>
            {
                Navigation.PopModalAsync();
            };

            var layout = new StackLayout
            {
                Padding         = new Thickness(20, 50, 20, 20),
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        =
                {
                    new WhiteTextLabel("Please enter username"),
                    _usernameEntry,
                    new WhiteTextLabel("Please enter password"),
                    _passwordEntry,
                    _saveUsernameButton,
                    _cancelButton
                }
            };

            Content = new Xamarin.Forms.ScrollView {
                Content = layout
            };
        }
        public StyledButton geradorDeBotao(string textoBotao)
        {
            StyledButton botao = new StyledButton
            {
                Text           = textoBotao,
                Font           = Font.SystemFontOfSize(NamedSize.Small),
                WidthRequest   = 30,
                HeightRequest  = 45,
                Style          = (Style)Application.Current.Resources["buttonStyle1"],
                FontAttributes = FontAttributes.Bold
            };

            return(botao);
        }
        public void onClickedCreate(object sender, RoutedEventArgs e)
        {
            string sql = "INSERT INTO cusindex (Stage,Name) VALUES ('" + (NewPicker.SelectedIndex + 1) + "','x')";

            DatabaseFunctions.SendToPhp(sql);
            System.Threading.Thread.Sleep(500);
            string       sql2 = "SELECT IDKey,Stage FROM cusindex ORDER BY IDKey Desc LIMIT 1";
            TaskCallback call = OpenPage;

            DatabaseFunctions.SendToPhp(false, sql2, call);
            StyledButton x = (StyledButton)sender;

            x.Background = new SolidColorBrush(Colors.SlateGray);
        }
Example #9
0
        void CreateGlobalChildren()
        {
            logo       = new Image();
            logoSlogan = new StyledLabel
            {
                Opacity = 0,
                Text    = "Delighting Developers."
            };
            loginEntry = new StyledEntry
            {
                AutomationId = AutomationIdConstants.UsernameEntry,
                Placeholder  = "Username",
            };
            CustomReturnEffect.SetReturnType(loginEntry, ReturnType.Next);
            CustomReturnEffect.SetReturnCommand(loginEntry, new Command(() => passwordEntry.Focus()));

            passwordEntry = new StyledEntry
            {
                AutomationId = AutomationIdConstants.PasswordEntry,
                Placeholder  = "Password",
                IsPassword   = true,
            };
            CustomReturnEffect.SetReturnType(passwordEntry, ReturnType.Go);
            CustomReturnEffect.SetReturnCommand(passwordEntry, new Command(() => HandleLoginButtonClicked(passwordEntry, EventArgs.Empty)));

            loginButton = new StyledButton(Borders.Thin)
            {
                AutomationId = AutomationIdConstants.LoginButton,
                Text         = "Login",
            };
            newUserSignUpButton = new StyledButton(Borders.None)
            {
                AutomationId = AutomationIdConstants.NewUserButton,
                Text         = "Sign-up",
            };
            forgotPasswordButton = new StyledButton(Borders.None)
            {
                AutomationId = AutomationIdConstants.ForgotPasswordButton,
                Text         = "Forgot Password?",
            };

            loginButton.Clicked += HandleLoginButtonClicked;

            newUserSignUpButton.Clicked  += (object sender, EventArgs e) => NewUserSignUp();
            forgotPasswordButton.Clicked += (object sender, EventArgs e) => ForgotPassword();
        }
        public void criarBotoesdaPagina()
        {
            /*if(Pagina.Pagina != 0)
             * {
             *  Button botaoVoltar = geradorDeBotao("<");
             *
             *  botaoVoltar.Clicked += abreTopicoAnterior;
             *
             *  layoutPageButtons.Children.Add(botaoVoltar);
             * }*/

            for (int i = 1; i < Topico.Count + 1; i++)
            {
                if (i != (Pagina.Pagina + 1))
                {
                    StyledButton button = geradorDeBotao(i + "");

                    button.Clicked += TrocarPagina;

                    layoutPageButtons.Children.Add(button);
                }
                else
                {
                    Label label = new Label
                    {
                        Text            = i + "",
                        FontSize        = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                        VerticalOptions = LayoutOptions.Center,
                        TextColor       = Color.FromHex("#000000"),
                        FontAttributes  = FontAttributes.Bold
                    };

                    layoutPageButtons.Children.Add(label);
                }
            }

            /*if(Pagina.Pagina != (Topico.Count - 1))
             * {
             *  Button botaoProximo = geradorDeBotao(">");
             *
             *  botaoProximo.Clicked += abreProximoTopico;
             *
             *  layoutPageButtons.Children.Add(botaoProximo);
             * }*/
        }
Example #11
0
        void CreateGlobalChildren()
        {
            _logoSlogan = new StyledLabel
            {
                Opacity = 0,
                Text    = "Delighting Developers."
            };
            _loginEntry = new StyledEntry
            {
                AutomationId = AutomationIdConstants.LoginPage_UsernameEntry,
                Placeholder  = "Username",
            };
            CustomReturnEffect.SetReturnType(_loginEntry, ReturnType.Next);
            CustomReturnEffect.SetReturnCommand(_loginEntry, new Command(() => _passwordEntry.Focus()));

            _passwordEntry = new StyledEntry
            {
                AutomationId = AutomationIdConstants.LoginPage_PasswordEntry,
                Placeholder  = "Password",
                IsPassword   = true,
            };
            CustomReturnEffect.SetReturnType(_passwordEntry, ReturnType.Go);
            CustomReturnEffect.SetReturnCommand(_passwordEntry, new Command(() => HandleLoginButtonClicked(_passwordEntry, EventArgs.Empty)));

            _loginButton = new StyledButton(Borders.Thin)
            {
                AutomationId = AutomationIdConstants.LoginPage_LoginButton,
                Text         = "Login",
            };
            _newUserSignUpButton = new StyledButton(Borders.None)
            {
                AutomationId = AutomationIdConstants.LoginPage_NewUserSignUpButton,
                Text         = "Sign-up",
            };
            _forgotPasswordButton = new StyledButton(Borders.None)
            {
                AutomationId = AutomationIdConstants.LoginPage_ForgotPasswordButton,
                Text         = "Forgot Password?",
            };
        }
Example #12
0
        public AddTapPage()
        {
            this.Title = "Add a Prayer Request";

            mySharedText.Text      = "Hey guys, this is what's going on...";
            mySharedText.TextColor = Color.Gray;

            mySharedText.Focused   += myQuestion_Focused;
            mySharedText.Unfocused += myQuestion_Unfocused;

            //BUTTON
            Button submitButton = new StyledButton(StyledButton.Borders.Thin, 1);

            submitButton.Text = "Submit";
            submitButton.HorizontalOptions = LayoutOptions.FillAndExpand;

            submitButton.Clicked += (sender, e) => {
                Device.BeginInvokeOnMainThread(() => {
                    System.Random random = new Random();
                    int randomId         = random.Next(1, 1000000000);
                    string randomNumber  = string.Join(string.Empty, Enumerable.Range(0, 10).Select(number => random.Next(0, 5).ToString()));

                    PrayerRequest newPrayerRequest = new PrayerRequest()
                    {
                        Id = randomId,
                        CreatedDateTimeString = DateTime.Now.ToString("MMM d h:mm tt", new CultureInfo("en-US")),
                        CreatedDateTime       = DateTimeOffset.UtcNow,
                        StringOnlyDateTime    = "March 1, 2018",
                        FirstName             = "Andrew",
                        LastName        = "Kim",
                        FullName        = "Andrew Kim",
                        FullNameAndDate = "Andrew Kim\r\nMarch 1, 2018",
                        //FBProfileUrl = "http://loremflickr.com/600/600/nature?filename=simple.jpg",
                        FBProfileUrl             = "http://graph.facebook.com/450/picture?type=normal",
                        PrayerRequestText        = mySharedText.Text,
                        NumberOfThoughts         = 0,
                        NumberOfPrayers          = 0,
                        StringTheNumberOfPrayers = "first test string"
                    };

                    ParentViewModel.MyObservableCollectionOfUnderlyingData.Add(newPrayerRequest);
                    ParentViewModel.ResetDataSource();

                    Navigation.PopModalAsync();
                });
            };

            Button cancelButton = new StyledButton(StyledButton.Borders.Thin, 1);

            cancelButton.Text = "Cancel";
            cancelButton.HorizontalOptions = LayoutOptions.FillAndExpand;

            cancelButton.Clicked += (sender, e) => {
                Device.BeginInvokeOnMainThread(() => {
                    Navigation.PopModalAsync();
                });
            };

            StackLayout myEnterTextStacklayout = new StackLayout
            {
                BackgroundColor   = Color.Transparent,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.FillAndExpand,

                Children =
                {
                    mST, mySharedText
                }
            };


            StackLayout myButtonStacklayout = new StackLayout
            {
                Padding           = new Thickness(10, 10, 10, 10),
                Orientation       = StackOrientation.Horizontal,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.FillAndExpand,

                Children =
                {
                    cancelButton, submitButton
                }
            };

            StackLayout combinedLayout = new StackLayout
            {
                BackgroundColor   = Color.White,
                Padding           = new Thickness(10, 50, 10, 10),
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    myEnterTextStacklayout, myButtonStacklayout
                }
            };


            #region GRID DEFINITION
            var grid = new Grid()
            {
                //Padding = new Thickness(10, 10, 10, 10),
                Padding = new Thickness(10, 10, 10, 10),
                //BackgroundColor = MyColors.DarkGray
                BackgroundColor = MyColors.LighterGray
            };

            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(.5, GridUnitType.Star)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });

            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });

            grid.Children.Add(combinedLayout, 0, 1);
            //Grid.SetRowSpan(cachedImage, 2);
            //Grid.SetColumnSpan(cachedImage, 2);

            Content = grid;
            #endregion



            //Content = new StackLayout
            //{
            //    Padding = new Thickness(10, 50, 10, 10),
            //    VerticalOptions = LayoutOptions.Start,
            //    HorizontalOptions = LayoutOptions.FillAndExpand,
            //    Children = {
            //        myEnterTextStacklayout, myButtonStacklayout

            //    }
            //};
        }
        public DeviceLandingPage(ParticleDevice device)
        {
            Title           = "Mission Control";
            BackgroundColor = AppColors.BackgroundColor;
            ViewModel       = new DeviceLandingPageViewModel(device);
            BindingContext  = ViewModel;

            var refreshDevice = new ToolbarItem {
                Icon = "ic_cached_white_24dp.png"
            };
            var back = new ToolbarItem {
                Icon = "ic_clear_white.png"
            };
            var layout = new RelativeLayout();

            var indicator  = new ActivityIndicator();
            var deviceName = new StyledLabel {
                CssStyle = "h1"
            };
            var deviceConnected = new Image {
                Source = "notconnected.png"
            };
            var currentAppLabel = new StyledLabel {
                CssStyle = "h2"
            };
            var variableWidget = new DashboardWidget();
            var functionWidget = new DashboardWidget();
            var appDescription = new StyledLabel {
                CssStyle = "body"
            };
            var interactButton = new StyledButton
            {
                StyleId         = "startInteractionButton",
                Text            = "START INTERACTION",
                BackgroundColor = AppColors.Green,
                CssStyle        = "button",
                BorderRadius    = 0,
                HeightRequest   = AppSettings.ButtonHeight,
                IsEnabled       = false
            };
            var flashButton = new StyledButton
            {
                StyleId         = "flashBinaryButton",
                Text            = "FLASH NEW APP",
                BackgroundColor = AppColors.Purple,
                CssStyle        = "button",
                BorderRadius    = 0,
                HeightRequest   = AppSettings.ButtonHeight,
                IsEnabled       = false
            };

            var boxConstraint = Constraint.RelativeToParent(p => p.Width / 2 - AppSettings.Margin - AppSettings.ItemPadding / 2);

            layout.Children.Add(deviceName,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.Constant(Device.OnPlatform(AppSettings.Margin, 10, 10)),
                                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2)
                                );
            layout.Children.Add(currentAppLabel,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.RelativeToView(deviceName, (p, v) => v.Y + v.Height + 5),
                                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                                heightConstraint: Constraint.RelativeToView(deviceName, (p, v) => v.Height)
                                );
            layout.Children.Add(variableWidget,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.RelativeToView(currentAppLabel, (p, v) => Device.OnPlatform(
                                                                           v.Y + v.Height + 5,
                                                                           v.Y + v.Height,
                                                                           v.Y + v.Height)
                                                                       ),
                                widthConstraint: boxConstraint,
                                heightConstraint: boxConstraint
                                );
            layout.Children.Add(functionWidget,
                                xConstraint: Constraint.RelativeToParent(p => p.Width / 2 + AppSettings.ItemPadding / 2),
                                yConstraint: Constraint.RelativeToView(variableWidget, (p, v) => v.Y),
                                widthConstraint: boxConstraint,
                                heightConstraint: boxConstraint
                                );
            layout.Children.Add(new ScrollView {
                Content = appDescription
            },
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.RelativeToView(functionWidget, (p, v) => v.Y + v.Height + 10),
                                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                                heightConstraint: Constraint.RelativeToView(functionWidget, (p, v) => p.Height - v.Y - v.Height - 10 - AppSettings.Margin - 2 * AppSettings.ButtonHeight - 20)
                                );
            layout.Children.Add(flashButton,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.RelativeToParent(p => p.Height - AppSettings.Margin - AppSettings.ButtonHeight),
                                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                                heightConstraint: Constraint.Constant(AppSettings.ButtonHeight)
                                );
            layout.Children.Add(interactButton,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.RelativeToView(flashButton, (p, v) => v.Y - AppSettings.ButtonHeight - 10),
                                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                                heightConstraint: Constraint.Constant(AppSettings.ButtonHeight)
                                );
            layout.Children.Add(indicator,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.RelativeToView(functionWidget, (p, v) => v.Y + v.Height + 10),
                                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                                heightConstraint: Constraint.RelativeToView(functionWidget, (p, v) => p.Height - v.Y - v.Height - 10 - AppSettings.Margin - 2 * AppSettings.ButtonHeight - 20)
                                );

            variableWidget.WidgetTitle.Text = "Variables";
            functionWidget.WidgetTitle.Text = "Functions";

            if (Device.OS == TargetPlatform.iOS)
            {
                interactButton.TextColor = Color.FromHex("#ffffff");
                flashButton.TextColor    = Color.FromHex("#ffffff");
            }

            Content = layout;
            ToolbarItems.Add(refreshDevice);
            ToolbarItems.Add(back);

            indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");
            if (Device.OS != TargetPlatform.iOS && Device.OS != TargetPlatform.Android)
            {
                indicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");
            }

            deviceName.SetBinding(Label.TextProperty, "Device.Name");
            currentAppLabel.SetBinding(Label.TextProperty, "CurrentApp");
            deviceConnected.SetBinding(Image.IsVisibleProperty, "DeviceConnected");
            variableWidget.WidgetCount.SetBinding(Label.TextProperty, "VariableCount");
            functionWidget.WidgetCount.SetBinding(Label.TextProperty, "FunctionCount");
            interactButton.SetBinding(Button.IsEnabledProperty, "InteractButtonLock");
            flashButton.SetBinding(Button.IsEnabledProperty, "FlashButtonLock");
            refreshDevice.SetBinding(ToolbarItem.CommandProperty, "RefreshDeviceCommand");
            appDescription.SetBinding(Label.TextProperty, "AppDescription");

            interactButton.Clicked += async(object sender, EventArgs e) =>
            {
                if (ViewModel.CurrentApp.ToLower().Contains("rgb led picker"))
                {
                    await Navigation.PushAsync(new ChangeLEDColorPage(ViewModel.Device, ViewModel.variables));
                }
                else if (ViewModel.CurrentApp.ToLower().Contains("simonsays"))
                {
                    await Navigation.PushAsync(new SimonSaysPage(ViewModel.Device));
                }
                else
                {
                    DisplayAlert("Sorry...", "There isn't a mobile interaction with this IoT app. Try flashing either the 'Simon Says' or ' RBG LED' app.", "Ok");
                }
            };

            flashButton.Clicked += async(object sender, EventArgs e) =>
            {
                var result = await DisplayActionSheet("Pick File to Flash", "Cancel", null, "RGB LED", "Shake LED", "Simon Says", "Follow me LED");

                if (result != "Cancel")
                {
                    var success = await ViewModel.TryFlashFileAsync(result);

                    if (!success)
                    {
                        await DisplayAlert("Error", "The Device connection timed out. Please try again once the device breaths a solid cyan light", "Ok");
                    }
                }
            };

            back.Clicked += async(object sender, EventArgs e) =>
            {
                var success = await ViewModel.Device.UnclaimAsync();

                //if (success)
                Navigation.PopModalAsync(true);
            };
        }
        void CreateGlobalChildren()
        {
            logo       = new Image();
            logoSlogan = new StyledLabel
            {
                Opacity = 0,
                Text    = "Delighting Developers."
            };
            loginEntry = new StyledEntry
            {
                AutomationId = AutomationIdConstants.UsernameEntry,
                Placeholder  = "Username",
                ReturnType   = ReturnType.Next
            };
            loginEntry.Completed += (sender, e) => passwordEntry.Focus();

            passwordEntry = new StyledEntry
            {
                AutomationId = AutomationIdConstants.PasswordEntry,
                Placeholder  = "Password",
                IsPassword   = true,
            };
            passwordEntry.Completed += HandleLoginButtonClicked;

            loginButton = new StyledButton(Borders.Thin)
            {
                AutomationId = AutomationIdConstants.LoginButton,
                Text         = "Login",
            };
            newUserSignUpButton = new StyledButton(Borders.None)
            {
                AutomationId = AutomationIdConstants.NewUserButton,
                Text         = "Sign-up",
            };
            forgotPasswordButton = new StyledButton(Borders.None)
            {
                AutomationId = AutomationIdConstants.ForgotPasswordButton,
                Text         = "Forgot Password?",
            };
            rememberMe = new Label
            {
                Opacity    = 0,
                Text       = "Remember Me",
                TextColor  = Color.White,
                FontFamily = Device.OnPlatform(
                    iOS: "AppleSDGothicNeo-Light",
                    Android: "Droid Sans Mono",
                    WinPhone: "Comic Sans MS"),
            };
            saveUsername = new Switch
            {
                AutomationId = AutomationIdConstants.SaveUsernameSwitch,
                IsToggled    = true,
                Opacity      = 0
            };

            loginButton.Clicked += HandleLoginButtonClicked;

            newUserSignUpButton.Clicked += (object sender, EventArgs e) =>
            {
                NewUserSignUp();
            };
            forgotPasswordButton.Clicked += (object sender, EventArgs e) =>
            {
                ForgotPassword();
            };
        }
        void CreateGlobalChildren()
        {
            logo       = new Image();
            logoSlogan = new StyledLabel
            {
                Opacity = 0,
                Text    = "Delighting Developers."
            };
            loginEntry = new StyledEntry
            {
                AutomationId = AutomationIdConstants.UsernameEntry,
                Placeholder  = "Username",
            };
            passwordEntry = new StyledEntry
            {
                AutomationId = AutomationIdConstants.PasswordEntry,
                Placeholder  = "Password",
                IsPassword   = true,
            };
            loginButton = new StyledButton(Borders.Thin)
            {
                AutomationId = AutomationIdConstants.LoginButton,
                Text         = "Login",
            };
            newUserSignUpButton = new StyledButton(Borders.None)
            {
                AutomationId = AutomationIdConstants.NewUserButton,
                Text         = "Sign-up",
            };
            forgotPasswordButton = new StyledButton(Borders.None)
            {
                AutomationId = AutomationIdConstants.ForgotPasswordButton,
                Text         = "Forgot Password?",
            };
            rememberMe = new Label
            {
                Opacity    = 0,
                Text       = "Remember Me",
                TextColor  = Color.White,
                FontFamily = Device.OnPlatform(
                    iOS: "AppleSDGothicNeo-Light",
                    Android: "Droid Sans Mono",
                    WinPhone: "Comic Sans MS"),
            };
            saveUsername = new Switch
            {
                AutomationId = AutomationIdConstants.SaveUsernameSwitch,
                IsToggled    = true,
                Opacity      = 0
            };

            loginButton.Clicked += (object sender, EventArgs e) =>
            {
                if (string.IsNullOrEmpty(loginEntry.Text) || string.IsNullOrEmpty(passwordEntry.Text))
                {
                    DisplayAlert("Error", "You must enter a username and password.", "Okay");
                    return;
                }

                Login(loginEntry.Text, passwordEntry.Text, saveUsername.IsToggled);
            };
            newUserSignUpButton.Clicked += (object sender, EventArgs e) =>
            {
                NewUserSignUp();
            };
            forgotPasswordButton.Clicked += (object sender, EventArgs e) =>
            {
                ForgotPassword();
            };
        }
Example #16
0
        void CreateGlobalChildren()
        {
            logo = new Image {
                HeightRequest = 30, Aspect = Aspect.AspectFit
            };
            loginLabel = new StyledLabel
            {
                CssStyle = "h1",
                Text     = "Login with your particle username",
                Opacity  = 0
            };
            loginEntry = new LoginEntry
            {
                StyleId     = "usernameEntry",
                Placeholder = "Email",
                Keyboard    = Keyboard.Email
            };
            passwordEntry = new LoginEntry
            {
                StyleId     = "passwordEntry",
                Placeholder = "Password",
                IsPassword  = true,
            };
            loginButton = new StyledButton
            {
                StyleId         = "loginButton",
                Text            = "LOGIN",
                TextColor       = Color.White,
                BackgroundColor = AppColors.Green,
                CssStyle        = "button",
                BorderRadius    = 0,
                HeightRequest   = AppSettings.ButtonHeight,
                Opacity         = 0
            };
            newUserSignUpButton = new StyledButton
            {
                StyleId         = "newUserButton",
                Text            = "SIGN-UP",
                TextColor       = Color.White,
                BackgroundColor = AppColors.Purple,
                CssStyle        = "button",
                BorderRadius    = 0,
                HeightRequest   = AppSettings.ButtonHeight,
                Opacity         = 0
            };

            loginButton.Clicked += (object sender, EventArgs e) =>
            {
                if (String.IsNullOrEmpty(loginEntry.Text) || String.IsNullOrEmpty(passwordEntry.Text))
                {
                    DisplayAlert("Error", "You must enter a username and password.", "Okay");
                    return;
                }

                Login(loginEntry.Text, passwordEntry.Text);
            };
            newUserSignUpButton.Clicked += (object sender, EventArgs e) =>
            {
                NewUserSignUp();
            };
        }
        public void ConstructUI()
        {
            layout = new StackLayout
            {
                Padding         = new Thickness(20, 50, 20, 20),
                VerticalOptions = LayoutOptions.FillAndExpand,
            };

            usernameEntry = new StyledEntry(1)
            {
                Style                   = StyleConstants.UnderlinedEntry,
                AutomationId            = AutomationIdConstants.NewUserNameEntry,
                Placeholder             = "Username",
                HorizontalOptions       = LayoutOptions.Fill,
                HorizontalTextAlignment = TextAlignment.End,
                PlaceholderColor        = Color.FromHex("749FA8")
            };

            passwordEntry = new StyledEntry(1)
            {
                Style                   = StyleConstants.UnderlinedEntry,
                AutomationId            = AutomationIdConstants.NewPasswordEntry,
                Placeholder             = "Password",
                IsPassword              = true,
                HorizontalOptions       = LayoutOptions.Fill,
                HorizontalTextAlignment = TextAlignment.End,
                VerticalOptions         = LayoutOptions.Fill,
                PlaceholderColor        = Color.FromHex("749FA8")
            };

            saveUsernameButton = new StyledButton(Borders.Thin, 1)
            {
                Style             = StyleConstants.BorderedButton,
                AutomationId      = AutomationIdConstants.SaveUsernameButton,
                Text              = "Save Username",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.EndAndExpand
            };
            cancelButton = new StyledButton(Borders.Thin, 1)
            {
                Style             = StyleConstants.BorderedButton,
                AutomationId      = AutomationIdConstants.CancelButton,
                Text              = "Cancel",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.End
            };

            saveUsernameButton.Clicked += async(object sender, EventArgs e) =>
            {
                var success = await DependencyService.Get <ILogin>().SetPasswordForUsername(usernameEntry.Text, passwordEntry.Text);

                if (success)
                {
                    await Navigation.PopModalAsync();
                }
                else
                {
                    await DisplayAlert("Error", "You must enter a username and a password", "Okay");
                }
            };

            cancelButton.Clicked += (object sender, EventArgs e) =>
            {
                Navigation.PopModalAsync();
            };
        }
Example #18
0
		public DeviceLandingPage(ParticleDevice device)
		{
			Title = "Mission Control";
			BackgroundColor = AppColors.BackgroundColor;
			ViewModel = new DeviceLandingPageViewModel(device);
			BindingContext = ViewModel;

			var refreshDevice = new ToolbarItem { Icon = "ic_cached_white_24dp.png" };
			var back = new ToolbarItem { Icon = "ic_clear_white.png" };
			var layout = new RelativeLayout();

			var indicator = new ActivityIndicator();
			var deviceName = new StyledLabel { CssStyle = "h1" };
			var deviceConnected = new Image { Source = "notconnected.png" };
			var currentAppLabel = new StyledLabel { CssStyle = "h2" };
			var variableWidget = new DashboardWidget();
			var functionWidget = new DashboardWidget();
			var appDescription = new StyledLabel { CssStyle = "body" };
			var interactButton = new StyledButton
			{
				StyleId = "startInteractionButton",
				Text = "START INTERACTION",
				BackgroundColor = AppColors.Green,
				CssStyle = "button",
				BorderRadius = 0,
				HeightRequest = AppSettings.ButtonHeight,
				IsEnabled = false
			};
			var flashButton = new StyledButton
			{
				StyleId = "flashBinaryButton",
				Text = "FLASH NEW APP",
				BackgroundColor = AppColors.Purple,
				CssStyle = "button",
				BorderRadius = 0,
				HeightRequest = AppSettings.ButtonHeight,
				IsEnabled = false
			};

			var boxConstraint = Constraint.RelativeToParent(p => p.Width / 2 - AppSettings.Margin - AppSettings.ItemPadding / 2);

			layout.Children.Add(deviceName,
				xConstraint: Constraint.Constant(AppSettings.Margin),
				yConstraint: Constraint.Constant(Device.OnPlatform(AppSettings.Margin, 10, 10)),
				widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2)
			);
			layout.Children.Add(currentAppLabel,
				xConstraint: Constraint.Constant(AppSettings.Margin),
				yConstraint: Constraint.RelativeToView(deviceName, (p, v) => v.Y + v.Height + 5),
				widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
				heightConstraint: Constraint.RelativeToView(deviceName, (p, v) => v.Height)
			);
			layout.Children.Add(variableWidget,
				xConstraint: Constraint.Constant(AppSettings.Margin),
				yConstraint: Constraint.RelativeToView(currentAppLabel, (p, v) => Device.OnPlatform(
																v.Y + v.Height + 5,
																v.Y + v.Height,
																v.Y + v.Height)
													  ),
				widthConstraint: boxConstraint,
				heightConstraint: boxConstraint
			);
			layout.Children.Add(functionWidget,
				xConstraint: Constraint.RelativeToParent(p => p.Width / 2 + AppSettings.ItemPadding / 2),
				yConstraint: Constraint.RelativeToView(variableWidget, (p, v) => v.Y),
				widthConstraint: boxConstraint,
				heightConstraint: boxConstraint
			);
			layout.Children.Add(new ScrollView { Content = appDescription },
				xConstraint: Constraint.Constant(AppSettings.Margin),
				yConstraint: Constraint.RelativeToView(functionWidget, (p, v) => v.Y + v.Height + 10),
				widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
				heightConstraint: Constraint.RelativeToView(functionWidget, (p, v) => p.Height - v.Y - v.Height - 10 - AppSettings.Margin - 2 * AppSettings.ButtonHeight - 20)
			);
			layout.Children.Add(flashButton,
				xConstraint: Constraint.Constant(AppSettings.Margin),
				yConstraint: Constraint.RelativeToParent(p => p.Height - AppSettings.Margin - AppSettings.ButtonHeight),
				widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
				heightConstraint: Constraint.Constant(AppSettings.ButtonHeight)
			);
			layout.Children.Add(interactButton,
				xConstraint: Constraint.Constant(AppSettings.Margin),
				yConstraint: Constraint.RelativeToView(flashButton, (p, v) => v.Y - AppSettings.ButtonHeight - 10),
				widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
				heightConstraint: Constraint.Constant(AppSettings.ButtonHeight)
			);
			layout.Children.Add(indicator,
				xConstraint: Constraint.Constant(AppSettings.Margin),
				yConstraint: Constraint.RelativeToView(functionWidget, (p, v) => v.Y + v.Height + 10),
				widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
				heightConstraint: Constraint.RelativeToView(functionWidget, (p, v) => p.Height - v.Y - v.Height - 10 - AppSettings.Margin - 2 * AppSettings.ButtonHeight - 20)
			);

			variableWidget.WidgetTitle.Text = "Variables";
			functionWidget.WidgetTitle.Text = "Functions";

			if (Device.OS == TargetPlatform.iOS)
			{
				interactButton.TextColor = Color.FromHex("#ffffff");
				flashButton.TextColor = Color.FromHex("#ffffff");
			}

			Content = layout;
			ToolbarItems.Add(refreshDevice);
			ToolbarItems.Add(back);

			indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");
			if (Device.OS != TargetPlatform.iOS && Device.OS != TargetPlatform.Android)
				indicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");

			deviceName.SetBinding(Label.TextProperty, "Device.Name");
			currentAppLabel.SetBinding(Label.TextProperty, "CurrentApp");
			deviceConnected.SetBinding(Image.IsVisibleProperty, "DeviceConnected");
			variableWidget.WidgetCount.SetBinding(Label.TextProperty, "VariableCount");
			functionWidget.WidgetCount.SetBinding(Label.TextProperty, "FunctionCount");
			interactButton.SetBinding(Button.IsEnabledProperty, "InteractButtonLock");
			flashButton.SetBinding(Button.IsEnabledProperty, "FlashButtonLock");
			refreshDevice.SetBinding(ToolbarItem.CommandProperty, "RefreshDeviceCommand");
			appDescription.SetBinding(Label.TextProperty, "AppDescription");

			interactButton.Clicked += async (object sender, EventArgs e) =>
			{
				if (ViewModel.CurrentApp.ToLower().Contains("rgb led picker"))
					await Navigation.PushAsync(new ChangeLEDColorPage(ViewModel.Device, ViewModel.variables));
				else if (ViewModel.CurrentApp.ToLower().Contains("simonsays"))
					await Navigation.PushAsync(new SimonSaysPage(ViewModel.Device));
				else
					DisplayAlert("Sorry...", "There isn't a mobile interaction with this IoT app. Try flashing either the 'Simon Says' or ' RBG LED' app.", "Ok");
			};

			flashButton.Clicked += async (object sender, EventArgs e) =>
			{
				var result = await DisplayActionSheet("Pick File to Flash", "Cancel", null, "RGB LED", "Shake LED", "Simon Says", "Follow me LED");
				if (result != "Cancel")
				{
					var success = await ViewModel.TryFlashFileAsync(result);
					if (!success)
					{
						await DisplayAlert("Error", "The Device connection timed out. Please try again once the device breaths a solid cyan light", "Ok");
					}
				}
			};

			back.Clicked += async (object sender, EventArgs e) =>
			{
				var success = await ViewModel.Device.UnclaimAsync();
				//if (success)
				Navigation.PopModalAsync(true);
			};
		}
Example #19
0
        public LoginPage()
        {
            try
            {
                ViewModel.LoginFailed   += HandleLoginFailed;
                ViewModel.LoginApproved += HandleLoginApproved;

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

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

                _logoSlogan = new StyledLabel
                {
                    Opacity = 0,
                    Text    = "ABSENSI",
                };
                _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));

                _HomeAutomationButton = new StyledButton(Borders.None)
                {
                    Text = "Home Automation"
                };
                _HomeAutomationButton.Clicked += HandleHomeAutomationClicked;
                _HomeAutomationButton.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(
                    _HomeAutomationButton,
                    xConstraint: Constraint.Constant(40),
                    yConstraint: Constraint.RelativeToView(_newUserSignUpButton, (p, v) => v.Y + v.Height + _relativeLayoutPadding),
                    widthConstraint: Constraint.RelativeToParent(p => p.Width - 80)
                    );

                _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
                };
            }
            catch (Exception ec)
            {
                DisplayAlert("Error", ec.ToString(), "Ok");
            }
        }
Example #20
0
		public SimonSaysPage(ParticleDevice device)
		{
			ViewModel = new SimonSaysViewModel(device);
			BindingContext = ViewModel;
			BackgroundColor = AppColors.BackgroundColor;
			Title = $"{device.Name} Says";

			red = new Button { StyleId = "red", BackgroundColor = SimonSaysColors.Red, BorderRadius = 0 };
			blue = new Button { StyleId = "blue", BackgroundColor = SimonSaysColors.Blue, BorderRadius = 0 };
			green = new Button { StyleId = "green", BackgroundColor = SimonSaysColors.Green, BorderRadius = 0 };
			yellow = new Button { StyleId = "yellow", BackgroundColor = SimonSaysColors.Yellow, BorderRadius = 0 };

			l1 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l2 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l3 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l4 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l5 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l6 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l7 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l8 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l9 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l10 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };

			var stackPadding = 2d;
			StackLayout lightStack = new StackLayout
			{
				Orientation = StackOrientation.Horizontal,
				Children = { l1, l2, l3, l4, l5, l6, l7, l8, l9, l10 },
				Padding = new Thickness(stackPadding, 0, stackPadding, 0),
				BackgroundColor = Color.Transparent
			};

			var clearSubmission = new Button
			{
				StyleId = "clearMoveButton",
				Text = "X",
				FontSize = Device.OnPlatform(10, 8, 10),
				TextColor = Color.Black,
				FontAttributes = FontAttributes.Bold,
				BorderRadius = 10,
				BackgroundColor = Color.White,
				BorderColor = Color.Black,
				BorderWidth = 1
			};
			StyledButton actionButton = new StyledButton { StyleId = "actionButton", BorderRadius = 0, TextColor = Color.White, CssStyle = "button", BorderColor = AppColors.Blue };

			var layout = new RelativeLayout();

			var buttonConstraint = Constraint.RelativeToParent((p) => (p.Width / 2) - AppSettings.Margin - AppSettings.ItemPadding / 2);

			layout.Children.Add(red,
				xConstraint: Constraint.Constant(AppSettings.Margin),
				yConstraint: Constraint.Constant(AppSettings.Margin),
				widthConstraint: buttonConstraint,
				heightConstraint: buttonConstraint
			);

			layout.Children.Add(yellow,
				xConstraint: Constraint.RelativeToParent((p) => (p.Width / 2) + AppSettings.ItemPadding / 2),
				yConstraint: Constraint.Constant(AppSettings.Margin),
				widthConstraint: buttonConstraint,
				heightConstraint: buttonConstraint
			);

			layout.Children.Add(blue,
				xConstraint: Constraint.Constant(AppSettings.Margin),
				yConstraint: Constraint.RelativeToView(red, (p, v) => v.Height + v.Y + AppSettings.ItemPadding),
				widthConstraint: buttonConstraint,
				heightConstraint: buttonConstraint
			);

			layout.Children.Add(green,
				xConstraint: Constraint.RelativeToParent((p) => (p.Width / 2) + AppSettings.ItemPadding / 2),
				yConstraint: Constraint.RelativeToView(yellow, (p, v) => v.Height + v.Y + AppSettings.ItemPadding),
				widthConstraint: buttonConstraint,
				heightConstraint: buttonConstraint
			);

			layout.Children.Add(lightStack,
				xConstraint: Constraint.Constant(AppSettings.Margin - stackPadding),
				yConstraint: Constraint.RelativeToView(blue, (p, v) => v.Height + v.Y + AppSettings.ItemPadding * 2),
				widthConstraint: Constraint.RelativeToParent((p) => p.Width - AppSettings.Margin * 2 + stackPadding * 2),
				heightConstraint: Constraint.Constant(25) // TODO calculate the square size based on the width of the view
			);
			layout.Children.Add(clearSubmission,
				xConstraint: Constraint.RelativeToParent((p) => p.Width - AppSettings.Margin - Device.OnPlatform(10, 15, 15)),
				yConstraint: Constraint.RelativeToView(lightStack, (p, v) => Device.OnPlatform(
																				v.Y - 10,
																				v.Y - 15,
																				v.Y - 15
																			)
				),
				widthConstraint: Constraint.Constant(Device.OnPlatform(25, 30, 30)),
				heightConstraint: Constraint.Constant(Device.OnPlatform(25, 30, 30))
			);

			layout.Children.Add(actionButton,
				xConstraint: Constraint.Constant(AppSettings.Margin),
				yConstraint: Constraint.RelativeToParent(p => p.Height - AppSettings.Margin - AppSettings.ButtonHeight),
				widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
				heightConstraint: Constraint.Constant(50)
			);

			Content = layout;

			red.Clicked += async (object sender, EventArgs e) =>
			{
				await ViewModel.PlayerPressButtonAsync("r");
			};
			blue.Clicked += async (object sender, EventArgs e) =>
			{
				await ViewModel.PlayerPressButtonAsync("b");
			};
			green.Clicked += async (object sender, EventArgs e) =>
			{
				await ViewModel.PlayerPressButtonAsync("g");
			};
			yellow.Clicked += async (object sender, EventArgs e) =>
			{
				await ViewModel.PlayerPressButtonAsync("y");
			};
			clearSubmission.Clicked += (object sender, EventArgs e) =>
			{
				ViewModel.ClearPlayerEntry();
			};

			red.SetBinding(Button.OpacityProperty, "RedOpacity");
			green.SetBinding(Button.OpacityProperty, "GreenOpacity");
			blue.SetBinding(Button.OpacityProperty, "BlueOpacity");
			yellow.SetBinding(Button.OpacityProperty, "YellowOpacity");

			l1.SetBinding(ContentView.BackgroundColorProperty, "L1");
			l2.SetBinding(ContentView.BackgroundColorProperty, "L2");
			l3.SetBinding(ContentView.BackgroundColorProperty, "L3");
			l4.SetBinding(ContentView.BackgroundColorProperty, "L4");
			l5.SetBinding(ContentView.BackgroundColorProperty, "L5");
			l6.SetBinding(ContentView.BackgroundColorProperty, "L6");
			l7.SetBinding(ContentView.BackgroundColorProperty, "L7");
			l8.SetBinding(ContentView.BackgroundColorProperty, "L8");
			l9.SetBinding(ContentView.BackgroundColorProperty, "L9");
			l10.SetBinding(ContentView.BackgroundColorProperty, "L10");

			clearSubmission.SetBinding(Button.IsVisibleProperty, "ShowClearButton");
			actionButton.SetBinding(Button.BackgroundColorProperty, "ActionColor");
			actionButton.SetBinding(Button.TextProperty, "ActionText");
			actionButton.SetBinding(Button.CommandProperty, "ActionCommand");
		}
Example #21
0
        public NewUserSignUpPage()
        {
            ViewModel      = new BaseViewModel();
            BindingContext = ViewModel;

            RelativeLayout    relativeLayout = new RelativeLayout();
            ActivityIndicator indicator      = new ActivityIndicator();

            var usernameEntry = new LoginEntry(1)
            {
                StyleId                 = "newUsernameEntry",
                Placeholder             = "Email",
                Keyboard                = Keyboard.Email,
                HorizontalTextAlignment = TextAlignment.Center,
            };
            var passwordEntry = new LoginEntry(1)
            {
                StyleId                 = "newPasswordEntry",
                Placeholder             = "Password",
                IsPassword              = true,
                HorizontalTextAlignment = TextAlignment.Center
            };
            var reEnterPasswordEntry = new LoginEntry(1)
            {
                StyleId                 = "reEnterPasswordEntry",
                Placeholder             = "Re-enter password",
                IsPassword              = true,
                HorizontalTextAlignment = TextAlignment.Center,
            };
            var saveUsernameButton = new StyledButton
            {
                CssStyle          = "button",
                StyleId           = "saveUsernameButton",
                Text              = "Save Username",
                TextColor         = Color.White,
                BackgroundColor   = AppColors.Green,
                BorderRadius      = 0,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.EndAndExpand
            };
            var usernameLabel = new StyledLabel
            {
                CssStyle          = "h2",
                Text              = "Please enter username",
                HorizontalOptions = LayoutOptions.Start
            };
            var passwordLabel = new StyledLabel
            {
                CssStyle          = "h2",
                Text              = "Please enter password",
                HorizontalOptions = LayoutOptions.Start
            };
            var reEnterPasswordLabel = new StyledLabel
            {
                CssStyle          = "h2",
                Text              = "Please re-enter password",
                HorizontalOptions = LayoutOptions.Start
            };

            relativeLayout.Children.Add(usernameLabel,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.Constant(AppSettings.Margin),
                                        widthConstraint: Constraint.RelativeToParent(p => p.Width - 2 * AppSettings.Margin)
                                        );
            relativeLayout.Children.Add(usernameEntry,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToView(usernameLabel, (p, v) => v.Y + v.Height + AppSettings.ItemPadding),
                                        widthConstraint: Constraint.RelativeToParent(p => p.Width - 2 * AppSettings.Margin)
                                        );
            relativeLayout.Children.Add(passwordLabel,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToView(usernameEntry, (p, v) => v.Y + v.Height + AppSettings.ItemPadding),
                                        widthConstraint: Constraint.RelativeToParent(p => p.Width - 2 * AppSettings.Margin)
                                        );
            relativeLayout.Children.Add(passwordEntry,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToView(passwordLabel, (p, v) => v.Y + v.Height + AppSettings.ItemPadding),
                                        widthConstraint: Constraint.RelativeToParent(p => p.Width - 2 * AppSettings.Margin)
                                        );
            relativeLayout.Children.Add(reEnterPasswordLabel,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToView(passwordEntry, (p, v) => v.Y + v.Height + AppSettings.ItemPadding),
                                        widthConstraint: Constraint.RelativeToParent(p => p.Width - 2 * AppSettings.Margin)
                                        );
            relativeLayout.Children.Add(reEnterPasswordEntry,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToView(reEnterPasswordLabel, (p, v) => v.Y + v.Height + AppSettings.ItemPadding),
                                        widthConstraint: Constraint.RelativeToParent(p => p.Width - 2 * AppSettings.Margin)
                                        );
            relativeLayout.Children.Add(saveUsernameButton,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToParent(p => p.Height - AppSettings.Margin - AppSettings.ButtonHeight),
                                        widthConstraint: Constraint.RelativeToParent(p => p.Width - 2 * AppSettings.Margin)
                                        );
            relativeLayout.Children.Add(indicator,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToView(reEnterPasswordEntry, (p, v) => v.Y + v.Height),
                                        widthConstraint: Constraint.RelativeToParent(p => p.Width - 2 * AppSettings.Margin),
                                        heightConstraint: Constraint.RelativeToView(reEnterPasswordEntry, (p, v) => p.Height - v.Y - v.Height - AppSettings.Margin - AppSettings.ButtonHeight)
                                        );

            Content = relativeLayout;

            indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");

            if (Device.OS == TargetPlatform.Windows)
            {
                indicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");
            }

            saveUsernameButton.Clicked += async(object sender, EventArgs e) =>
            {
                ViewModel.IsBusy = true;

                if (String.IsNullOrEmpty(usernameEntry.Text))
                {
                    DisplayAlert("Error", "Username cannot be blank", "Ok");
                    ViewModel.IsBusy = false;
                    return;
                }
                else if (!usernameEntry.Text.Contains("@"))
                {
                    DisplayAlert("Error", "Username is invalid. Please enter a valid email address.", "Ok");
                    ViewModel.IsBusy = false;
                    return;
                }
                else if (String.IsNullOrEmpty(passwordEntry.Text))
                {
                    DisplayAlert("Error", "Password cannot be blank", "Ok");
                    ViewModel.IsBusy = false;
                    return;
                }
                else if (String.IsNullOrEmpty(reEnterPasswordEntry.Text))
                {
                    DisplayAlert("Error", "Please re-enter your password", "Ok");
                    ViewModel.IsBusy = false;
                    return;
                }
                else if (passwordEntry.Text != reEnterPasswordEntry.Text)
                {
                    DisplayAlert("Error", "Passwords don't match.", "Ok");
                    ViewModel.IsBusy = false;
                    return;
                }

                var result = await ParticleCloud.SharedInstance.SignupWithUserAsync(usernameEntry.Text, passwordEntry.Text);

                ViewModel.IsBusy = false;

                if (result == "Success")
                {
                    await DisplayAlert("Success", "Your account was successfully created. Now let's login.", "Ok");

                    await Navigation.PopAsync();
                }
                else
                {
                    DisplayAlert("Error", $"{result}", "Ok");
                }
            };
        }
Example #22
0
        public SimonSaysPage(ParticleDevice device)
        {
            ViewModel       = new SimonSaysViewModel(device);
            BindingContext  = ViewModel;
            BackgroundColor = AppColors.BackgroundColor;
            Title           = $"{device.Name} Says";

            red = new Button {
                StyleId = "red", BackgroundColor = SimonSaysColors.Red, BorderRadius = 0
            };
            blue = new Button {
                StyleId = "blue", BackgroundColor = SimonSaysColors.Blue, BorderRadius = 0
            };
            green = new Button {
                StyleId = "green", BackgroundColor = SimonSaysColors.Green, BorderRadius = 0
            };
            yellow = new Button {
                StyleId = "yellow", BackgroundColor = SimonSaysColors.Yellow, BorderRadius = 0
            };

            l1 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l2 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l3 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l4 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l5 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l6 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l7 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l8 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l9 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            l10 = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            var         stackPadding = 2d;
            StackLayout lightStack   = new StackLayout
            {
                Orientation     = StackOrientation.Horizontal,
                Children        = { l1, l2, l3, l4, l5, l6, l7, l8, l9, l10 },
                Padding         = new Thickness(stackPadding, 0, stackPadding, 0),
                BackgroundColor = Color.Transparent
            };

            var clearSubmission = new Button
            {
                StyleId         = "clearMoveButton",
                Text            = "X",
                FontSize        = Device.OnPlatform(10, 8, 10),
                TextColor       = Color.Black,
                FontAttributes  = FontAttributes.Bold,
                BorderRadius    = 10,
                BackgroundColor = Color.White,
                BorderColor     = Color.Black,
                BorderWidth     = 1
            };
            StyledButton actionButton = new StyledButton {
                StyleId = "actionButton", BorderRadius = 0, TextColor = Color.White, CssStyle = "button", BorderColor = AppColors.Blue
            };

            var layout = new RelativeLayout();

            var buttonConstraint = Constraint.RelativeToParent((p) => (p.Width / 2) - AppSettings.Margin - AppSettings.ItemPadding / 2);

            layout.Children.Add(red,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.Constant(AppSettings.Margin),
                                widthConstraint: buttonConstraint,
                                heightConstraint: buttonConstraint
                                );

            layout.Children.Add(yellow,
                                xConstraint: Constraint.RelativeToParent((p) => (p.Width / 2) + AppSettings.ItemPadding / 2),
                                yConstraint: Constraint.Constant(AppSettings.Margin),
                                widthConstraint: buttonConstraint,
                                heightConstraint: buttonConstraint
                                );

            layout.Children.Add(blue,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.RelativeToView(red, (p, v) => v.Height + v.Y + AppSettings.ItemPadding),
                                widthConstraint: buttonConstraint,
                                heightConstraint: buttonConstraint
                                );

            layout.Children.Add(green,
                                xConstraint: Constraint.RelativeToParent((p) => (p.Width / 2) + AppSettings.ItemPadding / 2),
                                yConstraint: Constraint.RelativeToView(yellow, (p, v) => v.Height + v.Y + AppSettings.ItemPadding),
                                widthConstraint: buttonConstraint,
                                heightConstraint: buttonConstraint
                                );

            layout.Children.Add(lightStack,
                                xConstraint: Constraint.Constant(AppSettings.Margin - stackPadding),
                                yConstraint: Constraint.RelativeToView(blue, (p, v) => v.Height + v.Y + AppSettings.ItemPadding * 2),
                                widthConstraint: Constraint.RelativeToParent((p) => p.Width - AppSettings.Margin * 2 + stackPadding * 2),
                                heightConstraint: Constraint.Constant(25) // TODO calculate the square size based on the width of the view
                                );
            layout.Children.Add(clearSubmission,
                                xConstraint: Constraint.RelativeToParent((p) => p.Width - AppSettings.Margin - Device.OnPlatform(10, 15, 15)),
                                yConstraint: Constraint.RelativeToView(lightStack, (p, v) => Device.OnPlatform(
                                                                           v.Y - 10,
                                                                           v.Y - 15,
                                                                           v.Y - 15
                                                                           )
                                                                       ),
                                widthConstraint: Constraint.Constant(Device.OnPlatform(25, 30, 30)),
                                heightConstraint: Constraint.Constant(Device.OnPlatform(25, 30, 30))
                                );

            layout.Children.Add(actionButton,
                                xConstraint: Constraint.Constant(AppSettings.Margin),
                                yConstraint: Constraint.RelativeToParent(p => p.Height - AppSettings.Margin - AppSettings.ButtonHeight),
                                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                                heightConstraint: Constraint.Constant(50)
                                );

            Content = layout;

            red.Clicked += async(object sender, EventArgs e) =>
            {
                await ViewModel.PlayerPressButtonAsync("r");
            };
            blue.Clicked += async(object sender, EventArgs e) =>
            {
                await ViewModel.PlayerPressButtonAsync("b");
            };
            green.Clicked += async(object sender, EventArgs e) =>
            {
                await ViewModel.PlayerPressButtonAsync("g");
            };
            yellow.Clicked += async(object sender, EventArgs e) =>
            {
                await ViewModel.PlayerPressButtonAsync("y");
            };
            clearSubmission.Clicked += (object sender, EventArgs e) =>
            {
                ViewModel.ClearPlayerEntry();
            };

            red.SetBinding(Button.OpacityProperty, "RedOpacity");
            green.SetBinding(Button.OpacityProperty, "GreenOpacity");
            blue.SetBinding(Button.OpacityProperty, "BlueOpacity");
            yellow.SetBinding(Button.OpacityProperty, "YellowOpacity");

            l1.SetBinding(ContentView.BackgroundColorProperty, "L1");
            l2.SetBinding(ContentView.BackgroundColorProperty, "L2");
            l3.SetBinding(ContentView.BackgroundColorProperty, "L3");
            l4.SetBinding(ContentView.BackgroundColorProperty, "L4");
            l5.SetBinding(ContentView.BackgroundColorProperty, "L5");
            l6.SetBinding(ContentView.BackgroundColorProperty, "L6");
            l7.SetBinding(ContentView.BackgroundColorProperty, "L7");
            l8.SetBinding(ContentView.BackgroundColorProperty, "L8");
            l9.SetBinding(ContentView.BackgroundColorProperty, "L9");
            l10.SetBinding(ContentView.BackgroundColorProperty, "L10");

            clearSubmission.SetBinding(Button.IsVisibleProperty, "ShowClearButton");
            actionButton.SetBinding(Button.BackgroundColorProperty, "ActionColor");
            actionButton.SetBinding(Button.TextProperty, "ActionText");
            actionButton.SetBinding(Button.CommandProperty, "ActionCommand");
        }
Example #23
0
        public void InitializeComponent()
        {
            scroll = new ScrollViewer();
            scroll.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
            holder      = new StackPanel();
            controlGrid = new Grid();
            bodyGrid    = new Grid();
            controlGrid = new Grid()
            {
                Background = new SolidColorBrush(Color.FromRgb(0, 0, 0))
            };
            bodyGrid = new Grid()
            {
                Background = new SolidColorBrush(Color.FromRgb(0, 0, 0))
            };                                //Create the grids
            holder.Children.Add(controlGrid); //Add the grids to the holder
            holder.Children.Add(bodyGrid);
            scroll.Content = holder;
            Content        = scroll;
            controlGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(10, GridUnitType.Star)
            });
            controlGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(10, GridUnitType.Star)
            });
            controlGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(10, GridUnitType.Star)
            });
            Add = new StyledButton()
            {
                Content = "Add Field"
            };
            Add.Click += onClickAddFields;
            Save       = new StyledButton()
            {
                Content = "Save Changes"
            };
            Save.Click += onClickSave;
            Advance     = new StyledButton()
            {
                Content = "Advance"
            };
            Advance.Click += onClickAdvance;
            NameLabel      = new Label()
            {
                Content = "Job Name:"
            };
            NameBox    = new TextBox();
            StageLabel = new Label();
            List <UIElement> uIs = new List <UIElement>()
            {
                NameLabel, NameBox, StageLabel
            };

            GridFiller.rapidFillPremadeObjects(uIs, controlGrid, new bool[] { true, true, true });
            uIs = new List <UIElement>()
            {
                Add, Advance, Save
            };
            GridFiller.rapidFillPremadeObjects(uIs, controlGrid, new bool[] { false, false, false });
            Label l1 = new Label()
            {
                Content = "Index"
            };
            Label l2 = new Label()
            {
                Content = "Value"
            };

            uIs = new List <UIElement>()
            {
                l1, l2
            };
            GridFiller.rapidFillSpacedPremadeObjects(uIs, controlGrid, new int[] { 1, 2 }, new bool[] { true, true });
            bodyGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(10, GridUnitType.Star)
            });
            bodyGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(20, GridUnitType.Star)
            });
        }
Example #24
0
        public ChangeLEDColorPage(ParticleDevice device, Dictionary <string, string> variables)
        {
            Title           = "RBG LED";
            BackgroundColor = AppColors.BackgroundColor;
            ViewModel       = new ChangeLEDColorViewModel(device, variables);
            BindingContext  = ViewModel;

            var indicator = new ActivityIndicator {
                HeightRequest = Device.OnPlatform(50, 30, 50)
            };
            var colorPreview = new BoxView {
                HeightRequest = 100
            };
            var redSlider = new Slider {
                StyleId = "redSlider", Minimum = 0, Maximum = 255, Value = 0
            };
            var greenSlider = new Slider {
                StyleId = "greenSlider", Minimum = 0, Maximum = 255, Value = 0
            };
            var blueSlider = new Slider {
                StyleId = "blueSlider", Minimum = 0, Maximum = 255, Value = 0
            };
            var push = new StyledButton
            {
                StyleId         = "pushRGBvalueButton",
                Text            = "PUSH TO PHOTON",
                BackgroundColor = AppColors.Blue,
                CssStyle        = "button",
                BorderRadius    = 0,
                HeightRequest   = AppSettings.ButtonHeight,
                VerticalOptions = LayoutOptions.Fill
            };
            var lightShow = new StyledButton
            {
                StyleId         = "startLightShowButton",
                Text            = "START A LIGHT SHOW",
                BackgroundColor = AppColors.Green,
                CssStyle        = "button",
                BorderRadius    = 0,
                HeightRequest   = AppSettings.ButtonHeight,
                VerticalOptions = LayoutOptions.End
            };
            var previewLabel = new StyledLabel {
                CssStyle = "body", Text = "Color Preview:", HorizontalOptions = LayoutOptions.Start
            };
            var rLabel = new StyledLabel {
                CssStyle = "body", Text = "R Value", HorizontalOptions = LayoutOptions.Start
            };
            var gLabel = new StyledLabel {
                CssStyle = "body", Text = "G Value", HorizontalOptions = LayoutOptions.Start
            };
            var bLabel = new StyledLabel {
                CssStyle = "body", Text = "B Value", HorizontalOptions = LayoutOptions.Start
            };

            Func <RelativeLayout, View, double> layoutAfterPrevious = (p, v) => Device.OnPlatform(
                v.Y + v.Height + 5,
                v.Y + v.Height + 5,
                v.Y + v.Height + 2);

            RelativeLayout relativeLayout = new RelativeLayout();

            relativeLayout.Children.Add(previewLabel,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.Constant(10)
                                        );
            relativeLayout.Children.Add(colorPreview,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToView(previewLabel, layoutAfterPrevious),
                                        widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                                        heightConstraint: Constraint.Constant(AppSettings.ButtonHeight * 2)
                                        );
            relativeLayout.Children.Add(rLabel,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToView(colorPreview, layoutAfterPrevious)
                                        );
            relativeLayout.Children.Add(redSlider,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToView(rLabel, layoutAfterPrevious),
                                        widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2)
                                        );
            relativeLayout.Children.Add(gLabel,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToView(redSlider, layoutAfterPrevious)
                                        );
            relativeLayout.Children.Add(greenSlider,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToView(gLabel, layoutAfterPrevious),
                                        widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2)
                                        );
            relativeLayout.Children.Add(bLabel,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToView(greenSlider, layoutAfterPrevious)
                                        );
            relativeLayout.Children.Add(blueSlider,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToView(bLabel, layoutAfterPrevious),
                                        widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2)
                                        );
            relativeLayout.Children.Add(indicator,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToView(blueSlider, layoutAfterPrevious),
                                        widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                                        heightConstraint: Constraint.Constant(Device.OnPlatform(50, 50, 25))
                                        );
            relativeLayout.Children.Add(lightShow,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToParent(p => p.Height - AppSettings.Margin - AppSettings.ButtonHeight),
                                        widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                                        heightConstraint: Constraint.Constant(AppSettings.ButtonHeight)
                                        );
            relativeLayout.Children.Add(push,
                                        xConstraint: Constraint.Constant(AppSettings.Margin),
                                        yConstraint: Constraint.RelativeToView(lightShow, (p, v) => v.Y - AppSettings.ButtonHeight - 10),
                                        widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                                        heightConstraint: Constraint.Constant(AppSettings.ButtonHeight)
                                        );



            //         StackLayout layout = new StackLayout
            //{
            //	VerticalOptions = LayoutOptions.CenterAndExpand,
            //	Padding = new Thickness(AppSettings.Margin, 10, AppSettings.Margin, AppSettings.Margin),
            //	Spacing = 10,
            //	Children = {
            //		new StyledLabel { CssStyle = "body", Text = "Color Preview:", HorizontalOptions = LayoutOptions.Start },
            //		colorPreview,
            //		new StyledLabel { CssStyle = "body", Text = "R Value", HorizontalOptions = LayoutOptions.Start },
            //		redSlider,
            //		new StyledLabel { CssStyle = "body", Text = "G Value", HorizontalOptions = LayoutOptions.Start },
            //		greenSlider,
            //		new StyledLabel { CssStyle = "body", Text = "B Value", HorizontalOptions = LayoutOptions.Start },
            //		blueSlider,
            //		indicator,
            //		push,
            //		lightShow
            //	}
            //};

            if (Device.OS == TargetPlatform.iOS)
            {
                push.FontFamily = "SegoeUI-Light";
                push.FontSize   = 16;
                push.TextColor  = Color.FromHex("#ffffff");

                lightShow.FontFamily = "SegoeUI-Light";
                lightShow.FontSize   = 16;
                lightShow.TextColor  = Color.FromHex("#ffffff");
            }

            var off = new ToolbarItem {
                Text = "LEDs Off"
            };

            Content = relativeLayout;


            indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");
            if (Device.OS != TargetPlatform.iOS && Device.OS != TargetPlatform.Android)
            {
                indicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");
            }

            redSlider.SetBinding(Slider.ValueProperty, "R", BindingMode.TwoWay);
            greenSlider.SetBinding(Slider.ValueProperty, "G", BindingMode.TwoWay);
            blueSlider.SetBinding(Slider.ValueProperty, "B", BindingMode.TwoWay);
            colorPreview.SetBinding(BoxView.BackgroundColorProperty, "ColorBoxColor");
            push.SetBinding(Button.CommandProperty, "PushColorCommand");
            lightShow.SetBinding(Button.CommandProperty, "LightShowCommand");
            off.SetBinding(ToolbarItem.CommandProperty, "LedsOffCommand");

            ToolbarItems.Add(off);
        }
Example #25
0
        public FirstPage()
        {
            const string entryTextPaceHolder = "Enter text and click 'Go'";

            var viewModel = new FirstPageViewModel();

            BindingContext = viewModel;

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

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

            textEntry.Completed += (sender, e) => viewModel?.GoButtonTapped?.Execute(null);
            textEntry.SetBinding <FirstPageViewModel>(Entry.TextProperty, vm => vm.EntryText);

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

            textLabel.SetBinding <FirstPageViewModel>(Label.TextProperty, vm => vm.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 <FirstPageViewModel>(ActivityIndicator.IsVisibleProperty, vm => vm.IsActiityIndicatorRunning);
            activityIndicator.SetBinding <FirstPageViewModel>(ActivityIndicator.IsRunningProperty, vm => vm.IsActiityIndicatorRunning);

            var stackLayout = new StackLayout
            {
                Children =
                {
                    textEntry,
                    _goButton,
                    activityIndicator,
                    textLabel,
                },
                VerticalOptions   = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };

            var relativeLayout = new RelativeLayout();

            relativeLayout.Children.Add(stackLayout,
                                        Constraint.RelativeToParent((parent) =>
            {
                return(parent.X);
            }),
                                        Constraint.RelativeToParent((parent) =>
            {
                return(parent.Y);
            }),
                                        Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width - 20);
            }),
                                        Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height / 2);
            })
                                        );

            relativeLayout.Children.Add(_listPageButton,
                                        Constraint.RelativeToParent((parent) =>
            {
                return(parent.X);
            }),
                                        Constraint.Constant(250),
                                        Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width - 20);
            })
                                        );

            Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
            Title   = "First Page";
            Content = relativeLayout;
        }
Example #26
0
        protected ReusableLoginPage(string logoFileImageSource)
        {
            On <iOS>().SetUseSafeArea(true);

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

            LogoFileImageSource = logoFileImageSource;

            _logoSlogan = new StyledLabel
            {
                Opacity = 0,
                Text    = "Delighting Developers."
            };
            _loginEntry = new StyledEntry
            {
                AutomationId = AutomationIdConstants.LoginPage_UsernameEntry,
                Placeholder  = "Username",
                ReturnType   = ReturnType.Next
            };

            _passwordEntry = new StyledEntry
            {
                AutomationId  = AutomationIdConstants.LoginPage_PasswordEntry,
                Placeholder   = "Password",
                IsPassword    = true,
                ReturnType    = ReturnType.Go,
                ReturnCommand = new Command(() => HandleLoginButtonClicked(_passwordEntry, EventArgs.Empty))
            };

            _loginButton = new StyledButton(Borders.Thin)
            {
                AutomationId = AutomationIdConstants.LoginPage_LoginButton,
                Text         = "Login",
            };
            _loginButton.Clicked += HandleLoginButtonClicked;

            _newUserSignUpButton = new StyledButton(Borders.None)
            {
                AutomationId = AutomationIdConstants.LoginPage_NewUserSignUpButton,
                Text         = "Sign-up",
            };
            _newUserSignUpButton.Clicked += HandleNewUserSignUpButtonClicked;

            _forgotPasswordButton = new StyledButton(Borders.None)
            {
                AutomationId = AutomationIdConstants.LoginPage_ForgotPasswordButton,
                Text         = "Forgot Password?",
            };
            _forgotPasswordButton.Clicked += HandleForgotPasswordButtonClicked;

            MainLayout.Children.Add(_logo,
                                    Constraint.Constant(100),
                                    Constraint.Constant(250),
                                    Constraint.RelativeToParent(p => p.Width - 200));

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

            MainLayout.Children.Add(_loginEntry,
                                    Constraint.Constant(40),
                                    Constraint.RelativeToView(_logoSlogan, (p, v) => v.Y + v.Height + _relativeLayoutPadding),
                                    Constraint.RelativeToParent(p => p.Width - 80));
            MainLayout.Children.Add(_passwordEntry,
                                    Constraint.Constant(40),
                                    Constraint.RelativeToView(_loginEntry, (p, v) => v.Y + v.Height + _relativeLayoutPadding),
                                    Constraint.RelativeToParent(p => p.Width - 80));

            MainLayout.Children.Add(_loginButton,
                                    Constraint.Constant(40),
                                    Constraint.RelativeToView(_passwordEntry, (p, v) => v.Y + v.Height + _relativeLayoutPadding),
                                    Constraint.RelativeToParent(p => p.Width - 80));
            MainLayout.Children.Add(_newUserSignUpButton,
                                    Constraint.RelativeToParent(p => (p.Width / 2) - (getNewUserButtonWidth(p) / 2)),
                                    Constraint.RelativeToView(_loginButton, (p, v) => v.Y + _loginButton.Height + 15));
            MainLayout.Children.Add(_forgotPasswordButton,
                                    Constraint.RelativeToParent(p => (p.Width / 2) - (getForgotButtonWidth(p) / 2)),
                                    Constraint.RelativeToView(_newUserSignUpButton, (p, v) => v.Y + _newUserSignUpButton.Height + _relativeLayoutPadding));

            Content = new Xamarin.Forms.ScrollView {
                Content = MainLayout
            };

            double getNewUserButtonWidth(RelativeLayout p) => _newUserSignUpButton.Measure(p.Width, p.Height).Request.Width;
            double getForgotButtonWidth(RelativeLayout p) => _forgotPasswordButton.Measure(p.Width, p.Height).Request.Width;
            double getLogoSloganWidth(RelativeLayout p) => _logoSlogan.Measure(p.Width, p.Height).Request.Width;
        }
Example #27
0
        public static void criarConteudo(StackLayout layout, List <string> listaDeConteudo)
        {
            FontAttributes atributoDaFonte = FontAttributes.None;
            double         tamanhoDaFonte  = Device.GetNamedSize(NamedSize.Medium, typeof(Label));

            foreach (string linha in listaDeConteudo)
            {
                if (linha.Equals("[botao]"))
                {
                    StyledButton button = new StyledButton
                    {
                        Text           = "Áudio Demonstrativo",
                        FontSize       = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                        Style          = (Style)Application.Current.Resources["buttonStyle1"],
                        FontAttributes = FontAttributes.Bold
                    };

                    button.Clicked += TocarAudio;
                    layout.Children.Add(button);
                }
                else if (linha.Contains("[link]"))
                {
                    string linhaLink = linha;
                    linhaLink = linhaLink.Replace("[link]", "");
                    linhaLink = linhaLink.Replace("[/link]", "");

                    var label = new Label()
                    {
                        Text           = linhaLink,
                        FontSize       = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                        FontAttributes = FontAttributes.Bold,
                        TextColor      = Color.FromHex("#2D12DB") //8E97E1
                    };

                    string enderecoSite = label.Text.Trim();

                    if (!(enderecoSite.Substring(0, 4).Equals("http")))
                    {
                        enderecoSite = enderecoSite.Insert(0, "http://");
                    }

                    var tapGestureRecognizer = new TapGestureRecognizer();
                    tapGestureRecognizer.Tapped += (s, e) => {
                        try
                        {
                            Device.OpenUri(new Uri(enderecoSite));
                        }
                        catch (Exception exc)
                        {
                            System.Diagnostics.Debug.WriteLine("ERRO: " + exc.Message);
                        }
                    };
                    label.GestureRecognizers.Add(tapGestureRecognizer);

                    layout.Children.Add(label);
                }
                else
                {
                    var label = new StyledLabel()
                    {
                        Style = (Style)Application.Current.Resources["labelStyle1"]
                    };
                    var s = new FormattedString();
                    if (linha.Contains("[b]") || linha.Contains("[i]") || linha.Contains("[small]") || linha.Contains("[large]"))
                    {
                        string linhaComAtributos = linha;
                        while (linhaComAtributos.Contains("[b]") || linhaComAtributos.Contains("[i]") || linhaComAtributos.Contains("[small]") || linhaComAtributos.Contains("[/b]") || linhaComAtributos.Contains("[/i]") || linhaComAtributos.Contains("[/small]") || linhaComAtributos.Contains("[large]") || linhaComAtributos.Contains("[/large]"))
                        {
                            string trecho = "";

                            int posicaoAtributoMaisProximo = linhaComAtributos.IndexOf('[');

                            if (posicaoAtributoMaisProximo != 0)
                            {
                                trecho            = linhaComAtributos.Substring(0, posicaoAtributoMaisProximo);
                                linhaComAtributos = linhaComAtributos.Substring(posicaoAtributoMaisProximo);
                            }
                            else
                            {
                                if (linhaComAtributos.Substring(0, 3).Equals("[b]"))
                                {
                                    atributoDaFonte   = FontAttributes.Bold;
                                    linhaComAtributos = linhaComAtributos.Substring(3);
                                }
                                else if (linhaComAtributos.Substring(0, 3).Equals("[i]"))
                                {
                                    atributoDaFonte   = FontAttributes.Italic;
                                    linhaComAtributos = linhaComAtributos.Substring(3);
                                }
                                else if (linhaComAtributos.Substring(0, 4).Equals("[/b]"))
                                {
                                    atributoDaFonte   = FontAttributes.None;
                                    linhaComAtributos = linhaComAtributos.Substring(4);
                                }
                                else if (linhaComAtributos.Substring(0, 4).Equals("[/i]"))
                                {
                                    atributoDaFonte   = FontAttributes.None;
                                    linhaComAtributos = linhaComAtributos.Substring(4);
                                }
                                else if (linhaComAtributos.Contains("[small]") || linhaComAtributos.Contains("[/small]"))
                                {
                                    if (linhaComAtributos.Substring(0, 7).Equals("[small]"))
                                    {
                                        tamanhoDaFonte    = Device.GetNamedSize(NamedSize.Small, typeof(Label));
                                        linhaComAtributos = linhaComAtributos.Substring(7);
                                    }
                                    if (linhaComAtributos.Substring(0, 8).Equals("[/small]"))
                                    {
                                        tamanhoDaFonte    = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                                        linhaComAtributos = linhaComAtributos.Substring(8);
                                    }
                                }
                                else if (linhaComAtributos.Contains("[large]") || linhaComAtributos.Contains("[/large]"))
                                {
                                    if (linhaComAtributos.Substring(0, 7).Equals("[large]"))
                                    {
                                        tamanhoDaFonte    = Device.GetNamedSize(NamedSize.Large, typeof(Label));
                                        linhaComAtributos = linhaComAtributos.Substring(7);
                                    }
                                    if (linhaComAtributos.Substring(0, 8).Equals("[/large]"))
                                    {
                                        tamanhoDaFonte    = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                                        linhaComAtributos = linhaComAtributos.Substring(8);
                                    }
                                }
                                else
                                {
                                    trecho            = "[";
                                    linhaComAtributos = linhaComAtributos.Substring(1);
                                }
                            }

                            s.Spans.Add(new Span {
                                Text = trecho + "", FontSize = tamanhoDaFonte, FontAttributes = atributoDaFonte
                            });
                        }
                        s.Spans.Add(new Span {
                            Text = linhaComAtributos, FontSize = tamanhoDaFonte, FontAttributes = atributoDaFonte
                        });
                    }
                    else
                    {
                        s.Spans.Add(new Span {
                            Text = linha, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label))
                        });
                    }
                    label.FormattedText = s;
                    layout.Children.Add(label);
                }
            }
        }
Example #28
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;
        }
Example #29
0
        public NewUserSignUpPage()
        {
            ViewModel.SaveFailed                += HandleSaveFailed;
            ViewModel.TakePhotoFailed           += HandleTakePhotoFailed;
            ViewModel.SaveSuccessfullyCompleted += HandleSaveSuccessfullyCompleted;

            BackgroundColor = Color.FromHex("2980b9");

            var passwordEntry = new StyledEntry(1)
            {
                Placeholder             = "Password",
                IsPassword              = true,
                HorizontalOptions       = LayoutOptions.Fill,
                HorizontalTextAlignment = TextAlignment.End,
                VerticalOptions         = LayoutOptions.Fill,
                PlaceholderColor        = Color.FromHex("749FA8"),
                ReturnType              = ReturnType.Done
            };

            passwordEntry.ReturnCommand = new Command(() => passwordEntry.Unfocus());
            passwordEntry.SetBinding(Xamarin.Forms.Entry.TextProperty, nameof(ViewModel.PasswordEntryText));

            var usernameEntry = new StyledEntry(1)
            {
                Placeholder             = "Username",
                HorizontalOptions       = LayoutOptions.Fill,
                HorizontalTextAlignment = TextAlignment.End,
                PlaceholderColor        = Color.FromHex("749FA8"),
                ReturnType    = ReturnType.Next,
                ReturnCommand = new Command(() => passwordEntry.Focus())
            };

            usernameEntry.SetBinding(Xamarin.Forms.Entry.TextProperty, nameof(ViewModel.UsernameEntryText));

            _saveUsernameButton = new StyledButton(Borders.Thin, 1)
            {
                Text = "Save User",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.EndAndExpand
            };
            _saveUsernameButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsInternetConnectionInactive));
            _saveUsernameButton.SetBinding(Button.CommandProperty, nameof(ViewModel.SaveButtonCommand));

            _cancelButton = new StyledButton(Borders.Thin, 1)
            {
                Text = "Cancel",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.End
            };
            _cancelButton.Clicked += HandleCancelButtonClicked;
            _cancelButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsInternetConnectionInactive));
            _cancelButton.SetBinding(Button.CommandProperty, nameof(ViewModel.CancelButtonCommand));

            _takePhotoButton = new StyledButton(Borders.Thin, 1)
            {
                Text = "Take Photo",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.EndAndExpand
            };
            _takePhotoButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsInternetConnectionInactive));
            _takePhotoButton.SetBinding(Button.CommandProperty, nameof(ViewModel.TakePhotoButtonCommand));

            var isFacialRecognitionCompletedDescriptionLabel = new StyledLabel
            {
                Text = "Facial Recognition Completed",
                VerticalTextAlignment = TextAlignment.Center
            };

            var isFacialRecognitionCompletedLabel = new FontAwesomeIcon
            {
                TextColor               = Color.White,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center
            };

            isFacialRecognitionCompletedLabel.SetBinding(Label.TextProperty, nameof(ViewModel.FontAwesomeLabelText));

            if (Device.RuntimePlatform is Device.iOS)
            {
                isFacialRecognitionCompletedLabel.SetBinding(IsVisibleProperty, nameof(ViewModel.IsInternetConnectionInactive));
            }

            var activityIndicator = new ActivityIndicator
            {
                Color             = Color.White,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.EndAndExpand,
            };

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

            var facialRecognitionStackLayout = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Center,

                Children =
                {
                    isFacialRecognitionCompletedDescriptionLabel,
                    isFacialRecognitionCompletedLabel
                }
            };

            var stackLayout = new StackLayout
            {
                Padding         = new Thickness(20, 50, 20, 20),
                VerticalOptions = LayoutOptions.FillAndExpand,

                Children =
                {
                    new Label
                    {
                        Text              = "Please enter username",
                        TextColor         = Color.White,
                        HorizontalOptions = LayoutOptions.Start
                    },

                    usernameEntry,

                    new Label
                    {
                        Text              = "Please enter password",
                        TextColor         = Color.White,
                        HorizontalOptions = LayoutOptions.Start
                    },

                    passwordEntry,
                    _takePhotoButton,
                    facialRecognitionStackLayout,
                }
            };

            switch (Device.RuntimePlatform)
            {
            case Device.iOS:
                facialRecognitionStackLayout.Children.Add(activityIndicator);
                break;

            case Device.Android:
                stackLayout.Children.Add(activityIndicator);
                break;

            default:
                throw new NotSupportedException("Device Runtime Unsupported");
            }
            stackLayout.Children.Add(_saveUsernameButton);
            stackLayout.Children.Add(_cancelButton);

            Content = new Xamarin.Forms.ScrollView {
                Content = stackLayout
            };

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