Continuing work on the Settings and color scheme aspects. Deciding on the default colors for the dark theme. $14 and #5
This commit is contained in:
@@ -56,7 +56,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Plugin.MediaManager">
|
||||
<Version>0.6.1</Version>
|
||||
<Version>0.6.7</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="RestSharp">
|
||||
<Version>106.6.9</Version>
|
||||
@@ -64,7 +64,7 @@
|
||||
<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.482894" />
|
||||
<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.v4" Version="28.0.0.1" />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="launcher_background">#FFFFFF</color>
|
||||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
<color name="launcher_background">#000000</color>
|
||||
<color name="colorPrimary">#555555</color>
|
||||
<color name="colorPrimaryDark">#000000</color>
|
||||
<color name="colorAccent">#bbaa11</color>
|
||||
</resources>
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
<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.482894" />
|
||||
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||
|
||||
@@ -3,6 +3,52 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Mear.App">
|
||||
<Application.Resources>
|
||||
<Color x:Key="NavigationPageColor">#000010</Color>
|
||||
<Color x:Key="BarTextColor">#ffffff</Color>
|
||||
<Color x:Key="NavigationPageBackgroundColor">#000000</Color>
|
||||
|
||||
<Color x:Key="TabbedBarTextColor">#ffffff</Color>
|
||||
<Color x:Key="TabbedUnselectedColor">#000000</Color>
|
||||
<Color x:Key="TabbedSelectedColor">#333333</Color>
|
||||
|
||||
<Color x:Key="ButtonColor">#660066</Color>
|
||||
<Color x:Key="ButtonTextColor">#ffccff</Color>
|
||||
<Color x:Key="ButtonBorderColor">#ffe6ff</Color>
|
||||
|
||||
<Color x:Key="LabelTextColor">#ffffee</Color>
|
||||
<Color x:Key="LabelBackgroundColor">#aaaaaa</Color>
|
||||
|
||||
<Color x:Key="EntryTextColor">#ffffee</Color>
|
||||
|
||||
<Style TargetType="NavigationPage">
|
||||
<Setter Property="BackgroundColor" Value="{StaticResource NavigationPageBackgroundColor}" />
|
||||
<Setter Property="BarBackgroundColor" Value="{StaticResource NavigationPageColor}" />
|
||||
<Setter Property="BarTextColor" Value="{StaticResource BarTextColor}" />
|
||||
</Style>
|
||||
<Style TargetType="ContentPage">
|
||||
<Setter Property="BackgroundColor" Value="{StaticResource NavigationPageBackgroundColor}" />
|
||||
</Style>
|
||||
<Style TargetType="TabbedPage">
|
||||
<Setter Property="BarTextColor" Value="{StaticResource TabbedBarTextColor}" />
|
||||
<Setter Property="UnselectedTabColor" Value="{StaticResource TabbedUnselectedColor}" />
|
||||
<Setter Property="SelectedTabColor" Value="{StaticResource TabbedSelectedColor}" />
|
||||
<Setter Property="BarBackgroundColor" Value="Green" />
|
||||
</Style>
|
||||
<Style TargetType="StackLayout">
|
||||
<Setter Property="BackgroundColor" Value="{StaticResource NavigationPageColor}" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="BackgroundColor" Value="{StaticResource ButtonColor}" />
|
||||
<Setter Property="TextColor" Value="{StaticResource ButtonTextColor}" />
|
||||
<Setter Property="BorderColor" Value="{StaticResource ButtonBorderColor}" />
|
||||
</Style>
|
||||
<Style TargetType="Label">
|
||||
<Setter Property="TextColor" Value="{StaticResource LabelTextColor}" />
|
||||
</Style>
|
||||
<Style TargetType="Entry">
|
||||
<Setter Property="TextColor" Value="{StaticResource EntryTextColor}" />
|
||||
</Style>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -13,7 +13,8 @@ namespace Mear
|
||||
InitializeComponent();
|
||||
|
||||
MainPage = new Landing();
|
||||
//MainPage = new MusicLibrary();
|
||||
MainPage.SetValue(NavigationPage.BarBackgroundColorProperty, Color.Black);
|
||||
MainPage.SetValue(NavigationPage.BarTextColorProperty, Color.White);
|
||||
}
|
||||
|
||||
protected override void OnStart()
|
||||
|
||||
@@ -12,11 +12,10 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||
<PackageReference Include="Plugin.MediaManager" Version="0.6.1" />
|
||||
<PackageReference Include="Plugin.MediaManager" Version="0.6.7" />
|
||||
<PackageReference Include="RestSharp" Version="106.6.9" />
|
||||
<PackageReference Include="sqlite-net-pcl" Version="1.5.231" />
|
||||
<PackageReference Include="taglib" Version="2.1.0" />
|
||||
<PackageReference Include="Xamarin.Forms" Version="4.0.0.425677" />
|
||||
<PackageReference Include="Xamarin.Forms" Version="4.0.0.482894" />
|
||||
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
|
||||
using SQLite;
|
||||
|
||||
namespace Mear.Models
|
||||
{
|
||||
[DataContract]
|
||||
[Table("Settings")]
|
||||
public class Settings
|
||||
{
|
||||
[PrimaryKey, Column("Id"), AutoIncrement]
|
||||
public int Id { get; set; }
|
||||
public bool DarkTheme { get; set; } = true;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ using Mear.Models;
|
||||
using Mear.Models.Authentication;
|
||||
using Mear.Models.PlayerControls;
|
||||
using Mear.Repositories.Database;
|
||||
using Mear.Repositories.Remote;
|
||||
using Mear.Utilities;
|
||||
|
||||
namespace Mear.Playback
|
||||
@@ -87,10 +88,10 @@ namespace Mear.Playback
|
||||
InitializeRepeatMode();
|
||||
break;
|
||||
case PlayControls.PAUSE:
|
||||
await CrossMediaManager.Current.Pause();
|
||||
PauseSong();
|
||||
break;
|
||||
case PlayControls.RESUME:
|
||||
await CrossMediaManager.Current.Play();
|
||||
ResumeSong();
|
||||
break;
|
||||
case PlayControls.STREAM:
|
||||
song = StreamSong(song);
|
||||
@@ -148,6 +149,13 @@ namespace Mear.Playback
|
||||
return null;
|
||||
}
|
||||
|
||||
public static async Task DownloadSongToFS()
|
||||
{
|
||||
var songRepo = new RemoteSongRepository();
|
||||
songRepo.DownloadSong(_song);
|
||||
|
||||
_song.Downloaded = true;
|
||||
}
|
||||
public static async Task PlaySong(Song song)
|
||||
{
|
||||
try
|
||||
@@ -161,6 +169,17 @@ namespace Mear.Playback
|
||||
var msg = ex.Message;
|
||||
}
|
||||
}
|
||||
public static async Task RemoveSongFromFS()
|
||||
{
|
||||
var dbSongRepo = new DBSongRepository();
|
||||
var plyCount = new DBPlayCountRepository();
|
||||
dbSongRepo.DeleteSong(_song);
|
||||
plyCount.DeletePlayCount(_song);
|
||||
|
||||
File.Delete(_song.SongPath);
|
||||
|
||||
_song.Downloaded = false;
|
||||
}
|
||||
public static async Task SeekTo(double songProress)
|
||||
{
|
||||
double newPosition = (songProress / 100) * ((double)_song.Duration);
|
||||
@@ -184,6 +203,21 @@ namespace Mear.Playback
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
public static string RetrieveShuffleString()
|
||||
{
|
||||
var controlRepo = new DBMusicControlsRepository();
|
||||
var shuffleOn = controlRepo.IsShuffleOn();
|
||||
try
|
||||
{
|
||||
return shuffleOn ? "ShfOn" : "ShfOff";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var msg = ex.Message;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static bool IsPlaying()
|
||||
{
|
||||
@@ -258,6 +292,10 @@ namespace Mear.Playback
|
||||
|
||||
CrossMediaManager.Current.RepeatMode = mode;
|
||||
}
|
||||
private static async Task PauseSong()
|
||||
{
|
||||
await CrossMediaManager.Current.Pause();
|
||||
}
|
||||
private static async Task PlaySong(string songPath)
|
||||
{
|
||||
await CrossMediaManager.Current.Play(songPath);
|
||||
@@ -268,6 +306,10 @@ namespace Mear.Playback
|
||||
_initialized = true;
|
||||
}
|
||||
}
|
||||
private static async Task ResumeSong()
|
||||
{
|
||||
await CrossMediaManager.Current.Play();
|
||||
}
|
||||
|
||||
private static void ToggleRepeat()
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Mear.Repositories.Database
|
||||
#region Fields
|
||||
protected SQLiteConnection _Db;
|
||||
protected string _dbPath;
|
||||
protected string _tableName;
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Mear.Models;
|
||||
|
||||
namespace Mear.Repositories.Database
|
||||
{
|
||||
public class DBSettingsRepository : DBRepository
|
||||
{
|
||||
#region Fields
|
||||
#endregion
|
||||
|
||||
|
||||
#region Properties
|
||||
#endregion
|
||||
|
||||
|
||||
#region Constructors
|
||||
public DBSettingsRepository()
|
||||
{
|
||||
_tableName = "Settings";
|
||||
Initialize();
|
||||
InitializeTable();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Methods
|
||||
public bool IsDarkThemeOn()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DoesTableExist(_tableName))
|
||||
{
|
||||
bool? darkTheme = RetrieveSettings().DarkTheme;
|
||||
|
||||
if (darkTheme != null)
|
||||
{
|
||||
return darkTheme.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var msg = ex.Message;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void UpdateDarkTheme()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DoesTableExist(_tableName))
|
||||
{
|
||||
var settings = RetrieveSettings();
|
||||
settings.DarkTheme = !settings.DarkTheme;
|
||||
|
||||
_Db.Update(settings);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var msg = ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private Settings RetrieveSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
var settings = _Db.Table<Settings>().First();
|
||||
|
||||
return settings;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var msg = ex.Message;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void InitializeTable()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!DoesTableExist(_tableName))
|
||||
{
|
||||
_Db.CreateTable<Settings>();
|
||||
}
|
||||
|
||||
var settings = RetrieveSettings();
|
||||
|
||||
if (settings == null)
|
||||
{
|
||||
var initSettings = new Settings();
|
||||
_Db.Insert(initSettings);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var msg = ex.Message;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
using TagLib;
|
||||
|
||||
using Mear.Models;
|
||||
|
||||
using IOFile = System.IO.File;
|
||||
|
||||
@@ -63,6 +63,8 @@ namespace Mear.ViewModels
|
||||
{
|
||||
var msg = ex.Message;
|
||||
}
|
||||
|
||||
IsRefreshing = false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -63,6 +63,8 @@ namespace Mear.ViewModels
|
||||
{
|
||||
var msg = ex.Message;
|
||||
}
|
||||
|
||||
IsRefreshing = false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ using System.Text;
|
||||
|
||||
using Xamarin.Forms;
|
||||
|
||||
using Mear.Repositories.Database;
|
||||
|
||||
namespace Mear.ViewModels
|
||||
{
|
||||
public class SettingsViewModel : BaseViewModel
|
||||
@@ -36,10 +38,13 @@ namespace Mear.ViewModels
|
||||
#region Methods
|
||||
private SwitchItem RetrieveColorSchemeSwitch()
|
||||
{
|
||||
var settingsRepo = new DBSettingsRepository();
|
||||
var darkTheme = settingsRepo.IsDarkThemeOn();
|
||||
|
||||
var colorScheme = new SwitchItem
|
||||
{
|
||||
Title = "Dark Theme",
|
||||
IsOn = true
|
||||
IsOn = darkTheme
|
||||
};
|
||||
|
||||
return colorScheme;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
IsPullToRefreshEnabled="True"
|
||||
RowHeight="80"
|
||||
RefreshCommand="{Binding RefreshAlbums}"
|
||||
IsRefreshing="{Binding IsRefreshing}"
|
||||
ItemSelected="AlbumListView_ItemSelected" >
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Mear.Views
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Methods
|
||||
#region Events
|
||||
private void AlbumListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
IsPullToRefreshEnabled="True"
|
||||
RowHeight="80"
|
||||
RefreshCommand="{Binding RefreshArtists}"
|
||||
IsRefreshing="{Binding IsRefreshing}"
|
||||
ItemSelected="ArtistListView_ItemSelected" >
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
|
||||
@@ -100,14 +100,16 @@ namespace Mear.Views
|
||||
var dur = _song.Duration;
|
||||
var endTime = songCnvrt.ConvertToSongTime(dur.Value);
|
||||
|
||||
var controlRepo = new DBMusicControlsRepository();
|
||||
var shuffleOn = controlRepo.IsShuffleOn();
|
||||
|
||||
Shuffle.Text = (shuffleOn) ? "ShfOn" : "ShfOff";
|
||||
Shuffle.Text = MearPlayer.RetrieveShuffleString();
|
||||
Repeat.Text = MearPlayer.RetrieveRepeatString();
|
||||
|
||||
EndTime.Text = endTime;
|
||||
}
|
||||
private void RemoveSyncToolbar()
|
||||
{
|
||||
var act = ToolbarItems.Where(tl => tl.Priority == 1).First();
|
||||
ToolbarItems.Remove(act);
|
||||
}
|
||||
|
||||
#region Background
|
||||
private async Task BackgroundSongElasping()
|
||||
@@ -212,10 +214,8 @@ namespace Mear.Views
|
||||
private void Shuffle_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
var musicCtrl = new DBMusicControlsRepository();
|
||||
var control = musicCtrl.IsShuffleOn();
|
||||
Shuffle.Text = (!control) ? "ShfOn" : "ShfOff";
|
||||
|
||||
musicCtrl.UpdateShuffle();
|
||||
Shuffle.Text = MearPlayer.RetrieveShuffleString();
|
||||
}
|
||||
|
||||
|
||||
@@ -227,24 +227,20 @@ namespace Mear.Views
|
||||
|
||||
private void Download_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
var act = ToolbarItems.Where(tl => tl.Priority == 1).First();
|
||||
ToolbarItems.Remove(act);
|
||||
var songRepo = new RemoteSongRepository();
|
||||
songRepo.DownloadSong(_song);
|
||||
RemoveSyncToolbar();
|
||||
MearPlayer.DownloadSongToFS();
|
||||
|
||||
ToolbarItems.Add(RemoveOption());
|
||||
|
||||
_song.Downloaded = true;
|
||||
}
|
||||
private async void Remove_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
var act = ToolbarItems.Where(tl => tl.Priority == 1).First();
|
||||
RemoveSyncToolbar();
|
||||
MearPlayer.RemoveSongFromFS();
|
||||
|
||||
ToolbarItems.Remove(act);
|
||||
var dbSongRepo = new DBSongRepository();
|
||||
var plyCount = new DBPlayCountRepository();
|
||||
dbSongRepo.DeleteSong(_song);
|
||||
plyCount.DeletePlayCount(_song);
|
||||
_song.Downloaded = false;
|
||||
|
||||
File.Delete(_song.SongPath);
|
||||
|
||||
ToolbarItems.Add(DownloadOption());
|
||||
}
|
||||
|
||||
@@ -31,8 +31,7 @@
|
||||
d:Text="{Binding .}"
|
||||
LineBreakMode="NoWrap"
|
||||
FontSize="14" />
|
||||
<Switch x:Name="{Binding Title}"
|
||||
IsToggled="{Binding On}"
|
||||
<Switch IsToggled="{Binding On}"
|
||||
Toggled="Switch_Toggled" />
|
||||
</StackLayout>
|
||||
</Grid>
|
||||
|
||||
@@ -33,6 +33,9 @@ namespace Mear.Views
|
||||
#region Events
|
||||
private void Switch_Toggled(object sender, ToggledEventArgs e)
|
||||
{
|
||||
var val = e;
|
||||
var valOne = sender;
|
||||
var yp = "";
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user