Skip to content

Commit 48ab573

Browse files
committed
Adding Examples Folder + FInding 2 bugs
Found Bugs in Stepper, and in DateTime Pickers. Also added fully working Example in MAUI
1 parent dc45a54 commit 48ab573

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1113
-10
lines changed

examples/maui-demo/App.xaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:Syncfusion.JsonForms.MauiDemo"
5+
x:Class="Syncfusion.JsonForms.MauiDemo.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
9+
<!--
10+
For information about styling .NET MAUI pages
11+
please refer to the documentation:
12+
https://go.microsoft.com/fwlink/?linkid=2282329
13+
-->
14+
15+
</ResourceDictionary>
16+
</Application.Resources>
17+
</Application>

examples/maui-demo/App.xaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Syncfusion.JsonForms.MauiDemo
2+
{
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
9+
MainPage = new MainPage();
10+
}
11+
}
12+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@inherits LayoutComponentBase
2+
3+
<div class="page">
4+
<div class="sidebar">
5+
<NavMenu />
6+
</div>
7+
8+
<main>
9+
<div class="top-row px-4">
10+
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
11+
</div>
12+
13+
<article class="content px-4">
14+
@Body
15+
</article>
16+
</main>
17+
</div>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
.page {
2+
position: relative;
3+
display: flex;
4+
flex-direction: column;
5+
}
6+
7+
main {
8+
flex: 1;
9+
}
10+
11+
.sidebar {
12+
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
13+
}
14+
15+
.top-row {
16+
background-color: #f7f7f7;
17+
border-bottom: 1px solid #d6d5d5;
18+
justify-content: flex-end;
19+
height: 3.5rem;
20+
display: flex;
21+
align-items: center;
22+
}
23+
24+
.top-row ::deep a, .top-row ::deep .btn-link {
25+
white-space: nowrap;
26+
margin-left: 1.5rem;
27+
text-decoration: none;
28+
}
29+
30+
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
31+
text-decoration: underline;
32+
}
33+
34+
.top-row ::deep a:first-child {
35+
overflow: hidden;
36+
text-overflow: ellipsis;
37+
}
38+
39+
@media (max-width: 640.98px) {
40+
.top-row {
41+
justify-content: space-between;
42+
}
43+
44+
.top-row ::deep a, .top-row ::deep .btn-link {
45+
margin-left: 0;
46+
}
47+
}
48+
49+
@media (min-width: 641px) {
50+
.page {
51+
flex-direction: row;
52+
}
53+
54+
.sidebar {
55+
width: 250px;
56+
height: 100vh;
57+
position: sticky;
58+
top: 0;
59+
}
60+
61+
.top-row {
62+
position: sticky;
63+
top: 0;
64+
z-index: 1;
65+
}
66+
67+
.top-row.auth ::deep a:first-child {
68+
flex: 1;
69+
text-align: right;
70+
width: 0;
71+
}
72+
73+
.top-row, article {
74+
padding-left: 2rem !important;
75+
padding-right: 1.5rem !important;
76+
}
77+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div class="top-row ps-3 navbar navbar-dark">
2+
<div class="container-fluid">
3+
<a class="navbar-brand" href="">Syncfusion.JsonForms.MauiDemo</a>
4+
</div>
5+
</div>
6+
7+
<input type="checkbox" title="Navigation menu" class="navbar-toggler" />
8+
9+
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
10+
<nav class="flex-column">
11+
<div class="nav-item px-3">
12+
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
13+
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
14+
</NavLink>
15+
</div>
16+
</nav>
17+
</div>
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
.navbar-toggler {
2+
appearance: none;
3+
cursor: pointer;
4+
width: 3.5rem;
5+
height: 2.5rem;
6+
color: white;
7+
position: absolute;
8+
top: 0.5rem;
9+
right: 1rem;
10+
border: 1px solid rgba(255, 255, 255, 0.1);
11+
background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1);
12+
}
13+
14+
.navbar-toggler:checked {
15+
background-color: rgba(255, 255, 255, 0.5);
16+
}
17+
18+
.top-row {
19+
height: 3.5rem;
20+
background-color: rgba(0,0,0,0.4);
21+
}
22+
23+
.navbar-brand {
24+
font-size: 1.1rem;
25+
}
26+
27+
.bi {
28+
display: inline-block;
29+
position: relative;
30+
width: 1.25rem;
31+
height: 1.25rem;
32+
margin-right: 0.75rem;
33+
top: -1px;
34+
background-size: cover;
35+
}
36+
37+
.bi-house-door-fill-nav-menu {
38+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E");
39+
}
40+
41+
.bi-plus-square-fill-nav-menu {
42+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E");
43+
}
44+
45+
.bi-list-nested-nav-menu {
46+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
47+
}
48+
49+
.nav-item {
50+
font-size: 0.9rem;
51+
padding-bottom: 0.5rem;
52+
}
53+
54+
.nav-item:first-of-type {
55+
padding-top: 1rem;
56+
}
57+
58+
.nav-item:last-of-type {
59+
padding-bottom: 1rem;
60+
}
61+
62+
.nav-item ::deep a {
63+
color: #d7d7d7;
64+
border-radius: 4px;
65+
height: 3rem;
66+
display: flex;
67+
align-items: center;
68+
line-height: 3rem;
69+
}
70+
71+
.nav-item ::deep a.active {
72+
background-color: rgba(255,255,255,0.37);
73+
color: white;
74+
}
75+
76+
.nav-item ::deep a:hover {
77+
background-color: rgba(255,255,255,0.1);
78+
color: white;
79+
}
80+
81+
.nav-scrollable {
82+
display: none;
83+
}
84+
85+
.navbar-toggler:checked ~ .nav-scrollable {
86+
display: block;
87+
}
88+
89+
@media (min-width: 641px) {
90+
.navbar-toggler {
91+
display: none;
92+
}
93+
94+
.nav-scrollable {
95+
/* Never collapse the sidebar for wide screens */
96+
display: block;
97+
/* Allow sidebar to scroll for tall menus */
98+
height: calc(100vh - 3.5rem);
99+
overflow-y: auto;
100+
}
101+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
@page "/"
2+
@using Newtonsoft.Json.Linq
3+
@using Orbyss.Blazor.JsonForms.Context.Models
4+
5+
6+
<h1>Syncfusion Json Form!</h1>
7+
8+
<label for="languageselector">
9+
Change language
10+
</label>
11+
<select id="languageselector" @bind="selectedLanguage">
12+
<option value="">-- Select Language --</option>
13+
@foreach (var lan in languages)
14+
{
15+
<option value="@lan">@lan</option>
16+
}
17+
</select>
18+
19+
@if (string.IsNullOrWhiteSpace(value))
20+
{
21+
<CascadingValue Value="@selectedLanguage">
22+
23+
<JsonForm InitOptions="@options"
24+
OnSubmit="@OnSubmit" />
25+
26+
</CascadingValue>
27+
}
28+
else
29+
{
30+
<p>Submitted form data:</p>
31+
<p>@value</p>
32+
}
33+
34+
@code {
35+
string? value;
36+
37+
const string jsonSchema = "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"required\":[\"name\",\"address\",\"status\",\"dateOfBirth\",\"requestedOn\"],\"properties\":{\"name\":{\"type\":\"string\"},\"dateOfBirth\":{\"type\":\"string\",\"format\":\"date\"},\"address\":{\"type\":\"object\",\"required\":[\"street\",\"number\"],\"properties\":{\"street\":{\"type\":\"string\",\"minLength\":5},\"number\":{\"type\":\"string\",\"maxLength\":5}}},\"requestedOn\":{\"type\":\"string\",\"format\":\"datetime\"},\"status\":{\"type\":\"string\",\"enum\":[\"Pending\",\"Approved\",\"Rejected\"]}}}";
38+
const string uiSchema = "{\"type\":\"VerticalLayout\",\"elements\":[{\"type\":\"Control\",\"scope\":\"#/properties/name\"},{\"type\":\"Control\",\"scope\":\"#/properties/dateOfBirth\"},{\"type\":\"Control\",\"scope\":\"#/properties/address/properties/street\"},{\"type\":\"Control\",\"scope\":\"#/properties/address/properties/number\"},{\"type\":\"Control\",\"scope\":\"#/properties/status\"},{\"type\":\"Control\",\"scope\":\"#/properties/requestedOn\"}]}";
39+
const string translationSchemaJson = "{\"resources\":{\"en\":{\"translation\":{\"name\":{\"label\":\"Name\"},\"dateOfBirth\":{\"label\":\"Date of birth\"},\"status\":{\"label\":\"Status\",\"Pending\":\"Pending\",\"Approved\":\"Approved\",\"Rejected\":\"Rejected\"},\"address\":{\"label\":\"Address\",\"street\":{\"label\":\"Street\",\"error\":{\"minimumLength\":\"Custom message: street must have more than 5 characters\"}},\"number\":{\"label\":\"Street number\",\"error\":{\"maximumLength\":\"Custom message: street number can have no more than 5 characters\"}}},\"requestedOn\":{\"label\":\"Requested on\"}}},\"nl\":{\"translation\":{\"name\":{\"label\":\"Naam\"},\"dateOfBirth\":{\"label\":\"Geboortedatum\"},\"status\":{\"label\":\"Status\",\"Pending\":\"In afwachting\",\"Approved\":\"Goedgekeurd\",\"Rejected\":\"Afgekeurd\"},\"address\":{\"label\":\"Adres\",\"street\":{\"label\":\"Straat\",\"error\":{\"minimumLength\":\"Custom bericht: Straat moet minimaal 5 karaketers bevatten\"}},\"number\":{\"label\":\"Straatnummer\",\"error\":{\"maximumLength\":\"Custom bericht: Straat nummer mag maximaal 5 karaketers bevatten\"}}},\"requestedOn\":{\"label\":\"Aangevraag op\"}}}}}";
40+
41+
private static readonly JsonFormContextInitOptions options = new(jsonSchema, uiSchema, translationSchemaJson);
42+
43+
string? selectedLanguage = "";
44+
string[] languages =
45+
[
46+
"nl",
47+
"en"
48+
];
49+
50+
Task OnSubmit(JToken value)
51+
{
52+
this.value = $"{value}";
53+
return InvokeAsync(StateHasChanged);
54+
}
55+
56+
protected override void OnInitialized()
57+
{
58+
base.OnInitialized();
59+
}
60+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Router AppAssembly="@typeof(MauiProgram).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)" />
4+
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
5+
</Found>
6+
</Router>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@using System.Net.Http
2+
@using System.Net.Http.Json
3+
@using Microsoft.AspNetCore.Components.Forms
4+
@using Microsoft.AspNetCore.Components.Routing
5+
@using Microsoft.AspNetCore.Components.Web
6+
@using Microsoft.AspNetCore.Components.Web.Virtualization
7+
@using Microsoft.JSInterop
8+
@using Syncfusion.JsonForms.MauiDemo
9+
@using Syncfusion.JsonForms.MauiDemo.Components
10+
11+
@using Orbyss.Blazor.JsonForms

examples/maui-demo/MainPage.xaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:Syncfusion.JsonForms.MauiDemo"
5+
x:Class="Syncfusion.JsonForms.MauiDemo.MainPage">
6+
7+
<BlazorWebView x:Name="blazorWebView" HostPage="wwwroot/index.html">
8+
<BlazorWebView.RootComponents>
9+
<RootComponent Selector="#app" ComponentType="{x:Type local:Components.Routes}" />
10+
</BlazorWebView.RootComponents>
11+
</BlazorWebView>
12+
13+
</ContentPage>

0 commit comments

Comments
 (0)