From c3d1c03a25dc05969ebd7430578f6a28121274e2 Mon Sep 17 00:00:00 2001 From: Naveenkumar S Date: Mon, 23 Dec 2024 17:10:33 +0530 Subject: [PATCH] Added a new example for bottom sheet --- BottomSheet/BottomSheetFoodOrder/App.xaml | 14 + BottomSheet/BottomSheetFoodOrder/App.xaml.cs | 15 + .../BottomSheetFoodOrder/AppShell.xaml | 15 + .../BottomSheetFoodOrder/AppShell.xaml.cs | 10 + .../BottomSheetBehavior.cs | 159 + .../BottomSheetFoodOrder.csproj | 77 + .../BottomSheetFoodOrder.csproj.user | 44 + .../BottomSheetFoodOrder.sln | 22 + .../GettingStartedDesktop.xaml | 152 + .../GettingStartedDesktop.xaml.cs | 9 + .../GettingStartedMobile.xaml | 146 + .../GettingStartedMobile.xaml.cs | 9 + .../BottomSheetFoodOrder/MainPage.xaml | 8 + .../BottomSheetFoodOrder/MainPage.xaml.cs | 27 + .../BottomSheetFoodOrder/MauiProgram.cs | 27 + .../BottomSheetFoodOrder/Model/Item.cs | 68 + .../Platforms/Android/AndroidManifest.xml | 6 + .../Platforms/Android/MainActivity.cs | 11 + .../Platforms/Android/MainApplication.cs | 16 + .../Android/Resources/values/colors.xml | 6 + .../Platforms/MacCatalyst/AppDelegate.cs | 10 + .../Platforms/MacCatalyst/Entitlements.plist | 14 + .../Platforms/MacCatalyst/Info.plist | 38 + .../Platforms/MacCatalyst/Program.cs | 16 + .../Platforms/Tizen/Main.cs | 17 + .../Platforms/Tizen/tizen-manifest.xml | 15 + .../Platforms/Windows/App.xaml | 8 + .../Platforms/Windows/App.xaml.cs | 25 + .../Platforms/Windows/Package.appxmanifest | 46 + .../Platforms/Windows/app.manifest | 15 + .../Platforms/iOS/AppDelegate.cs | 10 + .../Platforms/iOS/Info.plist | 32 + .../Platforms/iOS/Program.cs | 16 + .../iOS/Resources/PrivacyInfo.xcprivacy | 51 + .../Properties/launchSettings.json | 8 + .../Resources/AppIcon/appicon.svg | 4 + .../Resources/AppIcon/appiconfg.svg | 8 + .../Resources/Fonts/FluentUI.cs | 7921 +++++++++++++++++ .../Resources/Fonts/MauiSampleFontIcon.ttf | Bin 0 -> 88684 bytes .../Resources/Fonts/OpenSans-Regular.ttf | Bin 0 -> 107280 bytes .../Resources/Fonts/OpenSans-Semibold.ttf | Bin 0 -> 111184 bytes .../Resources/Images/dotnet_bot.png | Bin 0 -> 93437 bytes .../Resources/Images/pizza1.png | Bin 0 -> 30985 bytes .../Resources/Images/pizza10.png | Bin 0 -> 76502 bytes .../Resources/Images/pizza11.png | Bin 0 -> 74510 bytes .../Resources/Images/pizza12.png | Bin 0 -> 76648 bytes .../Resources/Images/pizza13.png | Bin 0 -> 74267 bytes .../Resources/Images/pizza14.png | Bin 0 -> 76777 bytes .../Resources/Images/pizza15.png | Bin 0 -> 72447 bytes .../Resources/Images/pizza16.png | Bin 0 -> 81027 bytes .../Resources/Images/pizza17.png | Bin 0 -> 85282 bytes .../Resources/Images/pizza2.png | Bin 0 -> 30258 bytes .../Resources/Images/pizza3.png | Bin 0 -> 30985 bytes .../Resources/Images/pizza4.png | Bin 0 -> 34054 bytes .../Resources/Images/pizza5.png | Bin 0 -> 33130 bytes .../Resources/Images/pizza6.png | Bin 0 -> 32464 bytes .../Resources/Images/pizza7.png | Bin 0 -> 31885 bytes .../Resources/Images/pizza8.png | Bin 0 -> 35759 bytes .../Resources/Images/pizza9.png | Bin 0 -> 78750 bytes .../Resources/Raw/AboutAssets.txt | 15 + .../Resources/Splash/splash.svg | 8 + .../Resources/Styles/Colors.xaml | 45 + .../Resources/Styles/Styles.xaml | 451 + .../ViewModel/ItemViewModel.cs | 47 + 64 files changed, 9661 insertions(+) create mode 100644 BottomSheet/BottomSheetFoodOrder/App.xaml create mode 100644 BottomSheet/BottomSheetFoodOrder/App.xaml.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/AppShell.xaml create mode 100644 BottomSheet/BottomSheetFoodOrder/AppShell.xaml.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/BottomSheetBehavior.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/BottomSheetFoodOrder.csproj create mode 100644 BottomSheet/BottomSheetFoodOrder/BottomSheetFoodOrder.csproj.user create mode 100644 BottomSheet/BottomSheetFoodOrder/BottomSheetFoodOrder.sln create mode 100644 BottomSheet/BottomSheetFoodOrder/GettingStartedDesktop.xaml create mode 100644 BottomSheet/BottomSheetFoodOrder/GettingStartedDesktop.xaml.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/GettingStartedMobile.xaml create mode 100644 BottomSheet/BottomSheetFoodOrder/GettingStartedMobile.xaml.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/MainPage.xaml create mode 100644 BottomSheet/BottomSheetFoodOrder/MainPage.xaml.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/MauiProgram.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/Model/Item.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/Android/AndroidManifest.xml create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/Android/MainActivity.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/Android/MainApplication.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/Android/Resources/values/colors.xml create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/MacCatalyst/AppDelegate.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/MacCatalyst/Entitlements.plist create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/MacCatalyst/Info.plist create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/MacCatalyst/Program.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/Tizen/Main.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/Tizen/tizen-manifest.xml create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/Windows/App.xaml create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/Windows/App.xaml.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/Windows/Package.appxmanifest create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/Windows/app.manifest create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/iOS/AppDelegate.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/iOS/Info.plist create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/iOS/Program.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/Platforms/iOS/Resources/PrivacyInfo.xcprivacy create mode 100644 BottomSheet/BottomSheetFoodOrder/Properties/launchSettings.json create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/AppIcon/appicon.svg create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/AppIcon/appiconfg.svg create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Fonts/FluentUI.cs create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Fonts/MauiSampleFontIcon.ttf create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Fonts/OpenSans-Regular.ttf create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Fonts/OpenSans-Semibold.ttf create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/dotnet_bot.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza1.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza10.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza11.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza12.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza13.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza14.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza15.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza16.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza17.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza2.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza3.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza4.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza5.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza6.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza7.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza8.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Images/pizza9.png create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Raw/AboutAssets.txt create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Splash/splash.svg create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Styles/Colors.xaml create mode 100644 BottomSheet/BottomSheetFoodOrder/Resources/Styles/Styles.xaml create mode 100644 BottomSheet/BottomSheetFoodOrder/ViewModel/ItemViewModel.cs diff --git a/BottomSheet/BottomSheetFoodOrder/App.xaml b/BottomSheet/BottomSheetFoodOrder/App.xaml new file mode 100644 index 0000000..ae1ccb5 --- /dev/null +++ b/BottomSheet/BottomSheetFoodOrder/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/BottomSheet/BottomSheetFoodOrder/App.xaml.cs b/BottomSheet/BottomSheetFoodOrder/App.xaml.cs new file mode 100644 index 0000000..b412937 --- /dev/null +++ b/BottomSheet/BottomSheetFoodOrder/App.xaml.cs @@ -0,0 +1,15 @@ +namespace BottomSheetFoodOrder +{ + public partial class App : Application + { + public App() + { + InitializeComponent(); + } + + protected override Window CreateWindow(IActivationState? activationState) + { + return new Window(new AppShell()); + } + } +} \ No newline at end of file diff --git a/BottomSheet/BottomSheetFoodOrder/AppShell.xaml b/BottomSheet/BottomSheetFoodOrder/AppShell.xaml new file mode 100644 index 0000000..f0ce7ef --- /dev/null +++ b/BottomSheet/BottomSheetFoodOrder/AppShell.xaml @@ -0,0 +1,15 @@ + + + + + + diff --git a/BottomSheet/BottomSheetFoodOrder/AppShell.xaml.cs b/BottomSheet/BottomSheetFoodOrder/AppShell.xaml.cs new file mode 100644 index 0000000..7e5e4ba --- /dev/null +++ b/BottomSheet/BottomSheetFoodOrder/AppShell.xaml.cs @@ -0,0 +1,10 @@ +namespace BottomSheetFoodOrder +{ + public partial class AppShell : Shell + { + public AppShell() + { + InitializeComponent(); + } + } +} diff --git a/BottomSheet/BottomSheetFoodOrder/BottomSheetBehavior.cs b/BottomSheet/BottomSheetFoodOrder/BottomSheetBehavior.cs new file mode 100644 index 0000000..df2c251 --- /dev/null +++ b/BottomSheet/BottomSheetFoodOrder/BottomSheetBehavior.cs @@ -0,0 +1,159 @@ +using Syncfusion.Maui.Toolkit.BottomSheet; +using Syncfusion.Maui.Toolkit.EffectsView; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BottomSheetFoodOrder +{ + public class BottomSheetBehavior : Behavior + { + ListView? _listView; + ItemViewModel? _itemViewModel; + SfBottomSheet? _bottomSheet; + SfEffectsView? _decreaseQuantity; + SfEffectsView? _increaseQuantity; + SfEffectsView? _closeIcon; + CheckBox? _extraOne; + CheckBox? _extraTwo; + Grid? grid; + + /// + /// You can override this method to subscribe to AssociatedObject events and initialize properties. + /// + /// SampleView type parameter named as bindable. + protected override void OnAttachedTo(ContentPage bindable) + { + _listView = bindable.FindByName("ListView"); + _listView.ItemTapped += ListView_ItemTapped; + _itemViewModel = new ItemViewModel(); + bindable.BindingContext = _itemViewModel; + _bottomSheet = bindable.FindByName("BottomSheet"); + _bottomSheet.StateChanged += OnStateChanged; + _decreaseQuantity = bindable.FindByName("DecreaseQuantity"); + _increaseQuantity = bindable.FindByName("IncreaseQuantity"); + _closeIcon = bindable.FindByName("CloseIcon"); + _extraOne = bindable.FindByName("ExtraCheese"); + _extraTwo = bindable.FindByName("ExtraDoubleCheese"); + grid = bindable.FindByName("Grid"); + + TapGestureRecognizer decreaseTapped = new TapGestureRecognizer(); + decreaseTapped.Tapped += OnDecreaseTapped; + _decreaseQuantity.GestureRecognizers.Add(decreaseTapped); + + TapGestureRecognizer increaseTapped = new TapGestureRecognizer(); + increaseTapped.Tapped += OnIncreaseTapped; + _increaseQuantity.GestureRecognizers.Add(increaseTapped); + + TapGestureRecognizer closeIconTapped = new TapGestureRecognizer(); + closeIconTapped.Tapped += OnCloseIconTapped; + _closeIcon.GestureRecognizers.Add(closeIconTapped); + + _extraOne.CheckedChanged += ExtraOne_CheckedChanged; + _extraTwo.CheckedChanged += ExtraTwo_CheckedChanged; + + base.OnAttachedTo(bindable); + } + + private void ExtraTwo_CheckedChanged(object? sender, CheckedChangedEventArgs e) + { + if (_extraTwo is not null && _bottomSheet is not null && grid is not null) + { + if (_extraTwo.IsChecked && _extraOne is not null) + { + _extraOne.IsChecked = false; + var item = (Item)grid.BindingContext; + item.TotalPrice = (item.Price + 4) * item.Quantity; + } + else + { + var item = (Item)grid.BindingContext; + item.TotalPrice = item.Price * item.Quantity; + } + } + } + + private void ExtraOne_CheckedChanged(object? sender, CheckedChangedEventArgs e) + { + if (_extraOne is not null && _bottomSheet is not null && grid is not null) + { + if (_extraOne.IsChecked && _extraTwo is not null) + { + _extraTwo.IsChecked = false; + var item = (Item)grid.BindingContext; + item.TotalPrice = (item.Price + 2) * item.Quantity; + } + else + { + var item = (Item)grid.BindingContext; + item.TotalPrice = item.Price * item.Quantity; + } + } + } + + private void OnStateChanged(object? sender, StateChangedEventArgs e) + { + if (_bottomSheet is not null && _bottomSheet.State is BottomSheetState.Hidden && grid is not null) + { + grid.BindingContext = null; + } + } + + private void ListView_ItemTapped(object? sender, ItemTappedEventArgs e) + { + var selectedItem = (Item)e.Item; + if (_bottomSheet is not null && grid is not null) + { + grid.BindingContext = selectedItem; + if (_bottomSheet.IsOpen) + { + _bottomSheet.State = BottomSheetState.HalfExpanded; + } + + _bottomSheet.Show(); + } + } + + private void OnDecreaseTapped(object? sender, TappedEventArgs e) + { + if (_bottomSheet is not null && grid is not null) + { + var temp = (Item)grid.BindingContext; + if (temp.Quantity > 1) + { + temp.Quantity--; + } + } + } + + private void OnIncreaseTapped(object? sender, TappedEventArgs e) + { + if (_bottomSheet is not null && grid is not null) + { + var temp = (Item)grid.BindingContext; + temp.Quantity++; + } + } + + private void OnCloseIconTapped(object? sender, TappedEventArgs e) + { + if (_bottomSheet is not null) + { + _bottomSheet.Close(); + } + } + + /// + /// You can override this method while View was detached from window + /// + /// SampleView type parameter named as bindable + protected override void OnDetachingFrom(ContentPage bindable) + { + _listView = null; + _itemViewModel = null; + base.OnDetachingFrom(bindable); + } + } +} diff --git a/BottomSheet/BottomSheetFoodOrder/BottomSheetFoodOrder.csproj b/BottomSheet/BottomSheetFoodOrder/BottomSheetFoodOrder.csproj new file mode 100644 index 0000000..bdc301c --- /dev/null +++ b/BottomSheet/BottomSheetFoodOrder/BottomSheetFoodOrder.csproj @@ -0,0 +1,77 @@ + + + + net9.0-android;net9.0-ios;net9.0-maccatalyst + $(TargetFrameworks);net9.0-windows10.0.19041.0 + + + + + + + Exe + BottomSheetFoodOrder + true + true + enable + enable + + + BottomSheetFoodOrder + + + com.companyname.bottomsheetfoodorder + + + 1.0 + 1 + + + None + + 15.0 + 15.0 + 21.0 + 10.0.17763.0 + 10.0.17763.0 + 6.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MSBuild:Compile + + + MSBuild:Compile + + + + diff --git a/BottomSheet/BottomSheetFoodOrder/BottomSheetFoodOrder.csproj.user b/BottomSheet/BottomSheetFoodOrder/BottomSheetFoodOrder.csproj.user new file mode 100644 index 0000000..a5eec38 --- /dev/null +++ b/BottomSheet/BottomSheetFoodOrder/BottomSheetFoodOrder.csproj.user @@ -0,0 +1,44 @@ + + + + False + net9.0-windows10.0.19041.0 + Windows Machine + Emulator + pixel_5_-_api_34 + + + ProjectDebugger + + + + Designer + + + Designer + + + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + \ No newline at end of file diff --git a/BottomSheet/BottomSheetFoodOrder/BottomSheetFoodOrder.sln b/BottomSheet/BottomSheetFoodOrder/BottomSheetFoodOrder.sln new file mode 100644 index 0000000..2617b83 --- /dev/null +++ b/BottomSheet/BottomSheetFoodOrder/BottomSheetFoodOrder.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35506.116 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BottomSheetFoodOrder", "BottomSheetFoodOrder.csproj", "{462D8B5B-ADF0-427B-BE4D-BE33B419007C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {462D8B5B-ADF0-427B-BE4D-BE33B419007C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {462D8B5B-ADF0-427B-BE4D-BE33B419007C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {462D8B5B-ADF0-427B-BE4D-BE33B419007C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {462D8B5B-ADF0-427B-BE4D-BE33B419007C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/BottomSheet/BottomSheetFoodOrder/GettingStartedDesktop.xaml b/BottomSheet/BottomSheetFoodOrder/GettingStartedDesktop.xaml new file mode 100644 index 0000000..7188dac --- /dev/null +++ b/BottomSheet/BottomSheetFoodOrder/GettingStartedDesktop.xaml @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +