Can now authneticate via Icarus. Next is to setup the Song view and test streaming.

This commit is contained in:
amazing-username
2019-05-27 14:48:20 -04:00
parent 55940deda1
commit 1962979271
18 changed files with 268 additions and 34 deletions
+1
View File
@@ -13,6 +13,7 @@ namespace Mear
InitializeComponent(); InitializeComponent();
MainPage = new Landing(); MainPage = new Landing();
//MainPage = new MusicLibrary();
} }
protected override void OnStart() protected override void OnStart()
+26
View File
@@ -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
}
}
-4
View File
@@ -20,10 +20,6 @@
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" /> <PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="ViewModel\" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Update="Views\ArtistView.xaml.cs"> <Compile Update="Views\ArtistView.xaml.cs">
<DependentUpon>ArtistView.xaml</DependentUpon> <DependentUpon>ArtistView.xaml</DependentUpon>
+19
View File
@@ -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.Collections.Generic;
using System.Text; using System.Text;
using SQLite;
using Mear.Constants.App;
using Mear.Models.Authentication;
namespace Mear.Repositories.Database 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>(); _users = new List<User>();
var firstname = ""; var firstname = "kuoth";
var lastname = ""; var lastname = "Universe";
var email = ""; var email = "life@hell.org";
var phone = ""; var phone = "4330944491";
var username = ""; var username = "kverse";
var password = ""; var password = "demolaugh";
_users.Add(new User _users.Add(new User
{ {
+18
View File
@@ -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
}
}
+26
View File
@@ -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
}
}
+4 -4
View File
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?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:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" mc:Ignorable="d"
x:Class="Mear.Views.AlbumView"> x:Class="Mear.Views.AlbumView">
<ContentView.Content> <ContentPage.Content>
<StackLayout> <StackLayout>
<Label Text="Album view!" /> <Label Text="Album view!" />
</StackLayout> </StackLayout>
</ContentView.Content> </ContentPage.Content>
</ContentView> </ContentPage>
+1 -1
View File
@@ -10,7 +10,7 @@ using Xamarin.Forms.Xaml;
namespace Mear.Views namespace Mear.Views
{ {
[XamlCompilation(XamlCompilationOptions.Compile)] [XamlCompilation(XamlCompilationOptions.Compile)]
public partial class AlbumView : ContentView public partial class AlbumView : ContentPage
{ {
public AlbumView() public AlbumView()
{ {
+4 -4
View File
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?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:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" mc:Ignorable="d"
x:Class="Mear.Views.ArtistView"> x:Class="Mear.Views.ArtistView">
<ContentView.Content> <ContentPage.Content>
<StackLayout> <StackLayout>
<Label Text="Artist view!" /> <Label Text="Artist view!" />
</StackLayout> </StackLayout>
</ContentView.Content> </ContentPage.Content>
</ContentView> </ContentPage>
+1 -1
View File
@@ -10,7 +10,7 @@ using Xamarin.Forms.Xaml;
namespace Mear.Views namespace Mear.Views
{ {
[XamlCompilation(XamlCompilationOptions.Compile)] [XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ArtistView : ContentView public partial class ArtistView : ContentPage
{ {
public ArtistView() public ArtistView()
{ {
+7
View File
@@ -9,6 +9,7 @@ using Xamarin.Forms.Xaml;
using Mear.Managers; using Mear.Managers;
using Mear.Models.Authentication; using Mear.Models.Authentication;
using Mear.Repositories.Database;
using Mear.Repositories.Mock; using Mear.Repositories.Mock;
namespace Mear.Views namespace Mear.Views
@@ -67,6 +68,12 @@ namespace Mear.Views
if (loginRes.Expiration > 0 && loginRes != null) 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"); await DisplayAlert("Icarus Login", "Successfully logged in", "Ok");
App.Current.MainPage = new MusicLibrary(); App.Current.MainPage = new MusicLibrary();
} }
+3 -7
View File
@@ -7,12 +7,6 @@
xmlns:views="clr-namespace:Mear.Views" xmlns:views="clr-namespace:Mear.Views"
x:Class="Mear.Views.MusicLibrary"> x:Class="Mear.Views.MusicLibrary">
<!--Pages can be added as references or inline-->
<ContentPage Title="Songs" />
<ContentPage Title="Albums" />
<ContentPage Title="Artists" />
<!--
<TabbedPage.Children> <TabbedPage.Children>
<NavigationPage Title="Songs"> <NavigationPage Title="Songs">
<NavigationPage.Icon> <NavigationPage.Icon>
@@ -31,6 +25,9 @@
<On Platform="iOS" Value="tab_feed.png" /> <On Platform="iOS" Value="tab_feed.png" />
</OnPlatform> </OnPlatform>
</NavigationPage.Icon> </NavigationPage.Icon>
<x:Arguments>
<views:AlbumView />
</x:Arguments>
</NavigationPage> </NavigationPage>
<NavigationPage Title="Artists"> <NavigationPage Title="Artists">
@@ -44,6 +41,5 @@
</x:Arguments> </x:Arguments>
</NavigationPage> </NavigationPage>
</TabbedPage.Children> </TabbedPage.Children>
-->
</TabbedPage> </TabbedPage>
+24
View File
@@ -7,14 +7,38 @@ using System.Threading.Tasks;
using Xamarin.Forms; using Xamarin.Forms;
using Xamarin.Forms.Xaml; using Xamarin.Forms.Xaml;
using Mear.Models.Authentication;
using Mear.Repositories.Database;
namespace Mear.Views namespace Mear.Views
{ {
[XamlCompilation(XamlCompilationOptions.Compile)] [XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MusicLibrary : TabbedPage public partial class MusicLibrary : TabbedPage
{ {
#region Fields
#endregion
#region Properties
#endregion
#region Constructors
public MusicLibrary() public MusicLibrary()
{ {
InitializeComponent(); InitializeComponent();
} }
#endregion
#region Methods
#region Test
public void TokenTest()
{
DBTokenRepository tokRepo = new DBTokenRepository();
var token = tokRepo.RetrieveToken();
}
#endregion
#endregion
} }
} }
+10 -5
View File
@@ -1,13 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?> <?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:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" mc:Ignorable="d"
x:Class="Mear.Views.SongView"> x:Class="Mear.Views.SongView"
<ContentView.Content> xmlns:vm="clr-namespace:Mear.ViewModels"
Title="{Binding Title}">
<ContentPage.BindingContext>
<vm:SongViewModel />
</ContentPage.BindingContext>
<StackLayout> <StackLayout>
<Label Text="Song view!" /> <Label Text="Song view!" />
</StackLayout> </StackLayout>
</ContentView.Content> </ContentPage>
</ContentView>
+1 -1
View File
@@ -10,7 +10,7 @@ using Xamarin.Forms.Xaml;
namespace Mear.Views namespace Mear.Views
{ {
[XamlCompilation(XamlCompilationOptions.Compile)] [XamlCompilation(XamlCompilationOptions.Compile)]
public partial class SongView : ContentView public partial class SongView : ContentPage
{ {
public SongView() public SongView()
{ {