Exemplo n.º 1
0
        public FeedbackPage()
            : base(typeof(FeedbackViewModel), typeof(FeedbackContentUI))
        {
            BackgroundColor         = MainStyles.StatusBarColor.FromResources <Color>();
            Content.BackgroundColor = MainStyles.MainBackgroundColor.FromResources <Color>();

            var loadingColor = MainStyles.LoadingColor.FromResources <Color>();

            LoadingActivityIndicator.Color = loadingColor;
            LoadingActivityText.TextColor  = loadingColor;

            var appBar = new TitleBar(this, TitleBar.BarBtnEnum.bbBack)
            {
                BarColor   = MainStyles.StatusBarColor.FromResources <Color>(),
                TitleStyle = LabelStyles.PageTitleStyle.FromResources <Style>(),
                BtnBack    =
                {
                    Source = contentUI.IconBack
                }
            };

            appBar.SetBinding(TitleBar.TitleProperty, "Title");

            var txtNameTitle = new Label
            {
                Style = LabelStyles.FeedbackLabelStyle.FromResources <Style>(),
                Text  = contentUI.TxtName
            };

            _txtName = new Entry
            {
                Style     = LabelStyles.FeedbackEntryStyle.FromResources <Style>(),
                MaxLength = 30
            };
            _txtName.SetBinding(Entry.TextProperty, "Name");
            _txtName.SetBinding(IsEnabledProperty, "IsNotLoading");

            var txtCommentTitle = new Label
            {
                Style = LabelStyles.FeedbackLabelStyle.FromResources <Style>(),
                Text  = contentUI.TxtComment
            };

            _txtComment = new Editor
            {
                Style           = LabelStyles.FeedbackEditorStyle.FromResources <Style>(),
                VerticalOptions = LayoutOptions.FillAndExpand,
                MaxLength       = 1000
            };
            _txtComment.SetBinding(Editor.TextProperty, "Comment");
            _txtComment.SetBinding(IsEnabledProperty, "IsNotLoading");

            var btnSubmit = new ButtonExtended
            {
                Style             = LabelStyles.ButtonStyle.FromResources <Style>(),
                Text              = contentUI.TxtSubmit.ToUpper(),
                HorizontalOptions = LayoutOptions.Center,
                WidthRequest      = 150
            };

            btnSubmit.SetBinding(IsEnabledProperty, "IsValidFeedback");
            btnSubmit.SetBinding(IsVisibleProperty, "IsNotLoading");
            btnSubmit.Clicked += viewModel.BtnSubmit_Clicked;

            var activityIndicator = new ActivityIndicator
            {
                Color             = loadingColor,
                HorizontalOptions = LayoutOptions.Center
            };

            activityIndicator.SetBinding(IsVisibleProperty, "IsSubmitting");
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsSubmitting");

            _layoutFeedback = new KeyboardView
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    }
                }
            };

            _layoutFeedback.Children.Add(txtNameTitle, 0, 0);
            _layoutFeedback.Children.Add(_txtName, 0, 1);
            _layoutFeedback.Children.Add(txtCommentTitle, 0, 2);
            _layoutFeedback.Children.Add(_txtComment, 0, 3);
            _layoutFeedback.Children.Add(btnSubmit, 0, 4);
            _layoutFeedback.Children.Add(activityIndicator, 0, 5);

            var layoutContainer = new ContentView
            {
                Padding         = 24,
                Content         = _layoutFeedback,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var safeAreaHelper = new SafeAreaHelper();

            safeAreaHelper.UseSafeArea(this, SafeAreaHelper.CustomSafeAreaFlags.Top);
            safeAreaHelper.UseSafeArea(appBar.BtnBack, SafeAreaHelper.CustomSafeAreaFlags.Left);
            safeAreaHelper.UseSafeArea(layoutContainer, SafeAreaHelper.CustomSafeAreaFlags.Horizontal);

            ContentLayout.Children.Add(appBar);
            ContentLayout.Children.Add(layoutContainer);
        }
Exemplo n.º 2
0
        public AboutPage()
            : base(typeof(AboutViewModel), typeof(AboutContentUI))
        {
            BackgroundColor         = MainStyles.StatusBarColor.FromResources <Color>();
            Content.BackgroundColor = MainStyles.MainBackgroundColor.FromResources <Color>();

            var loadingColor = MainStyles.LoadingColor.FromResources <Color>();

            LoadingActivityIndicator.Color = loadingColor;
            LoadingActivityText.TextColor  = loadingColor;

            var appBar = new TitleBar(this, TitleBar.BarBtnEnum.bbBack)
            {
                BarColor   = MainStyles.StatusBarColor.FromResources <Color>(),
                TitleStyle = LabelStyles.PageTitleStyle.FromResources <Style>(),
                BtnBack    =
                {
                    Source = contentUI.IconBack
                }
            };

            appBar.SetBinding(TitleBar.TitleProperty, "Title");

            var imgLogo = new Image
            {
                Source = contentUI.ImgLogo
            };

            var txtTitle = new Label
            {
                Text  = contentUI.TxtTitle,
                Style = LabelStyles.TitleLightStyle.FromResources <Style>()
            };

            #region Description info

            var txtDescription1 = new Label
            {
                Text  = contentUI.TxtDescription1,
                Style = LabelStyles.DescriptionLightStyle.FromResources <Style>()
            };

            var stackDescriptionBullet1 = new StackLayout
            {
                Padding     = new Thickness(12, 0, 0, 0),
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    new Label
                    {
                        VerticalOptions = LayoutOptions.Start,
                        Text            = contentUI.TxtDescriptionBulletSymbol,
                        Style           = LabelStyles.DescriptionLightStyle.FromResources <Style>()
                    },
                    new Label
                    {
                        Text  = contentUI.TxtDescriptionBullet1,
                        Style = LabelStyles.DescriptionLightStyle.FromResources <Style>()
                    }
                }
            };

            var stackDescriptionBullet2 = new StackLayout
            {
                Padding     = new Thickness(12, 0, 0, 0),
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    new Label
                    {
                        VerticalOptions = LayoutOptions.Start,
                        Text            = contentUI.TxtDescriptionBulletSymbol,
                        Style           = LabelStyles.DescriptionLightStyle.FromResources <Style>()
                    },
                    new Label
                    {
                        Text  = contentUI.TxtDescriptionBullet2,
                        Style = LabelStyles.DescriptionLightStyle.FromResources <Style>()
                    }
                }
            };

            var stackDescriptionBullet3 = new StackLayout
            {
                Padding     = new Thickness(12, 0, 0, 0),
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    new Label
                    {
                        VerticalOptions = LayoutOptions.Start,
                        Text            = contentUI.TxtDescriptionBulletSymbol,
                        Style           = LabelStyles.DescriptionLightStyle.FromResources <Style>()
                    },
                    new Label
                    {
                        Text  = contentUI.TxtDescriptionBullet3,
                        Style = LabelStyles.DescriptionLightStyle.FromResources <Style>()
                    }
                }
            };

            var stackDescriptionBullet4 = new StackLayout
            {
                Padding     = new Thickness(12, 0, 0, 0),
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    new Label
                    {
                        VerticalOptions = LayoutOptions.Start,
                        Text            = contentUI.TxtDescriptionBulletSymbol,
                        Style           = LabelStyles.DescriptionLightStyle.FromResources <Style>()
                    },
                    new Label
                    {
                        Text  = contentUI.TxtDescriptionBullet4,
                        Style = LabelStyles.DescriptionLightStyle.FromResources <Style>()
                    }
                }
            };

            var txtDescription2 = new Label
            {
                Text  = contentUI.TxtDescription2,
                Style = LabelStyles.DescriptionLightStyle.FromResources <Style>()
            };

            var tapEmailAlternate = new TapGestureRecognizer
            {
                CommandParameter = contentUI.TxtEmailAlternateValue
            };
            tapEmailAlternate.Tapped += viewModel.TxtEmail_Click;

            var txtDescription3 = new Label
            {
                Style         = LabelStyles.DescriptionLightStyle.FromResources <Style>(),
                FormattedText = new FormattedString
                {
                    Spans =
                    {
                        new Span
                        {
                            Text = contentUI.TxtDescription3
                        },
                        new Span
                        {
                            Text               = contentUI.TxtEmailAlternateValue,
                            TextDecorations    = TextDecorations.Underline,
                            GestureRecognizers =
                            {
                                tapEmailAlternate
                            }
                        }
                    }
                }
            };

            var stackDescription = new StackLayout
            {
                Spacing  = 0,
                Children =
                {
                    txtDescription1,
                    stackDescriptionBullet1,
                    stackDescriptionBullet2,
                    stackDescriptionBullet3,
                    stackDescriptionBullet4,
                    txtDescription2,
                    txtDescription3
                }
            };

            #endregion

            #region Version info

            var txtTitleVersion = new Label
            {
                Text      = contentUI.TitleVersion,
                Style     = LabelStyles.DescriptionStyle.FromResources <Style>(),
                TextColor = MainStyles.LightTextColor.FromResources <Color>(),
                Opacity   = 0.5
            };

            var txtNumberVersion = new Label
            {
                Text  = contentUI.TxtVersionValue,
                Style = LabelStyles.DescriptionLightStyle.FromResources <Style>()
            };

            var stackVersion = new StackLayout
            {
                Children =
                {
                    txtTitleVersion,
                    txtNumberVersion
                }
            };

            #endregion

            #region Developer info

            var txtTitleDeveloper = new Label
            {
                Text      = contentUI.TitleDeveloper,
                Style     = LabelStyles.DescriptionStyle.FromResources <Style>(),
                TextColor = MainStyles.LightTextColor.FromResources <Color>(),
                Opacity   = 0.5
            };

            #region Phone

            var txtPhoneSymbol = new Label
            {
                Text      = contentUI.TxtPhoneSymbol,
                Style     = LabelStyles.DescriptionStyle.FromResources <Style>(),
                TextColor = MainStyles.LightTextColor.FromResources <Color>()
            };

            var txtPhone = new Label
            {
                Text      = contentUI.TxtPhoneValue,
                Style     = LabelStyles.DescriptionStyle.FromResources <Style>(),
                TextColor = MainStyles.LightTextColor.FromResources <Color>()
            };

            var tapPhone = new TapGestureRecognizer
            {
                CommandParameter = contentUI.TxtPhoneValue
            };
            tapPhone.Tapped += viewModel.TxtPhone_Click;

            var stackPhone = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    txtPhoneSymbol,
                    txtPhone
                }
            };

            stackPhone.GestureRecognizers.Add(tapPhone);

            #endregion

            #region Email

            var txtEmailSymbol = new Label
            {
                Text      = contentUI.TxtEmailSymbol,
                Style     = LabelStyles.DescriptionStyle.FromResources <Style>(),
                TextColor = MainStyles.LightTextColor.FromResources <Color>()
            };

            var txtEmail = new Label
            {
                Text      = contentUI.TxtEmailValue,
                Style     = LabelStyles.LinkStyle.FromResources <Style>(),
                TextColor = MainStyles.LightTextColor.FromResources <Color>()
            };

            var tapEmail = new TapGestureRecognizer
            {
                CommandParameter = contentUI.TxtEmailValue
            };
            tapEmail.Tapped += viewModel.TxtEmail_Click;

            var stackEmail = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    txtEmailSymbol,
                    txtEmail
                }
            };

            stackEmail.GestureRecognizers.Add(tapEmail);

            #endregion

            #region Http

            var txtHttpSymbol = new Label
            {
                Text      = contentUI.TxtHttpSymbol,
                Style     = LabelStyles.DescriptionStyle.FromResources <Style>(),
                TextColor = MainStyles.LightTextColor.FromResources <Color>()
            };

            var txtHttp = new Label
            {
                Text      = contentUI.TxtHttpValue,
                Style     = LabelStyles.LinkStyle.FromResources <Style>(),
                TextColor = MainStyles.LightTextColor.FromResources <Color>()
            };

            var tapHttp = new TapGestureRecognizer
            {
                CommandParameter = contentUI.TxtHttpValue
            };
            tapHttp.Tapped += viewModel.TxtLink_Click;

            var stackHttp = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    txtHttpSymbol,
                    txtHttp
                }
            };

            stackHttp.GestureRecognizers.Add(tapHttp);

            #endregion

            var stackDeveloper = new StackLayout
            {
                Children =
                {
                    txtTitleDeveloper,
                    stackPhone,
                    stackEmail,
                    stackHttp
                }
            };

            #endregion

            var stackAbout = new StackLayout
            {
                Padding  = 24,
                Spacing  = 20,
                Children =
                {
                    imgLogo,
                    txtTitle,
                    stackDescription,
                    stackVersion,
                    stackDeveloper
                }
            };

            var scrollView = new ScrollView
            {
                Content = stackAbout
            };

            var safeAreaHelper = new SafeAreaHelper();
            safeAreaHelper.UseSafeArea(this, SafeAreaHelper.CustomSafeAreaFlags.Top);
            safeAreaHelper.UseSafeArea(appBar.BtnBack, SafeAreaHelper.CustomSafeAreaFlags.Left);
            safeAreaHelper.UseSafeArea(scrollView, SafeAreaHelper.CustomSafeAreaFlags.Horizontal);

            ContentLayout.Children.Add(appBar);
            ContentLayout.Children.Add(scrollView);
        }
Exemplo n.º 3
0
        public MainPage()
            : base(typeof(MainViewModel), typeof(MainContentUI),
                   Device.Idiom == TargetIdiom.Phone ? PanelSetEnum.psLeftRight : PanelSetEnum.psRight)
        {
            BackgroundColor = MainStyles.ListBackgroundColor.FromResources <Color>();

            appBar = new TitleBar(this, TitleBar.BarBtnEnum.bbLeftRight, TitleBar.BarAlignEnum.baBottom)
            {
                BarColor = Color.Transparent,
                BtnRight =
                {
                    Source = contentUI.IconMenuSideBar
                }
            };

            appBar.BtnRight.Click += viewModel.AppBar_BtnRightClick;

            MapLocation = new MapTile
            {
                HasScrollEnabled = true,
                HasZoomEnabled   = true,
                Context          = contentUI
            };

            MapLocation.ClickPinDetail += viewModel.MapLocation_ClickPinDetail;

            mainLayout = new RelativeLayout();
            mainLayout.Children.Add(MapLocation.MapLayout,
                                    Constraint.Constant(0),
                                    Constraint.Constant(0),
                                    Constraint.RelativeToParent(parent => parent.Width),
                                    Constraint.RelativeToParent(parent => parent.Height));

            mainLayout.Children.Add(appBar,
                                    Constraint.Constant(0),
                                    Constraint.RelativeToParent(
                                        parent => parent.Height - appBar.HeightBar - appBar.Margin.VerticalThickness),
                                    Constraint.RelativeToParent(parent => parent.Width));

            PanelChanged += (sender, args) =>
            {
                if (args.IsShow)
                {
                    MapLocation.CloseDetailInfo();
                }
            };

            InitPanelsAndLayout();

            var safeAreaHelper = new SafeAreaHelper();

            safeAreaHelper.UseSafeArea(this, SafeAreaHelper.CustomSafeAreaFlags.None);
            safeAreaHelper.UseSafeArea(appBar,
                                       SafeAreaHelper.CustomSafeAreaFlags.Horizontal | SafeAreaHelper.CustomSafeAreaFlags.Bottom);
            safeAreaHelper.UseSafeArea(RightPanel.Content,
                                       SafeAreaHelper.CustomSafeAreaFlags.Top | SafeAreaHelper.CustomSafeAreaFlags.Right);
            if (LeftPanel != null)
            {
                safeAreaHelper.UseSafeArea(LeftPanel.Content,
                                           SafeAreaHelper.CustomSafeAreaFlags.Top | SafeAreaHelper.CustomSafeAreaFlags.Left);
            }
            if (btnLocation != null)
            {
                safeAreaHelper.UseSafeArea(btnLocation, SafeAreaHelper.CustomSafeAreaFlags.Left);
            }
            if (Device.RuntimePlatform == Device.Android)
            {
                safeAreaHelper.UseSafeArea(MapLocation.MapPinDetail, SafeAreaHelper.CustomSafeAreaFlags.All);
            }

            ContentLayout.Children.Add(mainLayout);
        }
Exemplo n.º 4
0
        public DiscountPage()
            : base(typeof(DiscountViewModel), typeof(DiscountContentUI), PanelSetEnum.psRight)
        {
            BackgroundColor         = MainStyles.StatusBarColor.FromResources <Color>();
            Content.BackgroundColor = MainStyles.MainLightBackgroundColor.FromResources <Color>();

            var appBar = new TitleBar(this, TitleBar.BarBtnEnum.bbBackRight)
            {
                BarColor = MainStyles.StatusBarColor.FromResources <Color>(),
                BtnBack  =
                {
                    Source = contentUI.IconBack
                },
                BtnRight =
                {
                    Triggers                 =
                    {
                        new DataTrigger(typeof(ImageButton))
                        {
                            Binding = new Binding("IsCustomFiltering"),
                            Value   = true,
                            Setters =
                            {
                                new Setter
                                {
                                    Property = ImageButton.SourceProperty,
                                    Value    = contentUI.IconMoreFilter
                                }
                            }
                        },
                        new DataTrigger(typeof(ImageButton))
                        {
                            Binding = new Binding("IsCustomFiltering"),
                            Value   = false,
                            Setters =
                            {
                                new Setter
                                {
                                    Property = ImageButton.SourceProperty,
                                    Value    = contentUI.IconMore
                                }
                            }
                        }
                    }
                }
            };

            appBar.BtnRight.Click += BtnFilter_Click;

            InitSearchBar(appBar);
            InitFilterPanel();

            var listViewFooter = new ContentView
            {
                HeightRequest = 4
            };

            var discountListView = new ListView(ListViewCachingStrategy.RetainElement)
            {
                BackgroundColor     = MainStyles.MainLightBackgroundColor.FromResources <Color>(),
                SeparatorVisibility = SeparatorVisibility.None,
                SelectionMode       = ListViewSelectionMode.None,
                ItemTemplate        = new DataTemplate(typeof(DiscountItemTemplate)),
                RowHeight           = Functions.OnPlatform(125, 135),
                Header = new ContentView
                {
                    HeightRequest = 4
                },
                Footer = new ContentView
                {
                    Content = listViewFooter
                }
            };

            discountListView.SetBinding(ListView.ItemsSourceProperty, "DiscountItems");
            discountListView.SetBinding(IsVisibleProperty, "HasDiscountItems");
            discountListView.ItemSelected += (sender, args) => ((ListView)sender).SelectedItem = null;
            discountListView.ItemTapped   += viewModel.OnDiscountItemTapped;

            var emptyLabel = new Label
            {
                Style             = LabelStyles.EmptyListLabelStyle.FromResources <Style>(),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Text = contentUI.TxtEmptyList
            };

            emptyLabel.SetBinding(IsVisibleProperty, "HasNoDiscountItems");

            var safeAreaHelper = new SafeAreaHelper();

            safeAreaHelper.UseSafeArea(this, SafeAreaHelper.CustomSafeAreaFlags.Top);
            safeAreaHelper.UseSafeArea(appBar.BtnBack, SafeAreaHelper.CustomSafeAreaFlags.Left);
            safeAreaHelper.UseSafeArea(appBar.BtnRight, SafeAreaHelper.CustomSafeAreaFlags.Right);
            safeAreaHelper.UseSafeArea(RightPanel.Content, SafeAreaHelper.CustomSafeAreaFlags.Right);
            safeAreaHelper.UseSafeArea(discountListView, SafeAreaHelper.CustomSafeAreaFlags.Horizontal);
            safeAreaHelper.UseSafeArea(listViewFooter, SafeAreaHelper.CustomSafeAreaFlags.Bottom);
            safeAreaHelper.UseSafeArea(emptyLabel, SafeAreaHelper.CustomSafeAreaFlags.Horizontal);

            ContentLayout.Children.Add(appBar);
            ContentLayout.Children.Add(discountListView);
            ContentLayout.Children.Add(emptyLabel);
        }
Exemplo n.º 5
0
        public SettingsPage()
            : base(typeof(SettingsViewModel), typeof(SettingsContentUI))
        {
            BackgroundColor         = MainStyles.StatusBarColor.FromResources <Color>();
            Content.BackgroundColor = MainStyles.MainBackgroundColor.FromResources <Color>();

            var loadingColor = MainStyles.LoadingColor.FromResources <Color>();

            LoadingActivityIndicator.Color = loadingColor;
            LoadingActivityText.TextColor  = loadingColor;

            var appBar = new TitleBar(this, TitleBar.BarBtnEnum.bbBack)
            {
                BarColor   = MainStyles.StatusBarColor.FromResources <Color>(),
                TitleStyle = LabelStyles.PageTitleStyle.FromResources <Style>(),
                BtnBack    =
                {
                    Source = contentUI.IconBack
                }
            };

            appBar.SetBinding(TitleBar.TitleProperty, "Title");

            #region Language setting

            var txtLangTitle = new Label
            {
                Style = LabelStyles.SettingStyle.FromResources <Style>()
            };
            txtLangTitle.SetBinding(Label.TextProperty, "CurrentLanguageTitle");

            var txtLangValue = new Label
            {
                Style = LabelStyles.SettingHintStyle.FromResources <Style>()
            };
            txtLangValue.SetBinding(Label.TextProperty, "CurrLanguageName");

            var stackLang = new StackLayout
            {
                Children =
                {
                    txtLangTitle,
                    txtLangValue
                }
            };

            var tapLang = new TapGestureRecognizer();
            tapLang.Tapped += viewModel.LangSetting_Click;
            stackLang.GestureRecognizers.Add(tapLang);

            #endregion

            #region Push notifications setting

            var txtPushNotifications = new Label
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Center,
                Style             = LabelStyles.SettingStyle.FromResources <Style>()
            };
            txtPushNotifications.SetBinding(Label.TextProperty, "PushNotificationsTitle");

            var switchPushNotifications = new Switch
            {
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Center,
                OnColor           = MainStyles.SwitchColor.FromResources <Color>()
            };
            switchPushNotifications.SetBinding(Switch.IsToggledProperty, "IsPushEnabled");

            var stackPushNotifications = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Spacing           = 0,
                Children          =
                {
                    txtPushNotifications,
                    switchPushNotifications
                }
            };

            var tapPushNotifications = new TapGestureRecognizer();
            tapPushNotifications.Tapped += viewModel.SwitchPushNotifications_Toggled;
            stackPushNotifications.GestureRecognizers.Add(tapPushNotifications);

            #endregion

            var btnUpdateDb = new ButtonExtended
            {
                Style = LabelStyles.ButtonStyle.FromResources <Style>()
            };
            btnUpdateDb.SetBinding(Button.TextProperty, "UpdateDbTitle");
            btnUpdateDb.SetBinding(IsEnabledProperty, "IsNotLoading");
            btnUpdateDb.Clicked += viewModel.BtnUpdateDb_Clicked;

            var activityIndicator = new ActivityIndicator
            {
                Color             = loadingColor,
                HorizontalOptions = LayoutOptions.Center
            };
            activityIndicator.SetBinding(IsVisibleProperty, "IsUpdating");
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsUpdating");

            var txtProgress = new Label
            {
                Style = LabelStyles.DescriptionLightStyle.FromResources <Style>(),
                HorizontalTextAlignment = TextAlignment.Center
            };
            txtProgress.SetBinding(Label.TextProperty, "ProcessMessage");

            var layoutSettings = new StackLayout
            {
                Spacing  = 20,
                Padding  = 24,
                Children =
                {
                    stackLang,
                    stackPushNotifications,
                    btnUpdateDb,
                    activityIndicator,
                    txtProgress
                }
            };

            var safeAreaHelper = new SafeAreaHelper();
            safeAreaHelper.UseSafeArea(this, SafeAreaHelper.CustomSafeAreaFlags.Top);
            safeAreaHelper.UseSafeArea(appBar.BtnBack, SafeAreaHelper.CustomSafeAreaFlags.Left);
            safeAreaHelper.UseSafeArea(layoutSettings, SafeAreaHelper.CustomSafeAreaFlags.Horizontal);

            ContentLayout.Children.Add(appBar);
            ContentLayout.Children.Add(layoutSettings);
        }
Exemplo n.º 6
0
        public DiscountDetailPage(DiscountDetailData discountDetailData)
            : base(typeof(DiscountDetailViewModel), typeof(DiscountDetailContentUI))
        {
            BackgroundColor         = MainStyles.StatusBarColor.FromResources <Color>();
            Content.BackgroundColor = MainStyles.MainLightBackgroundColor.FromResources <Color>();

            viewModel.SetDiscount(discountDetailData);

            var mainLayout = new AbsoluteLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var appBar = new TitleBar(this, TitleBar.BarBtnEnum.bbBack)
            {
                BarColor   = Color.Transparent,
                BoxPadding =
                {
                    BackgroundColor = MainStyles.StatusBarColor.FromResources <Color>()
                },
                BtnBack =
                {
                    BackgroundColor = MainStyles.StatusBarColor.FromResources <Color>(),
                    Source          = contentUI.IconBack
                }
            };

            #region Photo

            var imageLayout = new RelativeLayout
            {
                HeightRequest = Device.Idiom == TargetIdiom.Phone ? 200 : 400
            };

            var fileNameConverter = new FileNameToImageConverter();
            var imgPhoto          = new Image
            {
                Aspect = Aspect.AspectFill
            };
            imgPhoto.SetBinding(Image.SourceProperty,
                                new Binding("ImageFileName", BindingMode.Default, fileNameConverter, true));

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

            #endregion

            #region Label percent

            const int sizeImgLabel = 60;

            var imgLabel = new Image
            {
                HeightRequest = sizeImgLabel,
                WidthRequest  = sizeImgLabel,
                Source        = contentUI.ImgPercentLabel
            };

            var labelLayout = new AbsoluteLayout();
            AbsoluteLayout.SetLayoutFlags(imgLabel, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(imgLabel, new Rectangle(0f, 0f, 1f, 1f));
            labelLayout.Children.Add(imgLabel);

            imageLayout.Children.Add(labelLayout,
                                     Constraint.RelativeToParent(parent => parent.Width - sizeImgLabel - 5),
                                     Constraint.RelativeToView(imgPhoto,
                                                               (parent, sibling) => sibling.Y + sibling.Height - sizeImgLabel - 5));

            var spanDiscountPercent = new Span
            {
                Style = LabelStyles.LabelPercentStyle.FromResources <Style>()
            };
            spanDiscountPercent.SetBinding(Span.TextProperty, "DiscountPercent", BindingMode.OneWay);

            var spanDiscountType = new Span
            {
                Style = LabelStyles.LabelPercentSymbolStyle.FromResources <Style>()
            };
            spanDiscountType.SetBinding(Span.TextProperty, "DiscountType", BindingMode.OneWay);

            var txtPercent = new Label
            {
                Rotation      = -15,
                TranslationY  = -1,
                FormattedText = new FormattedString
                {
                    Spans =
                    {
                        spanDiscountPercent,
                        spanDiscountType
                    }
                }
            };

            AbsoluteLayout.SetLayoutFlags(txtPercent, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(txtPercent,
                                           new Rectangle(0.5, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
            labelLayout.Children.Add(txtPercent);

            #endregion

            #region WebAddress & Category list

            var flexCategories = new FlexLayout
            {
                Direction      = FlexDirection.Row,
                Wrap           = FlexWrap.Wrap,
                JustifyContent = FlexJustify.Start,
                AlignItems     = FlexAlignItems.Center,
                AlignContent   = FlexAlignContent.Start,
                Margin         = new Thickness(20, 15, 15, 0)
            };

            foreach (var webAddress in viewModel.WebAddresses)
            {
                var imgWebAddress = new Image
                {
                    Source = webAddress.Type.GetWebAddressIcon()
                };

                var viewGesturesWebAddress = new ViewGestures
                {
                    Content         = imgWebAddress,
                    AnimationEffect = ViewGestures.AnimationType.atScaling,
                    AnimationScale  = -5,
                    Tag             = webAddress.Url,
                    Margin          = new Thickness(0, 0, 5, 5)
                };
                viewGesturesWebAddress.Tap += viewModel.TxtUrlAddress_Click;

                flexCategories.Children.Add(viewGesturesWebAddress);
            }

            var flexSeparator = new ContentView();
            FlexLayout.SetGrow(flexSeparator, 1);
            flexCategories.Children.Add(flexSeparator);

            foreach (var category in viewModel.Categories)
            {
                var categoryLayout = new CategoryItemTemplate
                {
                    Margin         = new Thickness(0, 0, 5, 5),
                    BindingContext = category
                };

                flexCategories.Children.Add(categoryLayout);
            }

            #endregion

            #region Name company

            var txtPartnerName = new Label
            {
                Style = LabelStyles.DetailTitleStyle.FromResources <Style>()
            };
            txtPartnerName.SetBinding(Label.TextProperty, "NameCompany");

            #endregion

            #region Description

            var txtDescription = new Label
            {
                Style         = LabelStyles.DescriptionStyle.FromResources <Style>(),
                LineBreakMode = LineBreakMode.WordWrap
            };
            txtDescription.SetBinding(Label.TextProperty, "Description");

            #endregion

            var stackDetails = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Padding     = new Thickness(20, 0),
                Children    =
                {
                    txtPartnerName,
                    txtDescription
                }
            };

            var discountLayout = new StackLayout
            {
                Spacing     = 0,
                Orientation = StackOrientation.Vertical,
                Children    =
                {
                    imageLayout,
                    flexCategories,
                    stackDetails
                }
            };

            foreach (var brachItem in viewModel.BranchItems)
            {
                var view = new BranchInfoViewTemplate(contentUI, viewModel).View;
                view.BindingContext = brachItem;

                discountLayout.Children.Add(view);
            }

            var scrollDiscount = new ScrollView
            {
                Content = discountLayout
            };

            AbsoluteLayout.SetLayoutFlags(scrollDiscount, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(scrollDiscount, new Rectangle(0f, 0f, 1f, 1f));
            mainLayout.Children.Add(scrollDiscount);

            AbsoluteLayout.SetLayoutFlags(appBar,
                                          AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.WidthProportional);
            AbsoluteLayout.SetLayoutBounds(appBar, new Rectangle(0f, 0f, 1f, AbsoluteLayout.AutoSize));
            mainLayout.Children.Add(appBar);

            var safeAreaHelper = new SafeAreaHelper();
            safeAreaHelper.UseSafeArea(this, SafeAreaHelper.CustomSafeAreaFlags.Top);
            safeAreaHelper.UseSafeArea(appBar.BtnBack, SafeAreaHelper.CustomSafeAreaFlags.Left);
            safeAreaHelper.UseSafeArea(scrollDiscount, SafeAreaHelper.CustomSafeAreaFlags.Horizontal);

            ContentLayout.Children.Add(mainLayout);
        }
Exemplo n.º 7
0
        public SettingsPage()
            : base(typeof(SettingsViewModel), typeof(SettingsContentUI))
        {
            BackgroundColor         = MainStyles.StatusBarColor.FromResources <Color>();
            Content.BackgroundColor = MainStyles.MainBackgroundColor.FromResources <Color>();

            var appBar = new TitleBar(this, TitleBar.BarBtnEnum.bbBack)
            {
                BarColor   = MainStyles.StatusBarColor.FromResources <Color>(),
                TitleStyle = LabelStyles.PageTitleStyle.FromResources <Style>(),
                BtnBack    =
                {
                    Source = contentUI.IconBack
                }
            };

            appBar.SetBinding(TitleBar.TitleProperty, "Title");

            #region Language setting

            var txtLangTitle = new Label
            {
                Style = LabelStyles.SettingStyle.FromResources <Style>()
            };
            txtLangTitle.SetBinding(Label.TextProperty, "CurrentLanguageTitle");

            var txtLangValue = new Label
            {
                Style = LabelStyles.SettingHintStyle.FromResources <Style>()
            };
            txtLangValue.SetBinding(Label.TextProperty, "CurrLanguageName");

            var stackLang = new StackLayout
            {
                Children =
                {
                    txtLangTitle,
                    txtLangValue
                }
            };

            var tapGestureRecognizer = new TapGestureRecognizer();
            tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandParameterProperty, "TypeName");
            tapGestureRecognizer.Tapped += viewModel.LangSetting_Click;
            stackLang.GestureRecognizers.Add(tapGestureRecognizer);

            #endregion

            var btnUpdateDb = new ButtonExtended
            {
                Style = LabelStyles.ButtonStyle.FromResources <Style>()
            };
            btnUpdateDb.SetBinding(Button.TextProperty, "UpdateDbTitle");
            btnUpdateDb.SetBinding(IsEnabledProperty, "IsNotLoading");
            btnUpdateDb.Clicked += viewModel.BtnUpdateDb_Clicked;

            var activityIndicator = new ActivityIndicator
            {
                Color             = Color.White,
                HorizontalOptions = LayoutOptions.Center
            };
            activityIndicator.SetBinding(IsVisibleProperty, "IsLoading");
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsLoading");

            var txtProgress = new Label
            {
                Style                   = LabelStyles.DescriptionStyle.FromResources <Style>(),
                LineBreakMode           = LineBreakMode.WordWrap,
                HorizontalTextAlignment = TextAlignment.Center,
                TextColor               = Color.White
            };
            txtProgress.SetBinding(Label.TextProperty, "ProcessMessage");

            var layoutSettings = new StackLayout
            {
                Spacing  = 20,
                Padding  = 24,
                Children =
                {
                    stackLang,
                    btnUpdateDb,
                    activityIndicator,
                    txtProgress
                }
            };

            var safeAreaHelper = new SafeAreaHelper();
            safeAreaHelper.UseSafeArea(this, SafeAreaHelper.CustomSafeAreaFlags.Top);
            safeAreaHelper.UseSafeArea(appBar.BtnBack, SafeAreaHelper.CustomSafeAreaFlags.Left);
            safeAreaHelper.UseSafeArea(layoutSettings, SafeAreaHelper.CustomSafeAreaFlags.Horizontal);

            ContentLayout.Children.Add(appBar);
            ContentLayout.Children.Add(layoutSettings);
        }
        public DiscountDetailPage(DiscountDetailData discountDetailData)
            : base(typeof(DiscountDetailViewModel), typeof(DiscountDetailContentUI))
        {
            BackgroundColor         = MainStyles.StatusBarColor.FromResources <Color>();
            Content.BackgroundColor = MainStyles.MainLightBackgroundColor.FromResources <Color>();

            var loadingColor = MainStyles.LoadingColor.FromResources <Color>();

            LoadingActivityIndicator.Color = loadingColor;
            LoadingActivityText.TextColor  = loadingColor;

            viewModel.SetDiscount(discountDetailData);

            var mainLayout = new AbsoluteLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var appBar = new TitleBar(this, TitleBar.BarBtnEnum.bbBack)
            {
                BarColor   = Color.Transparent,
                BoxPadding =
                {
                    BackgroundColor = MainStyles.StatusBarColor.FromResources <Color>()
                },
                BtnBack =
                {
                    BackgroundColor = MainStyles.StatusBarColor.FromResources <Color>(),
                    Source          = contentUI.IconBack
                }
            };

            #region Label percent

            const int sizeImgLabel = 60;

            var imgLabel = new Image
            {
                HeightRequest = sizeImgLabel,
                WidthRequest  = sizeImgLabel,
                Source        = contentUI.ImgPercentLabel
            };

            var labelLayout = new AbsoluteLayout
            {
                InputTransparent = true
            };
            AbsoluteLayout.SetLayoutFlags(imgLabel, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(imgLabel, new Rectangle(0f, 0f, 1f, 1f));
            labelLayout.Children.Add(imgLabel);

            var spanDiscountPercent = new Span
            {
                Style = LabelStyles.LabelPercentStyle.FromResources <Style>()
            };
            spanDiscountPercent.SetBinding(Span.TextProperty, nameof(DiscountDetailViewModel.DiscountPercent));

            var spanDiscountType = new Span
            {
                Style = LabelStyles.LabelPercentSymbolStyle.FromResources <Style>()
            };
            spanDiscountType.SetBinding(Span.TextProperty, nameof(DiscountDetailViewModel.DiscountType));

            var txtPercent = new Label
            {
                Rotation      = -15,
                TranslationY  = -1,
                FormattedText = new FormattedString
                {
                    Spans =
                    {
                        spanDiscountPercent,
                        spanDiscountType
                    }
                }
            };

            AbsoluteLayout.SetLayoutFlags(txtPercent, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(txtPercent,
                                           new Rectangle(0.5, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
            labelLayout.Children.Add(txtPercent);

            #endregion

            #region WebAddress & Category list

            var flexCategories = new FlexLayout
            {
                Direction      = FlexDirection.Row,
                Wrap           = FlexWrap.Wrap,
                JustifyContent = FlexJustify.Start,
                AlignItems     = FlexAlignItems.Center,
                AlignContent   = FlexAlignContent.Start,
                Margin         = new Thickness(20, 15, 15, 0)
            };

            const int sizeWebAddress = 40;

            foreach (var webAddress in viewModel.WebAddresses)
            {
                var imgWebAddress = new Image
                {
                    Source        = webAddress.Type.GetWebAddressIcon(),
                    Margin        = new Thickness(0, 0, 5, 5),
                    WidthRequest  = sizeWebAddress,
                    HeightRequest = sizeWebAddress
                };

                var tapWebAddress = new TapGestureRecognizer
                {
                    CommandParameter = webAddress.Url
                };
                tapWebAddress.Tapped += viewModel.TxtUrlAddress_Click;

                imgWebAddress.GestureRecognizers.Add(tapWebAddress);

                flexCategories.Children.Add(imgWebAddress);
            }

            var flexSeparator = new ContentView();
            FlexLayout.SetGrow(flexSeparator, 1);
            flexCategories.Children.Add(flexSeparator);

            foreach (var category in viewModel.Categories)
            {
                var categoryLayout = new CategoryItemTemplate
                {
                    Margin         = new Thickness(0, 0, 5, 5),
                    BindingContext = category
                };

                flexCategories.Children.Add(categoryLayout);
            }

            #endregion

            #region Carousel images

            var carouselView = new CarouselViewControl
            {
                Orientation  = CarouselViewOrientation.Horizontal,
                ItemTemplate = new DataTemplate(typeof(GalleryImageItemTemplate)),
                CurrentPageIndicatorTintColor = MainStyles.MainBackgroundColor.FromResources <Color>()
            };
            carouselView.SetBinding(CarouselViewControl.ItemsSourceProperty,
                                    nameof(DiscountDetailViewModel.GalleryImages));
            carouselView.SetBinding(CarouselViewControl.ShowIndicatorsProperty,
                                    nameof(DiscountDetailViewModel.HasGalleryImages));
            carouselView.SetBinding(CarouselViewControl.IsSwipeEnabledProperty,
                                    nameof(DiscountDetailViewModel.HasGalleryImages));

            var carouselLayout = new RelativeLayout
            {
                VerticalOptions = LayoutOptions.Start
            };

            carouselLayout.Children.Add(carouselView,
                                        Constraint.Constant(0),
                                        Constraint.Constant(0),
                                        Constraint.RelativeToParent(parent => parent.Width),
                                        Constraint.RelativeToParent(parent =>
                                                                    Device.Info.CurrentOrientation.IsPortrait() ? parent.Width * 0.5625 :
                                                                    Device.Idiom == TargetIdiom.Phone ? 200 : 400));

            carouselLayout.Children.Add(labelLayout,
                                        Constraint.RelativeToView(carouselView, (parent, view) => view.Width - sizeImgLabel - 5),
                                        Constraint.RelativeToView(carouselView, (parent, view) => view.Height - sizeImgLabel - 5));

            #endregion

            #region Name company

            var txtPartnerName = new Label
            {
                Style  = LabelStyles.DetailTitleStyle.FromResources <Style>(),
                Margin = new Thickness(20, 0)
            };
            txtPartnerName.SetBinding(Label.TextProperty, nameof(DiscountDetailViewModel.NameCompany));

            #endregion

            #region Description

            var txtDescription = new Label
            {
                Style         = LabelStyles.DescriptionStyle.FromResources <Style>(),
                Margin        = new Thickness(20, 10, 20, 0),
                LineBreakMode = LineBreakMode.WordWrap
            };
            txtDescription.SetBinding(Label.TextProperty, nameof(DiscountDetailViewModel.Description));

            #endregion

            #region Rating view

            var ratingView = new RatingView
            {
                Style = LabelStyles.RatingStyle.FromResources <Style>()
            };
            ratingView.SetBinding(RatingView.ValueProperty, nameof(DiscountDetailViewModel.UserRating));

            var ratingLabel = new Label
            {
                Style           = LabelStyles.DescriptionStyle.FromResources <Style>(),
                VerticalOptions = LayoutOptions.End
            };
            ratingLabel.SetBinding(Label.TextProperty, nameof(DiscountDetailViewModel.RatingString));
            ratingLabel.SetBinding(IsVisibleProperty, nameof(DiscountDetailViewModel.IsDiscountRatingAvailable));

            var activityIndicator = new ActivityIndicator
            {
                Color             = Color.FromHex("444"),
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.End,
                WidthRequest      = 20,
                HeightRequest     = 20
            };
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(DiscountDetailViewModel.IsLoadingRating));
            activityIndicator.SetBinding(IsVisibleProperty, nameof(DiscountDetailViewModel.IsLoadingRating));

            var stackRating = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Margin      = new Thickness(20, 0),
                Spacing     = 10,
                Children    =
                {
                    ratingView,
                    ratingLabel,
                    activityIndicator
                }
            };

            #endregion

            var discountLayout = new StackLayout
            {
                Spacing     = 0,
                Orientation = StackOrientation.Vertical,
                Children    =
                {
                    carouselLayout,
                    flexCategories,
                    txtPartnerName,
                    stackRating,
                    txtDescription
                }
            };

            foreach (var brachItem in viewModel.BranchItems)
            {
                var view = new BranchInfoViewTemplate(contentUI, viewModel)
                {
                    BindingContext = brachItem
                };

                discountLayout.Children.Add(view);
            }

            var scrollDiscount = new ScrollView
            {
                Content = discountLayout
            };

            AbsoluteLayout.SetLayoutFlags(scrollDiscount, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(scrollDiscount, new Rectangle(0f, 0f, 1f, 1f));
            mainLayout.Children.Add(scrollDiscount);

            AbsoluteLayout.SetLayoutFlags(appBar,
                                          AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.WidthProportional);
            AbsoluteLayout.SetLayoutBounds(appBar, new Rectangle(0f, 0f, 1f, AbsoluteLayout.AutoSize));
            mainLayout.Children.Add(appBar);

            var safeAreaHelper = new SafeAreaHelper();
            safeAreaHelper.UseSafeArea(this, SafeAreaHelper.CustomSafeAreaFlags.Top);
            safeAreaHelper.UseSafeArea(appBar.BtnBack, SafeAreaHelper.CustomSafeAreaFlags.Left);
            safeAreaHelper.UseSafeArea(scrollDiscount, SafeAreaHelper.CustomSafeAreaFlags.Horizontal);

            ContentLayout.Children.Add(mainLayout);
        }