From 877c6776be68d598e4194ad6f74c9e317b3879b5 Mon Sep 17 00:00:00 2001 From: Mohammad Hossein Rastegarinia Date: Sat, 20 Jan 2024 20:43:05 +0330 Subject: [PATCH] feat(butil): improve Navigator samples in bit Butil demo #6649 (#6650) --- .../Pages/NavigatorPage.razor | 229 +++++++++++++++++- 1 file changed, 225 insertions(+), 4 deletions(-) diff --git a/src/Butil/Demo/Bit.Butil.Demo.Core/Pages/NavigatorPage.razor b/src/Butil/Demo/Bit.Butil.Demo.Core/Pages/NavigatorPage.razor index c5aac2aa55..5aac7969bb 100644 --- a/src/Butil/Demo/Bit.Butil.Demo.Core/Pages/NavigatorPage.razor +++ b/src/Butil/Demo/Bit.Butil.Demo.Core/Pages/NavigatorPage.razor @@ -6,7 +6,7 @@

Navigator

-
+
 @@inject Bit.Butil.Navigator navigator
 
 @@code {
@@ -19,17 +19,238 @@
 

-

Open the DevTools and start clicking on buttons

+

Open the DevTools console and start clicking on buttons



- + +
+
+
Device memory is: @deviceMemory
+ +
+
+
+ + +
+
+
Hardware concurrency is: @hardwareConcurrency
+ +
+
+
+ + +
+
+
Language: @language
+ +
+
+
+ + +
+
+
Languages: @languages
+ +
+
+
+ + +
+
+
Max touch points: @maxTouchPoints
+ +
+
+
+ + +
+
+
Is OnLine: @isOnLine
+ +
+
+
+ + +
+
+
Is Pdf viewer enabled: @isPdfViewerEnabled
+ +
+
+
+ + +
+
+
User agent: @userAgent
+ +
+
+
+ + +
+
+
Is web driver: @isWebDriver
+ +
+
+
+ + +
+
+
Can share: @canShare
+ +
+
+
+ + + +
+
+
+
+ + + +
+
+
+
+ + + +
+
+
+
+ + +
+ +
+ +
+ + +
+
+
+
+ + + +
+
@code { + private string deviceMemory; + + private string hardwareConcurrency; + + private string language; + + private string languages; + + private string maxTouchPoints; + + private string isOnLine; + + private string isPdfViewerEnabled; + + private string userAgent; + + private string isWebDriver; + + private string canShare; + + private string textValue; + private string titleValue; + private string urlValue; + + private int[] sosPattern = [100, 30, 100, 30, 100, 30, 200, 30, 200, 30, 200, 30, 100, 30, 100, 30, 100]; + + + private async Task GetDeviceMemory() + { + var result = await navigator.GetDeviceMemory(); + deviceMemory = result.ToString(); + } + + private async Task GetHardwareConcurrency() + { + var result = await navigator.GetHardwareConcurrency(); + hardwareConcurrency = result.ToString(); + } + + private async Task GetLanguage() + { + var result = await navigator.GetLanguage(); + language = result.ToString(); + } + + private async Task GetLanguages() + { + var result = await navigator.GetLanguages(); + languages = string.Join(",", result); + } + + private async Task GetMaxTouchPoints() + { + var result = await navigator.GetMaxTouchPoints(); + maxTouchPoints = result.ToString(); + } + + private async Task GetIsOnLine() + { + var result = await navigator.IsOnLine(); + isOnLine = result.ToString(); + } + + private async Task GetIsPdfViewerEnabled() + { + var result = await navigator.IsPdfViewerEnabled(); + isPdfViewerEnabled = result.ToString(); + } + private async Task GetUserAgent() { - _ = console.Log("User agent:", await navigator.GetUserAgent()); + var result = await navigator.GetUserAgent(); + userAgent = result.ToString(); + } + + private async Task GetCanShare() + { + var result = await navigator.CanShare(); + canShare = result.ToString(); + } + + private async Task GetIsWebDriver() + { + var result = await navigator.IsWebDriver(); + isWebDriver = result.ToString(); + } + + private async Task Share() + { + var shareData = new ShareData() + { + Text = textValue, + title = titleValue, + url = urlValue + }; + + await navigator.Share(shareData); } } \ No newline at end of file