Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
naweed committed Aug 20, 2022
1 parent 8891eee commit 8a06cab
Show file tree
Hide file tree
Showing 11 changed files with 569 additions and 4 deletions.
84 changes: 84 additions & 0 deletions src/MauiTubePlayer/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<Color x:Key="DarkTextColor">#151515</Color>
<Color x:Key="LightTextColor">#F5F5F5</Color>

<Color x:Key="LightBorderColor">#A5A5A5</Color>

<!-- Content Page Style -->
<Style TargetType="ContentPage" ApplyToDerivedTypes="True">
<Setter Property="NavigationPage.HasNavigationBar" Value="False" />
Expand Down Expand Up @@ -59,6 +61,88 @@
<Setter Property="SelectionMode" Value="None" />
</Style>

<!-- Icon Styles -->
<Style TargetType="ImageButton" x:Key="IconButtonStyle">
<Setter Property="HeightRequest" Value="32" />
<Setter Property="WidthRequest" Value="32" />
<Setter Property="Padding" Value="{OnPlatform Android=4, Default=6}" />
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="Margin" Value="12,3" />
<Setter Property="Aspect" Value="AspectFit" />
<Setter Property="CornerRadius" Value="8" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="Opacity" Value="1" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="Opacity" Value="0.5" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>


<!-- Regular Label Styles -->
<Style TargetType="Label" x:Key="BaseRegularLightLabelTextStyle">
<Setter Property="LineBreakMode" Value="TailTruncation" />
<Setter Property="FontAutoScalingEnabled" Value="False" />
<Setter Property="FontFamily" Value="RegularFont" />
<Setter Property="TextColor" Value="{StaticResource LightTextColor}" />
</Style>

<Style TargetType="Label" x:Key="RegularLightText16" BasedOn="{StaticResource BaseRegularLightLabelTextStyle}">
<Setter Property="FontSize" Value="16" />
</Style>

<Style TargetType="Label" x:Key="RegularLightText14" BasedOn="{StaticResource BaseRegularLightLabelTextStyle}">
<Setter Property="FontSize" Value="14" />
</Style>

<Style TargetType="Label" x:Key="RegularLightText12" BasedOn="{StaticResource BaseRegularLightLabelTextStyle}">
<Setter Property="FontSize" Value="12" />
</Style>

<!-- Medium Label Style -->
<Style TargetType="Label" x:Key="BaseMediumLightLabelTextStyle">
<Setter Property="LineBreakMode" Value="TailTruncation" />
<Setter Property="FontAutoScalingEnabled" Value="False" />
<Setter Property="FontFamily" Value="MediumFont" />
<Setter Property="TextColor" Value="{StaticResource LightTextColor}" />
</Style>

<Style TargetType="Label" x:Key="BaseMediumDarkLabelTextStyle" BasedOn="{StaticResource BaseMediumLightLabelTextStyle}">
<Setter Property="TextColor" Value="{StaticResource DarkTextColor}" />
</Style>

<Style TargetType="Label" x:Key="MediumLightText20" BasedOn="{StaticResource BaseMediumLightLabelTextStyle}">
<Setter Property="FontSize" Value="20" />
</Style>

<Style TargetType="Label" x:Key="MediumLightText18" BasedOn="{StaticResource BaseMediumLightLabelTextStyle}">
<Setter Property="FontSize" Value="18" />
</Style>

<Style TargetType="Label" x:Key="MediumLightText14" BasedOn="{StaticResource BaseMediumLightLabelTextStyle}">
<Setter Property="FontSize" Value="14" />
</Style>

<Style TargetType="Label" x:Key="MediumLightText10" BasedOn="{StaticResource BaseMediumLightLabelTextStyle}">
<Setter Property="FontSize" Value="10" />
</Style>

<!-- Page Header Style -->
<Style TargetType="Label" x:Key="PageHeaderTextStyle" BasedOn="{StaticResource BaseMediumLightLabelTextStyle}">
<Setter Property="FontSize" Value="22" />
</Style>


</Application.Resources>
</Application>

6 changes: 5 additions & 1 deletion src/MauiTubePlayer/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
global using MauiTubePlayer.Views;
global using System.Text.Json.Serialization;
global using MauiTubePlayer.Models;
global using MauiTubePlayer.Models;
global using Maui.Apps.Framework.MVVM;
global using CommunityToolkit.Mvvm.Input;
global using MauiTubePlayer.IServices;
global using Maui.Apps.Framework.UI;
24 changes: 21 additions & 3 deletions src/MauiTubePlayer/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace MauiTubePlayer;
using Microsoft.Maui.LifecycleEvents;

namespace MauiTubePlayer;

public static class MauiProgram
{
Expand All @@ -11,9 +13,25 @@ public static MauiApp CreateMauiApp()
{
fonts.AddFont("FiraSans-Light.ttf", "RegularFont");
fonts.AddFont("FiraSans-Medium.ttf", "MediumFont");
});
})
.ConfigureLifecycleEvents(events =>
{
#if ANDROID
events.AddAndroid(android => android.OnCreate((activity, bundle) => MakeStatusBarTranslucent(activity)));

static void MakeStatusBarTranslucent(Android.App.Activity activity)
{
activity.Window.SetFlags(Android.Views.WindowManagerFlags.LayoutNoLimits, Android.Views.WindowManagerFlags.LayoutNoLimits);

activity.Window.ClearFlags(Android.Views.WindowManagerFlags.TranslucentStatus);

activity.Window.SetStatusBarColor(Android.Graphics.Color.Transparent);
}
#endif
})
;

return builder.Build();
return builder.Build();
}
}

11 changes: 11 additions & 0 deletions src/MauiTubePlayer/MauiTubePlayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<None Remove="ViewControls\" />
<None Remove="Views\Base\" />
<None Remove="ViewModels\Base\" />
<None Remove="ViewControls\Common\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
Expand All @@ -72,11 +73,21 @@
<Folder Include="ViewControls\" />
<Folder Include="Views\Base\" />
<Folder Include="ViewModels\Base\" />
<Folder Include="ViewControls\Common\" />
</ItemGroup>
<ItemGroup>
<MauiXaml Update="Views\StartPage.xaml">
<SubType></SubType>
</MauiXaml>
<MauiXaml Update="ViewControls\Common\ErrorIndicator.xaml">
<SubType></SubType>
</MauiXaml>
<MauiXaml Update="ViewControls\Common\LoadingIndicator.xaml">
<SubType></SubType>
</MauiXaml>
<MauiXaml Update="Views\Base\PageBase.xaml">
<SubType></SubType>
</MauiXaml>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Maui.Apps.Framework\Maui.Apps.Framework.csproj" />
Expand Down
32 changes: 32 additions & 0 deletions src/MauiTubePlayer/ViewControls/Common/ErrorIndicator.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8" ?>
<VerticalStackLayout
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiTubePlayer.ViewControls.Common.ErrorIndicator"
IsVisible="False"
Padding="48,12">

<Image
x:Name="imgError"
Source="{Binding ErrorImage, Mode=OneWay}"
HorizontalOptions="Center"
WidthRequest="64"
HeightRequest="64"
Aspect="AspectFit"/>

<Label
Margin="0,12,0,0"
Text="Uh-Oh!"
Style="{StaticResource MediumLightText18}"
HorizontalOptions="Center"
HorizontalTextAlignment="Center" />

<Label
x:Name="lblErrorText"
Style="{StaticResource RegularLightText14}"
LineBreakMode="WordWrap"
HorizontalOptions="Center"
HorizontalTextAlignment="Center" />

</VerticalStackLayout>

68 changes: 68 additions & 0 deletions src/MauiTubePlayer/ViewControls/Common/ErrorIndicator.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
namespace MauiTubePlayer.ViewControls.Common;

public partial class ErrorIndicator : VerticalStackLayout
{
//Bindable Properties

public static readonly BindableProperty IsErrorProperty = BindableProperty.Create(
"IsError",
typeof(bool),
typeof(ErrorIndicator),
false,
BindingMode.OneWay,
null,
SetIsError);

public bool IsError
{
get => (bool)this.GetValue(IsErrorProperty);
set => this.SetValue(IsErrorProperty, value);
}

private static void SetIsError(BindableObject bindable, object oldValue, object newValue) =>
(bindable as ErrorIndicator).IsVisible = (bool)newValue;


public static readonly BindableProperty ErrorTextProperty = BindableProperty.Create(
"ErrorText",
typeof(string),
typeof(ErrorIndicator),
string.Empty,
BindingMode.OneWay,
null,
SetErrorText);

public string ErrorText
{
get => (string)this.GetValue(ErrorTextProperty);
set => this.SetValue(ErrorTextProperty, value);
}

private static void SetErrorText(BindableObject bindable, object oldValue, object newValue) =>
(bindable as ErrorIndicator).lblErrorText.Text = (string)newValue;


public static readonly BindableProperty ErrorImageProperty = BindableProperty.Create(
"ErrorImage",
typeof(ImageSource),
typeof(ErrorIndicator),
null,
BindingMode.OneWay,
null,
SetErrorImage);

public ImageSource ErrorImage
{
get => (ImageSource)this.GetValue(ErrorImageProperty);
set => this.SetValue(ErrorImageProperty, value);
}

private static void SetErrorImage(BindableObject bindable, object oldValue, object newValue) =>
(bindable as ErrorIndicator).imgError.Source = (ImageSource)newValue;


public ErrorIndicator()
{
InitializeComponent();
}
}
27 changes: 27 additions & 0 deletions src/MauiTubePlayer/ViewControls/Common/LoadingIndicator.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<VerticalStackLayout
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiTubePlayer.ViewControls.Common.LoadingIndicator"
IsVisible="False"
Padding="48,12"
Spacing="4">

<ActivityIndicator
x:Name="actIndicator"
IsRunning="False"
WidthRequest="44"
HeightRequest="44"
HorizontalOptions="Center"
Color="{StaticResource LightColor}"
Scale="{OnPlatform iOS=1.3, Android=1.0}" />

<Label
x:Name="lblLoadingText"
Style="{StaticResource RegularLightText14}"
LineBreakMode="WordWrap"
HorizontalOptions="Center"
HorizontalTextAlignment="Center" />

</VerticalStackLayout>

53 changes: 53 additions & 0 deletions src/MauiTubePlayer/ViewControls/Common/LoadingIndicator.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
namespace MauiTubePlayer.ViewControls.Common;

public partial class LoadingIndicator : VerticalStackLayout
{
//Bindable Properties

public static readonly BindableProperty IsBusyProperty = BindableProperty.Create(
"IsBusy",
typeof(bool),
typeof(LoadingIndicator),
false,
BindingMode.OneWay,
null,
SetIsBusy);

public bool IsBusy
{
get => (bool)this.GetValue(IsBusyProperty);
set => this.SetValue(IsBusyProperty, value);
}

private static void SetIsBusy(BindableObject bindable, object oldValue, object newValue)
{
LoadingIndicator control = bindable as LoadingIndicator;

control.IsVisible = (bool)newValue;
control.actIndicator.IsRunning = (bool)newValue;
}


public static readonly BindableProperty LoadingTextProperty = BindableProperty.Create(
"LoadingText",
typeof(string),
typeof(LoadingIndicator),
string.Empty,
BindingMode.OneWay,
null,
SetLoadingText);

public string LoadingText
{
get => (string)this.GetValue(LoadingTextProperty);
set => this.SetValue(LoadingTextProperty, value);
}

private static void SetLoadingText(BindableObject bindable, object oldValue, object newValue) =>
(bindable as LoadingIndicator).lblLoadingText.Text = (string)newValue;

public LoadingIndicator()
{
InitializeComponent();
}
}
24 changes: 24 additions & 0 deletions src/MauiTubePlayer/ViewModels/Base/AppViewModelBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace MauiTubePlayer.ViewModels.Base;

public partial class AppViewModelBase : ViewModelBase
{
public INavigation NavigationService { get; set; }
public Page PageService { get; set; }

protected IApiService _appApiService { get; set; }

public AppViewModelBase(IApiService appApiService) :base()
{
_appApiService = appApiService;
}

[RelayCommand]
private async Task NavigateBack() =>
await NavigationService.PopAsync();

[RelayCommand]
private async Task CloseModal() =>
await NavigationService.PopModalAsync();

}

Loading

0 comments on commit 8a06cab

Please sign in to comment.