Can now authneticate via Icarus. Next is to setup the Song view and test streaming.
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Mear
|
||||
InitializeComponent();
|
||||
|
||||
MainPage = new Landing();
|
||||
//MainPage = new MusicLibrary();
|
||||
}
|
||||
|
||||
protected override void OnStart()
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Mear.Constants.App
|
||||
{
|
||||
public class Info
|
||||
{
|
||||
#region Fields
|
||||
private static string _appName = "Mear";
|
||||
private static string _appVersion = "Dev Pre-release";
|
||||
#endregion
|
||||
|
||||
|
||||
#region Properties
|
||||
public static string AppName
|
||||
{
|
||||
get => _appName;
|
||||
}
|
||||
public static string AppVersion
|
||||
{
|
||||
get => _appVersion;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,6 @@
|
||||
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="ViewModel\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Views\ArtistView.xaml.cs">
|
||||
<DependentUpon>ArtistView.xaml</DependentUpon>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
|
||||
using SQLite;
|
||||
|
||||
namespace Mear.Models.Authentication
|
||||
{
|
||||
[DataContract]
|
||||
[Table("Token")]
|
||||
public class Token
|
||||
{
|
||||
[PrimaryKey, Column("Id"), AutoIncrement]
|
||||
public int Id { get; set; }
|
||||
public string AccessToken { get; set; }
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
using Mear.Constants.App;
|
||||
|
||||
using SQLite;
|
||||
|
||||
namespace Mear.Repositories.Database
|
||||
{
|
||||
public class DBRepository
|
||||
{
|
||||
#region Fields
|
||||
protected SQLiteConnection _Db;
|
||||
protected string _dbPath;
|
||||
#endregion
|
||||
|
||||
|
||||
#region Properties
|
||||
public string DBPath
|
||||
{
|
||||
get => _dbPath;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Constructors
|
||||
#endregion
|
||||
|
||||
|
||||
#region Methods
|
||||
protected bool DoesTableExist(string tablename)
|
||||
{
|
||||
var result = 0;
|
||||
|
||||
try
|
||||
{
|
||||
result = _Db.GetTableInfo(tablename).Count;
|
||||
|
||||
if (result > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var msg = ex.Message;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void CloseDb()
|
||||
{
|
||||
_Db.Close();
|
||||
}
|
||||
protected void Initialize()
|
||||
{
|
||||
var appName = Info.AppName;
|
||||
_dbPath = Path.Combine(Environment.GetFolderPath(
|
||||
Environment.SpecialFolder.Personal), appName);
|
||||
|
||||
_Db = new SQLiteConnection(_dbPath);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,58 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using SQLite;
|
||||
|
||||
using Mear.Constants.App;
|
||||
using Mear.Models.Authentication;
|
||||
|
||||
namespace Mear.Repositories.Database
|
||||
{
|
||||
public class DBTokenRepository
|
||||
public class DBTokenRepository : DBRepository
|
||||
{
|
||||
#region Fields
|
||||
#endregion
|
||||
|
||||
|
||||
#region Properties
|
||||
#endregion
|
||||
|
||||
|
||||
#region Constructors
|
||||
public DBTokenRepository()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Methods
|
||||
public Token RetrieveToken()
|
||||
{
|
||||
try
|
||||
{
|
||||
var token = _Db.Table<Token>().FirstOrDefault();
|
||||
|
||||
return token;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var msg = ex.Message;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public void SaveToken(Token token)
|
||||
{
|
||||
if (!DoesTableExist("Token"))
|
||||
{
|
||||
_Db.CreateTable<Token>();
|
||||
}
|
||||
|
||||
_Db.DeleteAll<Token>();
|
||||
|
||||
_Db.Insert(token);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,12 +34,12 @@ namespace Mear.Repositories.Mock
|
||||
{
|
||||
_users = new List<User>();
|
||||
|
||||
var firstname = "";
|
||||
var lastname = "";
|
||||
var email = "";
|
||||
var phone = "";
|
||||
var username = "";
|
||||
var password = "";
|
||||
var firstname = "kuoth";
|
||||
var lastname = "Universe";
|
||||
var email = "life@hell.org";
|
||||
var phone = "4330944491";
|
||||
var username = "kverse";
|
||||
var password = "demolaugh";
|
||||
|
||||
_users.Add(new User
|
||||
{
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Mear.ViewModels
|
||||
{
|
||||
public class BaseViewModel : INotifyPropertyChanged
|
||||
{
|
||||
#region Fields
|
||||
#region INotifyPropertyChanged
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Mear.ViewModels
|
||||
{
|
||||
public class SongViewModel : BaseViewModel
|
||||
{
|
||||
#region Fields
|
||||
#endregion
|
||||
|
||||
|
||||
#region Properties
|
||||
#endregion
|
||||
|
||||
|
||||
#region Constructors
|
||||
public SongViewModel()
|
||||
{
|
||||
//Title = "Songs";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
<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.AlbumView">
|
||||
<ContentView.Content>
|
||||
<ContentPage.Content>
|
||||
<StackLayout>
|
||||
<Label Text="Album view!" />
|
||||
</StackLayout>
|
||||
</ContentView.Content>
|
||||
</ContentView>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
||||
@@ -10,7 +10,7 @@ using Xamarin.Forms.Xaml;
|
||||
namespace Mear.Views
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class AlbumView : ContentView
|
||||
public partial class AlbumView : ContentPage
|
||||
{
|
||||
public AlbumView()
|
||||
{
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
<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.ArtistView">
|
||||
<ContentView.Content>
|
||||
<ContentPage.Content>
|
||||
<StackLayout>
|
||||
<Label Text="Artist view!" />
|
||||
</StackLayout>
|
||||
</ContentView.Content>
|
||||
</ContentView>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
||||
@@ -10,7 +10,7 @@ using Xamarin.Forms.Xaml;
|
||||
namespace Mear.Views
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class ArtistView : ContentView
|
||||
public partial class ArtistView : ContentPage
|
||||
{
|
||||
public ArtistView()
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@ using Xamarin.Forms.Xaml;
|
||||
|
||||
using Mear.Managers;
|
||||
using Mear.Models.Authentication;
|
||||
using Mear.Repositories.Database;
|
||||
using Mear.Repositories.Mock;
|
||||
|
||||
namespace Mear.Views
|
||||
@@ -67,6 +68,12 @@ namespace Mear.Views
|
||||
|
||||
if (loginRes.Expiration > 0 && loginRes != null)
|
||||
{
|
||||
DBTokenRepository tokRepo = new DBTokenRepository();
|
||||
tokRepo.SaveToken(new Token
|
||||
{
|
||||
AccessToken = loginRes.Token,
|
||||
UserId = loginRes.UserId
|
||||
});
|
||||
await DisplayAlert("Icarus Login", "Successfully logged in", "Ok");
|
||||
App.Current.MainPage = new MusicLibrary();
|
||||
}
|
||||
|
||||
@@ -7,12 +7,6 @@
|
||||
xmlns:views="clr-namespace:Mear.Views"
|
||||
x:Class="Mear.Views.MusicLibrary">
|
||||
|
||||
<!--Pages can be added as references or inline-->
|
||||
<ContentPage Title="Songs" />
|
||||
<ContentPage Title="Albums" />
|
||||
<ContentPage Title="Artists" />
|
||||
|
||||
<!--
|
||||
<TabbedPage.Children>
|
||||
<NavigationPage Title="Songs">
|
||||
<NavigationPage.Icon>
|
||||
@@ -31,6 +25,9 @@
|
||||
<On Platform="iOS" Value="tab_feed.png" />
|
||||
</OnPlatform>
|
||||
</NavigationPage.Icon>
|
||||
<x:Arguments>
|
||||
<views:AlbumView />
|
||||
</x:Arguments>
|
||||
</NavigationPage>
|
||||
|
||||
<NavigationPage Title="Artists">
|
||||
@@ -44,6 +41,5 @@
|
||||
</x:Arguments>
|
||||
</NavigationPage>
|
||||
</TabbedPage.Children>
|
||||
-->
|
||||
|
||||
</TabbedPage>
|
||||
@@ -7,14 +7,38 @@ using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
using Mear.Models.Authentication;
|
||||
using Mear.Repositories.Database;
|
||||
|
||||
namespace Mear.Views
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class MusicLibrary : TabbedPage
|
||||
{
|
||||
#region Fields
|
||||
#endregion
|
||||
|
||||
|
||||
#region Properties
|
||||
#endregion
|
||||
|
||||
|
||||
#region Constructors
|
||||
public MusicLibrary()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Methods
|
||||
#region Test
|
||||
public void TokenTest()
|
||||
{
|
||||
DBTokenRepository tokRepo = new DBTokenRepository();
|
||||
var token = tokRepo.RetrieveToken();
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
<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.SongView">
|
||||
<ContentView.Content>
|
||||
x:Class="Mear.Views.SongView"
|
||||
xmlns:vm="clr-namespace:Mear.ViewModels"
|
||||
Title="{Binding Title}">
|
||||
|
||||
<ContentPage.BindingContext>
|
||||
<vm:SongViewModel />
|
||||
</ContentPage.BindingContext>
|
||||
|
||||
<StackLayout>
|
||||
<Label Text="Song view!" />
|
||||
</StackLayout>
|
||||
</ContentView.Content>
|
||||
</ContentView>
|
||||
</ContentPage>
|
||||
@@ -10,7 +10,7 @@ using Xamarin.Forms.Xaml;
|
||||
namespace Mear.Views
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class SongView : ContentView
|
||||
public partial class SongView : ContentPage
|
||||
{
|
||||
public SongView()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user