public GerenciarHorariosView (GerenciarHorariosViewModel viewModel)
		{
			Title = "Horários";
			BindingContext = viewModel;
			listHours.ItemTemplate = new DataTemplate (typeof(HourCell));
			listHours.SetBinding (ListView.ItemsSourceProperty, "AccessTimes");
			listHours.ItemTapped += listHours_ItemTapped;

			FloatButton.AnimateWithAction ();
			FloatButton.Command = new Command (ToolbarAction);

			/*ToolbarItems.Add(new ToolbarItem
            {
                Icon = Images.Add1,
                Order = ToolbarItemOrder.Primary,
                Command = new Command(ToolbarAction)
            });*/
			iconStack = new StackLayout {
				VerticalOptions = LayoutOptions.CenterAndExpand,
				HorizontalOptions = LayoutOptions.CenterAndExpand,
				Children = { iconMsg, labelMsg }
			}; 

			stack = new StackLayout {
				Padding = new Thickness (0, 15, 0, 0),
				VerticalOptions = LayoutOptions.FillAndExpand,
				HorizontalOptions = LayoutOptions.FillAndExpand,
				BackgroundColor = Colors.BackgroundDefault,
				Children = { iconStack, listHours }
			};

			var absoluteLayout = new AbsoluteLayout {
				VerticalOptions = LayoutOptions.FillAndExpand,
			};
			//var background = new Image { Source = Images.Background, Aspect = Aspect.Fill };

			//absoluteLayout.Children.Add (background, new Rectangle (0, 0, 1, 1), AbsoluteLayoutFlags.All);
			//AbsoluteLayout.SetLayoutFlags(background, AbsoluteLayoutFlags.All);
			//AbsoluteLayout.SetLayoutBounds(background, new Rectangle(0, 0, 1, 1));

			//absoluteLayout.Children.Add (stack, new Rectangle (0, 0, 1, 1), AbsoluteLayoutFlags.All);
			AbsoluteLayout.SetLayoutFlags (stack, AbsoluteLayoutFlags.All);
			AbsoluteLayout.SetLayoutBounds (stack, new Rectangle (0, 0, 1, 1));

			//absoluteLayout.Children.Add (Add, new Rectangle (0.85, 0.85, 0.185, 0.1), AbsoluteLayoutFlags.All);
			AbsoluteLayout.SetLayoutFlags (FloatButton, AbsoluteLayoutFlags.PositionProportional);
			AbsoluteLayout.SetLayoutBounds (FloatButton, new Rectangle (0.99f, 0.98f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));

			//absoluteLayout.Children.Add(background);
			absoluteLayout.Children.Add (stack);
			absoluteLayout.Children.Add (FloatButton);

			Content = absoluteLayout;
		}
Ejemplo n.º 2
0
        public AddHorariosView(GerenciarHorariosViewModel viewModel)
        {
            Title = "Adicionar horários";

            BindingContext = viewModel;

            FloatButton.AnimateWithAction ();
            FloatButton.Command = new Command (ToolbarAction);

            if (viewModel.EditingAccessTime != null) {
                if (viewModel.EditingAccessTime.Sun)
                    Dom.Style = Styles.DateSelectedButton;
                else
                    Dom.Style = Styles.DateUnselectedButton;
                if (viewModel.EditingAccessTime.Mon)
                    Seg.Style = Styles.DateSelectedButton;
                else
                    Seg.Style = Styles.DateUnselectedButton;
                if (viewModel.EditingAccessTime.Tue)
                    Ter.Style = Styles.DateSelectedButton;
                else
                    Ter.Style = Styles.DateUnselectedButton;
                if (viewModel.EditingAccessTime.Wed)
                    Qua.Style = Styles.DateSelectedButton;
                else
                    Qua.Style = Styles.DateUnselectedButton;
                if (viewModel.EditingAccessTime.Thu)
                    Qui.Style = Styles.DateSelectedButton;
                else
                    Qui.Style = Styles.DateUnselectedButton;
                if (viewModel.EditingAccessTime.Fri)
                    Sex.Style = Styles.DateSelectedButton;
                else
                    Sex.Style = Styles.DateUnselectedButton;
                if (viewModel.EditingAccessTime.Sat)
                    Sab.Style = Styles.DateSelectedButton;
                else
                    Sab.Style = Styles.DateUnselectedButton;
            }
            entryName.SetBinding (Entry.TextProperty, "Name", BindingMode.TwoWay);

            Dom.CommandParameter = Dom;
            Seg.CommandParameter = Seg;
            Ter.CommandParameter = Ter;
            Qua.CommandParameter = Qua;
            Qui.CommandParameter = Qui;
            Sex.CommandParameter = Sex;
            Sab.CommandParameter = Sab;

            Dom.SetBinding (Button.CommandProperty, "commandDomingo", BindingMode.TwoWay);
            Seg.SetBinding (Button.CommandProperty, "commandSegunda", BindingMode.TwoWay);
            Ter.SetBinding (Button.CommandProperty, "commandTerca", BindingMode.TwoWay);
            Qua.SetBinding (Button.CommandProperty, "commandQuarta", BindingMode.TwoWay);
            Qui.SetBinding (Button.CommandProperty, "commandQuinta", BindingMode.TwoWay);
            Sex.SetBinding (Button.CommandProperty, "commandSexta", BindingMode.TwoWay);
            Sab.SetBinding (Button.CommandProperty, "commandSabado", BindingMode.TwoWay);

            entryHorarioInicial.SetBinding (TimePicker.TimeProperty, "StartTime", BindingMode.TwoWay);
            entryHorarioFinal.SetBinding (TimePicker.TimeProperty, "EndTime", BindingMode.TwoWay);
            switchHollyday.SetBinding (SwitchCell.OnProperty, "isHoliday", BindingMode.TwoWay);

            //ToolbarItems.Add(new ToolbarItem
            //{
            //    Icon = Images.Save,
            //    Order = ToolbarItemOrder.Primary,
            //    Command = new Command(ToolBarAction)
            //});

            grid.Children.AddHorizontal (Dom);
            grid.Children.AddHorizontal (Seg);
            grid.Children.AddHorizontal (Ter);
            grid.Children.AddHorizontal (Qua);
            grid.Children.AddHorizontal (Qui);
            grid.Children.AddHorizontal (Sex);
            grid.Children.AddHorizontal (Sab);

            StackLayout durationStack = new StackLayout {
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Orientation = StackOrientation.Horizontal,
                Padding = new Thickness (15, 0, 0, 0),
                Children = {
                    new StackLayout {
                        VerticalOptions = LayoutOptions.FillAndExpand,
                        HorizontalOptions = LayoutOptions.StartAndExpand,
                        Orientation = StackOrientation.Horizontal,
                        Children = { HorarioInicial, entryHorarioInicial }
                    },
                    new StackLayout {
                        VerticalOptions = LayoutOptions.FillAndExpand,
                        HorizontalOptions = LayoutOptions.CenterAndExpand,
                        Orientation = StackOrientation.Horizontal,
                        Children = { HorarioFinal, entryHorarioFinal }
                    }
                }
            };

            ConfigTable = new TableView {
                Intent = TableIntent.Settings,
                BackgroundColor = Color.Default,
                Root = new TableRoot {
                    new TableSection ("Nome") {
                        new ViewCell { View = entryName }
                    },
                    new TableSection ("Dias da semana") {
                        new ViewCell{ View = grid }
                    },
                    new TableSection () {
                        switchHollyday
                    },
                    new TableSection ("Duração") {
                        new ViewCell { View = durationStack }
                        //new ViewCell{View = entryHorarioInicial}
                    }
                    //new TableSection("Horario final")
                    //{
                    //    new ViewCell{View = entryHorarioFinal}
                    //}
                }
            };

            StackLayout stack = new StackLayout {
                Padding = new Thickness (0, 0, 0, 0),
                Spacing = 0,
                Children = { ConfigTable }
            };

            var absoluteLayout = new AbsoluteLayout {
                VerticalOptions = LayoutOptions.FillAndExpand,
            };
            //var background = new Image { Source = Images.Background, Aspect = Aspect.Fill };

            //absoluteLayout.Children.Add (background, new Rectangle (0, 0, 1, 1), AbsoluteLayoutFlags.All);
            //AbsoluteLayout.SetLayoutFlags(background, AbsoluteLayoutFlags.All);
            //AbsoluteLayout.SetLayoutBounds(background, new Rectangle(0, 0, 1, 1));

            //absoluteLayout.Children.Add (stack, new Rectangle (0, 0, 1, 1), AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutFlags (stack, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds (stack, new Rectangle (0, 0, 1, 1));

            //absoluteLayout.Children.Add (Add, new Rectangle (0.85, 0.85, 0.185, 0.1), AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutFlags (FloatButton, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds (FloatButton, new Rectangle (0.99f, 0.98f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));

            //absoluteLayout.Children.Add(background);
            absoluteLayout.Children.Add (stack);
            absoluteLayout.Children.Add (FloatButton);

            Content = absoluteLayout;
        }