-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSignUpPage.xaml.cs
executable file
·42 lines (37 loc) · 1.02 KB
/
SignUpPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Linq;
using Xamarin.Forms;
namespace LoginNavigation
{
public partial class SignUpPage : ContentPage
{
public SignUpPage ()
{
InitializeComponent ();
}
async void OnSignUpButtonClicked (object sender, EventArgs e)
{
var user = new User () {
Username = usernameEntry.Text,
Password = passwordEntry.Text,
Email = emailEntry.Text
};
// Sign up logic goes here
var signUpSucceeded = AreDetailsValid (user);
if (signUpSucceeded) {
var rootPage = Navigation.NavigationStack.FirstOrDefault ();
if (rootPage != null) {
App.IsUserLoggedIn = true;
Navigation.InsertPageBefore (new MainPage (), Navigation.NavigationStack.First ());
await Navigation.PopToRootAsync ();
}
} else {
messageLabel.Text = "Sign up failed";
}
}
bool AreDetailsValid (User user)
{
return (!string.IsNullOrWhiteSpace (user.Username) && !string.IsNullOrWhiteSpace (user.Password) && !string.IsNullOrWhiteSpace (user.Email) && user.Email.Contains ("@"));
}
}
}