├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── .gitmodules ├── Docs ├── 20200428_114227.mp4 ├── 3-modes.gif ├── Banner.png ├── acrylic.png ├── acrylic_android.png ├── acrylic_ios.png ├── android_dark_blur.png ├── android_extralightblur.png ├── android_lightblur.png ├── android_mockups.pdn ├── blog_banner.pdn ├── blur_dark.png ├── blur_light.png ├── blur_toggle.gif ├── dark.png ├── dark_elevation.png ├── dynamic_themes.gif ├── frame_acrylic.png ├── frame_blur_dark.png ├── frame_blur_extralight.png ├── frame_blur_light.png ├── frame_dark.png ├── frame_light.png ├── github_banner.pdn ├── github_banner.png ├── ios_acrylic.png ├── ios_darkblur.png ├── ios_extralightblur.png ├── ios_lightblur.png ├── light.png ├── material_frame.pdn ├── material_frame.png ├── material_frame_maui.pdn ├── material_frame_maui.png ├── social_preview.png ├── twitter_banner.pdn ├── twitter_banner.png ├── uwp.mp4 ├── uwp_acrylic.png ├── uwp_dark_blur.png ├── uwp_extralight_blur.png └── uwp_light_blur.png ├── LICENSE ├── MaterialFrame ├── AssemblyInfo.targets ├── MaterialFrame.Android │ ├── AndroidMaterialFrameRenderer.Blur.cs │ ├── AndroidMaterialFrameRenderer.cs │ ├── AndroidStockBlurImpl.cs │ ├── AssemblyInfo.cs │ ├── BlurView │ │ ├── AndroidMaterialFrameRenderer.Blur.cs │ │ ├── BlockingBlurController.cs │ │ ├── BlurViewFacade.cs │ │ └── RenderScriptBlur.cs │ ├── IBlurImpl.cs │ ├── JniExtensions.cs │ ├── JniWeakReference.cs │ ├── MaterialFrame.Android.csproj │ └── RealtimeBlurView.cs ├── MaterialFrame.UWP │ ├── AssemblyInfo.cs │ ├── MaterialFrame.UWP.csproj │ ├── Properties │ │ └── MaterialFrame.UWP.rd.xml │ └── UWPMaterialFrameRenderer.cs ├── MaterialFrame.iOS │ ├── AssemblyInfo.cs │ ├── MaterialFrame.iOS.csproj │ └── iOSMaterialFrameRenderer.cs ├── MaterialFrame.macOS │ ├── AssemblyInfo.cs │ ├── MaterialFrame.macOS.csproj │ └── macOSMaterialFrameRenderer.cs ├── MaterialFrame.sln ├── MaterialFrame │ ├── AssemblyConfiguration.cs │ ├── AssemblyInfo.cs │ ├── Initializer.cs │ ├── InternalLogger.cs │ ├── MaterialFrame.Android.cs │ ├── MaterialFrame.UWP.cs │ ├── MaterialFrame.cs │ ├── MaterialFrame.csproj │ └── MaterialFrame.macOS.cs ├── Settings.XamlStyler └── StyleCopRules.ruleset ├── Maui.MaterialFrame ├── AssemblyConfiguration.cs ├── Initializer.cs ├── InternalLogger.cs ├── MaterialFrame.Android.cs ├── MaterialFrame.MacCatalyst.cs ├── MaterialFrame.Windows.cs ├── MaterialFrame.cs ├── Maui.MaterialFrame.csproj ├── Maui.MaterialFrame.sln ├── Maui.MaterialFrame.sln.DotSettings ├── MauiAppBuilderExtensions.cs ├── Platforms │ ├── Android │ │ ├── AndroidMaterialFrameRenderer.Blur.cs │ │ ├── AndroidMaterialFrameRenderer.cs │ │ ├── AndroidStockBlurImpl.cs │ │ ├── BlurView │ │ │ ├── BlockingBlurController.cs │ │ │ ├── BlurViewFacade.cs │ │ │ └── RenderScriptBlur.cs │ │ ├── IBlurImpl.cs │ │ ├── JniExtensions.cs │ │ ├── JniWeakReference.cs │ │ └── RealtimeBlurView.cs │ ├── MacCatalyst │ │ ├── MacCatalystMaterialFrameRenderer.cs │ │ └── macOSMaterialFrameRenderer.cs │ ├── Tizen │ │ └── PlatformClass1.cs │ ├── Windows │ │ └── WinUIMaterialFrameRenderer.cs │ └── iOS │ │ └── iOSMaterialFrameRenderer.cs ├── ReadMe.md ├── Settings.XamlStyler └── StyleCopRules.ruleset ├── README.md ├── Samples └── Sharpnado.Acrylic.Maui │ ├── App.xaml │ ├── App.xaml.cs │ ├── GridAnimations.cs │ ├── MainPage.xaml │ ├── MainPage.xaml.cs │ ├── MainPagePouet.xaml │ ├── MainPagePouet.xaml.cs │ ├── MauiProgram.cs │ ├── Platforms │ ├── Android │ │ ├── AndroidManifest.xml │ │ ├── MainActivity.cs │ │ ├── MainApplication.cs │ │ └── Resources │ │ │ └── values │ │ │ └── colors.xml │ ├── MacCatalyst │ │ ├── AppDelegate.cs │ │ ├── Info.plist │ │ └── Program.cs │ ├── Tizen │ │ ├── Main.cs │ │ └── tizen-manifest.xml │ ├── Windows │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── Package.appxmanifest │ │ └── app.manifest │ └── iOS │ │ ├── AppDelegate.cs │ │ ├── Info.plist │ │ └── Program.cs │ ├── Resources │ ├── AppIcon │ │ ├── appicon.svg │ │ └── appiconfg.svg │ ├── Fonts │ │ ├── Font-Awesome-5-Brands-Regular-400.otf │ │ ├── Font-Awesome-5-Free-Regular-400.otf │ │ ├── Font-Awesome-5-Free-Solid-900.otf │ │ ├── OpenSans-Bold.ttf │ │ ├── OpenSans-BoldItalic.ttf │ │ ├── OpenSans-ExtraBold.ttf │ │ ├── OpenSans-ExtraBoldItalic.ttf │ │ ├── OpenSans-Italic.ttf │ │ ├── OpenSans-Light.ttf │ │ ├── OpenSans-LightItalic.ttf │ │ ├── OpenSans-Regular.ttf │ │ ├── OpenSans-SemiBoldItalic.ttf │ │ └── OpenSans-Semibold.ttf │ ├── Images │ │ ├── ableton.png │ │ ├── azure.png │ │ ├── bing_dark.jpg │ │ ├── bing_light.jpg │ │ ├── catalina_dark.jpg │ │ ├── catalina_light.jpg │ │ ├── dota.png │ │ ├── dotnet_bot.svg │ │ ├── duckduckgo.png │ │ ├── file_gpx.png │ │ ├── file_mp3.png │ │ ├── file_pdf.png │ │ ├── file_word.png │ │ ├── me.jpg │ │ ├── milky_light.jpg │ │ ├── piedpiper.png │ │ ├── powerpoint.png │ │ ├── slack.png │ │ ├── undersea_light.jpg │ │ ├── vista_portrait_2.jpg │ │ ├── visualstudio.png │ │ ├── winamp.png │ │ ├── windows7_portrait.png │ │ ├── word.png │ │ └── xamarin.png │ ├── Raw │ │ └── AboutAssets.txt │ ├── Splash │ │ └── splash.svg │ └── Styles │ │ ├── Buttons.xaml │ │ ├── Colors.xaml │ │ ├── ColorsPouet.xaml │ │ ├── Global.xaml │ │ ├── IconFont.cs │ │ ├── Icons.xaml │ │ ├── Image.xaml │ │ ├── Labels.xaml │ │ ├── MaterialFrame.xaml │ │ ├── Sizes.xaml │ │ ├── StylesPouet.xaml │ │ └── Text.xaml │ ├── ResourcesHelper.cs │ ├── Sharpnado.Acrylic.Maui.App.sln │ ├── Sharpnado.Acrylic.Maui.csproj │ └── Sharpnado.Acrylic.Maui.sln ├── Sharpnado.MaterialFrame.nuspec └── make-package.ps1 /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Platform (please complete the following information):** 11 | - OS: [iOS/Android/Both] 12 | - Device: [iPhone6/iPhoneSimulator/Pixel/AndroidEmulator/...] 13 | - Sdk vervion: [iOS 11/Android SDK 21] 14 | - Xamarin.Forms: [3.4.0.1029999] 15 | 16 | **Describe the bug** 17 | A clear and concise description of what the bug is. 18 | 19 | **To Reproduce** 20 | Steps to reproduce the behavior: 21 | 1. Go to '...' 22 | 2. Click on '....' 23 | 3. Scroll down to '....' 24 | 4. See error 25 | 26 | **Exceptions (if applicable)** 27 | Copy paste the exception and the stack trace 28 | ``` 29 | Unhandled Exception: 30 | System.InvalidOperationException: exception message 31 | at Namespace.Call 32 | at .... 33 | ``` 34 | 35 | **Screenshots (if applicable)** 36 | If applicable, add screenshots to help explain your problem. 37 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015/2017 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # Visual Studio 2017 auto generated files 33 | Generated\ Files/ 34 | 35 | # MSTest test Results 36 | [Tt]est[Rr]esult*/ 37 | [Bb]uild[Ll]og.* 38 | 39 | # NUNIT 40 | *.VisualState.xml 41 | TestResult.xml 42 | 43 | # Build Results of an ATL Project 44 | [Dd]ebugPS/ 45 | [Rr]eleasePS/ 46 | dlldata.c 47 | 48 | # Benchmark Results 49 | BenchmarkDotNet.Artifacts/ 50 | 51 | # .NET Core 52 | project.lock.json 53 | project.fragment.lock.json 54 | artifacts/ 55 | **/Properties/launchSettings.json 56 | 57 | # StyleCop 58 | StyleCopReport.xml 59 | 60 | # Files built by Visual Studio 61 | *_i.c 62 | *_p.c 63 | *_i.h 64 | *.ilk 65 | *.meta 66 | *.obj 67 | *.iobj 68 | *.pch 69 | *.pdb 70 | *.ipdb 71 | *.pgc 72 | *.pgd 73 | *.rsp 74 | *.sbr 75 | *.tlb 76 | *.tli 77 | *.tlh 78 | *.tmp 79 | *.tmp_proj 80 | *.log 81 | *.vspscc 82 | *.vssscc 83 | .builds 84 | *.pidb 85 | *.svclog 86 | *.scc 87 | 88 | # Chutzpah Test files 89 | _Chutzpah* 90 | 91 | # Visual C++ cache files 92 | ipch/ 93 | *.aps 94 | *.ncb 95 | *.opendb 96 | *.opensdf 97 | *.sdf 98 | *.cachefile 99 | *.VC.db 100 | *.VC.VC.opendb 101 | 102 | # Visual Studio profiler 103 | *.psess 104 | *.vsp 105 | *.vspx 106 | *.sap 107 | 108 | # Visual Studio Trace Files 109 | *.e2e 110 | 111 | # TFS 2012 Local Workspace 112 | $tf/ 113 | 114 | # Guidance Automation Toolkit 115 | *.gpState 116 | 117 | # ReSharper is a .NET coding add-in 118 | _ReSharper*/ 119 | *.[Rr]e[Ss]harper 120 | *.DotSettings.user 121 | 122 | # JustCode is a .NET coding add-in 123 | .JustCode 124 | 125 | # TeamCity is a build add-in 126 | _TeamCity* 127 | 128 | # DotCover is a Code Coverage Tool 129 | *.dotCover 130 | 131 | # AxoCover is a Code Coverage Tool 132 | .axoCover/* 133 | !.axoCover/settings.json 134 | 135 | # Visual Studio code coverage results 136 | *.coverage 137 | *.coveragexml 138 | 139 | # NCrunch 140 | _NCrunch_* 141 | .*crunch*.local.xml 142 | nCrunchTemp_* 143 | 144 | # MightyMoose 145 | *.mm.* 146 | AutoTest.Net/ 147 | 148 | # Web workbench (sass) 149 | .sass-cache/ 150 | 151 | # Installshield output folder 152 | [Ee]xpress/ 153 | 154 | # DocProject is a documentation generator add-in 155 | DocProject/buildhelp/ 156 | DocProject/Help/*.HxT 157 | DocProject/Help/*.HxC 158 | DocProject/Help/*.hhc 159 | DocProject/Help/*.hhk 160 | DocProject/Help/*.hhp 161 | DocProject/Help/Html2 162 | DocProject/Help/html 163 | 164 | # Click-Once directory 165 | publish/ 166 | 167 | # Publish Web Output 168 | *.[Pp]ublish.xml 169 | *.azurePubxml 170 | # Note: Comment the next line if you want to checkin your web deploy settings, 171 | # but database connection strings (with potential passwords) will be unencrypted 172 | *.pubxml 173 | *.publishproj 174 | 175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 176 | # checkin your Azure Web App publish settings, but sensitive information contained 177 | # in these scripts will be unencrypted 178 | PublishScripts/ 179 | 180 | # NuGet Packages 181 | *.nupkg 182 | # The packages folder can be ignored because of Package Restore 183 | **/[Pp]ackages/* 184 | # except build/, which is used as an MSBuild target. 185 | !**/[Pp]ackages/build/ 186 | # Uncomment if necessary however generally it will be regenerated when needed 187 | #!**/[Pp]ackages/repositories.config 188 | # NuGet v3's project.json files produces more ignorable files 189 | *.nuget.props 190 | *.nuget.targets 191 | 192 | # Microsoft Azure Build Output 193 | csx/ 194 | *.build.csdef 195 | 196 | # Microsoft Azure Emulator 197 | ecf/ 198 | rcf/ 199 | 200 | # Windows Store app package directories and files 201 | AppPackages/ 202 | BundleArtifacts/ 203 | Package.StoreAssociation.xml 204 | _pkginfo.txt 205 | *.appx 206 | 207 | # Visual Studio cache files 208 | # files ending in .cache can be ignored 209 | *.[Cc]ache 210 | # but keep track of directories ending in .cache 211 | !*.[Cc]ache/ 212 | 213 | # Others 214 | ClientBin/ 215 | ~$* 216 | *~ 217 | *.dbmdl 218 | *.dbproj.schemaview 219 | *.jfm 220 | *.pfx 221 | *.publishsettings 222 | orleans.codegen.cs 223 | 224 | # Including strong name files can present a security risk 225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 226 | #*.snk 227 | 228 | # Since there are multiple workflows, uncomment next line to ignore bower_components 229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 230 | #bower_components/ 231 | 232 | # RIA/Silverlight projects 233 | Generated_Code/ 234 | 235 | # Backup & report files from converting an old project file 236 | # to a newer Visual Studio version. Backup files are not needed, 237 | # because we have git ;-) 238 | _UpgradeReport_Files/ 239 | Backup*/ 240 | UpgradeLog*.XML 241 | UpgradeLog*.htm 242 | ServiceFabricBackup/ 243 | *.rptproj.bak 244 | 245 | # SQL Server files 246 | *.mdf 247 | *.ldf 248 | *.ndf 249 | 250 | # Business Intelligence projects 251 | *.rdl.data 252 | *.bim.layout 253 | *.bim_*.settings 254 | *.rptproj.rsuser 255 | 256 | # Microsoft Fakes 257 | FakesAssemblies/ 258 | 259 | # GhostDoc plugin setting file 260 | *.GhostDoc.xml 261 | 262 | # Node.js Tools for Visual Studio 263 | .ntvs_analysis.dat 264 | node_modules/ 265 | 266 | # Visual Studio 6 build log 267 | *.plg 268 | 269 | # Visual Studio 6 workspace options file 270 | *.opt 271 | 272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 273 | *.vbw 274 | 275 | # Visual Studio LightSwitch build output 276 | **/*.HTMLClient/GeneratedArtifacts 277 | **/*.DesktopClient/GeneratedArtifacts 278 | **/*.DesktopClient/ModelManifest.xml 279 | **/*.Server/GeneratedArtifacts 280 | **/*.Server/ModelManifest.xml 281 | _Pvt_Extensions 282 | 283 | # Paket dependency manager 284 | .paket/paket.exe 285 | paket-files/ 286 | 287 | # FAKE - F# Make 288 | .fake/ 289 | 290 | # JetBrains Rider 291 | .idea/ 292 | *.sln.iml 293 | 294 | # CodeRush 295 | .cr/ 296 | 297 | # Python Tools for Visual Studio (PTVS) 298 | __pycache__/ 299 | *.pyc 300 | 301 | # Cake - Uncomment if you are using it 302 | # tools/** 303 | # !tools/packages.config 304 | 305 | # Tabs Studio 306 | *.tss 307 | 308 | # Telerik's JustMock configuration file 309 | *.jmconfig 310 | 311 | # BizTalk build output 312 | *.btp.cs 313 | *.btm.cs 314 | *.odx.cs 315 | *.xsd.cs 316 | 317 | # OpenCover UI analysis results 318 | OpenCover/ 319 | 320 | # Azure Stream Analytics local run output 321 | ASALocalRun/ 322 | 323 | # MSBuild Binary and Structured Log 324 | *.binlog 325 | 326 | # NVidia Nsight GPU debugger configuration file 327 | *.nvuser 328 | 329 | # MFractors (Xamarin productivity tool) working folder 330 | .mfractor/ 331 | 332 | # Ignore all differences in line endings 333 | * -crlf 334 | .DS_Store 335 | 336 | # visual studio code 337 | .vscode/ 338 | build*.txt 339 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Samples/Xamarin-Forms-Practices"] 2 | path = Samples/Xamarin-Forms-Practices 3 | url = https://github.com/roubachof/Xamarin-Forms-Practices.git 4 | [submodule "Samples/Sharpnado.Acrylic"] 5 | path = Samples/Sharpnado.Acrylic 6 | url = https://github.com/roubachof/Sharpnado.Acrylic.git 7 | -------------------------------------------------------------------------------- /Docs/20200428_114227.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/20200428_114227.mp4 -------------------------------------------------------------------------------- /Docs/3-modes.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/3-modes.gif -------------------------------------------------------------------------------- /Docs/Banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/Banner.png -------------------------------------------------------------------------------- /Docs/acrylic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/acrylic.png -------------------------------------------------------------------------------- /Docs/acrylic_android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/acrylic_android.png -------------------------------------------------------------------------------- /Docs/acrylic_ios.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/acrylic_ios.png -------------------------------------------------------------------------------- /Docs/android_dark_blur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/android_dark_blur.png -------------------------------------------------------------------------------- /Docs/android_extralightblur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/android_extralightblur.png -------------------------------------------------------------------------------- /Docs/android_lightblur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/android_lightblur.png -------------------------------------------------------------------------------- /Docs/android_mockups.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/android_mockups.pdn -------------------------------------------------------------------------------- /Docs/blog_banner.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/blog_banner.pdn -------------------------------------------------------------------------------- /Docs/blur_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/blur_dark.png -------------------------------------------------------------------------------- /Docs/blur_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/blur_light.png -------------------------------------------------------------------------------- /Docs/blur_toggle.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/blur_toggle.gif -------------------------------------------------------------------------------- /Docs/dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/dark.png -------------------------------------------------------------------------------- /Docs/dark_elevation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/dark_elevation.png -------------------------------------------------------------------------------- /Docs/dynamic_themes.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/dynamic_themes.gif -------------------------------------------------------------------------------- /Docs/frame_acrylic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/frame_acrylic.png -------------------------------------------------------------------------------- /Docs/frame_blur_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/frame_blur_dark.png -------------------------------------------------------------------------------- /Docs/frame_blur_extralight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/frame_blur_extralight.png -------------------------------------------------------------------------------- /Docs/frame_blur_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/frame_blur_light.png -------------------------------------------------------------------------------- /Docs/frame_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/frame_dark.png -------------------------------------------------------------------------------- /Docs/frame_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/frame_light.png -------------------------------------------------------------------------------- /Docs/github_banner.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/github_banner.pdn -------------------------------------------------------------------------------- /Docs/github_banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/github_banner.png -------------------------------------------------------------------------------- /Docs/ios_acrylic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/ios_acrylic.png -------------------------------------------------------------------------------- /Docs/ios_darkblur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/ios_darkblur.png -------------------------------------------------------------------------------- /Docs/ios_extralightblur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/ios_extralightblur.png -------------------------------------------------------------------------------- /Docs/ios_lightblur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/ios_lightblur.png -------------------------------------------------------------------------------- /Docs/light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/light.png -------------------------------------------------------------------------------- /Docs/material_frame.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/material_frame.pdn -------------------------------------------------------------------------------- /Docs/material_frame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/material_frame.png -------------------------------------------------------------------------------- /Docs/material_frame_maui.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/material_frame_maui.pdn -------------------------------------------------------------------------------- /Docs/material_frame_maui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/material_frame_maui.png -------------------------------------------------------------------------------- /Docs/social_preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/social_preview.png -------------------------------------------------------------------------------- /Docs/twitter_banner.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/twitter_banner.pdn -------------------------------------------------------------------------------- /Docs/twitter_banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/twitter_banner.png -------------------------------------------------------------------------------- /Docs/uwp.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/uwp.mp4 -------------------------------------------------------------------------------- /Docs/uwp_acrylic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/uwp_acrylic.png -------------------------------------------------------------------------------- /Docs/uwp_dark_blur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/uwp_dark_blur.png -------------------------------------------------------------------------------- /Docs/uwp_extralight_blur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/uwp_extralight_blur.png -------------------------------------------------------------------------------- /Docs/uwp_light_blur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/Docs/uwp_light_blur.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Jean-Marie Alfonsi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MaterialFrame/AssemblyInfo.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Copyright © Sharpnado 2021 6 | 1.3.0 7 | Sharpnado 8 | MaterialFrame 9 | Modern Frame supporting theming such as Blur styles, Acrylic style, Dark/Light modes for Xamarin.Forms (Android, iOS, UWP). 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame.Android/AndroidStockBlurImpl.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // https://github.com/mmin18/RealtimeBlurView 4 | // Latest commit 82df352 on 24 May 2019 5 | // 6 | // Copyright 2016 Tu Yimin (http://github.com/mmin18) 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | // See the License for the specific language governing permissions and 18 | // limitations under the License. 19 | // 20 | //------------------------------------------------------------------------------ 21 | // Adapted to csharp by Jean-Marie Alfonsi 22 | //------------------------------------------------------------------------------ 23 | // 24 | 25 | using Android.Content; 26 | using Android.Graphics; 27 | using Android.Renderscripts; 28 | 29 | namespace Sharpnado.MaterialFrame.Droid 30 | { 31 | public class AndroidStockBlurImpl : IBlurImpl 32 | { 33 | #if DEBUG 34 | private const bool DEBUG = true; 35 | #else 36 | private const bool DEBUG = false; 37 | #endif 38 | 39 | private RenderScript _mRenderScript; 40 | 41 | private ScriptIntrinsicBlur _mBlurScript; 42 | 43 | private Allocation _mBlurInput; 44 | 45 | private Allocation _mBlurOutput; 46 | 47 | public bool Prepare(Context context, Bitmap buffer, float radius) 48 | { 49 | if (_mRenderScript == null) 50 | { 51 | try 52 | { 53 | _mRenderScript = RenderScript.Create(context); 54 | _mBlurScript = ScriptIntrinsicBlur.Create(_mRenderScript, Element.U8_4(_mRenderScript)); 55 | } 56 | catch (Android.Renderscripts.RSRuntimeException e) 57 | { 58 | if (DEBUG) 59 | { 60 | throw e; 61 | } 62 | else 63 | { 64 | // In release mode, just ignore 65 | Release(); 66 | return false; 67 | } 68 | } 69 | } 70 | 71 | _mBlurScript.SetRadius(radius); 72 | 73 | _mBlurInput = Allocation.CreateFromBitmap( 74 | _mRenderScript, 75 | buffer, 76 | Allocation.MipmapControl.MipmapNone, 77 | AllocationUsage.Script); 78 | _mBlurOutput = Allocation.CreateTyped(_mRenderScript, _mBlurInput.Type); 79 | 80 | return true; 81 | } 82 | 83 | public void Release() 84 | { 85 | if (!_mBlurInput.IsNullOrDisposed()) 86 | { 87 | _mBlurInput.Destroy(); 88 | _mBlurInput = null; 89 | } 90 | 91 | if (!_mBlurOutput.IsNullOrDisposed()) 92 | { 93 | _mBlurOutput.Destroy(); 94 | _mBlurOutput = null; 95 | } 96 | 97 | if (!_mBlurScript.IsNullOrDisposed()) 98 | { 99 | _mBlurScript.Destroy(); 100 | _mBlurScript = null; 101 | } 102 | 103 | if (!_mRenderScript.IsNullOrDisposed()) 104 | { 105 | _mRenderScript.Destroy(); 106 | _mRenderScript = null; 107 | } 108 | } 109 | 110 | public void Blur(Bitmap input, Bitmap output) 111 | { 112 | _mBlurInput.CopyFrom(input); 113 | _mBlurScript.SetInput(_mBlurInput); 114 | _mBlurScript.ForEach(_mBlurOutput); 115 | _mBlurOutput.CopyTo(output); 116 | } 117 | } 118 | } -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame.Android/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | [assembly: System.Reflection.AssemblyDescription("Modern Frame supporting theming such as Blur styles, Acrylic style, Dark/Light mo" + 12 | "des for Xamarin.Forms (Android, iOS, UWP).")] 13 | [assembly: System.Reflection.AssemblyCompany("Sharpnado")] 14 | [assembly: System.Reflection.AssemblyProduct("MaterialFrame")] 15 | [assembly: System.Reflection.AssemblyCopyright("Copyright © Sharpnado 2021")] 16 | [assembly: System.Reflection.AssemblyFileVersion("1.3.0")] 17 | [assembly: System.Reflection.AssemblyVersion("1.3.0")] 18 | [assembly: System.Reflection.AssemblyTitle("Sharpnado.MaterialFrame.Android")] 19 | 20 | 21 | -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame.Android/BlurView/AndroidMaterialFrameRenderer.Blur.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Android.Graphics; 3 | using Android.Views; 4 | 5 | using Xamarin.Forms.Platform.Android; 6 | 7 | namespace Sharpnado.Presentation.Forms.Droid.Renderers.MaterialFrame 8 | { 9 | public partial class AndroidMaterialFrameRenderer 10 | { 11 | private BlockingBlurController _blurController; 12 | 13 | private bool IsBlurInitialized => _blurController != null; 14 | 15 | public override void Draw(Canvas canvas) 16 | { 17 | if (!IsBlurInitialized) 18 | { 19 | base.Draw(canvas); 20 | return; 21 | } 22 | 23 | bool shouldDraw = _blurController.Draw(canvas); 24 | if (shouldDraw) 25 | { 26 | base.Draw(canvas); 27 | } 28 | } 29 | 30 | private void DestroyBlur() 31 | { 32 | _blurController?.Destroy(); 33 | _blurController = null; 34 | 35 | ViewTreeObserver.RemoveOnPreDrawListener(null); 36 | } 37 | 38 | protected override void OnSizeChanged(int w, int h, int oldw, int oldh) 39 | { 40 | base.OnSizeChanged(w, h, oldw, oldh); 41 | 42 | if (!IsBlurInitialized) 43 | { 44 | return; 45 | } 46 | 47 | _blurController.UpdateBlurViewSize(); 48 | } 49 | 50 | protected override void OnDetachedFromWindow() 51 | { 52 | base.OnDetachedFromWindow(); 53 | 54 | if (!IsBlurInitialized) 55 | { 56 | return; 57 | } 58 | 59 | _blurController.SetBlurAutoUpdate(false); 60 | } 61 | 62 | protected override void OnAttachedToWindow() 63 | { 64 | base.OnAttachedToWindow(); 65 | if (!IsBlurInitialized) 66 | { 67 | return; 68 | } 69 | 70 | if (!IsHardwareAccelerated) 71 | { 72 | Console.WriteLine("Error: BlurView can't be used in not hardware-accelerated window!"); 73 | return; 74 | } 75 | 76 | _blurController.SetBlurAutoUpdate(true); 77 | } 78 | 79 | private bool InitializeBlurIfNeeded() 80 | { 81 | if (_blurController != null) 82 | { 83 | return false; 84 | } 85 | 86 | var decorView = Context.GetActivity().Window.DecorView; 87 | var rootView = decorView.FindViewById(Android.Resource.Id.Content); 88 | 89 | var newController = new BlockingBlurController(Context, this, rootView); 90 | _blurController = newController; 91 | return true; 92 | } 93 | 94 | private void EnableBlur() 95 | { 96 | InitializeBlurIfNeeded(); 97 | 98 | _blurController.SetBlurEnabled(true); 99 | } 100 | 101 | private void DisableBlur() 102 | { 103 | _blurController?.SetBlurEnabled(false); 104 | 105 | DestroyBlur(); 106 | } 107 | } 108 | } -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame.Android/BlurView/BlurViewFacade.cs: -------------------------------------------------------------------------------- 1 | // 2 | 3 | namespace Sharpnado.MaterialFrame.Droid.BlurView 4 | { 5 | public interface IBlurViewFacade 6 | { 7 | /** 8 | * Enables/disables the blur. Enabled by default 9 | * 10 | * @param enabled true to enable, false otherwise 11 | * @return {@link BlurViewFacade} 12 | */ 13 | IBlurViewFacade SetBlurEnabled(bool enabled); 14 | 15 | /** 16 | * Can be used to stop blur auto update or resume if it was stopped before. 17 | * Enabled by default. 18 | * 19 | * @return {@link BlurViewFacade} 20 | */ 21 | IBlurViewFacade SetBlurAutoUpdate(bool enabled); 22 | 23 | /** 24 | * Can be set to true to optimize position calculation before blur. 25 | * By default, BlurView calculates its translation, rotation and scale before each draw call. 26 | * If you are not changing these properties (for example, during animation), this behavior can be changed 27 | * to calculate them only once during initialization. 28 | * 29 | * @param hasFixedTransformationMatrix indicates if this BlurView has fixed transformation Matrix. 30 | * @return {@link BlurViewFacade} 31 | */ 32 | IBlurViewFacade SetHasFixedTransformationMatrix(bool hasFixedTransformationMatrix); 33 | 34 | 35 | /** 36 | * @param radius sets the blur radius 37 | * Default value is {@link BlurController#DEFAULT_BLUR_RADIUS} 38 | * @return {@link BlurViewFacade} 39 | */ 40 | IBlurViewFacade SetBlurRadius(float radius); 41 | 42 | /** 43 | * Sets the color overlay to be drawn on top of blurred content 44 | * 45 | * @param overlayColor int color 46 | * @return {@link BlurViewFacade} 47 | */ 48 | IBlurViewFacade SetOverlayColor(int overlayColor); 49 | } 50 | } -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame.Android/BlurView/RenderScriptBlur.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // https://github.com/Dimezis/BlurView 4 | // Latest commit a955a76 on 4 Nov 2019 5 | // 6 | // Copyright 2016 Dmitry Saviuk 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | // See the License for the specific language governing permissions and 18 | // limitations under the License. 19 | // 20 | //------------------------------------------------------------------------------ 21 | // Adapted to csharp by Jean-Marie Alfonsi 22 | //------------------------------------------------------------------------------ 23 | // 24 | 25 | using Android.Content; 26 | using Android.Graphics; 27 | using Android.Renderscripts; 28 | 29 | namespace Sharpnado.MaterialFrame.Droid.BlurView 30 | { 31 | public class RenderScriptBlur 32 | { 33 | private readonly RenderScript _renderScript; 34 | 35 | private readonly ScriptIntrinsicBlur _blurScript; 36 | 37 | private Allocation _outAllocation; 38 | 39 | private int _lastBitmapWidth = -1; 40 | 41 | private int _lastBitmapHeight = -1; 42 | 43 | public RenderScriptBlur(Context context) 44 | { 45 | _renderScript = RenderScript.Create(context); 46 | _blurScript = ScriptIntrinsicBlur.Create(_renderScript, Element.U8_4(_renderScript)); 47 | } 48 | 49 | /** 50 | * @param bitmap bitmap to blur 51 | * @param blurRadius blur radius (1..25) 52 | * @return blurred bitmap 53 | */ 54 | public Bitmap Blur(Bitmap bitmap, float blurRadius) 55 | { 56 | // Allocation will use the same backing array of pixels as bitmap if created with USAGE_SHARED flag 57 | Allocation inAllocation = Allocation.CreateFromBitmap(_renderScript, bitmap); 58 | 59 | if (!CanReuseAllocation(bitmap)) 60 | { 61 | _outAllocation?.Destroy(); 62 | 63 | _outAllocation = Allocation.CreateTyped(_renderScript, inAllocation.Type); 64 | _lastBitmapWidth = bitmap.Width; 65 | _lastBitmapHeight = bitmap.Height; 66 | } 67 | 68 | _blurScript.SetRadius(blurRadius); 69 | _blurScript.SetInput(inAllocation); 70 | 71 | // do not use inAllocation in forEach. it will cause visual artifacts on blurred Bitmap 72 | _blurScript.ForEach(_outAllocation); 73 | _outAllocation.CopyTo(bitmap); 74 | 75 | inAllocation.Destroy(); 76 | return bitmap; 77 | } 78 | 79 | public void Destroy() 80 | { 81 | _blurScript.Destroy(); 82 | _renderScript.Destroy(); 83 | _outAllocation?.Destroy(); 84 | } 85 | 86 | public bool CanModifyBitmap() 87 | { 88 | return true; 89 | } 90 | 91 | public Bitmap.Config GetSupportedBitmapConfig() 92 | { 93 | return Bitmap.Config.Argb8888; 94 | } 95 | 96 | private bool CanReuseAllocation(Bitmap bitmap) 97 | { 98 | return bitmap.Height == _lastBitmapHeight && bitmap.Width == _lastBitmapWidth; 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame.Android/IBlurImpl.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // https://github.com/mmin18/RealtimeBlurView 4 | // Latest commit 82df352 on 24 May 2019 5 | // 6 | // Copyright 2016 Tu Yimin (http://github.com/mmin18) 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | // See the License for the specific language governing permissions and 18 | // limitations under the License. 19 | // 20 | //------------------------------------------------------------------------------ 21 | // Adapted to csharp by Jean-Marie Alfonsi 22 | //------------------------------------------------------------------------------ 23 | // 24 | 25 | using Android.Content; 26 | using Android.Graphics; 27 | 28 | namespace Sharpnado.MaterialFrame.Droid 29 | { 30 | public interface IBlurImpl 31 | { 32 | bool Prepare(Context context, Bitmap buffer, float radius); 33 | 34 | void Release(); 35 | 36 | void Blur(Bitmap input, Bitmap output); 37 | } 38 | 39 | public class EmptyBlurImpl : IBlurImpl 40 | { 41 | public bool Prepare(Context context, Bitmap buffer, float radius) 42 | { 43 | return false; 44 | } 45 | 46 | public void Release() 47 | { 48 | } 49 | 50 | public void Blur(Bitmap input, Bitmap output) 51 | { 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame.Android/JniExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Sharpnado.MaterialFrame.Droid 4 | { 5 | internal static class JniExtensions 6 | { 7 | public static bool IsNullOrDisposed(this Java.Lang.Object javaObject) 8 | { 9 | return javaObject == null || javaObject.Handle == IntPtr.Zero; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame.Android/JniWeakReference.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Sharpnado.MaterialFrame.Droid 4 | { 5 | internal class JniWeakReference 6 | where T : Java.Lang.Object 7 | { 8 | private readonly WeakReference _reference; 9 | 10 | public JniWeakReference(T target) 11 | { 12 | _reference = new WeakReference(target); 13 | } 14 | 15 | public bool TryGetTarget(out T target) 16 | { 17 | target = null; 18 | if (_reference.TryGetTarget(out var innerTarget)) 19 | { 20 | if (innerTarget.Handle != IntPtr.Zero) 21 | { 22 | target = innerTarget; 23 | } 24 | } 25 | 26 | return target != null; 27 | } 28 | 29 | public override string ToString() 30 | { 31 | return $"[JniWeakReference] {_reference}"; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame.Android/MaterialFrame.Android.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {F6719964-727A-4C81-9C32-FA0B08CA8AE6} 7 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | {c9e5eea5-ca05-42a1-839b-61506e0a37df} 9 | Library 10 | Sharpnado.MaterialFrame.Droid 11 | Sharpnado.MaterialFrame.Android 12 | True 13 | latest 14 | True 15 | false 16 | true 17 | true 18 | Xamarin.Android.Net.AndroidClientHandler 19 | ..\StyleCopRules.ruleset 20 | v10.0 21 | 22 | 23 | true 24 | portable 25 | false 26 | bin\Debug 27 | DEBUG; 28 | prompt 29 | 4 30 | None 31 | v10.0 32 | 33 | 34 | true 35 | portable 36 | true 37 | bin\Release 38 | prompt 39 | 4 40 | true 41 | false 42 | v10.0 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | all 56 | runtime; build; native; contentfiles; analyzers; buildtransitive 57 | 58 | 59 | 1.5.0.235 60 | runtime; build; native; contentfiles; analyzers 61 | all 62 | 63 | 64 | all 65 | runtime; build; native; contentfiles; analyzers 66 | 67 | 68 | 69 | 70 | 5.0.0.2196 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | {B87012C9-AE85-42F5-95B0-AC77D9EF59AB} 91 | MaterialFrame 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame.UWP/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Ce code a été généré par un outil. 4 | // Version du runtime :4.0.30319.42000 5 | // 6 | // Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si 7 | // le code est régénéré. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | [assembly: System.Reflection.AssemblyDescription("Modern Frame supporting theming such as Blur styles, Acrylic style, Dark/Light mo" + 12 | "des for Xamarin.Forms (Android, iOS, UWP).")] 13 | [assembly: System.Reflection.AssemblyCompany("Sharpnado")] 14 | [assembly: System.Reflection.AssemblyProduct("MaterialFrame")] 15 | [assembly: System.Reflection.AssemblyCopyright("Copyright © Sharpnado 2021")] 16 | [assembly: System.Reflection.AssemblyFileVersion("1.3.0")] 17 | [assembly: System.Reflection.AssemblyVersion("1.3.0")] 18 | [assembly: System.Reflection.AssemblyTitle("Sharpnado.MaterialFrame.UWP")] 19 | 20 | 21 | -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame.UWP/MaterialFrame.UWP.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {1E904232-AE2E-4D45-95F3-0C9F4D12831C} 8 | Library 9 | Properties 10 | Sharpnado.MaterialFrame.UWP 11 | Sharpnado.MaterialFrame.UWP 12 | en-US 13 | UAP 14 | 10.0.18362.0 15 | 10.0.16299.0 16 | 14 17 | 512 18 | {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 19 | ..\StyleCopRules.ruleset 20 | 21 | 22 | AnyCPU 23 | true 24 | full 25 | false 26 | bin\Debug\ 27 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 28 | prompt 29 | 4 30 | 31 | 32 | AnyCPU 33 | pdbonly 34 | true 35 | bin\Release\ 36 | TRACE;NETFX_CORE;WINDOWS_UWP 37 | prompt 38 | 4 39 | 40 | 41 | PackageReference 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | all 51 | runtime; build; native; contentfiles; analyzers; buildtransitive 52 | 53 | 54 | 2.3.191211002 55 | 56 | 57 | 1.5.0.235 58 | runtime; build; native; contentfiles; analyzers 59 | all 60 | 61 | 62 | all 63 | runtime; build; native; contentfiles; analyzers 64 | 65 | 66 | 67 | 68 | 6.2.13 69 | 70 | 71 | 5.0.0.2196 72 | 73 | 74 | 75 | 76 | {127470F1-4C3F-442B-84C7-6B771CB5D113} 77 | MaterialFrame 78 | 79 | 80 | 81 | 14.0 82 | 83 | 84 | 85 | 92 | -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame.UWP/Properties/MaterialFrame.UWP.rd.xml: -------------------------------------------------------------------------------- 1 | 2 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame.iOS/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | [assembly: System.Reflection.AssemblyDescription("Modern Frame supporting theming such as Blur styles, Acrylic style, Dark/Light mo" + 12 | "des for Xamarin.Forms (Android, iOS, UWP).")] 13 | [assembly: System.Reflection.AssemblyCompany("Sharpnado")] 14 | [assembly: System.Reflection.AssemblyProduct("MaterialFrame")] 15 | [assembly: System.Reflection.AssemblyCopyright("Copyright © Sharpnado 2021")] 16 | [assembly: System.Reflection.AssemblyFileVersion("1.3.0")] 17 | [assembly: System.Reflection.AssemblyVersion("1.3.0")] 18 | [assembly: System.Reflection.AssemblyTitle("Sharpnado.MaterialFrame.iOS")] 19 | 20 | 21 | -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame.iOS/MaterialFrame.iOS.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | iPhoneSimulator 6 | 8.0.30703 7 | 2.0 8 | {29B1C798-02D7-4732-ACC5-0FD2E4BBEC8B} 9 | {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 10 | {6143fdea-f3c2-4a09-aafa-6e230626515e} 11 | Library 12 | Sharpnado.MaterialFrame.iOS 13 | Resources 14 | Sharpnado.MaterialFrame.iOS 15 | true 16 | NSUrlSessionHandler 17 | automatic 18 | ..\StyleCopRules.ruleset 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug 25 | DEBUG; 26 | prompt 27 | 4 28 | false 29 | 30 | 31 | full 32 | true 33 | bin\Release 34 | prompt 35 | 4 36 | false 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 5.0.0.2196 53 | 54 | 55 | all 56 | runtime; build; native; contentfiles; analyzers; buildtransitive 57 | 58 | 59 | 1.5.0.235 60 | runtime; build; native; contentfiles; analyzers 61 | all 62 | 63 | 64 | all 65 | runtime; build; native; contentfiles; analyzers 66 | 67 | 68 | 69 | 70 | 71 | 72 | {B87012C9-AE85-42F5-95B0-AC77D9EF59AB} 73 | MaterialFrame 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame.macOS/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Ce code a été généré par un outil. 4 | // Version du runtime :4.0.30319.42000 5 | // 6 | // Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si 7 | // le code est régénéré. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | [assembly: System.Reflection.AssemblyDescription("Modern Frame supporting theming such as Blur styles, Acrylic style, Dark/Light mo" + 12 | "des for Xamarin.Forms (Android, iOS, UWP).")] 13 | [assembly: System.Reflection.AssemblyCompany("Sharpnado")] 14 | [assembly: System.Reflection.AssemblyProduct("MaterialFrame")] 15 | [assembly: System.Reflection.AssemblyCopyright("Copyright © Sharpnado 2021")] 16 | [assembly: System.Reflection.AssemblyFileVersion("1.3.0")] 17 | [assembly: System.Reflection.AssemblyVersion("1.3.0")] 18 | [assembly: System.Reflection.AssemblyTitle("Sharpnado.MaterialFrame.macOS")] 19 | 20 | 21 | -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame.macOS/MaterialFrame.macOS.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {447A39AE-70B4-4656-A46C-55C6D60A8E5A} 7 | {A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | Library 9 | Sharpnado.MaterialFrame.macOS 10 | Sharpnado.MaterialFrame.macOS 11 | v2.0 12 | Xamarin.Mac 13 | Resources 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug 20 | DEBUG; 21 | prompt 22 | 4 23 | false 24 | false 25 | false 26 | false 27 | false 28 | 29 | 30 | 31 | 32 | full 33 | true 34 | bin\Release 35 | prompt 36 | 4 37 | false 38 | false 39 | false 40 | false 41 | false 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 4.5.0.356 57 | 58 | 59 | all 60 | runtime; build; native; contentfiles; analyzers; buildtransitive 61 | 62 | 63 | 1.5.0.235 64 | runtime; build; native; contentfiles; analyzers 65 | all 66 | 67 | 68 | all 69 | runtime; build; native; contentfiles; analyzers 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | {127470F1-4C3F-442B-84C7-6B771CB5D113} 79 | MaterialFrame 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame/AssemblyConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Xamarin.Forms; 2 | 3 | [assembly: XmlnsDefinition("http://sharpnado.com", "Sharpnado.MaterialFrame")] 4 | [assembly: XmlnsPrefix("http://sharpnado.com", "sho")] -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | [assembly: System.Reflection.AssemblyDescription("Modern Frame supporting theming such as Blur styles, Acrylic style, Dark/Light mo" + 12 | "des for Xamarin.Forms (Android, iOS, UWP).")] 13 | [assembly: System.Reflection.AssemblyCompany("Sharpnado")] 14 | [assembly: System.Reflection.AssemblyProduct("MaterialFrame")] 15 | [assembly: System.Reflection.AssemblyCopyright("Copyright © Sharpnado 2021")] 16 | [assembly: System.Reflection.AssemblyFileVersion("1.3.0")] 17 | [assembly: System.Reflection.AssemblyVersion("1.3.0")] 18 | [assembly: System.Reflection.AssemblyTitle("Sharpnado.MaterialFrame")] 19 | 20 | 21 | -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame/Initializer.cs: -------------------------------------------------------------------------------- 1 | namespace Sharpnado.MaterialFrame 2 | { 3 | public static class Initializer 4 | { 5 | public static void Initialize(bool loggerEnable, bool debugLogEnable) 6 | { 7 | InternalLogger.EnableDebug = debugLogEnable; 8 | InternalLogger.EnableLogging = loggerEnable; 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame/InternalLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using System.Threading; 4 | 5 | [assembly:InternalsVisibleTo("Sharpnado.MaterialFrame.Android")] 6 | [assembly:InternalsVisibleTo("Sharpnado.MaterialFrame.iOS")] 7 | [assembly:InternalsVisibleTo("Sharpnado.MaterialFrame.macOS")] 8 | [assembly:InternalsVisibleTo("Sharpnado.MaterialFrame.UWP")] 9 | [assembly:InternalsVisibleTo("Sharpnado.Presentation.Forms")] 10 | 11 | namespace Sharpnado.MaterialFrame 12 | { 13 | internal static class InternalLogger 14 | { 15 | public static bool EnableLogging { get; set; } = false; 16 | 17 | public static bool EnableDebug { get; set; } = false; 18 | 19 | public static void Debug(string tag, Func message) 20 | { 21 | if (!EnableDebug) 22 | { 23 | return; 24 | } 25 | 26 | Debug(tag, message()); 27 | } 28 | 29 | public static void Debug(string tag, string format, params object[] parameters) 30 | { 31 | if (!EnableDebug) 32 | { 33 | return; 34 | } 35 | 36 | DiagnosticLog(tag + " | DBUG | " + format, parameters); 37 | } 38 | 39 | public static void Debug(string format, params object[] parameters) 40 | { 41 | if (!EnableDebug) 42 | { 43 | return; 44 | } 45 | 46 | DiagnosticLog("DBUG | " + format, parameters); 47 | } 48 | 49 | public static void Info(string tag, string format, params object[] parameters) 50 | { 51 | DiagnosticLog(tag + " | INFO | " + format, parameters); 52 | } 53 | 54 | public static void Info(string format, params object[] parameters) 55 | { 56 | DiagnosticLog("INFO | " + format, parameters); 57 | } 58 | 59 | public static void Warn(string format, params object[] parameters) 60 | { 61 | DiagnosticLog("WARN | " + format, parameters); 62 | } 63 | 64 | public static void Error(string format, params object[] parameters) 65 | { 66 | DiagnosticLog("ERRO | " + format, parameters); 67 | } 68 | 69 | public static void Error(Exception exception) 70 | { 71 | Error($"{exception.Message}{Environment.NewLine}{exception}"); 72 | } 73 | 74 | private static void DiagnosticLog(string format, params object[] parameters) 75 | { 76 | if (!EnableLogging) 77 | { 78 | return; 79 | } 80 | 81 | #if DEBUG 82 | System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("MM-dd H:mm:ss.fff") + " | SharpnadoInternals | " + format, parameters); 83 | #else 84 | Console.WriteLine(DateTime.Now.ToString("MM-dd H:mm:ss.fff") + " | SharpnadoInternals | " + format, parameters); 85 | #endif 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame/MaterialFrame.Android.cs: -------------------------------------------------------------------------------- 1 | using Xamarin.Forms; 2 | 3 | namespace Sharpnado.MaterialFrame 4 | { 5 | public partial class MaterialFrame 6 | { 7 | public static readonly BindableProperty AndroidBlurRootElementProperty = BindableProperty.Create( 8 | nameof(AndroidBlurRootElement), 9 | typeof(Layout), 10 | typeof(MaterialFrame)); 11 | 12 | public static readonly BindableProperty AndroidBlurOverlayColorProperty = BindableProperty.Create( 13 | nameof(AndroidBlurOverlayColor), 14 | typeof(Color), 15 | typeof(MaterialFrame), 16 | defaultValueCreator: _ => Color.Transparent); 17 | 18 | public static readonly BindableProperty AndroidBlurRadiusProperty = BindableProperty.Create( 19 | nameof(AndroidBlurRadius), 20 | typeof(float), 21 | typeof(MaterialFrame), 22 | defaultValue: 0f); 23 | 24 | /// 25 | /// Android only: the root element must be an ancestor of the MaterialFrame. 26 | /// Blur computation is very costly on Android since it needs to process all the view hierarchy from the 27 | /// root element to be blurred (most of the time the element displaying the underlying image) to the blur frame. 28 | /// The shorter the path, the better the performance. If no root element is set, the activity decor view is used. 29 | /// 30 | public Layout AndroidBlurRootElement 31 | { 32 | get => (Layout)GetValue(AndroidBlurRootElementProperty); 33 | set => SetValue(AndroidBlurRootElementProperty, value); 34 | } 35 | 36 | /// 37 | /// Android only. 38 | /// Changes the overlay color over the blur (should be a transparent color, obviously). 39 | /// If not set, the different blur style styles take over. 40 | /// 41 | public Color AndroidBlurOverlayColor 42 | { 43 | get => (Color)GetValue(AndroidBlurOverlayColorProperty); 44 | set => SetValue(AndroidBlurOverlayColorProperty, value); 45 | } 46 | 47 | /// 48 | /// Android only. 49 | /// Changes the blur radius on Android. 50 | /// If set, it takes precedence over MaterialBlurStyle. 51 | /// If not set, the different blur style styles take over. 52 | /// 53 | public float AndroidBlurRadius 54 | { 55 | get => (float)GetValue(AndroidBlurRadiusProperty); 56 | set => SetValue(AndroidBlurRadiusProperty, value); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame/MaterialFrame.UWP.cs: -------------------------------------------------------------------------------- 1 | using Xamarin.Forms; 2 | 3 | namespace Sharpnado.MaterialFrame 4 | { 5 | public partial class MaterialFrame 6 | { 7 | public static readonly BindableProperty UwpBlurOverlayColorProperty = BindableProperty.Create( 8 | nameof(UwpBlurOverlayColor), 9 | typeof(Color), 10 | typeof(MaterialFrame), 11 | defaultValueCreator: _ => Color.Default); 12 | 13 | public static readonly BindableProperty UwpHostBackdropBlurProperty = BindableProperty.Create( 14 | nameof(UwpHostBackdropBlur), 15 | typeof(bool), 16 | typeof(MaterialFrame), 17 | defaultValueCreator: _ => false); 18 | 19 | /// 20 | /// UWP only. 21 | /// Changes the overlay color over the blur (should be a transparent color, obviously). 22 | /// If not set, the different blur style styles take over. 23 | /// 24 | public Color UwpBlurOverlayColor 25 | { 26 | get => (Color)GetValue(UwpBlurOverlayColorProperty); 27 | set => SetValue(UwpBlurOverlayColorProperty, value); 28 | } 29 | 30 | /// 31 | /// UWP only. 32 | /// HostBackdropBlur reveals the desktop wallpaper and other windows that are behind the currently active app. 33 | /// If not set, the default in app BackdropBlur take over. 34 | /// 35 | public bool UwpHostBackdropBlur 36 | { 37 | get => (bool)GetValue(UwpHostBackdropBlurProperty); 38 | set => SetValue(UwpHostBackdropBlurProperty, value); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame/MaterialFrame.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Xamarin.Forms; 4 | 5 | namespace Sharpnado.MaterialFrame 6 | { 7 | public partial class MaterialFrame : Frame 8 | { 9 | public const int AcrylicElevation = 20; 10 | 11 | public static readonly BindableProperty MaterialThemeProperty = BindableProperty.Create( 12 | nameof(MaterialTheme), 13 | typeof(Theme), 14 | typeof(MaterialFrame), 15 | defaultValueCreator: _ => globalTheme); 16 | 17 | public static readonly BindableProperty MaterialBlurStyleProperty = BindableProperty.Create( 18 | nameof(MaterialBlurStyle), 19 | typeof(BlurStyle), 20 | typeof(MaterialFrame), 21 | defaultValue: DefaultBlurStyle); 22 | 23 | public static readonly BindableProperty LightThemeBackgroundColorProperty = BindableProperty.Create( 24 | nameof(LightThemeBackgroundColor), 25 | typeof(Color), 26 | typeof(MaterialFrame), 27 | defaultValueCreator: _ => DefaultLightThemeBackgroundColor); 28 | 29 | public static readonly BindableProperty AcrylicGlowColorProperty = BindableProperty.Create( 30 | nameof(AcrylicGlowColor), 31 | typeof(Color), 32 | typeof(MaterialFrame), 33 | defaultValueCreator: _ => DefaultAcrylicGlowColor); 34 | 35 | public static readonly BindableProperty ElevationProperty = BindableProperty.Create( 36 | nameof(Elevation), 37 | typeof(int), 38 | typeof(MaterialFrame), 39 | defaultValue: DefaultElevation); 40 | 41 | private const Theme DefaultTheme = Theme.Light; 42 | 43 | private const int DefaultElevation = 2; 44 | 45 | private const BlurStyle DefaultBlurStyle = BlurStyle.Light; 46 | 47 | private static readonly Color DefaultLightThemeBackgroundColor = Color.White; 48 | 49 | private static readonly Color DefaultAcrylicGlowColor = Color.White; 50 | 51 | // https://material.io/design/color/dark-theme.html#properties 52 | private static readonly Color[] DarkColors = new[] 53 | { 54 | Color.FromHex("121212"), // 00dp 55 | Color.FromHex("1D1D1D"), 56 | Color.FromHex("212121"), 57 | Color.FromHex("242424"), 58 | Color.FromHex("272727"), // 04dp 59 | Color.FromHex("272727"), 60 | Color.FromHex("2C2C2C"), // 06dp 61 | Color.FromHex("2C2C2C"), 62 | Color.FromHex("2D2D2D"), // 08dp 63 | Color.FromHex("2D2D2D"), 64 | Color.FromHex("2D2D2D"), 65 | Color.FromHex("2D2D2D"), 66 | Color.FromHex("323232"), // 12dp 67 | Color.FromHex("323232"), 68 | Color.FromHex("323232"), 69 | Color.FromHex("323232"), 70 | Color.FromHex("353535"), // 16dp 71 | Color.FromHex("353535"), 72 | Color.FromHex("353535"), 73 | Color.FromHex("353535"), 74 | Color.FromHex("353535"), 75 | Color.FromHex("353535"), 76 | Color.FromHex("353535"), 77 | Color.FromHex("353535"), 78 | Color.FromHex("373737"), // 24dp 79 | }; 80 | 81 | private static Theme globalTheme = DefaultTheme; 82 | 83 | public MaterialFrame() 84 | { 85 | HasShadow = false; 86 | 87 | ThemeChanged += OnThemeChanged; 88 | } 89 | 90 | public static event EventHandler ThemeChanged; 91 | 92 | public enum Theme 93 | { 94 | Light = 0, 95 | Dark, 96 | Acrylic, 97 | AcrylicBlur, 98 | } 99 | 100 | public enum BlurStyle 101 | { 102 | Light = 0, 103 | ExtraLight, 104 | Dark, 105 | } 106 | 107 | public bool IsShadowCompatible => MaterialTheme == Theme.Acrylic || (MaterialTheme == Theme.Light && Elevation > 0); 108 | 109 | public Theme MaterialTheme 110 | { 111 | get => (Theme)GetValue(MaterialThemeProperty); 112 | set => SetValue(MaterialThemeProperty, value); 113 | } 114 | 115 | public Color LightThemeBackgroundColor 116 | { 117 | get => (Color)GetValue(LightThemeBackgroundColorProperty); 118 | set => SetValue(LightThemeBackgroundColorProperty, value); 119 | } 120 | 121 | public Color AcrylicGlowColor 122 | { 123 | get => (Color)GetValue(AcrylicGlowColorProperty); 124 | set => SetValue(AcrylicGlowColorProperty, value); 125 | } 126 | 127 | public BlurStyle MaterialBlurStyle 128 | { 129 | get => (BlurStyle)GetValue(MaterialBlurStyleProperty); 130 | set => SetValue(MaterialBlurStyleProperty, value); 131 | } 132 | 133 | public int Elevation 134 | { 135 | get => (int)GetValue(ElevationProperty); 136 | set => SetValue(ElevationProperty, value); 137 | } 138 | 139 | public static void ChangeGlobalTheme(Theme newTheme) 140 | { 141 | var previousTheme = globalTheme; 142 | globalTheme = newTheme; 143 | 144 | if (previousTheme != globalTheme) 145 | { 146 | ThemeChanged?.Invoke(null, new EventArgs()); 147 | } 148 | } 149 | 150 | public void Unsubscribe() 151 | { 152 | ThemeChanged -= OnThemeChanged; 153 | } 154 | 155 | public Color ElevationToColor() 156 | { 157 | if (MaterialTheme == Theme.Light) 158 | { 159 | return Color.Default; 160 | } 161 | 162 | if (Elevation < 0) 163 | { 164 | return Color.Default; 165 | } 166 | 167 | int index = Elevation > 24 ? 24 : Elevation; 168 | return DarkColors[index]; 169 | } 170 | 171 | private void OnThemeChanged(object sender, EventArgs eventArgs) 172 | { 173 | MaterialTheme = globalTheme; 174 | } 175 | } 176 | } -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame/MaterialFrame.csproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roubachof/Sharpnado.MaterialFrame/c558555c9fc81d36f6a225fb422f64859921d3b5/MaterialFrame/MaterialFrame/MaterialFrame.csproj -------------------------------------------------------------------------------- /MaterialFrame/MaterialFrame/MaterialFrame.macOS.cs: -------------------------------------------------------------------------------- 1 | using Xamarin.Forms; 2 | 3 | namespace Sharpnado.MaterialFrame 4 | { 5 | public partial class MaterialFrame 6 | { 7 | public static readonly BindableProperty MacOSBehindWindowBlurProperty = BindableProperty.Create( 8 | nameof(MacOSBehindWindowBlur), 9 | typeof(bool), 10 | typeof(MaterialFrame), 11 | defaultValueCreator: _ => false); 12 | 13 | /// 14 | /// macOS only. 15 | /// BehindWindow reveals the desktop wallpaper and other windows that are behind the currently active app. 16 | /// If not set, the default in app WithinWindow take over. 17 | /// 18 | public bool MacOSBehindWindowBlur 19 | { 20 | get => (bool)GetValue(MacOSBehindWindowBlurProperty); 21 | set => SetValue(MacOSBehindWindowBlurProperty, value); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /MaterialFrame/Settings.XamlStyler: -------------------------------------------------------------------------------- 1 | { 2 | "AttributesTolerance": 2, 3 | "KeepFirstAttributeOnSameLine": true, 4 | "MaxAttributeCharactersPerLine": 0, 5 | "MaxAttributesPerLine": 1, 6 | "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransfom, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter", 7 | "SeparateByGroups": false, 8 | "AttributeIndentation": 0, 9 | "AttributeIndentationStyle": 1, 10 | "RemoveDesignTimeReferences": false, 11 | "EnableAttributeReordering": true, 12 | "AttributeOrderingRuleGroups": [ 13 | "x:Class", 14 | "xmlns, xmlns:x, xmlns:d, xmlns:mc, mc:Ignorable", 15 | "xmlns:*", 16 | "x:Key, Key, x:Name, Name, x:Uid, Uid, Title", 17 | "Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan, AbsoluteLayout.LayoutFlags, AbsoluteLayout.LayoutBounds", 18 | "Style, WidthRequest, HeightRequest, MinimumWidthRequest, MinimumHeightRequest", 19 | "Margin, Padding, HorizontalOptions, VerticalOptions, HorizontalTextAlignment, VerticalTextAlignment", 20 | "*:*, *", 21 | "PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint", 22 | "mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText", 23 | "Storyboard.*, From, To, Duration" 24 | ], 25 | "FirstLineAttributes": "", 26 | "OrderAttributesByName": true, 27 | "PutEndingBracketOnNewLine": false, 28 | "RemoveEndingTagOfEmptyElement": true, 29 | "SpaceBeforeClosingSlash": true, 30 | "RootElementLineBreakRule": 0, 31 | "ReorderVSM": 2, 32 | "ReorderGridChildren": false, 33 | "ReorderCanvasChildren": false, 34 | "ReorderSetters": 0, 35 | "FormatMarkupExtension": true, 36 | "NoNewLineMarkupExtensions": "x:Bind, Binding", 37 | "ThicknessSeparator": 2, 38 | "ThicknessAttributes": "Margin, Padding, BorderThickness, ThumbnailClipMargin", 39 | "FormatOnSave": true, 40 | "CommentPadding": 2, 41 | } -------------------------------------------------------------------------------- /MaterialFrame/StyleCopRules.ruleset: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Maui.MaterialFrame/AssemblyConfiguration.cs: -------------------------------------------------------------------------------- 1 | [assembly: XmlnsDefinition("http://sharpnado.com", "Sharpnado.MaterialFrame")] 2 | [assembly: Microsoft.Maui.Controls.XmlnsPrefix("http://sharpnado.com", "sho")] 3 | -------------------------------------------------------------------------------- /Maui.MaterialFrame/Initializer.cs: -------------------------------------------------------------------------------- 1 | namespace Sharpnado.MaterialFrame 2 | { 3 | public static class Initializer 4 | { 5 | public static void Initialize(bool loggerEnable, bool debugLogEnable) 6 | { 7 | InternalLogger.EnableDebug = debugLogEnable; 8 | InternalLogger.EnableLogging = loggerEnable; 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Maui.MaterialFrame/InternalLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using System.Threading; 4 | 5 | [assembly:InternalsVisibleTo("Sharpnado.MaterialFrame.Android")] 6 | [assembly:InternalsVisibleTo("Sharpnado.MaterialFrame.iOS")] 7 | [assembly:InternalsVisibleTo("Sharpnado.MaterialFrame.macOS")] 8 | [assembly:InternalsVisibleTo("Sharpnado.MaterialFrame.UWP")] 9 | [assembly:InternalsVisibleTo("Sharpnado.Presentation.Forms")] 10 | 11 | namespace Sharpnado.MaterialFrame 12 | { 13 | internal static class InternalLogger 14 | { 15 | public static bool EnableLogging { get; set; } = false; 16 | 17 | public static bool EnableDebug { get; set; } = false; 18 | 19 | public static void Debug(string tag, Func message) 20 | { 21 | if (!EnableDebug) 22 | { 23 | return; 24 | } 25 | 26 | Debug(tag, message()); 27 | } 28 | 29 | public static void Debug(string tag, string format, params object[] parameters) 30 | { 31 | if (!EnableDebug) 32 | { 33 | return; 34 | } 35 | 36 | DiagnosticLog(tag + " | DBUG | " + format, parameters); 37 | } 38 | 39 | public static void Debug(string format, params object[] parameters) 40 | { 41 | if (!EnableDebug) 42 | { 43 | return; 44 | } 45 | 46 | DiagnosticLog("DBUG | " + format, parameters); 47 | } 48 | 49 | public static void Info(string tag, string format, params object[] parameters) 50 | { 51 | DiagnosticLog(tag + " | INFO | " + format, parameters); 52 | } 53 | 54 | public static void Info(string format, params object[] parameters) 55 | { 56 | DiagnosticLog("INFO | " + format, parameters); 57 | } 58 | 59 | public static void Warn(string format, params object[] parameters) 60 | { 61 | DiagnosticLog("WARN | " + format, parameters); 62 | } 63 | 64 | public static void Error(string format, params object[] parameters) 65 | { 66 | DiagnosticLog("ERRO | " + format, parameters); 67 | } 68 | 69 | public static void Error(Exception exception) 70 | { 71 | Error($"{exception.Message}{Environment.NewLine}{exception}"); 72 | } 73 | 74 | private static void DiagnosticLog(string format, params object[] parameters) 75 | { 76 | if (!EnableLogging) 77 | { 78 | return; 79 | } 80 | 81 | #if DEBUG 82 | System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("MM-dd H:mm:ss.fff") + " | SharpnadoInternals | " + format, parameters); 83 | #else 84 | Console.WriteLine(DateTime.Now.ToString("MM-dd H:mm:ss.fff") + " | SharpnadoInternals | " + format, parameters); 85 | #endif 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /Maui.MaterialFrame/MaterialFrame.Android.cs: -------------------------------------------------------------------------------- 1 | namespace Sharpnado.MaterialFrame 2 | { 3 | public partial class MaterialFrame 4 | { 5 | public static readonly BindableProperty AndroidBlurRootElementProperty = BindableProperty.Create( 6 | nameof(AndroidBlurRootElement), 7 | typeof(Layout), 8 | typeof(MaterialFrame)); 9 | 10 | public static readonly BindableProperty AndroidBlurOverlayColorProperty = BindableProperty.Create( 11 | nameof(AndroidBlurOverlayColor), 12 | typeof(Color), 13 | typeof(MaterialFrame), 14 | defaultValueCreator: _ => KnownColor.Transparent); 15 | 16 | public static readonly BindableProperty AndroidBlurRadiusProperty = BindableProperty.Create( 17 | nameof(AndroidBlurRadius), 18 | typeof(float), 19 | typeof(MaterialFrame), 20 | defaultValue: 0f); 21 | 22 | /// 23 | /// Android only: the root element must be an ancestor of the MaterialFrame. 24 | /// Blur computation is very costly on Android since it needs to process all the view hierarchy from the 25 | /// root element to be blurred (most of the time the element displaying the underlying image) to the blur frame. 26 | /// The shorter the path, the better the performance. If no root element is set, the activity decor view is used. 27 | /// 28 | public Layout AndroidBlurRootElement 29 | { 30 | get => (Layout)GetValue(AndroidBlurRootElementProperty); 31 | set => SetValue(AndroidBlurRootElementProperty, value); 32 | } 33 | 34 | /// 35 | /// Android only. 36 | /// Changes the overlay color over the blur (should be a transparent color, obviously). 37 | /// If not set, the different blur style styles take over. 38 | /// 39 | public Color AndroidBlurOverlayColor 40 | { 41 | get => (Color)GetValue(AndroidBlurOverlayColorProperty); 42 | set => SetValue(AndroidBlurOverlayColorProperty, value); 43 | } 44 | 45 | /// 46 | /// Android only. 47 | /// Changes the blur radius on Android. 48 | /// If set, it takes precedence over MaterialBlurStyle. 49 | /// If not set, the different blur style styles take over. 50 | /// 51 | public float AndroidBlurRadius 52 | { 53 | get => (float)GetValue(AndroidBlurRadiusProperty); 54 | set => SetValue(AndroidBlurRadiusProperty, value); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Maui.MaterialFrame/MaterialFrame.MacCatalyst.cs: -------------------------------------------------------------------------------- 1 | namespace Sharpnado.MaterialFrame 2 | { 3 | public partial class MaterialFrame 4 | { 5 | public static readonly BindableProperty MacOSBehindWindowBlurProperty = BindableProperty.Create( 6 | nameof(MacOSBehindWindowBlur), 7 | typeof(bool), 8 | typeof(MaterialFrame), 9 | defaultValueCreator: _ => false); 10 | 11 | /// 12 | /// macOS only. 13 | /// BehindWindow reveals the desktop wallpaper and other windows that are behind the currently active app. 14 | /// If not set, the default in app WithinWindow take over. 15 | /// 16 | public bool MacOSBehindWindowBlur 17 | { 18 | get => (bool)GetValue(MacOSBehindWindowBlurProperty); 19 | set => SetValue(MacOSBehindWindowBlurProperty, value); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Maui.MaterialFrame/MaterialFrame.Windows.cs: -------------------------------------------------------------------------------- 1 | namespace Sharpnado.MaterialFrame 2 | { 3 | public partial class MaterialFrame 4 | { 5 | public static readonly BindableProperty WinUIBlurOverlayColorProperty = BindableProperty.Create( 6 | nameof(WinUIBlurOverlayColor), 7 | typeof(Color), 8 | typeof(MaterialFrame), 9 | defaultValueCreator: _ => Colors.Transparent); 10 | 11 | public static readonly BindableProperty WinUIHostBackdropBlurProperty = BindableProperty.Create( 12 | nameof(WinUIHostBackdropBlur), 13 | typeof(bool), 14 | typeof(MaterialFrame), 15 | defaultValueCreator: _ => false); 16 | 17 | /// 18 | /// WinUI only. 19 | /// Changes the overlay color over the blur (should be a transparent color, obviously). 20 | /// If not set, the different blur style styles take over. 21 | /// 22 | public Color WinUIBlurOverlayColor 23 | { 24 | get => (Color)GetValue(WinUIBlurOverlayColorProperty); 25 | set => SetValue(WinUIBlurOverlayColorProperty, value); 26 | } 27 | 28 | /// 29 | /// Not supported in WinUI 3: https://github.com/microsoft/microsoft-ui-xaml/issues/6618 30 | /// HostBackdropBlur reveals the desktop wallpaper and other windows that are behind the currently active app. 31 | /// If not set, the default in app BackdropBlur take over. 32 | /// 33 | public bool WinUIHostBackdropBlur 34 | { 35 | get => (bool)GetValue(WinUIHostBackdropBlurProperty); 36 | set => SetValue(WinUIHostBackdropBlurProperty, value); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Maui.MaterialFrame/MaterialFrame.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Sharpnado.MaterialFrame 4 | { 5 | public partial class MaterialFrame : Frame 6 | { 7 | public const int AcrylicElevation = 16; 8 | 9 | public static readonly BindableProperty MaterialThemeProperty = BindableProperty.Create( 10 | nameof(MaterialTheme), 11 | typeof(Theme), 12 | typeof(MaterialFrame), 13 | defaultValueCreator: _ => globalTheme); 14 | 15 | public static readonly BindableProperty MaterialBlurStyleProperty = BindableProperty.Create( 16 | nameof(MaterialBlurStyle), 17 | typeof(BlurStyle), 18 | typeof(MaterialFrame), 19 | defaultValue: DefaultBlurStyle); 20 | 21 | public static readonly BindableProperty LightThemeBackgroundColorProperty = BindableProperty.Create( 22 | nameof(LightThemeBackgroundColor), 23 | typeof(Color), 24 | typeof(MaterialFrame), 25 | defaultValueCreator: _ => DefaultLightThemeBackgroundColor); 26 | 27 | public static readonly BindableProperty AcrylicGlowColorProperty = BindableProperty.Create( 28 | nameof(AcrylicGlowColor), 29 | typeof(Color), 30 | typeof(MaterialFrame), 31 | defaultValueCreator: _ => DefaultAcrylicGlowColor); 32 | 33 | public static readonly BindableProperty ElevationProperty = BindableProperty.Create( 34 | nameof(Elevation), 35 | typeof(int), 36 | typeof(MaterialFrame), 37 | defaultValue: DefaultElevation); 38 | 39 | private const Theme DefaultTheme = Theme.Light; 40 | 41 | private const int DefaultElevation = 2; 42 | 43 | private const BlurStyle DefaultBlurStyle = BlurStyle.Light; 44 | 45 | private static readonly Color DefaultLightThemeBackgroundColor = Colors.White; 46 | 47 | private static readonly Color DefaultAcrylicGlowColor = Colors.White; 48 | 49 | // https://material.io/design/color/dark-theme.html#properties 50 | private static readonly Color[] DarkColors = new[] 51 | { 52 | Color.FromArgb("121212"), // 00dp 53 | Color.FromArgb("1D1D1D"), 54 | Color.FromArgb("212121"), 55 | Color.FromArgb("242424"), 56 | Color.FromArgb("272727"), // 04dp 57 | Color.FromArgb("272727"), 58 | Color.FromArgb("2C2C2C"), // 06dp 59 | Color.FromArgb("2C2C2C"), 60 | Color.FromArgb("2D2D2D"), // 08dp 61 | Color.FromArgb("2D2D2D"), 62 | Color.FromArgb("2D2D2D"), 63 | Color.FromArgb("2D2D2D"), 64 | Color.FromArgb("323232"), // 12dp 65 | Color.FromArgb("323232"), 66 | Color.FromArgb("323232"), 67 | Color.FromArgb("323232"), 68 | Color.FromArgb("353535"), // 16dp 69 | Color.FromArgb("353535"), 70 | Color.FromArgb("353535"), 71 | Color.FromArgb("353535"), 72 | Color.FromArgb("353535"), 73 | Color.FromArgb("353535"), 74 | Color.FromArgb("353535"), 75 | Color.FromArgb("353535"), 76 | Color.FromArgb("373737"), // 24dp 77 | }; 78 | 79 | private static Theme globalTheme = DefaultTheme; 80 | 81 | public MaterialFrame() 82 | { 83 | HasShadow = false; 84 | 85 | ThemeChanged += OnThemeChanged; 86 | } 87 | 88 | public static event EventHandler ThemeChanged; 89 | 90 | public enum Theme 91 | { 92 | Light = 0, 93 | Dark, 94 | Acrylic, 95 | AcrylicBlur, 96 | } 97 | 98 | public enum BlurStyle 99 | { 100 | Light = 0, 101 | ExtraLight, 102 | Dark, 103 | } 104 | 105 | public bool IsShadowCompatible => MaterialTheme == Theme.Acrylic || (MaterialTheme == Theme.Light && Elevation > 0); 106 | 107 | public Theme MaterialTheme 108 | { 109 | get => (Theme)GetValue(MaterialThemeProperty); 110 | set => SetValue(MaterialThemeProperty, value); 111 | } 112 | 113 | public Color LightThemeBackgroundColor 114 | { 115 | get => (Color)GetValue(LightThemeBackgroundColorProperty); 116 | set => SetValue(LightThemeBackgroundColorProperty, value); 117 | } 118 | 119 | public Color AcrylicGlowColor 120 | { 121 | get => (Color)GetValue(AcrylicGlowColorProperty); 122 | set => SetValue(AcrylicGlowColorProperty, value); 123 | } 124 | 125 | public BlurStyle MaterialBlurStyle 126 | { 127 | get => (BlurStyle)GetValue(MaterialBlurStyleProperty); 128 | set => SetValue(MaterialBlurStyleProperty, value); 129 | } 130 | 131 | public int Elevation 132 | { 133 | get => (int)GetValue(ElevationProperty); 134 | set => SetValue(ElevationProperty, value); 135 | } 136 | 137 | public static void ChangeGlobalTheme(Theme newTheme) 138 | { 139 | var previousTheme = globalTheme; 140 | globalTheme = newTheme; 141 | 142 | if (previousTheme != globalTheme) 143 | { 144 | ThemeChanged?.Invoke(null, new EventArgs()); 145 | } 146 | } 147 | 148 | public void Unsubscribe() 149 | { 150 | ThemeChanged -= OnThemeChanged; 151 | } 152 | 153 | public Color ElevationToColor() 154 | { 155 | if (MaterialTheme == Theme.Light) 156 | { 157 | return Colors.Transparent; 158 | } 159 | 160 | if (Elevation < 0) 161 | { 162 | return Colors.Transparent; 163 | } 164 | 165 | int index = Elevation > 24 ? 24 : Elevation; 166 | return DarkColors[index]; 167 | } 168 | 169 | private void OnThemeChanged(object sender, EventArgs eventArgs) 170 | { 171 | MaterialTheme = globalTheme; 172 | } 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /Maui.MaterialFrame/Maui.MaterialFrame.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net7.0;net7.0-android;net7.0-ios;net7.0-maccatalyst 5 | $(TargetFrameworks);net7.0-windows10.0.19041.0 6 | 7 | 8 | true 9 | true 10 | enable 11 | 12 | Sharpnado.MaterialFrame 13 | 14 | 14.2 15 | 14.0 16 | 21.0 17 | 10.0.17763.0 18 | 10.0.17763.0 19 | 6.5 20 | 21 | StyleCopRules.ruleset 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | $(AssemblyName) ($(TargetFramework)) 56 | 2.0.0 57 | 2.0.0 58 | 2.0.0 59 | true 60 | en 61 | 62 | false 63 | 64 | latest 65 | 66 | true 67 | 68 | 69 | 70 | Sharpnado.MaterialFrame.Maui 71 | https://github.com/roubachof/Sharpnado.MaterialFrame 72 | https://github.com/roubachof/Sharpnado.MaterialFrame 73 | images/material_frame_maui.png 74 | docs/ReadMe.md 75 | maui android ios winUI netstandard blurview blur UIVisualEffectView acrylic dark mode frame blurred background AcrylicBrush 76 | 77 | First MAUI release \o/ 78 | 79 | 80 | A modern MAUI Frame component supporting blur, acrylic, dark mode. 81 | A modern .Net MAUI Frame component supporting blur, acrylic, dark mode. Implemented with RealtimeBlurView on Android (custom blurview), UIVisualEffectView on iOS and AcrylicBrush on WinUI. 82 | 83 | The MAUI MaterialFrame aims at delivering out of the box modern popular theming such as: 84 | * Light 85 | * Dark 86 | * Acrylic 87 | * AcrylicBlur 88 | 89 | The AcrylicBlur theme also provides three different blur styles inherited from the iOS UIVisualEffectView: 90 | * Light 91 | * ExtraLight 92 | * Dark 93 | 94 | On Android, the blur is implemented thanks to the RealtimeBlurView from Tu Yimin (mmin18). 95 | ## Installation 96 | 97 | * In Core project, in `MauiProgram.cs`: 98 | 99 | ```csharp 100 | public static MauiApp CreateMauiApp() 101 | { 102 | var builder = MauiApp.CreateBuilder(); 103 | builder 104 | .UseMauiApp() 105 | .UseSharpnadoMaterialFrame(loggerEnabled: false); 106 | } 107 | ``` 108 | 109 | 110 | Jean-Marie Alfonsi 111 | Jean-Marie Alfonsi 112 | Copyright 2024 Sharpnado 113 | true 114 | MIT 115 | 116 | true 117 | true 118 | true 119 | snupkg 120 | 2.0.0 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | true 130 | 131 | 132 | 133 | 134 | 135 | 136 | all 137 | runtime; build; native; contentfiles; analyzers 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /Maui.MaterialFrame/Maui.MaterialFrame.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Maui.MaterialFrame", "Maui.MaterialFrame.csproj", "{429883AE-0FDC-44D3-AD4F-7ED4C0485F88}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug|Any CPU = Debug|Any CPU 8 | Release|Any CPU = Release|Any CPU 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {429883AE-0FDC-44D3-AD4F-7ED4C0485F88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 12 | {429883AE-0FDC-44D3-AD4F-7ED4C0485F88}.Debug|Any CPU.Build.0 = Debug|Any CPU 13 | {429883AE-0FDC-44D3-AD4F-7ED4C0485F88}.Release|Any CPU.ActiveCfg = Release|Any CPU 14 | {429883AE-0FDC-44D3-AD4F-7ED4C0485F88}.Release|Any CPU.Build.0 = Release|Any CPU 15 | EndGlobalSection 16 | EndGlobal 17 | -------------------------------------------------------------------------------- /Maui.MaterialFrame/Maui.MaterialFrame.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True -------------------------------------------------------------------------------- /Maui.MaterialFrame/MauiAppBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Maui.Controls.Compatibility.Hosting; 2 | 3 | namespace Sharpnado.MaterialFrame; 4 | 5 | public static class MauiAppBuilderExtensions 6 | { 7 | public static MauiAppBuilder UseSharpnadoMaterialFrame( 8 | this MauiAppBuilder builder, 9 | bool loggerEnable, 10 | bool debugLogEnable = false) 11 | { 12 | Initializer.Initialize(loggerEnable, debugLogEnable); 13 | 14 | builder.UseMauiCompatibility(); 15 | builder.ConfigureMauiHandlers(handlers => 16 | { 17 | #if ANDROID 18 | handlers.AddHandler(); 19 | #elif IOS 20 | handlers.AddHandler(); 21 | #elif MACCATALYST 22 | handlers.AddHandler(); 23 | #elif WINDOWS 24 | 25 | handlers.AddHandler(); 26 | #endif 27 | }); 28 | 29 | return builder; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Maui.MaterialFrame/Platforms/Android/AndroidStockBlurImpl.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // https://github.com/mmin18/RealtimeBlurView 4 | // Latest commit 82df352 on 24 May 2019 5 | // 6 | // Copyright 2016 Tu Yimin (http://github.com/mmin18) 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | // See the License for the specific language governing permissions and 18 | // limitations under the License. 19 | // 20 | //------------------------------------------------------------------------------ 21 | // Adapted to csharp by Jean-Marie Alfonsi 22 | //------------------------------------------------------------------------------ 23 | // 24 | 25 | using Android.Content; 26 | using Android.Graphics; 27 | using Android.Renderscripts; 28 | using Element = Android.Renderscripts.Element; 29 | 30 | namespace Sharpnado.MaterialFrame.Droid 31 | { 32 | public class AndroidStockBlurImpl : IBlurImpl 33 | { 34 | #if DEBUG 35 | private const bool DEBUG = true; 36 | #else 37 | private const bool DEBUG = false; 38 | #endif 39 | 40 | private RenderScript _mRenderScript; 41 | 42 | private ScriptIntrinsicBlur _mBlurScript; 43 | 44 | private Allocation _mBlurInput; 45 | 46 | private Allocation _mBlurOutput; 47 | 48 | public bool Prepare(Context context, Bitmap buffer, float radius) 49 | { 50 | if (_mRenderScript == null) 51 | { 52 | try 53 | { 54 | _mRenderScript = RenderScript.Create(context); 55 | _mBlurScript = ScriptIntrinsicBlur.Create(_mRenderScript, Element.U8_4(_mRenderScript)); 56 | } 57 | catch (Android.Renderscripts.RSRuntimeException e) 58 | { 59 | if (DEBUG) 60 | { 61 | throw e; 62 | } 63 | else 64 | { 65 | // In release mode, just ignore 66 | Release(); 67 | return false; 68 | } 69 | } 70 | } 71 | 72 | _mBlurScript.SetRadius(radius); 73 | 74 | _mBlurInput = Allocation.CreateFromBitmap( 75 | _mRenderScript, 76 | buffer, 77 | Allocation.MipmapControl.MipmapNone, 78 | AllocationUsage.Script); 79 | _mBlurOutput = Allocation.CreateTyped(_mRenderScript, _mBlurInput.Type); 80 | 81 | return true; 82 | } 83 | 84 | public void Release() 85 | { 86 | if (!_mBlurInput.IsNullOrDisposed()) 87 | { 88 | _mBlurInput.Destroy(); 89 | _mBlurInput = null; 90 | } 91 | 92 | if (!_mBlurOutput.IsNullOrDisposed()) 93 | { 94 | _mBlurOutput.Destroy(); 95 | _mBlurOutput = null; 96 | } 97 | 98 | if (!_mBlurScript.IsNullOrDisposed()) 99 | { 100 | _mBlurScript.Destroy(); 101 | _mBlurScript = null; 102 | } 103 | 104 | if (!_mRenderScript.IsNullOrDisposed()) 105 | { 106 | _mRenderScript.Destroy(); 107 | _mRenderScript = null; 108 | } 109 | } 110 | 111 | public void Blur(Bitmap input, Bitmap output) 112 | { 113 | _mBlurInput.CopyFrom(input); 114 | _mBlurScript.SetInput(_mBlurInput); 115 | _mBlurScript.ForEach(_mBlurOutput); 116 | _mBlurOutput.CopyTo(output); 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /Maui.MaterialFrame/Platforms/Android/BlurView/BlurViewFacade.cs: -------------------------------------------------------------------------------- 1 | // 2 | 3 | namespace Sharpnado.MaterialFrame.Droid.BlurView 4 | { 5 | public interface IBlurViewFacade 6 | { 7 | /** 8 | * Enables/disables the blur. Enabled by default 9 | * 10 | * @param enabled true to enable, false otherwise 11 | * @return {@link BlurViewFacade} 12 | */ 13 | IBlurViewFacade SetBlurEnabled(bool enabled); 14 | 15 | /** 16 | * Can be used to stop blur auto update or resume if it was stopped before. 17 | * Enabled by default. 18 | * 19 | * @return {@link BlurViewFacade} 20 | */ 21 | IBlurViewFacade SetBlurAutoUpdate(bool enabled); 22 | 23 | /** 24 | * Can be set to true to optimize position calculation before blur. 25 | * By default, BlurView calculates its translation, rotation and scale before each draw call. 26 | * If you are not changing these properties (for example, during animation), this behavior can be changed 27 | * to calculate them only once during initialization. 28 | * 29 | * @param hasFixedTransformationMatrix indicates if this BlurView has fixed transformation Matrix. 30 | * @return {@link BlurViewFacade} 31 | */ 32 | IBlurViewFacade SetHasFixedTransformationMatrix(bool hasFixedTransformationMatrix); 33 | 34 | 35 | /** 36 | * @param radius sets the blur radius 37 | * Default value is {@link BlurController#DEFAULT_BLUR_RADIUS} 38 | * @return {@link BlurViewFacade} 39 | */ 40 | IBlurViewFacade SetBlurRadius(float radius); 41 | 42 | /** 43 | * Sets the color overlay to be drawn on top of blurred content 44 | * 45 | * @param overlayColor int color 46 | * @return {@link BlurViewFacade} 47 | */ 48 | IBlurViewFacade SetOverlayColor(int overlayColor); 49 | } 50 | } -------------------------------------------------------------------------------- /Maui.MaterialFrame/Platforms/Android/BlurView/RenderScriptBlur.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // https://github.com/Dimezis/BlurView 4 | // Latest commit a955a76 on 4 Nov 2019 5 | // 6 | // Copyright 2016 Dmitry Saviuk 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | // See the License for the specific language governing permissions and 18 | // limitations under the License. 19 | // 20 | //------------------------------------------------------------------------------ 21 | // Adapted to csharp by Jean-Marie Alfonsi 22 | //------------------------------------------------------------------------------ 23 | // 24 | 25 | using Android.Content; 26 | using Android.Graphics; 27 | using Android.Renderscripts; 28 | using Element = Android.Renderscripts.Element; 29 | 30 | namespace Sharpnado.MaterialFrame.Droid.BlurView 31 | { 32 | public class RenderScriptBlur 33 | { 34 | private readonly RenderScript _renderScript; 35 | 36 | private readonly ScriptIntrinsicBlur _blurScript; 37 | 38 | private Allocation _outAllocation; 39 | 40 | private int _lastBitmapWidth = -1; 41 | 42 | private int _lastBitmapHeight = -1; 43 | 44 | public RenderScriptBlur(Context context) 45 | { 46 | _renderScript = RenderScript.Create(context); 47 | _blurScript = ScriptIntrinsicBlur.Create(_renderScript, Element.U8_4(_renderScript)); 48 | } 49 | 50 | /** 51 | * @param bitmap bitmap to blur 52 | * @param blurRadius blur radius (1..25) 53 | * @return blurred bitmap 54 | */ 55 | public Bitmap Blur(Bitmap bitmap, float blurRadius) 56 | { 57 | // Allocation will use the same backing array of pixels as bitmap if created with USAGE_SHARED flag 58 | Allocation inAllocation = Allocation.CreateFromBitmap(_renderScript, bitmap); 59 | 60 | if (!CanReuseAllocation(bitmap)) 61 | { 62 | _outAllocation?.Destroy(); 63 | 64 | _outAllocation = Allocation.CreateTyped(_renderScript, inAllocation.Type); 65 | _lastBitmapWidth = bitmap.Width; 66 | _lastBitmapHeight = bitmap.Height; 67 | } 68 | 69 | _blurScript.SetRadius(blurRadius); 70 | _blurScript.SetInput(inAllocation); 71 | 72 | // do not use inAllocation in forEach. it will cause visual artifacts on blurred Bitmap 73 | _blurScript.ForEach(_outAllocation); 74 | _outAllocation.CopyTo(bitmap); 75 | 76 | inAllocation.Destroy(); 77 | return bitmap; 78 | } 79 | 80 | public void Destroy() 81 | { 82 | _blurScript.Destroy(); 83 | _renderScript.Destroy(); 84 | _outAllocation?.Destroy(); 85 | } 86 | 87 | public bool CanModifyBitmap() 88 | { 89 | return true; 90 | } 91 | 92 | public Bitmap.Config GetSupportedBitmapConfig() 93 | { 94 | return Bitmap.Config.Argb8888; 95 | } 96 | 97 | private bool CanReuseAllocation(Bitmap bitmap) 98 | { 99 | return bitmap.Height == _lastBitmapHeight && bitmap.Width == _lastBitmapWidth; 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Maui.MaterialFrame/Platforms/Android/IBlurImpl.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // https://github.com/mmin18/RealtimeBlurView 4 | // Latest commit 82df352 on 24 May 2019 5 | // 6 | // Copyright 2016 Tu Yimin (http://github.com/mmin18) 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | // See the License for the specific language governing permissions and 18 | // limitations under the License. 19 | // 20 | //------------------------------------------------------------------------------ 21 | // Adapted to csharp by Jean-Marie Alfonsi 22 | //------------------------------------------------------------------------------ 23 | // 24 | 25 | using Android.Content; 26 | using Android.Graphics; 27 | 28 | namespace Sharpnado.MaterialFrame.Droid 29 | { 30 | public interface IBlurImpl 31 | { 32 | bool Prepare(Context context, Bitmap buffer, float radius); 33 | 34 | void Release(); 35 | 36 | void Blur(Bitmap input, Bitmap output); 37 | } 38 | 39 | public class EmptyBlurImpl : IBlurImpl 40 | { 41 | public bool Prepare(Context context, Bitmap buffer, float radius) 42 | { 43 | return false; 44 | } 45 | 46 | public void Release() 47 | { 48 | } 49 | 50 | public void Blur(Bitmap input, Bitmap output) 51 | { 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Maui.MaterialFrame/Platforms/Android/JniExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Sharpnado.MaterialFrame.Droid 4 | { 5 | internal static class JniExtensions 6 | { 7 | public static bool IsNullOrDisposed(this Java.Lang.Object javaObject) 8 | { 9 | return javaObject == null || javaObject.Handle == IntPtr.Zero; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Maui.MaterialFrame/Platforms/Android/JniWeakReference.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Sharpnado.MaterialFrame.Droid 4 | { 5 | internal class JniWeakReference 6 | where T : Java.Lang.Object 7 | { 8 | private readonly WeakReference _reference; 9 | 10 | public JniWeakReference(T target) 11 | { 12 | _reference = new WeakReference(target); 13 | } 14 | 15 | public bool TryGetTarget(out T target) 16 | { 17 | target = null; 18 | if (_reference.TryGetTarget(out var innerTarget)) 19 | { 20 | if (innerTarget.Handle != IntPtr.Zero) 21 | { 22 | target = innerTarget; 23 | } 24 | } 25 | 26 | return target != null; 27 | } 28 | 29 | public override string ToString() 30 | { 31 | return $"[JniWeakReference] {_reference}"; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Maui.MaterialFrame/Platforms/Tizen/PlatformClass1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Maui.MaterialFrame 4 | { 5 | // All the code in this file is only included on Tizen. 6 | public class PlatformClass1 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Maui.MaterialFrame/ReadMe.md: -------------------------------------------------------------------------------- 1 | # Sharpnado.MaterialFrame 2 | 3 | 4 | | Supported platforms | 5 | |----------------------------| 6 | | :heavy_check_mark: Android | 7 | | :heavy_check_mark: iOS | 8 | | :question: macOS | 9 | | :heavy_check_mark: WinUI | 10 | 11 | ## Initialization 12 | 13 | * In `MauiProgram.cs`: 14 | 15 | ```csharp 16 | public static MauiApp CreateMauiApp() 17 | { 18 | var builder = MauiApp.CreateBuilder(); 19 | builder 20 | .UseMauiApp() 21 | .UseSharpnadoMaterialFrame(loggerEnable: false) 22 | ... 23 | } 24 | ``` 25 | 26 | ## Mac Catalyst has not been tested yet 27 | 28 | But it should be working :) ? 29 | 30 | ## Android Compatibility issues 31 | 32 | Warning, because of `LayerDrawable` the `Acrylic` glow effect (the white glow on the top of the `MaterialFrame` is only available on API 23+ (since Marshmallow). 33 | 34 | ## iOS limitations 35 | 36 | For some yet to be discovered reasons, `AcrylicBlur` value doesn't work in a dynamic context on iOS. 37 | 38 | You can change the BlurStyle dynamically, but a dynamic change from a not blurry theme to the `AcrylicBlur` theme will result in a transparent frame. 39 | 40 | ## Presentation 41 | 42 | The Xamarin.Forms `MaterialFrame` aims at delivering out of the box modern popular theming such as: 43 | * Light 44 | * Dark 45 | * Acrylic 46 | * AcrylicBlur 47 | 48 | You can switch from one theme to another thanks to the `MaterialFrame` property. 49 | -------------------------------------------------------------------------------- /Maui.MaterialFrame/Settings.XamlStyler: -------------------------------------------------------------------------------- 1 | { 2 | "AttributesTolerance": 2, 3 | "KeepFirstAttributeOnSameLine": true, 4 | "MaxAttributeCharactersPerLine": 0, 5 | "MaxAttributesPerLine": 1, 6 | "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransfom, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter", 7 | "SeparateByGroups": false, 8 | "AttributeIndentation": 0, 9 | "AttributeIndentationStyle": 1, 10 | "RemoveDesignTimeReferences": false, 11 | "EnableAttributeReordering": true, 12 | "AttributeOrderingRuleGroups": [ 13 | "x:Class", 14 | "xmlns, xmlns:x, xmlns:d, xmlns:mc, mc:Ignorable", 15 | "xmlns:*", 16 | "x:Key, Key, x:Name, Name, x:Uid, Uid, Title", 17 | "Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan, AbsoluteLayout.LayoutFlags, AbsoluteLayout.LayoutBounds", 18 | "Style, WidthRequest, HeightRequest, MinimumWidthRequest, MinimumHeightRequest", 19 | "Margin, Padding, HorizontalOptions, VerticalOptions, HorizontalTextAlignment, VerticalTextAlignment", 20 | "*:*, *", 21 | "PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint", 22 | "mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText", 23 | "Storyboard.*, From, To, Duration" 24 | ], 25 | "FirstLineAttributes": "", 26 | "OrderAttributesByName": true, 27 | "PutEndingBracketOnNewLine": false, 28 | "RemoveEndingTagOfEmptyElement": true, 29 | "SpaceBeforeClosingSlash": true, 30 | "RootElementLineBreakRule": 0, 31 | "ReorderVSM": 2, 32 | "ReorderGridChildren": false, 33 | "ReorderCanvasChildren": false, 34 | "ReorderSetters": 0, 35 | "FormatMarkupExtension": true, 36 | "NoNewLineMarkupExtensions": "x:Bind, Binding", 37 | "ThicknessSeparator": 2, 38 | "ThicknessAttributes": "Margin, Padding, BorderThickness, ThumbnailClipMargin", 39 | "FormatOnSave": true, 40 | "CommentPadding": 2, 41 | } -------------------------------------------------------------------------------- /Maui.MaterialFrame/StyleCopRules.ruleset: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Samples/Sharpnado.Acrylic.Maui/App.xaml: -------------------------------------------------------------------------------- 1 |  2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Samples/Sharpnado.Acrylic.Maui/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace Sharpnado.Acrylic.Maui; 2 | 3 | public partial class App : Application 4 | { 5 | public App() 6 | { 7 | InitializeComponent(); 8 | 9 | MainPage = new MainPage(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Samples/Sharpnado.Acrylic.Maui/GridAnimations.cs: -------------------------------------------------------------------------------- 1 | namespace Sharpnado.Acrylic 2 | { 3 | 4 | public static class GridAnimations 5 | { 6 | private static readonly GridLength ZeroHeightGrid = new GridLength(0); 7 | 8 | public static Task AnimateRowHeightAsync( 9 | this Grid view, 10 | RowDefinition rowDefinition, 11 | double rowExpandedHeight, 12 | bool isVisible, 13 | string animationName, 14 | bool dontAnimate = false) 15 | { 16 | const double Tolerance = 2f; 17 | var tcs = new TaskCompletionSource(); 18 | Animation animation; 19 | 20 | if (view.AbortAnimation(animationName)) 21 | { 22 | } 23 | 24 | if (isVisible) 25 | { 26 | if (dontAnimate) 27 | { 28 | rowDefinition.Height = rowExpandedHeight; 29 | tcs.SetResult(true); 30 | return tcs.Task; 31 | } 32 | 33 | if (rowDefinition.Height.Value > (rowExpandedHeight - Tolerance)) 34 | { 35 | tcs.SetResult(false); 36 | return tcs.Task; 37 | } 38 | 39 | // Move back to original height 40 | animation = new Animation( 41 | d => rowDefinition.Height = new GridLength(Clamp(d, 0, double.MaxValue)), 42 | rowDefinition.Height.Value, 43 | rowExpandedHeight, 44 | Easing.Linear, 45 | () => animation = null); 46 | } 47 | else 48 | { 49 | if (dontAnimate) 50 | { 51 | rowDefinition.Height = ZeroHeightGrid; 52 | tcs.SetResult(true); 53 | return tcs.Task; 54 | } 55 | 56 | if (Math.Abs(rowDefinition.Height.Value) < Tolerance) 57 | { 58 | tcs.SetResult(false); 59 | return tcs.Task; 60 | } 61 | 62 | // Hide the row 63 | animation = new Animation( 64 | d => rowDefinition.Height = new GridLength(Clamp(d, 0, double.MaxValue)), 65 | rowExpandedHeight, 66 | 0, 67 | Easing.Linear, 68 | () => animation = null); 69 | } 70 | 71 | try 72 | { 73 | view.Animate( 74 | animationName, 75 | animation, 76 | length: 400, 77 | finished: (value, success) => tcs.TrySetResult(success)); 78 | } 79 | catch (Exception) 80 | { 81 | tcs.SetResult(false); 82 | } 83 | 84 | return tcs.Task; 85 | } 86 | 87 | public static double Clamp(double value, double minValue, double maxValue) 88 | { 89 | if (value < minValue) 90 | { 91 | return minValue; 92 | } 93 | 94 | if (value > maxValue) 95 | { 96 | return maxValue; 97 | } 98 | 99 | return value; 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Samples/Sharpnado.Acrylic.Maui/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using Sharpnado.Tasks; 3 | 4 | namespace Sharpnado.Acrylic.Maui 5 | { 6 | // Learn more about making custom code visible in the Xamarin.Forms previewer 7 | // by visiting https://aka.ms/xamarinforms-previewer 8 | [DesignTimeVisible(false)] 9 | public partial class MainPage : ContentPage 10 | { 11 | private bool _isAcrylicBlurEnabled; 12 | 13 | private MaterialFrame.MaterialFrame.BlurStyle _blurStyle; 14 | 15 | private bool _isSettingsShown = true; 16 | 17 | private static readonly GridLength SettingsRowHeight = new GridLength(40); 18 | 19 | private readonly Button[] _blurStyleButtons; 20 | 21 | public MainPage() 22 | { 23 | SetValue(NavigationPage.HasNavigationBarProperty, false); 24 | InitializeComponent(); 25 | 26 | _blurStyleButtons = new[] { LightButton, DarkButton, ExtraLightButton }; 27 | 28 | SettingsFrame.IsVisible = _isSettingsShown; 29 | SettingsFrame.Opacity = _isSettingsShown ? 1 : 0; 30 | 31 | BlurSwitch.IsToggled = false; 32 | SwitchOnToggled(BlurSwitch, new ToggledEventArgs(BlurSwitch.IsToggled)); 33 | } 34 | 35 | protected override void OnAppearing() 36 | { 37 | base.OnAppearing(); 38 | 39 | TaskMonitor.Create(DelayExecute); 40 | } 41 | 42 | private async Task DelayExecute() 43 | { 44 | await Task.Delay(3000); 45 | 46 | //var dump = PlatformHelper.Instance.DumpNativeViewHierarchy(Search, true); 47 | // Console.WriteLine($"Search Frame dump:{Environment.NewLine}{dump}"); 48 | 49 | // dump = PlatformHelper.Instance.DumpNativeViewHierarchy(ImageFrame, true); 50 | // Console.WriteLine($"Image Frame dump:{Environment.NewLine}{dump}"); 51 | } 52 | 53 | private void SettingsButtonOnClicked(object sender, EventArgs e) 54 | { 55 | if (!_isSettingsShown) 56 | { 57 | BlurStyleRow.Height = _isAcrylicBlurEnabled ? SettingsRowHeight : 0; 58 | SettingsFrame.IsVisible = true; 59 | 60 | TaskMonitor.Create(SettingsFrame.FadeTo(1)); 61 | _isSettingsShown = true; 62 | return; 63 | } 64 | 65 | // Hide 66 | _isSettingsShown = false; 67 | TaskMonitor.Create(async () => 68 | { 69 | await SettingsFrame.FadeTo(0); 70 | SettingsFrame.IsVisible = false; 71 | }); 72 | } 73 | 74 | private void SwitchOnToggled(object sender, ToggledEventArgs e) 75 | { 76 | var switchBlur = (Switch)sender; 77 | 78 | _isAcrylicBlurEnabled = switchBlur.IsToggled; 79 | 80 | if (_isAcrylicBlurEnabled) 81 | { 82 | ResourcesHelper.SetAcrylic(true); 83 | BlurStyleButtonOnClicked(LightButton, EventArgs.Empty); 84 | } 85 | else 86 | { 87 | ResourcesHelper.SetAcrylic(false); 88 | } 89 | 90 | BlurStyleRow.Height = _isAcrylicBlurEnabled ? SettingsRowHeight : 0; 91 | foreach (var button in _blurStyleButtons) 92 | { 93 | button.IsVisible = _isAcrylicBlurEnabled; 94 | } 95 | } 96 | 97 | private void BlurStyleButtonOnClicked(object sender, EventArgs e) 98 | { 99 | var selectedButton = (Button)sender; 100 | 101 | if (selectedButton == LightButton) 102 | { 103 | _blurStyle = MaterialFrame.MaterialFrame.BlurStyle.Light; 104 | } 105 | else if (selectedButton == DarkButton) 106 | { 107 | _blurStyle = MaterialFrame.MaterialFrame.BlurStyle.Dark; 108 | } 109 | else 110 | { 111 | _blurStyle = MaterialFrame.MaterialFrame.BlurStyle.ExtraLight; 112 | } 113 | 114 | ResourcesHelper.SetBlurStyle(_blurStyle); 115 | 116 | selectedButton.TextColor = _blurStyle != MaterialFrame.MaterialFrame.BlurStyle.ExtraLight 117 | ? ResourcesHelper.GetResourceColor("TextPrimaryColor" ) 118 | : ResourcesHelper.GetResourceColor("TextPrimaryDarkColor"); 119 | 120 | selectedButton.BackgroundColor = ResourcesHelper.GetResourceColor(ResourcesHelper.DynamicPrimaryColor); 121 | 122 | foreach (var button in _blurStyleButtons) 123 | { 124 | if (button == selectedButton) 125 | { 126 | continue; 127 | } 128 | 129 | button.TextColor = _blurStyle != MaterialFrame.MaterialFrame.BlurStyle.ExtraLight 130 | ? ResourcesHelper.GetResourceColor("TextPrimaryDarkColor") 131 | : ResourcesHelper.GetResourceColor("TextPrimaryColor" ); 132 | button.BackgroundColor = Colors.Transparent; 133 | } 134 | } 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /Samples/Sharpnado.Acrylic.Maui/MainPagePouet.xaml: -------------------------------------------------------------------------------- 1 |  2 | 5 | 6 | 7 | 11 | 12 | 17 | 18 |