-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a700911
commit 209d1c9
Showing
39 changed files
with
1,234 additions
and
2 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,52 @@ | ||
# Payment-method-choice-using-.NET-MAUI-Radio-button | ||
This example demonstrates, how to implement a streamlined payment selection interface using Syncfusion Maui Radio buttons. | ||
# Implementing Payment Method Selection: | ||
In this example, I will demonstrate how to implement payment method selection using the .NET Maui Radio button. Follow the steps below to create a project and implement payment selection from the available options using Maui Radio Buttons. | ||
|
||
## Create a Simple Maui RadioButton | ||
|
||
Start by referring to the Syncfusion .NET MAUI RadioButton documentation to create a MAUI application and include the RadioButton components. The IsChecked property is used to indicate whether the payment method is selected among the available options. | ||
|
||
``` | ||
<buttons:SfRadioButton Text="UPI" IsChecked="True"/> | ||
``` | ||
|
||
## Group Radio Buttons | ||
|
||
You can group a set of radio buttons using a SfRadioGroup element. It's a container that ensures only one radio button can be selected within the same group. | ||
|
||
``` | ||
<buttons:SfRadioGroup> | ||
<buttons:SfRadioButton Text="UPI" IsChecked="True" /> | ||
<buttons:SfRadioButton Text="Credit/Debit/ATM Card" /> | ||
<buttons:SfRadioButton Text="Net Banking" /> | ||
<buttons:SfRadioButton Text="Cash on Delivery" /> | ||
</buttons:SfRadioGroup> | ||
``` | ||
|
||
## Select Payment Options | ||
You can choose any of the available payment options and take the necessary actions in the StateChanged event. This event is triggered when the IsChecked state changes. | ||
|
||
``` | ||
<buttons:SfRadioGroup> | ||
<buttons:SfRadioButton Text="UPI" StateChanged="PaymentOption_Selected" IsChecked="True"/> | ||
<buttons:SfRadioButton Text="Credit/Debit/ATM Card" StateChanged="PaymentOption_Selected"/> | ||
<buttons:SfRadioButton Text="Net Banking" StateChanged="PaymentOption_Selected"/> | ||
<buttons:SfRadioButton Text="Cash on Delivery" StateChanged="PaymentOption_Selected"/> | ||
</buttons:SfRadioGroup> | ||
``` | ||
|
||
``` | ||
private void PaymentOption_Selected(object sender, StateChangedEventArgs e) | ||
{ | ||
// Add your code here | ||
} | ||
``` | ||
|
||
## Customize the Payment Form | ||
In this example, I enhanced the payment form UI by adding text input layout controls for entering the name, mobile number, and email ID. Additionally, I created different sections for each payment option as shown below. | ||
|
||
![image](Images/Payment_method_selection.png) | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version = "1.0" encoding = "UTF-8" ?> | ||
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:RadioButtonPaymentOption" | ||
x:Class="RadioButtonPaymentOption.App"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="Resources/Styles/Colors.xaml" /> | ||
<ResourceDictionary Source="Resources/Styles/Styles.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace RadioButtonPaymentOption | ||
{ | ||
public partial class App : Application | ||
{ | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
|
||
MainPage = new AppShell(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Shell | ||
x:Class="RadioButtonPaymentOption.AppShell" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:RadioButtonPaymentOption" | ||
Shell.FlyoutBehavior="Disabled" | ||
Title="RadioButtonPaymentOption"> | ||
|
||
<ShellContent | ||
ContentTemplate="{DataTemplate local:MainPage}" | ||
Route="MainPage" /> | ||
|
||
</Shell> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace RadioButtonPaymentOption | ||
{ | ||
public partial class AppShell : Shell | ||
{ | ||
public AppShell() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:buttons="clr-namespace:Syncfusion.Maui.Buttons;assembly=Syncfusion.Maui.Buttons" | ||
xmlns:inputs="clr-namespace:Syncfusion.Maui.Inputs;assembly=Syncfusion.Maui.Inputs" | ||
xmlns:core="clr-namespace:Syncfusion.Maui.Core;assembly=Syncfusion.Maui.Core" | ||
x:Class="RadioButtonPaymentOption.MainPage"> | ||
|
||
<VerticalStackLayout> | ||
<Label Text="Payments" FontSize="18" FontAttributes="Bold" Margin="15,0,0,5"/> | ||
|
||
<Grid Background="LightBlue" HeightRequest="40" Margin="15,0,15,0"> | ||
<Label Text="Total Amount" VerticalTextAlignment="Center" HorizontalOptions="Start" Margin="5" FontAttributes="Bold"/> | ||
<Label Text="$590" VerticalTextAlignment="Center" HorizontalOptions="End" Margin="5" FontAttributes="Bold"/> | ||
</Grid> | ||
|
||
<Grid ColumnDefinitions="*,*" HorizontalOptions="Center" RowDefinitions="90,90,auto,*" | ||
Margin="10"> | ||
<core:SfTextInputLayout Grid.Column="0" Margin="5" Hint="First Name" HelperText="Enter your first name" > | ||
<Entry /> | ||
</core:SfTextInputLayout> | ||
|
||
<core:SfTextInputLayout Grid.Column="1" Margin="5" Hint="Last Name" HelperText="Enter your last name" > | ||
<Entry /> | ||
</core:SfTextInputLayout> | ||
|
||
<core:SfTextInputLayout Grid.Column="0" Grid.Row="1" Margin="5" Hint="Phone" HelperText="Enter your phone number" > | ||
<Entry /> | ||
</core:SfTextInputLayout> | ||
|
||
<core:SfTextInputLayout Grid.Column="1" Grid.Row="1" Margin="5" Hint="E-mail" HelperText="Enter your E-mail ID" > | ||
<Entry /> | ||
</core:SfTextInputLayout> | ||
|
||
<VerticalStackLayout Grid.ColumnSpan="2" Grid.Row="2" Spacing="10"> | ||
<buttons:SfRadioGroup Orientation="{OnPlatform WinUI=Horizontal, Android=Vertical}" > | ||
<buttons:SfRadioButton Text="UPI" StateChanged="PaymentOption_Selected" IsChecked="True"/> | ||
<buttons:SfRadioButton Text="Credit/Debit/ATM Card" StateChanged="PaymentOption_Selected"/> | ||
<buttons:SfRadioButton Text="Net Banking" StateChanged="PaymentOption_Selected"/> | ||
<buttons:SfRadioButton Text="Cash on Delivery" StateChanged="PaymentOption_Selected"/> | ||
</buttons:SfRadioGroup> | ||
|
||
<BoxView Background="Gray" HeightRequest="1"/> | ||
|
||
<Grid> | ||
<VerticalStackLayout x:Name="upi_Grid" IsVisible="True" Spacing="10"> | ||
<Border Background="LightGray" HeightRequest="40"> | ||
<Label Text="UPI" VerticalTextAlignment="Center" Margin="5" FontAttributes="Bold"/> | ||
</Border> | ||
<buttons:SfRadioGroup Orientation="Vertical"> | ||
<buttons:SfRadioButton Text="GPay" IsChecked="True"/> | ||
<buttons:SfRadioButton Text="PnonePe" /> | ||
</buttons:SfRadioGroup> | ||
|
||
<Button Text="Pay Now" Margin="5" /> | ||
|
||
</VerticalStackLayout> | ||
|
||
|
||
<VerticalStackLayout x:Name="cards_Grid" IsVisible="False"> | ||
<Border Background="LightGray" HeightRequest="40"> | ||
<Label Text="Credit/Debit/ATM Card" VerticalTextAlignment="Center" Margin="5" FontAttributes="Bold"/> | ||
</Border> | ||
<core:SfTextInputLayout Hint="Card Number" ContainerType="Outlined" Margin="0,15,0,0" HorizontalOptions="Start" WidthRequest="300" > | ||
<inputs:SfMaskedEntry Mask="0000-0000-0000-0000" /> | ||
</core:SfTextInputLayout> | ||
<HorizontalStackLayout> | ||
<core:SfTextInputLayout Hint="Month/Year" ContainerType="Outlined" WidthRequest="100"> | ||
<inputs:SfMaskedEntry Mask="00/0000"/> | ||
</core:SfTextInputLayout> | ||
<core:SfTextInputLayout Hint="CVV" ContainerType="Outlined" Margin="15,0,0,0" WidthRequest="100"> | ||
<inputs:SfMaskedEntry Mask="000" /> | ||
</core:SfTextInputLayout> | ||
</HorizontalStackLayout> | ||
<Button Text="Pay Now"/> | ||
</VerticalStackLayout> | ||
|
||
<VerticalStackLayout x:Name="banking_Grid" IsVisible="False" Spacing="10"> | ||
<Border Background="LightGray" HeightRequest="40"> | ||
<Label Text="Net Banking" VerticalTextAlignment="Center" Margin="5" FontAttributes="Bold"/> | ||
</Border> | ||
<buttons:SfRadioGroup Orientation="Vertical"> | ||
<buttons:SfRadioButton Text="HDFC Bank" IsChecked="True"/> | ||
<buttons:SfRadioButton Text="SBI Bank" /> | ||
<buttons:SfRadioButton Text="ICICI Bank" /> | ||
</buttons:SfRadioGroup> | ||
<Button Text="Pay Now" Margin="5" /> | ||
</VerticalStackLayout> | ||
|
||
<VerticalStackLayout x:Name="cash_Grid" IsVisible="False" Spacing="10"> | ||
<Border Background="LightGray" HeightRequest="40"> | ||
<Label Text="Cash on Delivery" VerticalTextAlignment="Center" Margin="5" FontAttributes="Bold"/> | ||
</Border> | ||
<Label Margin="5" TextColor="Gray" Text="Due to handling costs, a nominal fee of $5 will be charged"/> | ||
<Button Text="Plaec Order" Margin="5" HeightRequest="40"/> | ||
</VerticalStackLayout> | ||
</Grid> | ||
</VerticalStackLayout> | ||
|
||
|
||
</Grid> | ||
|
||
</VerticalStackLayout> | ||
|
||
</ContentPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Syncfusion.Maui.Buttons; | ||
|
||
namespace RadioButtonPaymentOption | ||
{ | ||
public partial class MainPage : ContentPage | ||
{ | ||
int count = 0; | ||
|
||
public MainPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void PaymentOption_Selected(object sender, StateChangedEventArgs e) | ||
{ | ||
if (upi_Grid == null || !(sender as SfRadioButton).IsChecked) | ||
return; | ||
|
||
string text = (sender as SfRadioButton).Text; | ||
|
||
switch (text) | ||
{ | ||
case "UPI": | ||
upi_Grid.IsVisible = true; | ||
cards_Grid.IsVisible = false; | ||
banking_Grid.IsVisible = false; | ||
cash_Grid.IsVisible = false; | ||
break; | ||
|
||
case "Credit/Debit/ATM Card": | ||
cards_Grid.IsVisible = true; | ||
upi_Grid.IsVisible = false; | ||
banking_Grid.IsVisible = false; | ||
cash_Grid.IsVisible = false; | ||
break; | ||
|
||
case "Net Banking": | ||
banking_Grid.IsVisible = true; | ||
upi_Grid.IsVisible = false; | ||
cards_Grid.IsVisible = false; | ||
cash_Grid.IsVisible = false; | ||
break; | ||
|
||
case "Cash on Delivery": | ||
cash_Grid.IsVisible = true; | ||
upi_Grid.IsVisible = false; | ||
cards_Grid.IsVisible = false; | ||
banking_Grid.IsVisible = false; | ||
break; | ||
|
||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.Extensions.Logging; | ||
using Syncfusion.Maui.Core.Hosting; | ||
|
||
namespace RadioButtonPaymentOption | ||
{ | ||
public static class MauiProgram | ||
{ | ||
public static MauiApp CreateMauiApp() | ||
{ | ||
var builder = MauiApp.CreateBuilder(); | ||
builder | ||
.UseMauiApp<App>() | ||
.ConfigureSyncfusionCore() | ||
.ConfigureFonts(fonts => | ||
{ | ||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); | ||
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); | ||
}); | ||
|
||
#if DEBUG | ||
builder.Logging.AddDebug(); | ||
#endif | ||
|
||
return builder.Build(); | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
RadioButtonPaymentOption/Platforms/Android/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
</manifest> |
11 changes: 11 additions & 0 deletions
11
RadioButtonPaymentOption/Platforms/Android/MainActivity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Android.App; | ||
using Android.Content.PM; | ||
using Android.OS; | ||
|
||
namespace RadioButtonPaymentOption | ||
{ | ||
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] | ||
public class MainActivity : MauiAppCompatActivity | ||
{ | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
RadioButtonPaymentOption/Platforms/Android/MainApplication.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Android.App; | ||
using Android.Runtime; | ||
|
||
namespace RadioButtonPaymentOption | ||
{ | ||
[Application] | ||
public class MainApplication : MauiApplication | ||
{ | ||
public MainApplication(IntPtr handle, JniHandleOwnership ownership) | ||
: base(handle, ownership) | ||
{ | ||
} | ||
|
||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
RadioButtonPaymentOption/Platforms/Android/Resources/values/colors.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#512BD4</color> | ||
<color name="colorPrimaryDark">#2B0B98</color> | ||
<color name="colorAccent">#2B0B98</color> | ||
</resources> |
10 changes: 10 additions & 0 deletions
10
RadioButtonPaymentOption/Platforms/MacCatalyst/AppDelegate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Foundation; | ||
|
||
namespace RadioButtonPaymentOption | ||
{ | ||
[Register("AppDelegate")] | ||
public class AppDelegate : MauiUIApplicationDelegate | ||
{ | ||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
RadioButtonPaymentOption/Platforms/MacCatalyst/Entitlements.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<!-- See https://aka.ms/maui-publish-app-store#add-entitlements for more information about adding entitlements.--> | ||
<dict> | ||
<!-- App Sandbox must be enabled to distribute a MacCatalyst app through the Mac App Store. --> | ||
<key>com.apple.security.app-sandbox</key> | ||
<true/> | ||
<!-- When App Sandbox is enabled, this value is required to open outgoing network connections. --> | ||
<key>com.apple.security.network.client</key> | ||
<true/> | ||
</dict> | ||
</plist> | ||
|
Oops, something went wrong.