Exemple #1
0
        public static StackLayout FindBluetooth(ContentView titleBar, PairNewVehicleViewModel ViewModel)
        {
            Vm = ViewModel;
            RegisterEvents();

            ViewModel.GetBluetoothDeviceList();

            var lblTitle = GetUIElement.GetFirstElement <Label>(titleBar.Content as StackLayout);

            lblTitle.Text = Langs.Const_Screen_Title_Select_Bluetooth;

            lstDevices = new ListView
            {
                ItemsSource            = ViewModel.BluetoothDeviceList,
                ItemTemplate           = new DataTemplate(typeof(BluetoothViewCell)),
                IsPullToRefreshEnabled = true,
                SeparatorVisibility    = SeparatorVisibility.None
            };
            lstDevices.ItemSelected += (sender, e) =>
            {
                var obj = e.SelectedItem as BluetoothDevice;
                ViewModel.SelectedBluetoothDevice = obj.Id;
                ViewModel.PopulateBasedOnId();
            };
            lstDevices.Refreshing += (sender, e) =>
            {
                ViewModel.GetBluetoothDeviceList();
            };

            var grid = new Grid
            {
                WidthRequest = App.ScreenSize.Width * .9
            };

            grid.RowDefinitions = new RowDefinitionCollection
            {
                new RowDefinition {
                    Height = 80
                },
                new RowDefinition {
                    Height = App.ScreenSize.Height * .6
                },
                new RowDefinition {
                    Height = GridLength.Auto
                },
                new RowDefinition {
                    Height = 200
                }
            };

            var arrowButton = ArrowBtn.ArrowButton(Langs.Const_Button_Manage_Vehicle_Step_3, App.ScreenSize.Width * .8,
                                                   new Action(() => { if (ViewModel.SelectedVehicle.BluetoothId == ViewModel.SelectedBluetoothDevice.ToString())
                                                                      {
                                                                          ViewModel.MoveToSummary = true;
                                                                      }
                                                              }));

            arrowButton.SetBinding(Button.IsEnabledProperty, new Binding("Paired"));

            var inStack = new StackLayout
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Start,
                HeightRequest     = 100,
                Children          = { new Label {
                                          Text = " "
                                      } }
            };

            var imgHelp = new Image
            {
                Source        = "help".CorrectedImageSource(),
                HeightRequest = 32
            };
            var imgHelpGesture = new TapGestureRecognizer
            {
                NumberOfTapsRequired = 1,
                Command = new Command(() =>
                {
                    var src = imgHelp.Source as FileImageSource;

                    if (src.File == "help".CorrectedImageSource())
                    {
                        var _ = new SpeechBubble(Langs.Const_Msg_Pair_Vehicle_Help_Description_3, App.ScreenSize.Width * .8,
                                                 FormsConstants.AppySilverGray);

                        if (inStack.Children.Count > 0)
                        {
                            inStack.Children.RemoveAt(0);
                        }
                        inStack.Children.Add(_);
                        imgHelp.Source = "help_close".CorrectedImageSource();
                    }
                    else
                    {
                        imgHelp.Source = "help".CorrectedImageSource();
                        inStack.Children.RemoveAt(0);
                    }
                })
            };

            imgHelp.GestureRecognizers.Add(imgHelpGesture);

            var helpContainer = new StackLayout
            {
                Orientation       = StackOrientation.Vertical,
                WidthRequest      = App.ScreenSize.Width,
                HeightRequest     = 100,
                HorizontalOptions = LayoutOptions.Start,
                Children          =
                {
                    inStack,
                    new StackLayout
                    {
                        HorizontalOptions = LayoutOptions.End,
                        HeightRequest     = 64,
                        VerticalOptions   = LayoutOptions.Start,
                        Children          = { imgHelp }
                    }
                }
            };

            grid.Children.Add(new StackLayout
            {
                WidthRequest      = App.ScreenSize.Width,
                HorizontalOptions = LayoutOptions.Center,
                Children          =
                {
                    new StackLayout
                    {
                        Padding           = new Thickness(0, 12),
                        HorizontalOptions = LayoutOptions.Center,
                        Children          =
                        {
                            new StackLayout
                            {
                                WidthRequest      = App.ScreenSize.Width * .9,
                                HorizontalOptions = LayoutOptions.Center,
                                Children          =
                                {
                                    new Label
                                    {
                                        FormattedText           = FormattedProgress.GenerateProgress(true, true, false),
                                        FontFamily              = Helper.BoldFont,
                                        TextColor               = Color.White,
                                        HorizontalTextAlignment = TextAlignment.Center
                                    },
                                }
                            },
                            new BoxView {
                                WidthRequest = App.ScreenSize.Width, HeightRequest = 1, BackgroundColor = Color.White
                            },
                            new StackLayout
                            {
                                WidthRequest      = App.ScreenSize.Width * .9,
                                HorizontalOptions = LayoutOptions.Center,
                                Children          =
                                {
                                    new Label
                                    {
                                        Text              = Langs.Const_Button_Pair_Vehicle,
                                        FontFamily        = Helper.RegFont,
                                        TextColor         = Color.White,
                                        HorizontalOptions = LayoutOptions.Center
                                    },
                                }
                            },
                        }
                    },
                }
            }, 0, 0);

            grid.Children.Add(lstDevices, 0, 1);
            grid.Children.Add(arrowButton, 0, 2);
            grid.Children.Add(helpContainer, 0, 3);

            return(new StackLayout
            {
                WidthRequest = App.ScreenSize.Width,
                HorizontalOptions = LayoutOptions.Center,
                TranslationX = -6,
                Padding = new Thickness(4),
                Children = { grid }
            });
        }
        public static StackLayout VehicleSummary(ContentView titleBar, PairNewVehicleViewModel ViewModel)
        {
            var lblTitle = GetUIElement.GetFirstElement <Label>(titleBar.Content as StackLayout);

            lblTitle.Text = Langs.Const_Screen_Title_Pairing_Summary;

            var arrowButton = ArrowBtn.ArrowButton(Langs.Const_Button_Manage_Vehicle_Step_4, App.ScreenSize.Width * .9, new Action(() => ViewModel.MoveToComplete = true));

            return(new StackLayout
            {
                WidthRequest = App.ScreenSize.Width,
                HorizontalOptions = LayoutOptions.Center,
                Children =
                {
                    new StackLayout
                    {
                        HorizontalOptions = LayoutOptions.Center,
                        Padding = new Thickness(0, 12),
                        Children =
                        {
                            new Label
                            {
                                FormattedText = FormattedProgress.GenerateProgress(true, true, true),
                                TextColor = Color.White,
                                FontFamily = Helper.BoldFont
                            }
                        }
                    },
                    new BoxView {
                        WidthRequest = App.ScreenSize.Width, HeightRequest = 1, BackgroundColor = Color.White
                    },
                    new StackLayout
                    {
                        Padding = new Thickness(16, 8, 0, 16),
                        WidthRequest = App.ScreenSize.Width * .8,
                        Children =
                        {
                            new Label
                            {
                                Text = Langs.Const_Label_Review_Info,
                                FontFamily = Helper.BoldFont,
                                TextColor = Color.White
                            }
                        }
                    },
                    new StackLayout
                    {
                        WidthRequest = App.ScreenSize.Width * .8,
                        Padding = new Thickness(16, 12),
                        Children =
                        {
                            new Label
                            {
                                Text = $"{ViewModel.Nickname}",
                                TextColor = Color.White,
                                FontFamily = Helper.BoldFont
                            },
                            new Label
                            {
                                Text = ViewModel.Registration,
                                FontFamily = Helper.RegFont,
                                TextColor = Color.White
                            },
                            new Label
                            {
                                Text = $"{ViewModel.Make} {ViewModel.Model}",
                                TextColor = Color.White,
                                FontFamily = Helper.RegFont
                            },
                        }
                    },
                    new StackLayout
                    {
                        Padding = new Thickness(0, 16, 0, 8),
                        WidthRequest = App.ScreenSize.Width * .8,
                        IsVisible = ViewModel.Paired,
                        Children =
                        {
                            new Label
                            {
                                Text = Langs.Const_Label_Bluetooth_Registered,
                                TextColor = Color.White,
                                FontFamily = Helper.BoldFont
                            }
                        }
                    },
                    new BoxView {
                        WidthRequest = App.ScreenSize.Width, HeightRequest = 1, BackgroundColor = Color.White
                    },
                    new StackLayout
                    {
                        Padding = new Thickness(0, 12),
                        WidthRequest = App.ScreenSize.Width * .8,
                        Children =
                        {
                            new Label
                            {
                                Text = Langs.Const_Label_Confirm_Pairing,
                                TextColor = Color.White,
                                FontFamily = Helper.RegFont
                            }
                        }
                    },
                    arrowButton
                }
            });
        }
Exemple #3
0
        public static StackLayout SearchSelectAddVehicle(ContentView titleBar, PairNewVehicleViewModel ViewModel)
        {
            Vm = ViewModel;

            RegisterEvents();

            if (ViewModel.VehicleModels == null)
            {
                ViewModel.MoveToAdd = true;
            }
            else
            if (ViewModel.VehicleModels?.Count == 0)
            {
                ViewModel.GetVehiclesFromDb();
                if (ViewModel.VehicleModels.Count == 0)
                {
                    ViewModel.MoveToAdd = true;
                }
            }

            var lblTitle = GetUIElement.GetFirstElement <Label>(titleBar.Content as StackLayout);

            lblTitle.Text = Langs.Const_Screen_Title_Select_Vehicle;

            var srchVehicle = new SearchBar
            {
                WidthRequest = App.ScreenSize.Width * .9,
            };

            srchVehicle.SetBinding(SearchBar.TextProperty, new Binding("VehicleSearch"));

            var lblNoneFound = new Label
            {
                Text       = Langs.Const_Label_No_Search_Result,
                TextColor  = Color.White,
                FontFamily = Helper.BoldFont,
                IsVisible  = false
            };

            srchVehicle.SearchButtonPressed += (sender, e) =>
            {
                var _ = ViewModel.SearchBasedOnVehicle();
                if (!_)
                {
                    lblNoneFound.IsVisible = true;
                }
            };

            var grid = new Grid
            {
                WidthRequest = App.ScreenSize.Width
            };

            grid.ColumnDefinitions = new ColumnDefinitionCollection
            {
                new ColumnDefinition {
                    Width = App.ScreenSize.Width
                }
            };
            grid.RowDefinitions = new RowDefinitionCollection
            {
                new RowDefinition {
                    Height = GridLength.Auto
                },
                new RowDefinition {
                    Height = App.ScreenSize.Height * .5
                },
                new RowDefinition {
                    Height = GridLength.Auto
                }
            };

            var activitySpinner = new ActivityIndicator
            {
                BackgroundColor = Color.Transparent,
                WidthRequest    = 40,
                IsRunning       = true
            };

            activitySpinner.SetBinding(ActivityIndicator.IsVisibleProperty, new Binding("IsBusy"));

            listView = new ListView(ListViewCachingStrategy.RecycleElement)
            {
                IsPullToRefreshEnabled = true,
                ItemsSource            = ViewModel.VehicleModels,
                ItemTemplate           = new DataTemplate(typeof(RegisteredVehicleViewCell)),
                SeparatorVisibility    = SeparatorVisibility.None,
                HasUnevenRows          = true
            };
            listView.ItemSelected += (sender, e) =>
            {
                var obj = e.SelectedItem as VehicleModel;
                ViewModel.SelectedVehicle = obj;
            };
            listView.Refreshing += (sender, e) =>
            {
                listView.IsRefreshing = true;
                ViewModel.CmdGetRegisteredVehicles.Execute(null);
                listView.IsRefreshing = false;
            };

            var dummyCell = new StackLayout
            {
                Padding         = new Thickness(12),
                BackgroundColor = FormsConstants.AppyDarkShade,
                VerticalOptions = LayoutOptions.Center,
                Orientation     = StackOrientation.Horizontal,
                Children        =
                {
                    new Image
                    {
                        Source        = "add_new".CorrectedImageSource(),
                        HeightRequest = 48
                    },
                    new Label
                    {
                        Text                  = Langs.Const_Label_Add_Vehicle,
                        FontFamily            = Helper.RegFont,
                        TextColor             = Color.White,
                        HeightRequest         = 48,
                        VerticalTextAlignment = TextAlignment.Center
                    }
                }
            };
            var dummyListCellRecogniser = new TapGestureRecognizer
            {
                NumberOfTapsRequired = 1,
                Command = new Command(() => ViewModel.MoveToAdd = !ViewModel.MoveToAdd)
            };

            dummyCell.GestureRecognizers.Add(dummyListCellRecogniser);
            var dummyListCell = new StackLayout
            {
                HeightRequest    = 60,
                InputTransparent = true,
                Padding          = new Thickness(8),
                Children         =
                {
                    dummyCell
                }
            };


            var listStack = new StackLayout
            {
                WidthRequest = App.ScreenSize.Width * .9,
                Padding      = new Thickness(4),
                Children     = { lblNoneFound, activitySpinner, listView, dummyListCell }
            };

            grid.Children.Add(new StackLayout
            {
                WidthRequest      = App.ScreenSize.Width,
                HorizontalOptions = LayoutOptions.Center,
                Children          =
                {
                    new StackLayout
                    {
                        WidthRequest      = App.ScreenSize.Width * .9,
                        HorizontalOptions = LayoutOptions.Center,
                        Children          =
                        {
                            new Label {
                                FormattedText = FormattedProgress.GenerateProgress(true, false, false), HorizontalTextAlignment = TextAlignment.Center
                            },
                            srchVehicle
                        }
                    },
                    new BoxView       {
                        WidthRequest = App.ScreenSize.Width, HeightRequest = 1, BackgroundColor = Color.White
                    },
                }
            }, 0, 0);

            var arrowButton = ArrowBtn.ArrowButton(Langs.Const_Button_Manage_Vehicle_Step_1, App.ScreenSize.Width * .9,
                                                   new Action(() => { if (ViewModel.RegisteredVehicles?.Vehicles.Count != 0)
                                                                      {
                                                                          ViewModel.MoveToPair = true;
                                                                      }
                                                              }));

            grid.Children.Add(new StackLayout
            {
                WidthRequest      = App.ScreenSize.Width,
                HorizontalOptions = LayoutOptions.Center,
                Children          =
                {
                    new StackLayout
                    {
                        WidthRequest      = App.ScreenSize.Width * .9,
                        HorizontalOptions = LayoutOptions.Center,
                        Children          = { listStack             }
                    },
                    new BoxView {
                        WidthRequest = App.ScreenSize.Width, HeightRequest = 1, BackgroundColor = Color.White
                    },
                    arrowButton
                }
            }, 0, 1);



            var inStack = new StackLayout
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Start,
                HeightRequest     = 100,
                Children          = { new Label {
                                          Text = " "
                                      } }
            };

            var imgHelp = new Image
            {
                Source        = "help".CorrectedImageSource(),
                HeightRequest = 32
            };
            var imgHelpGesture = new TapGestureRecognizer
            {
                NumberOfTapsRequired = 1,
                Command = new Command(() =>
                {
                    var src = imgHelp.Source as FileImageSource;

                    if (src.File == "help".CorrectedImageSource())
                    {
                        var _ = new SpeechBubble(Langs.Const_Msg_Pair_Vehicle_Help_Description_1, App.ScreenSize.Width * .8, FormsConstants.AppySilverGray);

                        if (inStack.Children.Count > 0)
                        {
                            inStack.Children.RemoveAt(0);
                        }
                        inStack.Children.Add(_);
                        imgHelp.Source = "help_close".CorrectedImageSource();
                    }
                    else
                    {
                        imgHelp.Source = "help".CorrectedImageSource();
                        inStack.Children.RemoveAt(0);
                    }
                })
            };

            imgHelp.GestureRecognizers.Add(imgHelpGesture);

            var helpContainer = new StackLayout
            {
                Orientation  = StackOrientation.Vertical,
                WidthRequest = App.ScreenSize.Width,

                HorizontalOptions = LayoutOptions.Start,
                Children          =
                {
                    inStack,
                    new StackLayout
                    {
                        HorizontalOptions = LayoutOptions.End,
                        HeightRequest     = 64,
                        VerticalOptions   = LayoutOptions.Start,
                        Children          = { imgHelp }
                    }
                }
            };

            grid.Children.Add(helpContainer, 0, 2);

            return(new StackLayout
            {
                WidthRequest = App.ScreenSize.Width,
                TranslationX = -6,
                HorizontalOptions = LayoutOptions.Center,
                HeightRequest = App.ScreenSize.Height - 100,
                Children = { grid }
            });
        }