Esempio n. 1
0
        public ProviderPage()
        {
            AuthProviders aps = new AuthProviders();
            Dictionary <string, AuthProvider> AuthProviders = aps.AuthProviderDictionary;

            StackLayout ProviderList = new StackLayout();

            // TODO: what to do if no valid providers?
            foreach (AuthProvider p in AuthProviders.Values)
            {
                Button b = new Button()
                {
                    BackgroundColor = Color.White, HorizontalOptions = LayoutOptions.FillAndExpand
                };
                Image i = new Image()
                {
                    BackgroundColor = Color.White, HeightRequest = 30
                };
                StackLayout sl = new StackLayout {
                    BackgroundColor = Color.White, Orientation = StackOrientation.Horizontal, Children = { i, b }
                };
                ProviderList.Children.Add(sl);
#if false
                // Button image is too inflexible for use. It only offers resource  files as the source and not URIs or other image forms.
                //string defaultImageFolder = Device.OnPlatform(iOS: "Images/", Android: "", WinPhone: "Images/");
                //b.Image = defaultImageFolder + (string.IsNullOrEmpty(p.image) ? "oauth.png" : p.image);
#endif
                if (string.IsNullOrEmpty(p.image))
                {
                    i.Source = ImageSource.FromResource("OAuthForms1.oauth.jpg"); // PCL - must have "Build Action" set to "Embedded Resource". Note use of namespace.
                }
                else
                {
                    i.Source = ImageSource.FromUri(new Uri(p.image));
                }
                b.Text     = p.name;
                b.Clicked += (s, e) => { Navigation.PushModalAsync(new AuthenticatonPage(Auth.auth, AuthProviders[((Button)b).Text])); };
            }
            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Children        =
                {
                    new ScrollView {
                        Content =
                            ProviderList
                    }
                }
            };
        }
Esempio n. 2
0
        public ProviderPage()
        {
            AuthProviders aps = new AuthProviders();
            Dictionary<string, AuthProvider> AuthProviders = aps.AuthProviderDictionary;

            StackLayout ProviderList = new StackLayout();
            // TODO: what to do if no valid providers?
            foreach (AuthProvider p in AuthProviders.Values)
            {
                Button b = new Button() { BackgroundColor = Color.White, HorizontalOptions = LayoutOptions.FillAndExpand};
                Image i = new Image() { BackgroundColor = Color.White, HeightRequest = 30 };
                StackLayout sl = new StackLayout { BackgroundColor = Color.White, Orientation = StackOrientation.Horizontal, Children = { i, b } };
                ProviderList.Children.Add(sl);
            #if false
                // Button image is too inflexible for use. It only offers resource  files as the source and not URIs or other image forms.
                //string defaultImageFolder = Device.OnPlatform(iOS: "Images/", Android: "", WinPhone: "Images/");
                //b.Image = defaultImageFolder + (string.IsNullOrEmpty(p.image) ? "oauth.png" : p.image);
            #endif
                if (string.IsNullOrEmpty(p.image))
                    i.Source = ImageSource.FromResource("OAuthForms1.oauth.jpg"); // PCL - must have "Build Action" set to "Embedded Resource". Note use of namespace.
                else
                    i.Source = ImageSource.FromUri(new Uri(p.image));
                b.Text = p.name;
                b.Clicked += (s, e) => { Navigation.PushModalAsync(new AuthenticatonPage(Auth.auth, AuthProviders[((Button)b).Text])); };
            }
            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Children = {
                    new ScrollView {
                        Content =
                        ProviderList
                        }
                }
            };
        }