Did some work. Though it was a good idea to commit before something goes wrong.
This commit is contained in:
@@ -24,6 +24,7 @@ namespace Mear.Droid
|
|||||||
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
|
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
|
||||||
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
|
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
|
||||||
LoadApplication(new App());
|
LoadApplication(new App());
|
||||||
|
|
||||||
}
|
}
|
||||||
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
|
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,6 +55,15 @@
|
|||||||
<PackageReference Include="Plugin.MediaManager">
|
<PackageReference Include="Plugin.MediaManager">
|
||||||
<Version>0.6.1</Version>
|
<Version>0.6.1</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Plugin.MediaManager.Forms">
|
||||||
|
<Version>0.6.1</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="RestSharp">
|
||||||
|
<Version>106.6.9</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="sqlite-net-pcl">
|
||||||
|
<Version>1.5.231</Version>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Xamarin.Forms" Version="4.0.0.425677" />
|
<PackageReference Include="Xamarin.Forms" Version="4.0.0.425677" />
|
||||||
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.1" />
|
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.1" />
|
||||||
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.1" />
|
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.1" />
|
||||||
|
|||||||
@@ -124,8 +124,17 @@
|
|||||||
<Reference Include="System.Numerics.Vectors" />
|
<Reference Include="System.Numerics.Vectors" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Xamarin.Forms" Version="3.6.0.264807" />
|
<PackageReference Include="Plugin.MediaManager.Forms">
|
||||||
<PackageReference Include="Xamarin.Essentials" Version="1.0.1" />
|
<Version>0.6.1</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="RestSharp">
|
||||||
|
<Version>106.6.9</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="sqlite-net-pcl">
|
||||||
|
<Version>1.5.231</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Xamarin.Forms" Version="4.0.0.425677" />
|
||||||
|
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -12,7 +12,7 @@ namespace Mear
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
MainPage = new MusicLibrary();
|
MainPage = new Landing();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnStart()
|
protected override void OnStart()
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mear.Constants.API
|
||||||
|
{
|
||||||
|
public class API
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
private static string _apiUrl = @"https://www..com/";
|
||||||
|
private string _apiVersion;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
public static string ApiUrl
|
||||||
|
{
|
||||||
|
get => _apiUrl;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using RestSharp;
|
||||||
|
|
||||||
|
using Mear.Constants.API;
|
||||||
|
using Mear.Models.Authentication;
|
||||||
|
|
||||||
|
namespace Mear.Managers
|
||||||
|
{
|
||||||
|
public class LoginManager
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
private User _user;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
public LoginManager(User user)
|
||||||
|
{
|
||||||
|
_user = user;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
public LoginResult Login()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var client = new RestClient(API.ApiUrl);
|
||||||
|
var request = new RestRequest(@"api/login", Method.POST);
|
||||||
|
var userJson = JsonConvert.SerializeObject(_user);
|
||||||
|
|
||||||
|
request.AddParameter("application/json; charset=utf-8", userJson, ParameterType.RequestBody);
|
||||||
|
request.RequestFormat = DataFormat.Json;
|
||||||
|
|
||||||
|
var response = client.Execute(request);
|
||||||
|
|
||||||
|
var loginResult = JsonConvert.DeserializeObject<LoginResult>(response.Content);
|
||||||
|
|
||||||
|
return loginResult;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var msg = ex.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using RestSharp;
|
||||||
|
|
||||||
|
using Mear.Constants.API;
|
||||||
|
using Mear.Models;
|
||||||
|
using Mear.Models.Authentication;
|
||||||
|
|
||||||
|
namespace Mear.Managers
|
||||||
|
{
|
||||||
|
public class RegisterManager
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
private User _user;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
public RegisterManager(User user)
|
||||||
|
{
|
||||||
|
_user = user;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
public RegisterResult RegisterUser()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var client = new RestClient(API.ApiUrl);
|
||||||
|
var request = new RestRequest(@"api/register", Method.POST);
|
||||||
|
var userJson = JsonConvert.SerializeObject(_user);
|
||||||
|
request.AddParameter("application/json; charset=utf-8", userJson, ParameterType.RequestBody);
|
||||||
|
request.RequestFormat = DataFormat.Json;
|
||||||
|
|
||||||
|
var response = client.Execute(request);
|
||||||
|
|
||||||
|
var registerResult = JsonConvert.DeserializeObject<RegisterResult>(response.Content);
|
||||||
|
|
||||||
|
return registerResult;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var msg = ex.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||||
<PackageReference Include="Plugin.MediaManager" Version="0.6.1" />
|
<PackageReference Include="Plugin.MediaManager" Version="0.6.1" />
|
||||||
|
<PackageReference Include="Plugin.MediaManager.Forms" Version="0.6.1" />
|
||||||
|
<PackageReference Include="RestSharp" Version="106.6.9" />
|
||||||
|
<PackageReference Include="sqlite-net-pcl" Version="1.5.231" />
|
||||||
<PackageReference Include="Xamarin.Forms" Version="4.0.0.425677" />
|
<PackageReference Include="Xamarin.Forms" Version="4.0.0.425677" />
|
||||||
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
|
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -34,9 +37,18 @@
|
|||||||
<EmbeddedResource Update="Views\ArtistView.xaml">
|
<EmbeddedResource Update="Views\ArtistView.xaml">
|
||||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Update="Views\Landing.xaml">
|
||||||
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Update="Views\LoginPage.xaml">
|
||||||
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Update="Views\MusicLibrary.xaml">
|
<EmbeddedResource Update="Views\MusicLibrary.xaml">
|
||||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Update="Views\RegisterPage.xaml">
|
||||||
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Update="Views\SongView.xaml">
|
<EmbeddedResource Update="Views\SongView.xaml">
|
||||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Mear.Models.Authentication
|
||||||
|
{
|
||||||
|
public class BaseResult
|
||||||
|
{
|
||||||
|
[JsonProperty("message")]
|
||||||
|
public string Message { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Mear.Models.Authentication
|
||||||
|
{
|
||||||
|
public class LoginResult : BaseResult
|
||||||
|
{
|
||||||
|
[JsonProperty("id")]
|
||||||
|
public int UserId { get; set; }
|
||||||
|
[JsonProperty("username")]
|
||||||
|
public string Username { get; set; }
|
||||||
|
[JsonProperty("token")]
|
||||||
|
public string Token { get; set; }
|
||||||
|
[JsonProperty("token_type")]
|
||||||
|
public string TokenType { get; set; }
|
||||||
|
[JsonProperty("expiration")]
|
||||||
|
public int Expiration { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Mear.Models.Authentication
|
||||||
|
{
|
||||||
|
public class RegisterResult : BaseResult
|
||||||
|
{
|
||||||
|
[JsonProperty("username")]
|
||||||
|
public string Username { get; set; }
|
||||||
|
[JsonProperty("successfully_registered")]
|
||||||
|
public bool SuccessfullyRegistered { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Mear.Models.Authentication
|
||||||
|
{
|
||||||
|
public class User
|
||||||
|
{
|
||||||
|
[JsonProperty("id")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[JsonProperty("username")]
|
||||||
|
public string Username { get; set; }
|
||||||
|
[JsonProperty("nickname")]
|
||||||
|
public string Nickname { get; set; }
|
||||||
|
[JsonProperty("password")]
|
||||||
|
public string Password { get; set; }
|
||||||
|
[JsonProperty("email")]
|
||||||
|
public string Email { get; set; }
|
||||||
|
[JsonProperty("phone_number")]
|
||||||
|
public string PhoneNumber { get; set; }
|
||||||
|
[JsonProperty("first_name")]
|
||||||
|
public string Firstname { get; set; }
|
||||||
|
[JsonProperty("last_name")]
|
||||||
|
public string Lastname { get; set; }
|
||||||
|
[JsonProperty("email_verified")]
|
||||||
|
public bool EmailVerified { get; set; }
|
||||||
|
[JsonProperty("date_created")]
|
||||||
|
public DateTime DateCreated { get; set; }
|
||||||
|
[JsonProperty("last_login")]
|
||||||
|
public DateTime? LastLogin { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mear.Repositories.Database
|
||||||
|
{
|
||||||
|
public class DBTokenRepository
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using Mear.Models.Authentication;
|
||||||
|
|
||||||
|
namespace Mear.Repositories.Mock
|
||||||
|
{
|
||||||
|
public class MockUserRepository
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
private List<User> _users;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
public List<User> Users
|
||||||
|
{
|
||||||
|
get => _users;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
public MockUserRepository()
|
||||||
|
{
|
||||||
|
InitializeMockUser();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
private void InitializeMockUser()
|
||||||
|
{
|
||||||
|
_users = new List<User>();
|
||||||
|
|
||||||
|
var firstname = "";
|
||||||
|
var lastname = "";
|
||||||
|
var email = "";
|
||||||
|
var phone = "";
|
||||||
|
var username = "";
|
||||||
|
var password = "";
|
||||||
|
|
||||||
|
_users.Add(new User
|
||||||
|
{
|
||||||
|
Firstname = firstname,
|
||||||
|
Lastname = lastname,
|
||||||
|
Email = email,
|
||||||
|
PhoneNumber = phone,
|
||||||
|
Username = username,
|
||||||
|
Password = password
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
x:Class="Mear.Views.Landing">
|
||||||
|
<ContentPage.Content>
|
||||||
|
<StackLayout>
|
||||||
|
<Label Text="Mear powered by Icarus"
|
||||||
|
VerticalOptions="CenterAndExpand"
|
||||||
|
HorizontalOptions="CenterAndExpand" />
|
||||||
|
|
||||||
|
<Button x:Name="Login"
|
||||||
|
Text="Login"
|
||||||
|
Clicked="Login_Clicked" />
|
||||||
|
<Button x:Name="Register"
|
||||||
|
Text="Register"
|
||||||
|
Clicked="Register_Clicked" />
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage.Content>
|
||||||
|
</ContentPage>
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
|
namespace Mear.Views
|
||||||
|
{
|
||||||
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
|
public partial class Landing : ContentPage
|
||||||
|
{
|
||||||
|
public Landing()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Login_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Navigation.PushModalAsync(new LoginPage());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Register_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Navigation.PushModalAsync(new RegisterPage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
x:Class="Mear.Views.LoginPage">
|
||||||
|
<ContentPage.Content>
|
||||||
|
<StackLayout>
|
||||||
|
<Label Text="Login into Icarus account"
|
||||||
|
VerticalOptions="CenterAndExpand"
|
||||||
|
HorizontalOptions="CenterAndExpand" />
|
||||||
|
|
||||||
|
<Label Text="Username" />
|
||||||
|
<Entry x:Name="Username"
|
||||||
|
Placeholder="Username" />
|
||||||
|
|
||||||
|
<Label Text="Password" />
|
||||||
|
<Entry x:Name="Password"
|
||||||
|
IsPassword="True"
|
||||||
|
Placeholder="Password" />
|
||||||
|
|
||||||
|
<Button x:Name="AuthenticateUser"
|
||||||
|
Text="Login"
|
||||||
|
Clicked="AuthenticateUser_Clicked" />
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage.Content>
|
||||||
|
</ContentPage>
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
|
using Mear.Managers;
|
||||||
|
using Mear.Models.Authentication;
|
||||||
|
using Mear.Repositories.Mock;
|
||||||
|
|
||||||
|
namespace Mear.Views
|
||||||
|
{
|
||||||
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
|
public partial class LoginPage : ContentPage
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
public LoginPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
DummyUser();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
private User ExtractCredentials()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var username = Username.Text;
|
||||||
|
var password = Password.Text;
|
||||||
|
|
||||||
|
return new User
|
||||||
|
{
|
||||||
|
Username = username,
|
||||||
|
Password = password
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var msg = ex.Message;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Events
|
||||||
|
private async void AuthenticateUser_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
AuthenticateUser.IsEnabled = false;
|
||||||
|
|
||||||
|
var user = ExtractCredentials();
|
||||||
|
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
var loginMgr = new LoginManager(user);
|
||||||
|
var loginRes = loginMgr.Login();
|
||||||
|
|
||||||
|
if (loginRes.Expiration > 0 && loginRes != null)
|
||||||
|
{
|
||||||
|
await DisplayAlert("Icarus Login", "Successfully logged in", "Ok");
|
||||||
|
App.Current.MainPage = new MusicLibrary();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await DisplayAlert("Icarus Login", "Unable to login", "Ok");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AuthenticateUser.IsEnabled = true;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Test
|
||||||
|
private void DummyUser()
|
||||||
|
{
|
||||||
|
var mockUserRepo = new MockUserRepository();
|
||||||
|
var mockUser = mockUserRepo.Users[0];
|
||||||
|
|
||||||
|
Username.Text = mockUser.Username;
|
||||||
|
Password.Text = mockUser.Password;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,14 +8,12 @@
|
|||||||
x:Class="Mear.Views.MusicLibrary">
|
x:Class="Mear.Views.MusicLibrary">
|
||||||
|
|
||||||
<!--Pages can be added as references or inline-->
|
<!--Pages can be added as references or inline-->
|
||||||
<!--
|
|
||||||
<ContentPage Title="Songs" />
|
<ContentPage Title="Songs" />
|
||||||
<ContentPage Title="Albums" />
|
<ContentPage Title="Albums" />
|
||||||
<ContentPage Title="Artists" />
|
<ContentPage Title="Artists" />
|
||||||
-->
|
|
||||||
|
|
||||||
|
<!--
|
||||||
<TabbedPage.Children>
|
<TabbedPage.Children>
|
||||||
<!--
|
|
||||||
<NavigationPage Title="Songs">
|
<NavigationPage Title="Songs">
|
||||||
<NavigationPage.Icon>
|
<NavigationPage.Icon>
|
||||||
<OnPlatform x:TypeArguments="FileImageSource">
|
<OnPlatform x:TypeArguments="FileImageSource">
|
||||||
@@ -26,7 +24,6 @@
|
|||||||
<views:SongView />
|
<views:SongView />
|
||||||
</x:Arguments>
|
</x:Arguments>
|
||||||
</NavigationPage>
|
</NavigationPage>
|
||||||
-->
|
|
||||||
|
|
||||||
<NavigationPage Title="Albums">
|
<NavigationPage Title="Albums">
|
||||||
<NavigationPage.Icon>
|
<NavigationPage.Icon>
|
||||||
@@ -36,7 +33,6 @@
|
|||||||
</NavigationPage.Icon>
|
</NavigationPage.Icon>
|
||||||
</NavigationPage>
|
</NavigationPage>
|
||||||
|
|
||||||
<!--
|
|
||||||
<NavigationPage Title="Artists">
|
<NavigationPage Title="Artists">
|
||||||
<NavigationPage.Icon>
|
<NavigationPage.Icon>
|
||||||
<OnPlatform x:TypeArguments="FileImageSource">
|
<OnPlatform x:TypeArguments="FileImageSource">
|
||||||
@@ -47,7 +43,7 @@
|
|||||||
<views:ArtistView />
|
<views:ArtistView />
|
||||||
</x:Arguments>
|
</x:Arguments>
|
||||||
</NavigationPage>
|
</NavigationPage>
|
||||||
-->
|
|
||||||
</TabbedPage.Children>
|
</TabbedPage.Children>
|
||||||
|
-->
|
||||||
|
|
||||||
</TabbedPage>
|
</TabbedPage>
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
x:Class="Mear.Views.RegisterPage">
|
||||||
|
<ContentPage.Content>
|
||||||
|
<StackLayout>
|
||||||
|
<Label Text="Create Icarus account"
|
||||||
|
VerticalOptions="CenterAndExpand"
|
||||||
|
HorizontalOptions="CenterAndExpand" />
|
||||||
|
|
||||||
|
<Label Text="Firstname" />
|
||||||
|
<Entry x:Name="Firstname"
|
||||||
|
Placeholder="Firstname" />
|
||||||
|
<Label Text="Lastname" />
|
||||||
|
<Entry x:Name="Lastname"
|
||||||
|
Placeholder="Lastname" />
|
||||||
|
<Label Text="Email" />
|
||||||
|
<Entry x:Name="Email"
|
||||||
|
Keyboard="Email"
|
||||||
|
Placeholder="Email Address" />
|
||||||
|
<Label Text="Phone Number" />
|
||||||
|
<Entry x:Name="Phone"
|
||||||
|
Keyboard="Telephone"
|
||||||
|
Placeholder="Phone Number" />
|
||||||
|
<Label Text="Username" />
|
||||||
|
<Entry x:Name="Username"
|
||||||
|
Placeholder="Username" />
|
||||||
|
<Label Text="Password" />
|
||||||
|
<Entry x:Name="Password"
|
||||||
|
IsPassword="True"
|
||||||
|
Placeholder="Password" />
|
||||||
|
<Label Text="Password (Confirm)" />
|
||||||
|
<Entry x:Name="PasswordConfirm"
|
||||||
|
IsPassword="True"
|
||||||
|
Placeholder="Password (Confirm)" />
|
||||||
|
|
||||||
|
<Button x:Name="RegisterUser"
|
||||||
|
Text="Create Icarus account"
|
||||||
|
Clicked="RegisterUser_Clicked" />
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage.Content>
|
||||||
|
</ContentPage>
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
|
using Mear.Models;
|
||||||
|
using Mear.Managers;
|
||||||
|
using Mear.Models.Authentication;
|
||||||
|
using Mear.Repositories.Mock;
|
||||||
|
|
||||||
|
namespace Mear.Views
|
||||||
|
{
|
||||||
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
|
public partial class RegisterPage : ContentPage
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
public RegisterPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
DummyUser();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
private User ExtractCredentials()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var firstname = Firstname.Text.ToString();
|
||||||
|
var lastname = Lastname.Text.ToString();
|
||||||
|
var emailAddress = Email.Text.ToString();
|
||||||
|
var phoneNumber = Phone.Text.ToString();
|
||||||
|
var username = Username.Text.ToString();
|
||||||
|
var password = Password.Text.ToString();
|
||||||
|
var passwordConfirm = PasswordConfirm.Text.ToString();
|
||||||
|
|
||||||
|
if (!password.Equals(passwordConfirm))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new User
|
||||||
|
{
|
||||||
|
Firstname = firstname,
|
||||||
|
Lastname = lastname,
|
||||||
|
Email = emailAddress,
|
||||||
|
PhoneNumber = phoneNumber,
|
||||||
|
Username = username,
|
||||||
|
Password = password
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var msg = ex.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Events
|
||||||
|
private async void RegisterUser_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
RegisterUser.IsEnabled = false;
|
||||||
|
|
||||||
|
var user = ExtractCredentials();
|
||||||
|
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
var regMgr = new RegisterManager(user);
|
||||||
|
var regRes = regMgr.RegisterUser();
|
||||||
|
|
||||||
|
if (regRes.SuccessfullyRegistered)
|
||||||
|
{
|
||||||
|
// TODO: Implement functionality when registration succeeds
|
||||||
|
await DisplayAlert("Icarus Account Creation", "Successfully created Icarus user", "Ok");
|
||||||
|
await Navigation.PopModalAsync(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await DisplayAlert("Icarus Account Creation", "Icarus user was not created", "Ok");
|
||||||
|
// TODO: Implement functionality when registration fails
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterUser.IsEnabled = true;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Test
|
||||||
|
private void DummyUser()
|
||||||
|
{
|
||||||
|
var mockUserRepo = new MockUserRepository();
|
||||||
|
var mockUser = mockUserRepo.Users[0];
|
||||||
|
|
||||||
|
Firstname.Text = mockUser.Firstname;
|
||||||
|
Lastname.Text = mockUser.Lastname;
|
||||||
|
Email.Text = mockUser.Email;
|
||||||
|
Phone.Text = mockUser.PhoneNumber;
|
||||||
|
Username.Text = mockUser.Username;
|
||||||
|
Password.Text = mockUser.Password;
|
||||||
|
PasswordConfirm.Text = mockUser.Password;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user