Layout improvements

pull/301/head
Halil İbrahim Kalkan 7 years ago
parent a6a23f943c
commit 9d76e8c331

@ -8,11 +8,19 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic
{
public const string Name = "Basic";
public string DefaultLayout => "~/Themes/Basic/Layouts/App.cshtml";
public string GetLayoutOrNull(string name)
public string GetLayout(string name, bool fallbackToDefault = true)
{
return DefaultLayout;
switch (name)
{
case StandardLayouts.Application:
return "~/Themes/Basic/Layouts/Application.cshtml";
case StandardLayouts.Account:
return "~/Themes/Basic/Layouts/Application.cshtml";
case StandardLayouts.Empty:
return "~/Themes/Basic/Layouts/Empty.cshtml";
default:
return fallbackToDefault ? "~/Themes/Basic/Layouts/Application.cshtml" : null;
}
}
}
}

@ -1,6 +0,0 @@
@using Volo.Abp.AspNetCore.Mvc.UI.Theming
@inject IThemeManager ThemeManager
@{
//TODO: Move this to a lower layer... to Shared?
Layout = ThemeManager.CurrentTheme.DefaultLayout;
}

@ -0,0 +1,38 @@
@using Volo.Abp.AspNetCore.Mvc.AntiForgery
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.MainNavbar
@inject IAbpAntiForgeryManager AbpAntiForgeryManager
@{
Layout = null;
AbpAntiForgeryManager.SetCookie();
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>ABP Web Application</title>
<vc:abp-style-bundle name="GlobalStyles"></vc:abp-style-bundle>
<link rel="stylesheet" type="text/css" href="~/views/shared/_AppLayout.css" />
@RenderSection("styles", false)
</head>
<body>
<div class="container-fluid">
@RenderBody()
</div>
<vc:abp-script-bundle name="GlobalScripts"></vc:abp-script-bundle>
<script type="text/javascript" src="~/Abp/ApplicationConfigurationScript"></script>
<script type="text/javascript" src="~/Abp/ServiceProxyScript"></script>
@RenderSection("scripts", false)
</body>
</html>

@ -1,6 +0,0 @@
@using Volo.Abp.AspNetCore.Mvc.UI.Theming
@inject IThemeManager ThemeManager
@{
//TODO: Move this to a lower layer... to Shared?
Layout = ThemeManager.CurrentTheme.DefaultLayout;
}

@ -21,10 +21,6 @@
<EmbeddedResource Include="wwwroot\**\*.*" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Remove="Themes\Basic\_ViewImports.cshtml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj" />
</ItemGroup>

@ -0,0 +1,5 @@
@using Volo.Abp.AspNetCore.Mvc.UI.Theming
@inject IThemeManager ThemeManager
@{
Layout = ThemeManager.CurrentTheme.GetApplicationLayout();
}

@ -0,0 +1,5 @@
@using Volo.Abp.AspNetCore.Mvc.UI.Theming
@inject IThemeManager ThemeManager
@{
Layout = ThemeManager.CurrentTheme.GetApplicationLayout();
}

@ -0,0 +1,5 @@
@using Volo.Abp.AspNetCore.Mvc.UI.Theming
@inject IThemeManager ThemeManager
@{
Layout = ThemeManager.CurrentTheme.GetApplicationLayout();
}

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\common.props" />
@ -16,6 +16,9 @@
<ItemGroup>
<EmbeddedResource Include="wwwroot\**\*.*" />
<EmbeddedResource Include="Pages\**\*.cshtml" />
<EmbeddedResource Include="Views\**\*.cshtml" />
<EmbeddedResource Include="Areas\**\*.cshtml" />
</ItemGroup>
<ItemGroup>

@ -2,8 +2,6 @@
{
public interface ITheme
{
string DefaultLayout { get; }
string GetLayoutOrNull(string name);
string GetLayout(string name, bool fallbackToDefault = true);
}
}

@ -0,0 +1,9 @@
namespace Volo.Abp.AspNetCore.Mvc.UI.Theming
{
public static class StandardLayouts
{
public const string Application = "Application";
public const string Account = "Account";
public const string Empty = "Empty";
}
}

@ -0,0 +1,20 @@
namespace Volo.Abp.AspNetCore.Mvc.UI.Theming
{
public static class ThemeExtensions
{
public static string GetApplicationLayout(this ITheme theme, bool fallbackToDefault = true)
{
return theme.GetLayout(StandardLayouts.Application, fallbackToDefault);
}
public static string GetAccountLayout(this ITheme theme, bool fallbackToDefault = true)
{
return theme.GetLayout(StandardLayouts.Account, fallbackToDefault);
}
public static string GetEmptyLayout(this ITheme theme, bool fallbackToDefault = true)
{
return theme.GetLayout(StandardLayouts.Empty, fallbackToDefault);
}
}
}
Loading…
Cancel
Save