Beispiel #1
0
        public HomeMasterView(HomeViewModel viewModel)
        {
            this.Icon = "slideout.png";
            BindingContext = viewModel;
            Title = "MySafety";

            // layout.BackgroundColor = Color.FromRgba(0,0,0,0.5f);
            //this.BackgroundColor = Color.Yellow;

            var Logo = new Image {
                Source = Images.Menu,
                Aspect = Aspect.AspectFill,
                VerticalOptions = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Center
            };

            //            var stackMenu = new StackLayout
            //            {
            //                Orientation = StackOrientation.Horizontal,
            //                Spacing = 0,
            //                VerticalOptions = LayoutOptions.FillAndExpand,
            //                HorizontalOptions = LayoutOptions.FillAndExpand,
            //                BackgroundColor = Colors.BackgroundDefault,
            //                Children = { Logo }
            //            };
            //
            var UserLabel = new Label {
                Text = Settings.nome,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.Start,
                BackgroundColor = Color.Transparent,
                Style = Styles.DefaultCellText,
                TextColor = Color.FromHex ("#3f51b5").MultiplyAlpha (0.87f)
            };

            var UserEmailLabel = new Label {
                Text = Settings.email,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                BackgroundColor = Color.Transparent,
                LineBreakMode = LineBreakMode.TailTruncation,
                Style = Styles.DefaultCellDetail,
            };

            var TapGesture = new TapGestureRecognizer ();
            TapGesture.Tapped += (sender, args) => {
                menuType = MenuType.Data;
                Device.OpenUri (new Uri ("https://ineltec.com.br/ecommerce/login"));
            };

            var ContentView = new ContentView {
                BackgroundColor = Colors.BackgroundDefault,
                HeightRequest = 30,
                VerticalOptions = LayoutOptions.EndAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Content = new StackLayout {
                    Padding = new Thickness (10, 0, 0, 0),
                    Orientation = StackOrientation.Horizontal,
                    Spacing = 15,
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Children = { UserLabel, UserEmailLabel }
                }
            };
            ContentView.GestureRecognizers.Add (TapGesture);

            //layout.Children.Add(label);

            var listView = new ListView {
                Style = Styles.DefaultListView,
                VerticalOptions = LayoutOptions.StartAndExpand
            };

            DataTemplate cell = null;

            if (Device.OS == TargetPlatform.WinPhone) {
                cell = new DataTemplate (typeof(FancyListCell));
                //this.BackgroundColor = Color.FromHex("3498DB");
                // BackgroundColor = Color.Aqua;

            } else {
                cell = new DataTemplate (typeof(ListImageCell));
                //cell.SetBinding(TextCell.TextProperty, HomeViewModel.TitlePropertyName);
                // cell.SetBinding(TextCell.TextColorProperty, HomeViewModel.TitlePropertyColor);
                //cell.SetBinding(ImageCell.ImageSourceProperty, "Icon");
            }

            listView.ItemTemplate = cell;

            listView.ItemsSource = viewModel.MenuItems;
            //if (home == null)
            //    home = new HomePage();

            PageSelection = home;

            //Change to the correct page
            listView.ItemSelected += (sender, args) => {
                var menuItem = listView.SelectedItem as HomeMenuItem;
                menuType = menuItem.MenuType;
                switch (menuItem.MenuType) {
                case MenuType.Home:
                        //  if (home == null)
                    home = new HomePage (new HomePageViewModel ());

                    PageSelection = home;
                    break;
                case MenuType.MeusProdutos:
                        //  if (meusDados == null)
                    meusProdutos = new MeusProdutosPage (new MeusDadosViewModel ());

                    PageSelection = meusProdutos;
                    break;
                case MenuType.Emergencias:
                        //  if (acoesDePanico == null)
                        //if (new Repository<License>().GetAllAsync().Result.Where(li=>li.))
                    Emergencias = new AcoesDePanicoView (new AcoesDePanicoViewModel (this.Navigation));

                    PageSelection = Emergencias;
                    break;
                case MenuType.GerenciarPortoes:
                        //  if (gerenciarPortoes == null)
                    gerenciarPortoes = new GerenciarPortoesView (new GerenciarPortoesViewModel (this.Navigation));

                    PageSelection = gerenciarPortoes;
                    break;
                case MenuType.FeriadosGerais:
                        //  if (gerenciarFeriados == null)
                    feriadosGerais = new GerenciarFeriadosView (new GerenciarFeriadosViewModel (this.Navigation));

                    PageSelection = feriadosGerais;
                    break;
                case MenuType.HorariosParaPerfis:
                    horariosParaPerfis = new GerenciarHorariosView (new GerenciarHorariosViewModel (this.Navigation));

                    PageSelection = horariosParaPerfis;
                    break;
                case MenuType.PerfisDeAcesso:
                        //  if (gerenciarPerfis == null)
                    perfisDeAcesso = new GerenciarPerfisView (new GerenciarPerfisViewModel (this.Navigation));

                    PageSelection = perfisDeAcesso;
                    break;

                case MenuType.Configuracoes:
                        //    if (configuracoes == null)
                    configuracoes = new ConfigView (new ConfigViewModel ());

                    PageSelection = configuracoes;
                    break;
                case MenuType.Informacoes:
                        //   if (informacoes == null)
                    informacoes = new AboutPage ();

                    PageSelection = informacoes;
                    break;

                default:
                    {

                        break;
                    }
                }
            };

            listView.SelectedItem = viewModel.MenuItems [0];
            StackLayout layout = new StackLayout {
                Padding = new Thickness (0, 15, 0, 0),
                BackgroundColor = Color.White,
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children = { Logo, listView, ContentView }
            };

            var absoluteLayout = new AbsoluteLayout ();
            var background = new Image {
                Style = Styles.CellBackground,
                Source = Images.HomeStackBack
            };

            absoluteLayout.Children.Add (background, new Rectangle (0, 0, 1, 1), AbsoluteLayoutFlags.All);
            absoluteLayout.Children.Add (layout, new Rectangle (0, 0, 1, 1), AbsoluteLayoutFlags.All);

            Content = absoluteLayout;
        }
Beispiel #2
0
        public HomeView()
        {
            BindingContext = this;
            Settings.imei = Acr.DeviceInfo.DeviceInfo.Hardware.DeviceId;

            //         ((App)Application.Current).startSignalr();
            //((App)Application.Current).mysafetyHubProxy.On<string>("RequestGateAccess", async msg =>
            //{

            //    await DependencyService.Get<IToastNotificator>()
            //     .Notify(ToastNotificationType.Error, "MySafety", "Você tem uma nova solicitação de acesso ao seu portão", TimeSpan.FromSeconds(10));

            //});
            //((App)Application.Current).mysafetyHubProxy.Invoke("RequestGateAccess");
            pages = new Dictionary<MenuType, NavigationPage> ();

            BindingContext = new HomeViewModel ();

            Master = master = new HomeMasterView (ViewModel);

            var homeNav = new NavigationPage (master.PageSelection) {
                // BarBackgroundColor = Color.FromHex("#3498DB"),
                //BarBackgroundColor = Color.FromHex("#039BE5"),
                BarBackgroundColor = Color.FromHex ("#3f51b5"),
                BarTextColor = Color.White
            };
            Detail = homeNav;

            pages.Add (MenuType.Home, homeNav);

            master.PageSelectionChanged = async (menuType) => {

                if (Detail != null && Device.OS == TargetPlatform.WinPhone) {
                    await Detail.Navigation.PopToRootAsync ();
                }

                NavigationPage newPage;
                if (pages.ContainsKey (menuType)) {
                    newPage = pages [menuType];
                } else {
                    newPage = new NavigationPage (master.PageSelection) {
                        //BarBackgroundColor = Color.FromHex("#3498DB"),
                        // BarBackgroundColor = Color.Purple,
                        BarTextColor = Color.White
                    };
                    //newPage.
                    if (menuType.Equals (MenuType.MeusProdutos))
                        newPage.BarBackgroundColor = Color.FromHex ("#009688");
                    if (menuType.Equals (MenuType.Emergencias))
                        newPage.BarBackgroundColor = Color.FromHex ("#ffc107");
                    if (menuType.Equals (MenuType.GerenciarPortoes) || menuType.Equals (MenuType.HorariosParaPerfis) ||
                                       menuType.Equals (MenuType.PerfisDeAcesso) || menuType.Equals (MenuType.FeriadosGerais))
                        newPage.BarBackgroundColor = Color.FromHex ("#546E7A");
                    if (menuType.Equals (MenuType.Configuracoes) || menuType.Equals (MenuType.Informacoes) || menuType.Equals (MenuType.Data)) {
                        newPage.BarBackgroundColor = Color.FromHex ("#eceff1");
                        newPage.BarTextColor = Color.FromHex ("#000000").MultiplyAlpha (0.87f);
                    }

                    pages.Add (menuType, newPage);
                }
                newPage.Title = master.PageSelection.Title;

                //await master.Navigation.PushModalAsync(newPage);
                Detail = newPage;

                if (Device.Idiom != TargetIdiom.Tablet)
                    IsPresented = false;
            };

            this.Icon = "slideout.png";
        }