Пример #1
0
        public LoginPage()
        {
            //BACKGROUND COLOR
            //BackgroundColor = Color.FromHex ("#298555");
            BackgroundColor = MyColors.MyLightPurple;
            NavigationPage.SetHasNavigationBar(this, false);

            //LABEL
            Label welcomeLabel = new Label {
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Start, Text = "Thoughts and Prayers",
                //TextColor = Color.White
                TextColor = MyColors.MidnightBlue
            };

            Label deleteSpacingLabel = new Label {
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Start, Text = "      ",
                TextColor = Color.White
            };


            welcomeLabel.FontFamily = Device.OnPlatform(
                iOS: "AppleSDGothicNeo-Light",
                Android: "Droid Sans Mono",
                WinPhone: "Comic Sans MS"
                );

            //BUTTON
            Button loginButton = new StyledButton(StyledButton.Borders.Thin, 1);

            loginButton.Text = "Facebook Login";
            //loginButton.WidthRequest = 50;

            //loginButton.Clicked += (sender, e) =>

            //{
            //	if (AppConstants.Authenticated == false)
            //	{
            //		Device.BeginInvokeOnMainThread (NextMethod ());
            //	}
            //	else
            //	{
            //		Navigation.PushModalAsync (new StartingMasterDetailPage ());
            //	}

            loginButton.Clicked += async(sender, e) => {
                if (AppConstants.Authenticated == false)
                {
                    if (App.Authenticator != null)
                    {
                        AppConstants.Authenticated = await App.Authenticator.Authenticate();

                        if (AppConstants.Authenticated)
                        {
                            //great but not too many Dependency service
                            //var  userinfo = await DependencyService.Get<IFacebookID> ().GetFacebookIdAsync ();

                            //AppConstants.FBIdentityID = userinfo;



                            //int j =10;
                        }
                    }
                }
                else
                {
                    Navigation.PushModalAsync(new StartingMasterDetailPage());
                }
            };

//				{
            //November 2016
            //Navigation.PushAsync (new NavigationPage (new SamplePage ()) { //BarBackgroundColor = Color.Black  }   );  //FromHex ("#298555")

            //December 01.2016 - FREEZE
            //Navigation.PushAsync (new SamplePage ());

            //DECEMBER 05.2016
            //Navigation.PushAsync (new TheTabbedPage ());
            //Navigation.RemovePage (this);


            //try
            //			{
//					var cloudService = ServiceLocator.Instance.Resolve<ICloudService> ();
//					cloudService.LoginAsync ();
            //Application.Current.MainPage = new NavigationPage (new StartingMasterDetailPage ()); //Pages.TaskList ());

            //} catch (Exception ex) {

            //ADDING FACEBOOK LOGIN
            //					//DECEMBER 06.2016
//					Navigation.PushModalAsync (new StartingMasterDetailPage ());

//				});



//			};

            //https://forums.xamarin.com/discussion/18670/define-layout-sizes-in-inches-with-idisplay-extension-code-only

            //SET THE CONTENT ON THE PAGE
            Content = new StackLayout
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Children          =
                {
                    welcomeLabel, deleteSpacingLabel, loginButton
                }
            };
        }
Пример #2
0
        public AddTapPage()
        {
            this.Title = "Add a Prayer Request";


            mySharedText.Text = "Hey guys, this is what's going on!";

            mySharedText.Focused   += myQuestion_Focused;
            mySharedText.Unfocused += myQuestion_Unfocused;

            //BUTTON
            Button submitButton = new StyledButton(StyledButton.Borders.Thin, 1);

            submitButton.Text = "Submit";
            submitButton.HorizontalOptions = LayoutOptions.FillAndExpand;
            //loginButton.WidthRequest = 50;

            submitButton.Clicked += (sender, e) => {
                Device.BeginInvokeOnMainThread(() => {
                    //Navigation.PushAsync (new SamplePage ());
                    System.Random random = new Random();
                    string randomNumber  = string.Join(string.Empty, Enumerable.Range(0, 10).Select(number => random.Next(0, 5).ToString()));

//public class Example
//		{
//			public static void Main ()
//			{
//				DateTime localDate = DateTime.Now;
//				String [] cultureNames = { "en-US", "en-GB", "fr-FR",
//								"de-DE", "ru-RU" };
//				foreach (var cultureName in cultureNames) {
//					var culture = new CultureInfo (cultureName);
//					Console.WriteLine ("{0}: {1}", cultureName,
//									  localDate.ToString (culture));
//				}
//			}
//		}
//		// The example displays the following output:
//		//       en-US: 6/19/2015 10:03:06 AM
//		//       en-GB: 19/06/2015 10:03:06
//		//       fr-FR: 19/06/2015 10:03:06
//		//       de-DE: 19.06.2015 10:03:06
//		//       ru-RU: 19.06.2015 10:03:06

//Works with Hi question
                    //String introQuestion = "Question - hi there";
                    //DateTime timeNow = DateTime.Now;
                    //var culture = new CultureInfo ("en-US");
                    //String stringTimeNow = timeNow.ToString (culture);

                    //SurveyQuestion oneSurveyQuestion = new SurveyQuestion ()
                    //{
                    //	Id = randomNumber,
                    ////						Id = "1234567891234",
                    //	Question = String.Format("{0} at {1}", introQuestion, stringTimeNow  ),
                    //	Answers = "Answer - hi there"
                    //};

//Works with a submit button
                    String introQuestion = "Question - hi there";
                    DateTime dt          = DateTime.Now;
                    //var culture = new CultureInfo ("en-US");
                    //String stringTimeNow = timeNow.ToString (culture);

                    CultureInfo ci = new CultureInfo("en-US");
                    string sampleDateTimeString = dt.ToString("MMM d h:mm tt", ci);                      // dt.ToString ("MMM d", ci);

                    SurveyQuestion oneSurveyQuestion = new SurveyQuestion()
                    {
                        Id = randomNumber,
                        //						Id = "1234567891234",
                        Question = "My question text",                         //myQuestion.Text, // String.Format ("{0} at {1}", introQuestion, stringTimeNow),
                        Answers  = "Answer - hi there",

                        FirstName        = "A",                 // firstName.Text,
                        LastName         = "C",                 // lastName.Text,
                        FullName         = String.Format("{0} {1}", firstName.Text, lastName.Text),
                        SharedText       = mySharedText.Text,   //this is the field that gets updated in Azure,
                        FBProfileUrl     = AppConstants.FullURLPlusFBIdentityID,
                        CreateDateString = sampleDateTimeString
                    };


                    App.Service.AddOrUpdateSurveyQuestionAsync(oneSurveyQuestion);
                    //App.Service.SynchronizeQuestionsAsync (oneSurveyQuestion.Id);
                    //AppConstants.NeedsUpdating == false;
                    AppConstants.NeedsUpdating = true;

                    Navigation.PopModalAsync();

                    //Navigation.PushAsync (new NavigationPage (new SamplePage ()) { //BarBackgroundColor = Color.Black  }   );  //FromHex ("#298555")
                    //															   //Navigation.
                });
            };

            Button cancelButton = new StyledButton(StyledButton.Borders.Thin, 1);

            cancelButton.Text = "Cancel";
            cancelButton.HorizontalOptions = LayoutOptions.FillAndExpand;

            cancelButton.Clicked += (sender, e) => {
                Device.BeginInvokeOnMainThread(() => {
                    //Navigation.PushAsync (new SamplePage ());

                    Navigation.PopModalAsync();


                    //Navigation.PushAsync (new NavigationPage (new SamplePage ()) { //BarBackgroundColor = Color.Black  }   );  //FromHex ("#298555")
                    //															   //Navigation.
                });
            };

            StackLayout myEnterTextStacklayout = new StackLayout {
                //Padding = new Thickness (10, 10, 10, 10),
                VerticalOptions = LayoutOptions.Start,
//				HorizontalOptions = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,

                Children =
                {
                    //new Label { Text = "Tell your friends what's on your mind" },
                    //prompt, myQuestion, fnPrompt, firstName, lnPrompt, lastName, mST, mySharedText, submitButton, cancelButton
                    //prompt, myQuestion, fnPrompt, firstName, lnPrompt, lastName,
                    mST, mySharedText
                }
            };


            StackLayout myButtonStacklayout = new StackLayout {
                Padding         = new Thickness(10, 10, 10, 10),
                Orientation     = StackOrientation.Horizontal,
                VerticalOptions = LayoutOptions.Start,
//				HorizontalOptions = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,

                Children =
                {
                    cancelButton, submitButton
                }
            };


            Content = new StackLayout {
                Padding         = new Thickness(10, 50, 10, 10),
                VerticalOptions = LayoutOptions.Start,
//				HorizontalOptions = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    myEnterTextStacklayout, myButtonStacklayout
                }
            };
        }