-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from egvijayanand/working
Window TitleBar for Desktop
- Loading branch information
Showing
53 changed files
with
1,693 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Application | ||
x:Class="TitleBarApp.App" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:d="http://schemas.microsoft.com/dotnet/2021/maui/design" | ||
xmlns:local="clr-namespace:TitleBarApp" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="Resources/Colors.xaml" /> | ||
<ResourceDictionary Source="Resources/Styles.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
<!-- Additional Styles --> | ||
<x:Double x:Key="ItemSpacing">10</x:Double> | ||
<x:String x:Key="BoldFont">OS600</x:String> | ||
|
||
<Style | ||
ApplyToDerivedTypes="True" | ||
TargetType="StackBase"> | ||
<Setter Property="Spacing" Value="{StaticResource ItemSpacing}" /> | ||
</Style> | ||
|
||
<Style | ||
x:Key="Title" | ||
TargetType="Label"> | ||
<Setter Property="FontFamily" Value="{StaticResource AppFont}" /> | ||
<Setter Property="FontSize" Value="16" /> | ||
<Setter Property="TextColor" Value="{StaticResource White}" /> | ||
<Setter Property="HorizontalOptions" Value="Center" /> | ||
<Setter Property="VerticalOptions" Value="Center" /> | ||
</Style> | ||
|
||
<Style | ||
x:Key="AppTitle" | ||
BasedOn="{StaticResource Title}" | ||
TargetType="Label"> | ||
<Setter Property="FontFamily" Value="{StaticResource BoldFont}" /> | ||
<Setter Property="FontSize" Value="18" /> | ||
</Style> | ||
|
||
<Style | ||
x:Key="MauiLabel" | ||
TargetType="Label"> | ||
<Setter Property="TextColor" Value="{AppThemeBinding Dark={StaticResource White}, Light={StaticResource Primary}}" /> | ||
</Style> | ||
|
||
<Style | ||
x:Key="Action" | ||
TargetType="Button"> | ||
<Setter Property="BackgroundColor" Value="{AppThemeBinding Dark={StaticResource BackgroundDark}, Light={StaticResource BackgroundLight}}" /> | ||
<Setter Property="TextColor" Value="{AppThemeBinding Dark={StaticResource TextDark}, Light={StaticResource TextLight}}" /> | ||
<Setter Property="FontFamily" Value="{StaticResource AppFont}" /> | ||
<Setter Property="FontSize" Value="{StaticResource AppFontSize}" /> | ||
<Setter Property="Padding" Value="14,10" /> | ||
</Style> | ||
|
||
<Style | ||
x:Key="PrimaryAction" | ||
BasedOn="{StaticResource Action}" | ||
TargetType="Button"> | ||
<Setter Property="BackgroundColor" Value="{StaticResource Primary}" /> | ||
<Setter Property="FontAttributes" Value="Bold" /> | ||
<Setter Property="TextColor" Value="{StaticResource White}" /> | ||
</Style> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace TitleBarApp; | ||
|
||
public partial class App : Application | ||
{ | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
|
||
UserAppTheme = PlatformAppTheme; | ||
} | ||
|
||
protected override Window CreateWindow(IActivationState? activationState) | ||
=> new MainWindow(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Shell | ||
x:Class="TitleBarApp.AppShell" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:vw="clr-namespace:TitleBarApp.Views" | ||
FlyoutBehavior="Locked"> | ||
<!-- | ||
The overall app visual hierarchy is defined here, along with navigation. | ||
Ensure atleast a Flyout item or a TabBar is defined for Shell to work | ||
--> | ||
<Shell.Resources> | ||
<!-- | ||
Define the resources to be used within this Shell visual hierarchy | ||
--> | ||
</Shell.Resources> | ||
<!-- | ||
When the Flyout is visible this defines the content to display in the flyout. | ||
FlyoutDisplayOptions="AsMultipleItems" will create a separate flyout item for each child element | ||
--> | ||
<FlyoutItem Title="No TitleBar"> | ||
<ShellContent | ||
ContentTemplate="{DataTemplate vw:MainPage}" | ||
Route="home" /> | ||
</FlyoutItem> | ||
<FlyoutItem Title="TitleBar (XAML)"> | ||
<ShellContent | ||
ContentTemplate="{DataTemplate vw:XamlPage}" | ||
Route="xaml" /> | ||
</FlyoutItem> | ||
<FlyoutItem Title="TitleBar (C#)"> | ||
<ShellContent | ||
ContentTemplate="{DataTemplate vw:CSharpPage}" | ||
Route="csharp" /> | ||
</FlyoutItem> | ||
<!-- | ||
When the Flyout is visible this will be a menu item you can tie a click behavior to | ||
--> | ||
<!-- | ||
<MenuItem | ||
Clicked="OnMenuItemClicked" | ||
Text="Logout" /> | ||
--> | ||
<!-- | ||
TabBar lets you define content that won't show up in a Flyout menu. When this content is active | ||
the flyout menu won't be available. This is useful for creating areas of the application where | ||
you don't want users to be able to navigate away from. If you would like to navigate to this | ||
content you can do so by calling | ||
await Shell.Current.GoToAsync("//login"); | ||
--> | ||
<!-- | ||
<TabBar> | ||
<ShellContent | ||
ContentTemplate="{DataTemplate local:LoginPage}" | ||
Route="login" /> | ||
</TabBar> | ||
--> | ||
<!-- Optional Templates | ||
// These may be provided inline as below or as separate classes. | ||
// This header appears at the top of the Flyout | ||
<Shell.FlyoutHeaderTemplate> | ||
<DataTemplate> | ||
<Grid>ContentHere</Grid> | ||
</DataTemplate> | ||
</Shell.FlyoutHeaderTemplate> | ||
// ItemTemplate is for ShellItems as displayed in a Flyout | ||
<Shell.ItemTemplate> | ||
<DataTemplate> | ||
<ContentView> | ||
Bindable Properties: Title, Icon | ||
</ContentView> | ||
</DataTemplate> | ||
</Shell.ItemTemplate> | ||
// MenuItemTemplate is for MenuItems as displayed in a Flyout | ||
<Shell.MenuItemTemplate> | ||
<DataTemplate> | ||
<ContentView> | ||
Bindable Properties: Text, Icon | ||
</ContentView> | ||
</DataTemplate> | ||
</Shell.MenuItemTemplate> | ||
// This footer appears at the bottom of the Flyout | ||
<Shell.FlyoutFooterTemplate> | ||
<DataTemplate> | ||
<Grid>ContentHere</Grid> | ||
</DataTemplate> | ||
</Shell.FlyoutFooterTemplate> | ||
--> | ||
</Shell> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace TitleBarApp | ||
{ | ||
public partial class AppShell : Shell | ||
{ | ||
public AppShell() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally> | ||
<MauiVersion>9.*</MauiVersion> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// .NET MAUI Markup | ||
global using CommunityToolkit.Maui.Markup; | ||
|
||
// MVVM Toolkit | ||
global using CommunityToolkit.Mvvm.ComponentModel; | ||
global using CommunityToolkit.Mvvm.Input; | ||
|
||
global using TitleBarApp; | ||
global using TitleBarApp.Views; | ||
|
||
// Shared Toolkit | ||
global using VijayAnand.Toolkit.Markup; | ||
|
||
// Static | ||
global using static CommunityToolkit.Maui.Markup.GridRowsColumns; | ||
global using static Microsoft.Maui.Graphics.Colors; | ||
global using static VijayAnand.Toolkit.Markup.ResourceHelper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Window | ||
x:Class="TitleBarApp.MainWindow" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:TitleBarApp" | ||
Title="TitleBarApp"> | ||
<!-- Page is the Content Property of the Window --> | ||
<local:AppShell /> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace TitleBarApp | ||
{ | ||
public partial class MainWindow : Window | ||
{ | ||
public MainWindow() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public MainWindow(Page page) : base(page) | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace TitleBarApp | ||
{ | ||
public static partial class MauiProgram | ||
{ | ||
public static MauiApp CreateMauiApp() | ||
{ | ||
var builder = MauiApp.CreateBuilder(); | ||
builder.UseMauiApp<App>() | ||
.UseMauiCommunityToolkitMarkup() | ||
.ConfigureFonts(fonts => | ||
{ | ||
fonts.AddFont("OpenSans-Regular.ttf", "OS400"); | ||
fonts.AddFont("OpenSans-SemiBold.ttf", "OS600"); | ||
fonts.AddFont("fa-solid-900.ttf", "FAS"); | ||
}); | ||
|
||
#if DEBUG | ||
builder.Logging.AddDebug(); | ||
#endif | ||
|
||
return builder.Build(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Window | ||
x:Class="TitleBarApp.MyWindow" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:vw="clr-namespace:TitleBarApp.Views" | ||
Title="MyApp"> | ||
<Window.Page> | ||
<vw:MainPage /> | ||
</Window.Page> | ||
<Window.TitleBar> | ||
<!-- Can also be defined separately and included here --> | ||
<!--<vw:MyTitleBar />--> | ||
<TitleBar | ||
BackgroundColor="{StaticResource Primary}" | ||
ForegroundColor="{StaticResource White}" | ||
HeightRequest="48"> | ||
<!-- Customized Title and Subtitle --> | ||
<TitleBar.LeadingContent> | ||
<Grid | ||
Margin="20,0,0,0" | ||
ColumnDefinitions="Auto,Auto,Auto" | ||
ColumnSpacing="15" | ||
VerticalOptions="Center"> | ||
<Image | ||
HeightRequest="16" | ||
Source="dotnet_bot.png" | ||
WidthRequest="16" /> | ||
<Label | ||
Grid.Column="1" | ||
Style="{StaticResource AppTitle}" | ||
Text="MyApp" /> | ||
<Label | ||
Grid.Column="2" | ||
Style="{StaticResource Title}" | ||
Text="Home" /> | ||
</Grid> | ||
</TitleBar.LeadingContent> | ||
<TitleBar.Content> | ||
<SearchBar | ||
BackgroundColor="{StaticResource White}" | ||
HorizontalOptions="Fill" | ||
MaximumWidthRequest="300" | ||
Placeholder="Search" | ||
VerticalOptions="Center" /> | ||
</TitleBar.Content> | ||
<TitleBar.TrailingContent> | ||
<ImageButton | ||
Background="Transparent" | ||
BorderWidth="0" | ||
HeightRequest="36" | ||
WidthRequest="36"> | ||
<ImageButton.Source> | ||
<FontImageSource | ||
FontFamily="FAS" | ||
Glyph="" | ||
Size="18" /> | ||
</ImageButton.Source> | ||
</ImageButton> | ||
</TitleBar.TrailingContent> | ||
</TitleBar> | ||
</Window.TitleBar> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace TitleBarApp | ||
{ | ||
public partial class MyWindow : Window | ||
{ | ||
public MyWindow() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public MyWindow(Page page) : base(page) | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="35" /> | ||
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Android.App; | ||
using Android.Content.PM; | ||
using Android.OS; | ||
|
||
namespace TitleBarApp | ||
{ | ||
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)] | ||
public class MainActivity : MauiAppCompatActivity | ||
{ | ||
|
||
} | ||
} |
Oops, something went wrong.